aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Fürmetz <fuermetz@mailbox.org>2018-11-11 22:19:43 +0100
committerLukas Fürmetz <fuermetz@mailbox.org>2018-11-11 22:19:43 +0100
commitff9290905d5ea4dfe1381e0662bbe8bc88203f79 (patch)
tree536000e488475a9f85e9cbad01a8f22a03d0bbaf
parent3e4c65ad13f6f84219c5d0a5afaa7c186cd9e0b2 (diff)
Refactor Cursor
-rw-r--r--vterm-module.c10
-rw-r--r--vterm-module.h15
2 files changed, 12 insertions, 13 deletions
diff --git a/vterm-module.c b/vterm-module.c
index 9274a06..1eed2f1 100644
--- a/vterm-module.c
+++ b/vterm-module.c
@@ -318,8 +318,8 @@ static int term_movecursor(VTermPos new, VTermPos old, int visible,
static void term_redraw(Term *term, emacs_env *env) {
if (term->is_invalidated) {
- toggle_cursor_blinking(env, term->cursor_blinking);
- toggle_cursor(env, term->cursor_visible);
+ toggle_cursor_blinking(env, term->cursor.blinking);
+ toggle_cursor(env, term->cursor.visible);
long bufline_before = env->extract_integer(env, buffer_line_number(env));
/* refresh_size(term, env); */
refresh_scrollback(term, env);
@@ -368,10 +368,10 @@ static int term_settermprop(VTermProp prop, VTermValue *val, void *user_data) {
case VTERM_PROP_CURSORVISIBLE:
invalidate_terminal(term, term->cursor.row, term->cursor.row + 1);
- term->cursor_visible = val->boolean;
+ term->cursor.visible = val->boolean;
break;
case VTERM_PROP_CURSORBLINK:
- term->cursor_blinking = val->boolean;
+ term->cursor.blinking = val->boolean;
default:
return 0;
}
@@ -630,9 +630,9 @@ static emacs_value Fvterm_set_size(emacs_env *env, ptrdiff_t nargs,
vterm_get_size(term->vt, &old_rows, &old_cols);
if (cols != old_cols || rows != old_rows) {
+ term->pending_resize = true;
vterm_set_size(term->vt, rows, cols);
vterm_screen_flush_damage(term->vts);
- term->pending_resize = true;
invalidate_terminal(term, -1, -1);
term_redraw(term, env);
diff --git a/vterm-module.h b/vterm-module.h
index 3e636c7..dc8f778 100644
--- a/vterm-module.h
+++ b/vterm-module.h
@@ -22,6 +22,12 @@ static bool refresh_pending = false;
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
#endif
+typedef struct Cursor {
+ int row, col;
+ bool blinking;
+ bool visible;
+} Cursor;
+
typedef struct Term {
VTerm *vt;
VTermScreen *vts;
@@ -41,14 +47,7 @@ typedef struct Term {
bool pending_resize; // pending width/height
bool is_invalidated;
- struct {
- int row, col;
- } cursor;
-
- // Flag to indicate cursor is visible
- bool cursor_visible;
- // Flag to indicate cursor is blinking
- bool cursor_blinking;
+ Cursor cursor;
} Term;
// Faces