changeset 16334:52ebcf772310 v8.1.1172

patch 8.1.1172: cursor properties were not fully tested commit https://github.com/vim/vim/commit/74e3d4ec113d4061d24768b5a08f55b918132215 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 14 14:16:46 2019 +0200 patch 8.1.1172: cursor properties were not fully tested Problem: Cursor properties were not fully tested. Solution: Add a test. (Dominique Pelle, closes https://github.com/vim/vim/issues/4256)
author Bram Moolenaar <Bram@vim.org>
date Sun, 14 Apr 2019 14:30:05 +0200
parents 3a6e4a5e7120
children 759cb1a49570
files src/testdir/test_terminal.vim src/version.c
diffstat 2 files changed, 59 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -1892,6 +1892,63 @@ func Test_terminal_no_job()
   call WaitForAssert({-> assert_equal(v:null, term_getjob(term)) })
 endfunc
 
+func Test_term_getcursor()
+  if !has('unix')
+    return
+  endif
+  let buf = Run_shell_in_terminal({})
+
+  " Wait for the shell to display a prompt.
+  call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
+
+  " Hide the cursor.
+  call term_sendkeys(buf, "echo -e '\\033[?25l'\r")
+  call WaitForAssert({-> assert_equal(0, term_getcursor(buf)[2].visible)})
+
+  " Show the cursor.
+  call term_sendkeys(buf, "echo -e '\\033[?25h'\r")
+  call WaitForAssert({-> assert_equal(1, term_getcursor(buf)[2].visible)})
+
+  " Change color of cursor.
+  call WaitForAssert({-> assert_equal('', term_getcursor(buf)[2].color)})
+  call term_sendkeys(buf, "echo -e '\\033]12;blue\\007'\r")
+  call WaitForAssert({-> assert_equal('blue', term_getcursor(buf)[2].color)})
+  call term_sendkeys(buf, "echo -e '\\033]12;green\\007'\r")
+  call WaitForAssert({-> assert_equal('green', term_getcursor(buf)[2].color)})
+
+  " Make cursor a blinking block.
+  call term_sendkeys(buf, "echo -e '\\033[1 q'\r")
+  call WaitForAssert({-> assert_equal([1, 1],
+  \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])})
+
+  " Make cursor a steady block.
+  call term_sendkeys(buf, "echo -e '\\033[2 q'\r")
+  call WaitForAssert({-> assert_equal([0, 1],
+  \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])})
+
+  " Make cursor a blinking underline.
+  call term_sendkeys(buf, "echo -e '\\033[3 q'\r")
+  call WaitForAssert({-> assert_equal([1, 2],
+  \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])})
+
+  " Make cursor a steady underline.
+  call term_sendkeys(buf, "echo -e '\\033[4 q'\r")
+  call WaitForAssert({-> assert_equal([0, 2],
+  \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])})
+
+  " Make cursor a blinking vertical bar.
+  call term_sendkeys(buf, "echo -e '\\033[5 q'\r")
+  call WaitForAssert({-> assert_equal([1, 3],
+  \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])})
+
+  " Make cursor a steady vertical bar.
+  call term_sendkeys(buf, "echo -e '\\033[6 q'\r")
+  call WaitForAssert({-> assert_equal([0, 3],
+  \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])})
+
+  call Stop_shell_in_terminal(buf)
+endfunc
+
 func Test_term_gettitle()
   " term_gettitle() returns an empty string for a non-terminal buffer
   " and for a non-existing buffer.
--- a/src/version.c
+++ b/src/version.c
@@ -772,6 +772,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1172,
+/**/
     1171,
 /**/
     1170,