From 575c3875b619f8368c57959bdc7404fd6a17112e Mon Sep 17 00:00:00 2001 From: Leroy Hopson Date: Wed, 7 Feb 2024 23:14:52 +1300 Subject: [PATCH] Implement get_cursor_pos() --- addons/godot_xterm/native/src/terminal.cpp | 5 +++++ addons/godot_xterm/native/src/terminal.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/addons/godot_xterm/native/src/terminal.cpp b/addons/godot_xterm/native/src/terminal.cpp index 512e18c..bc5294d 100644 --- a/addons/godot_xterm/native/src/terminal.cpp +++ b/addons/godot_xterm/native/src/terminal.cpp @@ -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() @@ -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); diff --git a/addons/godot_xterm/native/src/terminal.h b/addons/godot_xterm/native/src/terminal.h index 70aa2b7..ad09827 100644 --- a/addons/godot_xterm/native/src/terminal.h +++ b/addons/godot_xterm/native/src/terminal.h @@ -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;