mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-10 04:40:25 +01:00
Change write method to accept both String and PoolByteArray
Will print a warning if neither of these types is used as an argument.
Former-commit-id: 57aed28a0e
This commit is contained in:
parent
11657d50f7
commit
2a5e07aa48
3 changed files with 30 additions and 3 deletions
|
@ -12,3 +12,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Changed
|
### Changed
|
||||||
- Implementation of Terminal node from GDScript to GDNative using [Aetf's patched version of libtsm](https://github.com/Aetf/libtsm).
|
- Implementation of Terminal node from GDScript to GDNative using [Aetf's patched version of libtsm](https://github.com/Aetf/libtsm).
|
||||||
- Move input handling to the Terminal node itself, rather than handling it in a seperate Control node.
|
- Move input handling to the Terminal node itself, rather than handling it in a seperate Control node.
|
||||||
|
- The Terminal `write()` method now accepts both String and PoolByteArray.
|
||||||
|
|
|
@ -566,8 +566,34 @@ void Terminal::update_size()
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Terminal::write(PoolByteArray data)
|
void Terminal::write(Variant data)
|
||||||
{
|
{
|
||||||
tsm_vte_input(vte, (char *)data.read().ptr(), data.size());
|
|
||||||
|
const char *u8;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
switch (data.get_type())
|
||||||
|
{
|
||||||
|
case Variant::Type::POOL_BYTE_ARRAY:
|
||||||
|
{
|
||||||
|
PoolByteArray bytes = data;
|
||||||
|
u8 = (char *)bytes.read().ptr();
|
||||||
|
len = bytes.size();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Variant::Type::STRING:
|
||||||
|
{
|
||||||
|
String string = data;
|
||||||
|
CharString utf8 = string.utf8();
|
||||||
|
u8 = utf8.get_data();
|
||||||
|
len = utf8.length();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
WARN_PRINT("Method expected a String or PoolByteArray");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsm_vte_input(vte, u8, len);
|
||||||
framebuffer_age = tsm_screen_draw(screen, text_draw_cb, this);
|
framebuffer_age = tsm_screen_draw(screen, text_draw_cb, this);
|
||||||
}
|
}
|
|
@ -58,7 +58,7 @@ namespace godot
|
||||||
void _gui_input(Variant event);
|
void _gui_input(Variant event);
|
||||||
void _draw();
|
void _draw();
|
||||||
|
|
||||||
void write(PoolByteArray bytes);
|
void write(Variant data);
|
||||||
|
|
||||||
int rows;
|
int rows;
|
||||||
int cols;
|
int cols;
|
||||||
|
|
Loading…
Reference in a new issue