Mercurial > vim
comparison src/testdir/test_terminal.vim @ 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 | 789a207c475f |
children | e8c081146788 |
comparison
equal
deleted
inserted
replaced
16333:3a6e4a5e7120 | 16334:52ebcf772310 |
---|---|
1890 func Test_terminal_no_job() | 1890 func Test_terminal_no_job() |
1891 let term = term_start('false', {'term_finish': 'close'}) | 1891 let term = term_start('false', {'term_finish': 'close'}) |
1892 call WaitForAssert({-> assert_equal(v:null, term_getjob(term)) }) | 1892 call WaitForAssert({-> assert_equal(v:null, term_getjob(term)) }) |
1893 endfunc | 1893 endfunc |
1894 | 1894 |
1895 func Test_term_getcursor() | |
1896 if !has('unix') | |
1897 return | |
1898 endif | |
1899 let buf = Run_shell_in_terminal({}) | |
1900 | |
1901 " Wait for the shell to display a prompt. | |
1902 call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))}) | |
1903 | |
1904 " Hide the cursor. | |
1905 call term_sendkeys(buf, "echo -e '\\033[?25l'\r") | |
1906 call WaitForAssert({-> assert_equal(0, term_getcursor(buf)[2].visible)}) | |
1907 | |
1908 " Show the cursor. | |
1909 call term_sendkeys(buf, "echo -e '\\033[?25h'\r") | |
1910 call WaitForAssert({-> assert_equal(1, term_getcursor(buf)[2].visible)}) | |
1911 | |
1912 " Change color of cursor. | |
1913 call WaitForAssert({-> assert_equal('', term_getcursor(buf)[2].color)}) | |
1914 call term_sendkeys(buf, "echo -e '\\033]12;blue\\007'\r") | |
1915 call WaitForAssert({-> assert_equal('blue', term_getcursor(buf)[2].color)}) | |
1916 call term_sendkeys(buf, "echo -e '\\033]12;green\\007'\r") | |
1917 call WaitForAssert({-> assert_equal('green', term_getcursor(buf)[2].color)}) | |
1918 | |
1919 " Make cursor a blinking block. | |
1920 call term_sendkeys(buf, "echo -e '\\033[1 q'\r") | |
1921 call WaitForAssert({-> assert_equal([1, 1], | |
1922 \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])}) | |
1923 | |
1924 " Make cursor a steady block. | |
1925 call term_sendkeys(buf, "echo -e '\\033[2 q'\r") | |
1926 call WaitForAssert({-> assert_equal([0, 1], | |
1927 \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])}) | |
1928 | |
1929 " Make cursor a blinking underline. | |
1930 call term_sendkeys(buf, "echo -e '\\033[3 q'\r") | |
1931 call WaitForAssert({-> assert_equal([1, 2], | |
1932 \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])}) | |
1933 | |
1934 " Make cursor a steady underline. | |
1935 call term_sendkeys(buf, "echo -e '\\033[4 q'\r") | |
1936 call WaitForAssert({-> assert_equal([0, 2], | |
1937 \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])}) | |
1938 | |
1939 " Make cursor a blinking vertical bar. | |
1940 call term_sendkeys(buf, "echo -e '\\033[5 q'\r") | |
1941 call WaitForAssert({-> assert_equal([1, 3], | |
1942 \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])}) | |
1943 | |
1944 " Make cursor a steady vertical bar. | |
1945 call term_sendkeys(buf, "echo -e '\\033[6 q'\r") | |
1946 call WaitForAssert({-> assert_equal([0, 3], | |
1947 \ [term_getcursor(buf)[2].blink, term_getcursor(buf)[2].shape])}) | |
1948 | |
1949 call Stop_shell_in_terminal(buf) | |
1950 endfunc | |
1951 | |
1895 func Test_term_gettitle() | 1952 func Test_term_gettitle() |
1896 " term_gettitle() returns an empty string for a non-terminal buffer | 1953 " term_gettitle() returns an empty string for a non-terminal buffer |
1897 " and for a non-existing buffer. | 1954 " and for a non-existing buffer. |
1898 call assert_equal('', term_gettitle(bufnr('%'))) | 1955 call assert_equal('', term_gettitle(bufnr('%'))) |
1899 call assert_equal('', term_gettitle(bufnr('$') + 1)) | 1956 call assert_equal('', term_gettitle(bufnr('$') + 1)) |