diff src/term.c @ 6727:7c5a0c69e1ac v7.4.687

updated for version 7.4.687 Problem: There is no way to use a different in Replace mode for a terminal. Solution: Add t_SR. (Omar Sandoval)
author Bram Moolenaar <bram@vim.org>
date Tue, 31 Mar 2015 18:31:03 +0200
parents c77ef1bf9623
children a89cff862dda
line wrap: on
line diff
--- a/src/term.c
+++ b/src/term.c
@@ -3567,27 +3567,46 @@ cursor_off()
 
 #if defined(CURSOR_SHAPE) || defined(PROTO)
 /*
- * Set cursor shape to match Insert mode.
+ * Set cursor shape to match Insert or 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;
+    char_u *p;
+
+    /* Only do something when redrawing the screen and we can restore the
+     * mode. */
+    if (!full_screen || *T_CEI == NUL)
 	return;
 
-    if (State & INSERT)
+    if ((State & REPLACE) == REPLACE)
     {
-	if (showing_insert_mode != TRUE)
-	    out_str(T_CSI);	    /* Insert mode cursor */
-	showing_insert_mode = TRUE;
+	if (showing_mode != REPLACE)
+	{
+	    if (*T_CSR != NUL)
+		p = T_CSR;	/* Replace mode cursor */
+	    else
+		p = T_CSI;	/* fall back to Insert mode cursor */
+	    if (*p != NUL)
+	    {
+		out_str(p);
+		showing_mode = REPLACE;
+	    }
+	}
     }
-    else
+    else if (State & INSERT)
     {
-	if (showing_insert_mode != FALSE)
-	    out_str(T_CEI);	    /* non-Insert mode cursor */
-	showing_insert_mode = FALSE;
+	if (showing_mode != INSERT && *T_CSI != NUL)
+	{
+	    out_str(T_CSI);	    /* Insert mode cursor */
+	    showing_mode = INSERT;
+	}
+    }
+    else if (showing_mode != NORMAL)
+    {
+	out_str(T_CEI);		    /* non-Insert mode cursor */
+	showing_mode = NORMAL;
     }
 }
 #endif