mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-04 12:14:24 +02:00
Add clear and sb_reset
Clearing the terminal removes all lines in the scrollback buffer except for the most recent. With sb_reset, the terminal will return the scrollback buffer to the bottom when the user starts typing if they have previously scrolled up.
This commit is contained in:
parent
ebb527cb8b
commit
e8c27f2796
5 changed files with 40 additions and 12 deletions
|
@ -288,6 +288,8 @@ void Terminal::_register_methods() {
|
|||
|
||||
register_method("sb_up", &Terminal::sb_up);
|
||||
register_method("sb_down", &Terminal::sb_down);
|
||||
register_method("sb_reset", &Terminal::sb_reset);
|
||||
register_method("clear_sb", &Terminal::clear_sb);
|
||||
|
||||
register_method("start_selection", &Terminal::start_selection);
|
||||
register_method("select_to_pointer", &Terminal::select_to_pointer);
|
||||
|
@ -567,7 +569,7 @@ void Terminal::update_size() {
|
|||
|
||||
cell_size = fontref->get_string_size("W");
|
||||
|
||||
rows = std::max(2, (int)floor(get_rect().size.y / cell_size.y));
|
||||
rows = std::max(1, (int)floor(get_rect().size.y / cell_size.y));
|
||||
cols = std::max(1, (int)floor(get_rect().size.x / cell_size.x));
|
||||
|
||||
tsm_screen_resize(screen, cols, rows);
|
||||
|
@ -592,6 +594,16 @@ void Terminal::sb_down(int num) {
|
|||
update();
|
||||
}
|
||||
|
||||
void Terminal::sb_reset() {
|
||||
tsm_screen_sb_reset(screen);
|
||||
update();
|
||||
}
|
||||
|
||||
void Terminal::clear_sb() {
|
||||
tsm_screen_clear_sb(screen);
|
||||
update();
|
||||
}
|
||||
|
||||
void Terminal::start_selection(Vector2 position) {
|
||||
tsm_screen_selection_start(screen, position.x, position.y);
|
||||
update();
|
||||
|
@ -613,4 +625,4 @@ String Terminal::copy_selection() {
|
|||
String result = String(out);
|
||||
std::free(out);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,8 @@ public:
|
|||
|
||||
void sb_up(int num);
|
||||
void sb_down(int num);
|
||||
void sb_reset();
|
||||
void clear_sb();
|
||||
|
||||
void start_selection(Vector2 position);
|
||||
void select_to_pointer(Vector2 position);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue