aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Fürmetz <fuermetz@mailbox.org>2018-10-25 22:14:38 +0200
committerLukas Fürmetz <fuermetz@mailbox.org>2018-10-25 22:14:38 +0200
commit81d2aeebaff7829e2082b5ca2fc50495f6215508 (patch)
treef1f9530e62f837013e517a464de3391b579cb58f
parentb4d13768eaab80efb32aecc154b25d2cc4c67fec (diff)
Add support for hiding the cursor
-rw-r--r--vterm-module.c10
-rw-r--r--vterm-module.h4
2 files changed, 9 insertions, 5 deletions
diff --git a/vterm-module.c b/vterm-module.c
index fcd8cb3..19f45c1 100644
--- a/vterm-module.c
+++ b/vterm-module.c
@@ -307,7 +307,7 @@ static VTermScreenCallbacks vterm_screen_callbacks = {
/* .damage = term_damage, */
/* .moverect = term_moverect, */
/* .movecursor = term_movecursor, */
- /* .settermprop = term_settermprop, */
+ .settermprop = term_settermprop,
/* .bell = term_bell, */
.sb_pushline = term_sb_push,
.sb_popline = term_sb_pop,
@@ -335,11 +335,11 @@ static bool is_key(unsigned char *key, size_t len, char *key_description) {
memcmp(key, key_description, len) == 0);
}
-static int set_term_prop_cb(VTermProp prop, VTermValue *val, void *user_data) {
- emacs_env *env = (emacs_env *)user_data;
+static int term_settermprop(VTermProp prop, VTermValue *val, void *user_data) {
+ Term *term = (Term *)user_data;
switch (prop) {
case VTERM_PROP_CURSORVISIBLE:
- toggle_cursor(env, val->boolean);
+ term->cursor_visible = val->boolean;
break;
default:
return 0;
@@ -556,6 +556,8 @@ static emacs_value Fvterm_update(emacs_env *env, ptrdiff_t nargs,
emacs_value args[], void *data) {
Term *term = env->get_user_ptr(env, args[0]);
+ toggle_cursor(env, term->cursor_visible);
+
// Process keys
if (nargs > 1) {
ptrdiff_t len = string_bytes(env, args[1]);
diff --git a/vterm-module.h b/vterm-module.h
index 775b59d..bf449ab 100644
--- a/vterm-module.h
+++ b/vterm-module.h
@@ -42,6 +42,8 @@ struct term {
int invalid_start, invalid_end; // invalid rows in libvterm screen
+ // Flag to indicate cursor is visible
+ bool cursor_visible;
};
@@ -62,7 +64,7 @@ static bool is_key(unsigned char *key, size_t len, char *key_description);
static emacs_value render_text(emacs_env *env, char *string, int len,
VTermScreenCell *cell);
-static int set_term_prop_cb(VTermProp prop, VTermValue *val, void *user_data);
+static int term_settermprop(VTermProp prop, VTermValue *val, void *user_data);
static void term_redraw(Term *term, emacs_env *env);
static void term_setup_colors(Term *term, emacs_env *env);