aboutsummaryrefslogtreecommitdiff
path: root/vterm-module.c
diff options
context:
space:
mode:
Diffstat (limited to 'vterm-module.c')
-rw-r--r--vterm-module.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/vterm-module.c b/vterm-module.c
index 61de618..e971884 100644
--- a/vterm-module.c
+++ b/vterm-module.c
@@ -343,14 +343,39 @@ static int term_movecursor(VTermPos new, VTermPos old, int visible,
return 1;
}
+static void term_redraw_cursor(Term *term, emacs_env *env) {
+ if (term->cursor.cursor_type_changed) {
+ term->cursor.cursor_type_changed = false;
+ switch (term->cursor.cursor_type) {
+ case VTERM_PROP_CURSOR_VISIBLE:
+ set_cursor_type(env, Qt);
+ break;
+ case VTERM_PROP_CURSOR_NOT_VISIBLE:
+ set_cursor_type(env, Qnil);
+ break;
+ case VTERM_PROP_CURSOR_BLOCK:
+ set_cursor_type(env, Qbox);
+ break;
+ case VTERM_PROP_CURSOR_UNDERLINE:
+ set_cursor_type(env, Qhbar);
+ break;
+ case VTERM_PROP_CURSOR_BAR_LEFT:
+ set_cursor_type(env, Qbar);
+ break;
+ default:
+ return;
+ }
+ }
+}
+
static void term_redraw(Term *term, emacs_env *env) {
+ term_redraw_cursor(term, env);
if (term->is_invalidated) {
if (term->cursor.blinking_changed) {
toggle_cursor_blinking(env, term->cursor.blinking);
term->cursor.blinking_changed = false;
}
- toggle_cursor(env, term->cursor.visible);
long bufline_before = env->extract_integer(env, buffer_line_number(env));
refresh_scrollback(term, env);
refresh_screen(term, env);
@@ -408,8 +433,18 @@ static int term_settermprop(VTermProp prop, VTermValue *val, void *user_data) {
switch (prop) {
case VTERM_PROP_CURSORVISIBLE:
invalidate_terminal(term, term->cursor.row, term->cursor.row + 1);
+ if (val->boolean) {
+ term->cursor.cursor_type = VTERM_PROP_CURSOR_VISIBLE;
+ } else {
+ term->cursor.cursor_type = VTERM_PROP_CURSOR_NOT_VISIBLE;
+ }
+ term->cursor.cursor_type_changed = true;
+ break;
+ case VTERM_PROP_CURSORSHAPE:
+ invalidate_terminal(term, term->cursor.row, term->cursor.row + 1);
+ term->cursor.cursor_type = val->number;
+ term->cursor.cursor_type_changed = true;
- term->cursor.visible = val->boolean;
break;
case VTERM_PROP_TITLE:
term_set_title(term, val->string);
@@ -611,7 +646,6 @@ static emacs_value Fvterm_new(emacs_env *env, ptrdiff_t nargs,
term->width = cols;
term->height = rows;
- term->cursor.visible = true;
term->cursor.blinking = env->is_not_nil(env, Fblink_cursor_mode);
term->title = NULL;
term->is_title_changed = false;
@@ -701,6 +735,9 @@ int emacs_module_init(struct emacs_runtime *ert) {
Qreverse = env->make_global_ref(env, env->intern(env, ":inverse-video"));
Qstrike = env->make_global_ref(env, env->intern(env, ":strike-through"));
Qface = env->make_global_ref(env, env->intern(env, "font-lock-face"));
+ Qbox = env->make_global_ref(env, env->intern(env, "box"));
+ Qbar = env->make_global_ref(env, env->intern(env, "bar"));
+ Qhbar = env->make_global_ref(env, env->intern(env, "hbar"));
Qcursor_type = env->make_global_ref(env, env->intern(env, "cursor-type"));
Qansi_color_names_vector =
env->make_global_ref(env, env->intern(env, "ansi-color-names-vector"));