diff options
| author | Lukas Fürmetz <fuermetz@mailbox.org> | 2019-07-04 15:04:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-04 15:04:02 +0200 |
| commit | 2422c3858b6a41c07c12d3c9482dd0d6bb821f84 (patch) | |
| tree | c7a986b90a28b84511173756fab6653a276faed0 /vterm-module.c | |
| parent | bfea244988177ac380bda405cbd2ac84b6068fda (diff) | |
| parent | dce7666b83d8c3a8d9ef9da532b3ac85590a926d (diff) | |
Merge pull request #88 from jixiuf/support-blink-cursor-mode
Support blink cursor mode and set cursor type
Diffstat (limited to 'vterm-module.c')
| -rw-r--r-- | vterm-module.c | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/vterm-module.c b/vterm-module.c index f4ee2b5..e971884 100644 --- a/vterm-module.c +++ b/vterm-module.c @@ -343,10 +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) { - toggle_cursor_blinking(env, term->cursor.blinking); - toggle_cursor(env, term->cursor.visible); + if (term->cursor.blinking_changed) { + toggle_cursor_blinking(env, term->cursor.blinking); + term->cursor.blinking_changed = false; + } + long bufline_before = env->extract_integer(env, buffer_line_number(env)); refresh_scrollback(term, env); refresh_screen(term, env); @@ -404,14 +433,25 @@ 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); break; case VTERM_PROP_CURSORBLINK: term->cursor.blinking = val->boolean; + term->cursor.blinking_changed = true; break; case VTERM_PROP_ALTSCREEN: invalidate_terminal(term, 0, term->height); @@ -606,8 +646,7 @@ static emacs_value Fvterm_new(emacs_env *env, ptrdiff_t nargs, term->width = cols; term->height = rows; - term->cursor.visible = true; - term->cursor.blinking = false; + term->cursor.blinking = env->is_not_nil(env, Fblink_cursor_mode); term->title = NULL; term->is_title_changed = false; @@ -696,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")); |
