diff options
| author | Lukas Fürmetz <fuermetz@mailbox.org> | 2018-10-25 21:51:11 +0200 |
|---|---|---|
| committer | Lukas Fürmetz <fuermetz@mailbox.org> | 2018-10-25 21:51:11 +0200 |
| commit | b4d13768eaab80efb32aecc154b25d2cc4c67fec (patch) | |
| tree | 95697e12bc66066ee2f57775c4639bd60a065f36 /vterm-module.h | |
| parent | 813352c278c70853251884b081844ed041080489 (diff) | |
| parent | a18e037ee61afa5e91e955e26710d068d3ee1f9c (diff) | |
Merge remote-tracking branch 'jixiuf/scrollback-support'
Diffstat (limited to 'vterm-module.h')
| -rw-r--r-- | vterm-module.h | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/vterm-module.h b/vterm-module.h index b9dcd8d..775b59d 100644 --- a/vterm-module.h +++ b/vterm-module.h @@ -7,11 +7,45 @@ #include <vterm.h> int plugin_is_GPL_compatible; +typedef struct { + size_t cols; + VTermScreenCell cells[]; +} ScrollbackLine; -struct Term { +#define SB_MAX 100000 // Maximum 'scrollback' value. +static bool refresh_pending = false; + +#ifndef MIN +# define MIN(X, Y) ((X) < (Y) ? (X) : (Y)) +#endif +#ifndef MAX +# define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) +#endif + + +struct term { VTerm *vt; + VTermScreen *vts; + // buffer used to: + // - convert VTermScreen cell arrays into utf8 strings + // - receive data from libvterm as a result of key presses. + char textbuf[0x1fff]; + ScrollbackLine **sb_buffer; // Scrollback buffer storage for libvterm + size_t sb_current; // number of rows pushed to sb_buffer + size_t sb_size; // sb_buffer size + // "virtual index" that points to the first sb_buffer row that we need to + // push to the terminal buffer when refreshing the scrollback. When negative, + // it actually points to entries that are no longer in sb_buffer (because the + // window height has increased) and must be deleted from the terminal buffer + int sb_pending; + + + int invalid_start, invalid_end; // invalid rows in libvterm screen + }; + +typedef struct term Term; // Faces emacs_value Qterm; emacs_value Qterm_color_black; @@ -30,12 +64,12 @@ static emacs_value render_text(emacs_env *env, char *string, int len, static int set_term_prop_cb(VTermProp prop, VTermValue *val, void *user_data); -static void term_redraw(struct Term *term, emacs_env *env); -static void term_setup_colors(struct Term *term, emacs_env *env); -static void term_flush_output(struct Term *term, emacs_env *env); -static void term_process_key(struct Term *term, unsigned char *key, size_t len, +static void term_redraw(Term *term, emacs_env *env); +static void term_setup_colors(Term *term, emacs_env *env); +static void term_flush_output(Term *term, emacs_env *env); +static void term_process_key(Term *term, unsigned char *key, size_t len, VTermModifier modifier); -static void term_put_caret(struct Term *term, emacs_env *env, int row, int col, +static void term_put_caret(Term *term, emacs_env *env, int row, int col, int offset); static void term_finalize(void *object); |
