Skip to content

Commit

Permalink
Implement get_cursor_pos()
Browse files Browse the repository at this point in the history
  • Loading branch information
lihop committed Feb 7, 2024
1 parent 8c30bec commit 575c387
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions addons/godot_xterm/native/src/terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void Terminal::_bind_methods()
// Methods.

ClassDB::bind_method(D_METHOD("write", "data"), &Terminal::write);
ClassDB::bind_method(D_METHOD("get_cursor_pos"), &Terminal::get_cursor_pos);
}

Terminal::Terminal()
Expand Down Expand Up @@ -104,6 +105,10 @@ int Terminal::get_rows() const
return rows;
}

Vector2 Terminal::get_cursor_pos() const {
return Vector2(tsm_screen_get_cursor_x(screen), tsm_screen_get_cursor_y(screen));
}

void Terminal::set_max_scrollback(const int p_max_scrollback)
{
max_scrollback = std::max(0, p_max_scrollback);
Expand Down
2 changes: 2 additions & 0 deletions addons/godot_xterm/native/src/terminal.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ namespace godot
void set_rows(const int p_rows);
int get_rows() const;

Vector2 get_cursor_pos() const;

void set_max_scrollback(const int p_max_scrollback);
int get_max_scrollback() const;

Expand Down

0 comments on commit 575c387

Please sign in to comment.