Mercurial > vim
comparison src/testdir/screendump.vim @ 14019:dc67449d648c v8.1.0027
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
commit https://github.com/vim/vim/commit/f273245f6433d5d43a5671306b520a3230c35787
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 3 14:47:35 2018 +0200
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Problem: Difficult to make a plugin that feeds a line to a job.
Solution: Add the nitial code for the "prompt" buftype.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 03 Jun 2018 15:00:07 +0200 |
parents | f22db93bd887 |
children | eb5ee7479d31 |
comparison
equal
deleted
inserted
replaced
14018:c3064aaf53fb | 14019:dc67449d648c |
---|---|
3 " Only load this script once. | 3 " Only load this script once. |
4 if exists('*CanRunVimInTerminal') | 4 if exists('*CanRunVimInTerminal') |
5 finish | 5 finish |
6 endif | 6 endif |
7 | 7 |
8 " Need to be able to run terminal Vim with 256 colors. On MS-Windows the | 8 " For most tests we need to be able to run terminal Vim with 256 colors. On |
9 " console only has 16 colors and the GUI can't run in a terminal. | 9 " MS-Windows the console only has 16 colors and the GUI can't run in a |
10 if !has('terminal') || has('win32') | 10 " terminal. |
11 func CanRunVimInTerminal() | 11 func CanRunVimInTerminal() |
12 return 0 | 12 return has('terminal') && !has('win32') |
13 endfunc | 13 endfunc |
14 | |
15 " Skip the rest if there is no terminal feature at all. | |
16 if !has('terminal') | |
14 finish | 17 finish |
15 endif | 18 endif |
16 | |
17 func CanRunVimInTerminal() | |
18 return 1 | |
19 endfunc | |
20 | 19 |
21 source shared.vim | 20 source shared.vim |
22 | 21 |
23 " Run Vim with "arguments" in a new terminal window. | 22 " Run Vim with "arguments" in a new terminal window. |
24 " By default uses a size of 20 lines and 75 columns. | 23 " By default uses a size of 20 lines and 75 columns. |
52 " Make the window 20 lines high and 75 columns, unless told otherwise. | 51 " Make the window 20 lines high and 75 columns, unless told otherwise. |
53 let rows = get(a:options, 'rows', 20) | 52 let rows = get(a:options, 'rows', 20) |
54 let cols = get(a:options, 'cols', 75) | 53 let cols = get(a:options, 'cols', 75) |
55 | 54 |
56 let cmd = GetVimCommandClean() | 55 let cmd = GetVimCommandClean() |
56 | |
57 " Add -v to have gvim run in the terminal (if possible) | 57 " Add -v to have gvim run in the terminal (if possible) |
58 let cmd .= ' -v ' . a:arguments | 58 let cmd .= ' -v ' . a:arguments |
59 let buf = term_start(cmd, {'curwin': 1, 'term_rows': rows, 'term_cols': cols}) | 59 let buf = term_start(cmd, {'curwin': 1, 'term_rows': rows, 'term_cols': cols}) |
60 if &termwinsize == '' | 60 if &termwinsize == '' |
61 call assert_equal([rows, cols], term_getsize(buf)) | 61 call assert_equal([rows, cols], term_getsize(buf)) |
62 else | 62 else |
63 let rows = term_getsize(buf)[0] | 63 let rows = term_getsize(buf)[0] |
64 let cols = term_getsize(buf)[1] | 64 let cols = term_getsize(buf)[1] |
65 endif | 65 endif |
66 | 66 |
67 " Wait for "All" or "Top" of the ruler in the status line to be shown. This | 67 " Wait for "All" or "Top" of the ruler to be shown in the last line or in |
68 " can be quite slow (e.g. when using valgrind). | 68 " the status line of the last window. This can be quite slow (e.g. when |
69 " using valgrind). | |
69 " If it fails then show the terminal contents for debugging. | 70 " If it fails then show the terminal contents for debugging. |
70 try | 71 try |
71 call WaitFor({-> len(term_getline(buf, rows)) >= cols - 1}) | 72 call WaitFor({-> len(term_getline(buf, rows)) >= cols - 1 || len(term_getline(buf, rows - 1)) >= cols - 1}) |
72 catch /timed out after/ | 73 catch /timed out after/ |
73 let lines = map(range(1, rows), {key, val -> term_getline(buf, val)}) | 74 let lines = map(range(1, rows), {key, val -> term_getline(buf, val)}) |
74 call assert_report('RunVimInTerminal() failed, screen contents: ' . join(lines, "<NL>")) | 75 call assert_report('RunVimInTerminal() failed, screen contents: ' . join(lines, "<NL>")) |
75 endtry | 76 endtry |
76 | 77 |
78 endfunc | 79 endfunc |
79 | 80 |
80 " Stop a Vim running in terminal buffer "buf". | 81 " Stop a Vim running in terminal buffer "buf". |
81 func StopVimInTerminal(buf) | 82 func StopVimInTerminal(buf) |
82 call assert_equal("running", term_getstatus(a:buf)) | 83 call assert_equal("running", term_getstatus(a:buf)) |
83 call term_sendkeys(a:buf, "\<Esc>\<Esc>:qa!\<cr>") | 84 call term_sendkeys(a:buf, "\<Esc>:qa!\<cr>") |
84 call WaitForAssert({-> assert_equal("finished", term_getstatus(a:buf))}) | 85 call WaitForAssert({-> assert_equal("finished", term_getstatus(a:buf))}) |
85 only! | 86 only! |
86 endfunc | 87 endfunc |
87 | 88 |
88 " Verify that Vim running in terminal buffer "buf" matches the screen dump. | 89 " Verify that Vim running in terminal buffer "buf" matches the screen dump. |