mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-04 20:24:23 +02:00
feat(term): implement clear() method
Clears all but the bottommost row of the terminal (including scrollback buffer) and moves the bottommost row to the top.
This commit is contained in:
parent
fc03595e29
commit
d00a31fb45
4 changed files with 82 additions and 12 deletions
|
@ -75,8 +75,8 @@ void Terminal::_bind_methods()
|
|||
ClassDB::bind_method(D_METHOD("get_copy_on_selection"), &Terminal::get_copy_on_selection);
|
||||
ClassDB::add_property("Terminal", PropertyInfo(Variant::BOOL, "copy_on_selection"), "set_copy_on_selection", "get_copy_on_selection");
|
||||
|
||||
// Methods.
|
||||
|
||||
// Other methods.
|
||||
ClassDB::bind_method(D_METHOD("clear"), &Terminal::clear);
|
||||
ClassDB::bind_method(D_METHOD("write", "data"), &Terminal::write);
|
||||
ClassDB::bind_method(D_METHOD("get_cursor_pos"), &Terminal::get_cursor_pos);
|
||||
ClassDB::bind_method(D_METHOD("get_cell_size"), &Terminal::get_cell_size);
|
||||
|
@ -642,6 +642,19 @@ double Terminal::get_blink_off_time() const
|
|||
return blink_off_time;
|
||||
}
|
||||
|
||||
void Terminal::clear() {
|
||||
// Resize the terminal to a single row, forcing content above in to the scrollback buffer.
|
||||
tsm_screen_resize(screen, cols, 1);
|
||||
|
||||
// Clear the scrollback buffer (hence clearing the content that was above).
|
||||
tsm_screen_clear_sb(screen);
|
||||
|
||||
// Resize the screen to its original size.
|
||||
tsm_screen_resize(screen, cols, rows);
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
String Terminal::_copy_screen(ScreenCopyFunction func) {
|
||||
char *out;
|
||||
PackedByteArray data;
|
||||
|
|
|
@ -72,6 +72,8 @@ namespace godot
|
|||
void set_blink_off_time(const double p_blink_off_time);
|
||||
double get_blink_off_time() const;
|
||||
|
||||
void clear();
|
||||
|
||||
String copy_all();
|
||||
String copy_selection();
|
||||
void set_copy_on_selection(const bool p_enable);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue