Expose blink_on_time and blink_off_time properties

This commit is contained in:
Leroy Hopson 2024-02-07 22:26:45 +13:00
parent 7de5e2a835
commit 930f3ef352
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
2 changed files with 45 additions and 0 deletions

View file

@ -31,6 +31,18 @@ void Terminal::_bind_methods()
ClassDB::bind_method(D_METHOD("set_max_scrollback", "max_scrollback"), &Terminal::set_max_scrollback); ClassDB::bind_method(D_METHOD("set_max_scrollback", "max_scrollback"), &Terminal::set_max_scrollback);
ClassDB::add_property("Terminal", PropertyInfo(Variant::INT, "max_scrollback"), "set_max_scrollback", "get_max_scrollback"); ClassDB::add_property("Terminal", PropertyInfo(Variant::INT, "max_scrollback"), "set_max_scrollback", "get_max_scrollback");
// Blink.
ClassDB::add_property_group("Terminal", "Blink", "blink_");
ClassDB::bind_method(D_METHOD("get_blink_on_time"), &Terminal::get_blink_on_time);
ClassDB::bind_method(D_METHOD("set_blink_on_time", "time"), &Terminal::set_blink_on_time);
ClassDB::add_property("Terminal", PropertyInfo(Variant::FLOAT, "blink_on_time"), "set_blink_on_time", "get_blink_on_time");
ClassDB::bind_method(D_METHOD("get_blink_off_time"), &Terminal::get_blink_off_time);
ClassDB::bind_method(D_METHOD("set_blink_off_time", "time"), &Terminal::set_blink_off_time);
ClassDB::add_property("Terminal", PropertyInfo(Variant::FLOAT, "blink_off_time"), "set_blink_off_time", "get_blink_off_time");
// Methods.
ClassDB::bind_method(D_METHOD("write", "data"), &Terminal::write); ClassDB::bind_method(D_METHOD("write", "data"), &Terminal::write);
} }
@ -38,6 +50,8 @@ Terminal::Terminal()
{ {
max_scrollback = 1000; max_scrollback = 1000;
blink_on_time = 0.6;
blink_off_time = 0.3;
if (tsm_screen_new(&screen, NULL, NULL)) if (tsm_screen_new(&screen, NULL, NULL))
{ {
@ -455,3 +469,25 @@ void Terminal::cleanup_rendering() {
rs->free_rid(char_material); rs->free_rid(char_material);
rs->free_rid(char_shader); rs->free_rid(char_shader);
} }
void Terminal::set_blink_on_time(const float time)
{
blink_on_time = time;
fore_material->set_shader_parameter("blink_on_time", blink_on_time);
}
float Terminal::get_blink_on_time() const
{
return blink_on_time;
}
void Terminal::set_blink_off_time(const float time)
{
blink_off_time = time;
fore_material->set_shader_parameter("blink_off_time", blink_off_time);
}
float Terminal::get_blink_off_time() const
{
return blink_off_time;
}

View file

@ -46,6 +46,12 @@ namespace godot
void set_max_scrollback(const int p_max_scrollback); void set_max_scrollback(const int p_max_scrollback);
int get_max_scrollback() const; int get_max_scrollback() const;
void set_blink_on_time(const float p_blink_on_time);
float get_blink_on_time() const;
void set_blink_off_time(const float p_blink_off_time);
float get_blink_off_time() const;
void write(Variant data); void write(Variant data);
protected: protected:
@ -57,6 +63,9 @@ namespace godot
unsigned int cols; unsigned int cols;
unsigned int rows; unsigned int rows;
float blink_on_time;
float blink_off_time;
RenderingServer *rs; RenderingServer *rs;
tsm_screen *screen; tsm_screen *screen;