Skip to content

Commit 46b0c22

Browse files
committed
Add vterm-ignore-cursor-change
1 parent a01a289 commit 46b0c22

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

vterm-module.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,8 @@ static int term_settermprop(VTermProp prop, VTermValue *val, void *user_data) {
725725
Term *term = (Term *)user_data;
726726
switch (prop) {
727727
case VTERM_PROP_CURSORVISIBLE:
728+
if (term->ignore_cursor_change)
729+
break;
728730
invalidate_terminal(term, term->cursor.row, term->cursor.row + 1);
729731
term->cursor.cursor_visible = val->boolean;
730732
term->cursor.cursor_type_changed = true;
@@ -737,6 +739,8 @@ static int term_settermprop(VTermProp prop, VTermValue *val, void *user_data) {
737739
term->cursor.cursor_blink_changed = true;
738740
break;
739741
case VTERM_PROP_CURSORSHAPE:
742+
if (term->ignore_cursor_change)
743+
break;
740744
invalidate_terminal(term, term->cursor.row, term->cursor.row + 1);
741745
term->cursor.cursor_type = val->number;
742746
term->cursor.cursor_type_changed = true;
@@ -1234,6 +1238,7 @@ emacs_value Fvterm_new(emacs_env *env, ptrdiff_t nargs, emacs_value args[],
12341238
int disable_inverse_video = env->is_not_nil(env, args[5]);
12351239
int ignore_blink_cursor = env->is_not_nil(env, args[6]);
12361240
int set_bold_highbright = env->is_not_nil(env, args[7]);
1241+
int ignore_cursor_change = env->is_not_nil(env, args[8]);
12371242

12381243
term->vt = vterm_new(rows, cols);
12391244
vterm_set_utf8(term->vt, 1);
@@ -1269,6 +1274,7 @@ emacs_value Fvterm_new(emacs_env *env, ptrdiff_t nargs, emacs_value args[],
12691274
term->disable_underline = disable_underline;
12701275
term->disable_inverse_video = disable_inverse_video;
12711276
term->ignore_blink_cursor = ignore_blink_cursor;
1277+
term->ignore_cursor_change = ignore_cursor_change;
12721278
emacs_value newline = env->make_string(env, "\n", 1);
12731279
for (int i = 0; i < term->height; i++) {
12741280
insert(env, newline);
@@ -1514,7 +1520,7 @@ int emacs_module_init(struct emacs_runtime *ert) {
15141520
// Exported functions
15151521
emacs_value fun;
15161522
fun =
1517-
env->make_function(env, 4, 8, Fvterm_new, "Allocate a new vterm.", NULL);
1523+
env->make_function(env, 4, 9, Fvterm_new, "Allocate a new vterm.", NULL);
15181524
bind_function(env, "vterm--new", fun);
15191525

15201526
fun = env->make_function(env, 1, 5, Fvterm_update,

vterm-module.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ typedef struct Term {
118118
bool disable_underline;
119119
bool disable_inverse_video;
120120
bool ignore_blink_cursor;
121+
bool ignore_cursor_change;
121122

122123
char *cmd_buffer;
123124

vterm.el

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,11 @@ you can use `M-x blink-cursor-mode` to toggle."
400400
:type 'boolean
401401
:group 'vterm)
402402

403+
(defcustom vterm-ignore-cursor-change nil
404+
"When t, vterm will ignore request from application to modify cursor shape or visibility."
405+
:type 'boolean
406+
:group 'vterm)
407+
403408
(defcustom vterm-copy-exclude-prompt t
404409
"When not-nil, the prompt is not included by `vterm-copy-mode-done'."
405410
:type 'boolean
@@ -778,7 +783,8 @@ Exceptions are defined by `vterm-keymap-exceptions'."
778783
vterm-disable-underline
779784
vterm-disable-inverse-video
780785
vterm-ignore-blink-cursor
781-
vterm-set-bold-highbright))
786+
vterm-set-bold-highbright
787+
vterm-ignore-cursor-change))
782788
(setq buffer-read-only t)
783789
(setq-local scroll-conservatively 101)
784790
(setq-local scroll-margin 0)

0 commit comments

Comments
 (0)