mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-04 12:14:24 +02:00
Yield for "frame_pre_draw" signal before writing to terminal
Fixes #41. But creates another issue where sometimes the yield will resume after the terminal node has already been freed logging an error to the console. Also a few changes to where update is called it the gdnative terminal code. Also changed gdnative terminal to only accept strings.
This commit is contained in:
parent
4e6715329a
commit
bfa561357e
3 changed files with 34 additions and 32 deletions
|
@ -1,3 +1,5 @@
|
|||
// Copyright (c) 2021, Leroy Hopson (MIT License).
|
||||
|
||||
#include "terminal.h"
|
||||
#include <Dictionary.hpp>
|
||||
#include <InputEventKey.hpp>
|
||||
|
@ -543,36 +545,14 @@ void Terminal::update_size() {
|
|||
rows = std::max(2, (int)floor(get_rect().size.y / cell_size.y));
|
||||
cols = std::max(1, (int)floor(get_rect().size.x / cell_size.x));
|
||||
|
||||
emit_signal("size_changed", Vector2(cols, rows));
|
||||
|
||||
tsm_screen_resize(screen, cols, rows);
|
||||
|
||||
update();
|
||||
emit_signal("size_changed", Vector2(cols, rows));
|
||||
}
|
||||
|
||||
void Terminal::write(Variant data) {
|
||||
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;
|
||||
u8 = string.alloc_c_string();
|
||||
len = strlen(u8);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
WARN_PRINT("Method expected a String or PoolByteArray");
|
||||
return;
|
||||
}
|
||||
void Terminal::write(String data) {
|
||||
const char *u8 = data.alloc_c_string();
|
||||
size_t len = strlen(u8);
|
||||
|
||||
tsm_vte_input(vte, u8, len);
|
||||
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// Copyright (c) 2021, Leroy Hopson (MIT License).
|
||||
|
||||
#ifndef TERMINAL_H
|
||||
#define TERMINAL_H
|
||||
|
||||
|
@ -52,7 +54,7 @@ public:
|
|||
void _gui_input(Variant event);
|
||||
void _draw();
|
||||
|
||||
void write(Variant data);
|
||||
void write(String data);
|
||||
|
||||
enum UpdateMode {
|
||||
DISABLED,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue