mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-07-05 13:15:32 +02:00
Multiple updates
- Use viewport as render target for terminal: Terminal now only draws cells which changed since the last _draw() call. A viewport is used with clear mode set to NEVER to cache previous draw calls. The terminal node and viewport are wrapped by a GDScript Terminal node which takes care of resizing the viewport scene, and forcing the terminal to redraw all cells when necessary (i.e. on resize or theme change). Adds update_mode to terminal interface which can be set to one of: - DISABLED: terminal will never be drawn - AUTO: terminal will only draw the cells that changed, but automatically redraw the full screen when necessary (for example, when the size or theme changed). - ALL: terminal will always draw every cell on every update. This is the most reliable but least performant option. - ALL_NEXT_FRAME: Will use update_mode ALL for the next _draw() call, then change update_mode back to AUTO. - Upgraded libtsm: Includes changes from Fredrik Wikstrom (salass00)'s fork of libtsm. - Don't require theme to be set. Terminal will use default fonts/colors if no theme is set.
This commit is contained in:
parent
3dd89ec0a7
commit
d2f073d7ae
13 changed files with 312 additions and 178 deletions
|
@ -14,18 +14,6 @@ class Terminal : public Control {
|
|||
GODOT_CLASS(Terminal, Control)
|
||||
|
||||
public:
|
||||
struct cell {
|
||||
char ch[5];
|
||||
struct tsm_screen_attr attr;
|
||||
};
|
||||
static const struct cell empty_cell;
|
||||
|
||||
public:
|
||||
typedef std::vector<std::vector<struct cell>> Cells;
|
||||
typedef std::vector<struct cell> Row;
|
||||
|
||||
Cells cells;
|
||||
|
||||
Ref<InputEventKey> input_event_key;
|
||||
|
||||
protected:
|
||||
|
@ -44,11 +32,13 @@ private:
|
|||
std::map<String, Ref<Font>> fontmap = {};
|
||||
|
||||
void update_size();
|
||||
|
||||
void update_theme();
|
||||
std::pair<Color, Color> get_cell_colors(int row, int col);
|
||||
|
||||
public:
|
||||
std::pair<Color, Color> get_cell_colors(const tsm_screen_attr *attr);
|
||||
void draw_background(int row, int col, Color bgcol);
|
||||
void draw_foreground(int row, int col, Color fgcol);
|
||||
void draw_foreground(int row, int col, char *ch, const tsm_screen_attr *attr,
|
||||
Color fgcol);
|
||||
|
||||
public:
|
||||
static void _register_methods();
|
||||
|
@ -64,10 +54,16 @@ public:
|
|||
|
||||
void write(Variant data);
|
||||
|
||||
enum UpdateMode {
|
||||
DISABLED,
|
||||
AUTO,
|
||||
ALL,
|
||||
ALL_NEXT_FRAME,
|
||||
};
|
||||
|
||||
int rows;
|
||||
int cols;
|
||||
|
||||
bool sleep;
|
||||
int update_mode;
|
||||
|
||||
uint8_t color_palette[TSM_COLOR_NUM][3];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue