Hi,
GVim changes the cursor to an underscore in Replace mode, but Vim doesn't
currently support changing the cursor when changing to Replace mode, only
Insert mode. This patch adds an escape sequence, t_SR (for start Replace) that
mirrors t_SI.
--
Omar
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff -r af110084ec06 runtime/doc/options.txt
--- a/runtime/doc/options.txt Thu Nov 27 19:14:49 2014 +0100
+++ b/runtime/doc/options.txt Sat Nov 29 20:35:16 2014 -0800
@@ -3421,7 +3421,8 @@
the height of the cursor can be changed. This can be done by
specifying a block cursor, or a percentage for a vertical or
horizontal cursor.
- For a console the 't_SI' and 't_EI' escape sequences are used.
+ For a console the 't_SI', 't_SR', and 't_EI' escape sequences are
+ used.
The option is a comma separated list of parts. Each part consist of a
mode-list and an argument-list:
diff -r af110084ec06 runtime/doc/tags
--- a/runtime/doc/tags Thu Nov 27 19:14:49 2014 +0100
+++ b/runtime/doc/tags Sat Nov 29 20:35:16 2014 -0800
@@ -932,6 +932,7 @@
't_RI' term.txt /*'t_RI'*
't_RV' term.txt /*'t_RV'*
't_SI' term.txt /*'t_SI'*
+'t_SR' term.txt /*'t_SR'*
't_Sb' term.txt /*'t_Sb'*
't_Sf' term.txt /*'t_Sf'*
't_WP' term.txt /*'t_WP'*
@@ -8079,6 +8080,7 @@
t_RI term.txt /*t_RI*
t_RV term.txt /*t_RV*
t_SI term.txt /*t_SI*
+t_SR term.txt /*t_SR*
t_Sb term.txt /*t_Sb*
t_Sf term.txt /*t_Sf*
t_WP term.txt /*t_WP*
diff -r af110084ec06 runtime/doc/term.txt
--- a/runtime/doc/term.txt Thu Nov 27 19:14:49 2014 +0100
+++ b/runtime/doc/term.txt Sat Nov 29 20:35:16 2014 -0800
@@ -290,7 +290,8 @@
t_WP set window position (Y, X) in pixels *t_WP* *'t_WP'*
t_WS set window size (height, width) in characters *t_WS* *'t_WS'*
t_SI start insert mode (bar cursor shape) *t_SI* *'t_SI'*
- t_EI end insert mode (block cursor shape) *t_EI* *'t_EI'*
+ t_SR start replace mode (underline cursor shape) *t_SR* *'t_SR'*
+ t_EI end insert or replace mode (block cursor shape) *t_EI* *'t_EI'*
|termcap-cursor-shape|
t_RV request terminal version string (for xterm) *t_RV* *'t_RV'*
|xterm-8bit| |v:termresponse| |'ttymouse'| |xterm-codes|
@@ -434,13 +435,15 @@
to reset to the default colors.
*termcap-cursor-shape* *termcap-cursor-color*
-When Vim enters Insert mode the 't_SI' escape sequence is sent. When leaving
-Insert mode 't_EI' is used. But only if both are defined. This can be used
-to change the shape or color of the cursor in Insert mode. These are not
-standard termcap/terminfo entries, you need to set them yourself.
+When Vim enters Insert mode the 't_SI' escape sequence is sent. When Vim
+enters Replace mode the 't_SR' escape sequence is sent. When leaving Insert
+mode or Replace mode 't_EI' is used. This can be used to change the shape or
+color of the cursor in Insert mode. These are not standard termcap/terminfo
+entries, you need to set them yourself.
Example for an xterm, this changes the color of the cursor: >
if &term =~ "xterm"
let &t_SI = "\<Esc>]12;purple\x7"
+ let &t_SR = "\<Esc>]12;red\x7"
let &t_EI = "\<Esc>]12;blue\x7"
endif
NOTE: When Vim exits the shape for Normal mode will remain. The shape from
diff -r af110084ec06 runtime/syntax/vim.vim
--- a/runtime/syntax/vim.vim Thu Nov 27 19:14:49 2014 +0100
+++ b/runtime/syntax/vim.vim Sat Nov 29 20:35:16 2014 -0800
@@ -46,7 +46,7 @@
syn keyword vimOption contained invakm invanti invarab invari invautoindent invautowriteall invbackup invbin invbioskey invbomb invci invcompatible invconskey invcrb invcscopeverbose invcsverb invcursorbind invdeco invdiff inveb invek invequalalways invet invexrc invfileignorecase invfoldenable invguipty invhk
" termcap codes (which can also be set) {{{2
-syn keyword vimOption contained t_AB t_al t_bc t_ce t_cl t_Co t_Cs t_CS t_CV t_da t_db t_dl t_DL t_EI t_F1 t_F2 t_F3 t_F4 t_F5 t_F6 t_F7 t_F8 t_F9 t_fs t_IE t_IS t_k1 t_K1 t_k2 t_k3 t_K3 t_k4 t_K4 t_k5 t_K5 t_k6 t_K6 t_k7 t_K7 t_k8 t_K8 t_k9 t_K9 t_KA t_kb t_kB t_KB t_KC t_kd t_kD t_KD t_ke t_KE t_KF t_KG t_kh t_KH t_kI t_KI t_KJ t_KK t_kl t_KL t_kN t_kP t_kr t_ks t_ku t_le t_mb t_md t_me t_mr t_ms t_nd t_op t_RI t_RV t_Sb t_se t_Sf t_SI t_so t_sr t_te t_ti t_ts t_u7 t_ue t_us t_ut t_vb t_ve t_vi t_vs t_WP t_WS t_xs t_ZH t_ZR
+syn keyword vimOption contained t_AB t_al t_bc t_ce t_cl t_Co t_Cs t_CS t_CV t_da t_db t_dl t_DL t_EI t_F1 t_F2 t_F3 t_F4 t_F5 t_F6 t_F7 t_F8 t_F9 t_fs t_IE t_IS t_k1 t_K1 t_k2 t_k3 t_K3 t_k4 t_K4 t_k5 t_K5 t_k6 t_K6 t_k7 t_K7 t_k8 t_K8 t_k9 t_K9 t_KA t_kb t_kB t_KB t_KC t_kd t_kD t_KD t_ke t_KE t_KF t_KG t_kh t_KH t_kI t_KI t_KJ t_KK t_kl t_KL t_kN t_kP t_kr t_ks t_ku t_le t_mb t_md t_me t_mr t_ms t_nd t_op t_RI t_RV t_Sb t_se t_Sf t_SI t_SR t_so t_sr t_te t_ti t_ts t_u7 t_ue t_us t_ut t_vb t_ve t_vi t_vs t_WP t_WS t_xs t_ZH t_ZR
syn keyword vimOption contained t_AF t_AL t_cd t_Ce t_cm t_cs
syn match vimOption contained "t_%1"
syn match vimOption contained "t_#2"
diff -r af110084ec06 src/option.c
--- a/src/option.c Thu Nov 27 19:14:49 2014 +0100
+++ b/src/option.c Sat Nov 29 20:35:16 2014 -0800
@@ -2978,6 +2978,7 @@
p_term("t_WS", T_CWS)
p_term("t_SI", T_CSI)
p_term("t_EI", T_CEI)
+ p_term("t_SR", T_CSR)
p_term("t_xs", T_XS)
p_term("t_ZH", T_CZH)
p_term("t_ZR", T_CZR)
diff -r af110084ec06 src/term.c
--- a/src/term.c Thu Nov 27 19:14:49 2014 +0100
+++ b/src/term.c Sat Nov 29 20:35:16 2014 -0800
@@ -3560,27 +3560,33 @@
#if defined(CURSOR_SHAPE) || defined(PROTO)
/*
- * Set cursor shape to match Insert mode.
+ * Set cursor shape to match Insert mode/Replace mode.
*/
void
term_cursor_shape()
{
- static int showing_insert_mode = MAYBE;
-
- if (!full_screen || *T_CSI == NUL || *T_CEI == NUL)
+ static int showing_mode = NORMAL;
+
+ if (!full_screen)
return;
- if (State & INSERT)
+ if ((State & REPLACE) == REPLACE)
{
- if (showing_insert_mode != TRUE)
+ if (showing_mode != REPLACE && *T_CSR != NUL)
+ out_str(T_CSR); /* Replace mode cursor */
+ showing_mode = REPLACE;
+ }
+ else if ((State & INSERT) == INSERT)
+ {
+ if (showing_mode != INSERT && *T_CSI != NUL)
out_str(T_CSI); /* Insert mode cursor */
- showing_insert_mode = TRUE;
+ showing_mode = INSERT;
}
else
{
- if (showing_insert_mode != FALSE)
+ if (showing_mode != NORMAL && *T_CEI != NUL)
out_str(T_CEI); /* non-Insert mode cursor */
- showing_insert_mode = FALSE;
+ showing_mode = NORMAL;
}
}
#endif
diff -r af110084ec06 src/term.h
--- a/src/term.h Thu Nov 27 19:14:49 2014 +0100
+++ b/src/term.h Sat Nov 29 20:35:16 2014 -0800
@@ -80,6 +80,7 @@
KS_CRV, /* request version string */
KS_CSI, /* start insert mode (bar cursor) */
KS_CEI, /* end insert mode (block cursor) */
+ KS_CSR, /* start replace mode (underline cursor) */
#ifdef FEAT_VERTSPLIT
KS_CSV, /* scroll region vertical */
#endif
@@ -157,6 +158,7 @@
#define T_CWS (term_str(KS_CWS)) /* window size */
#define T_CSI (term_str(KS_CSI)) /* start insert mode */
#define T_CEI (term_str(KS_CEI)) /* end insert mode */
+#define T_CSR (term_str(KS_CSR)) /* start replace mode */
#define T_CRV (term_str(KS_CRV)) /* request version string */
#define T_OP (term_str(KS_OP)) /* original color pair */
#define T_U7 (term_str(KS_U7)) /* request cursor position */