Merge remote-tracking branch 'vim/master'

This commit is contained in:
Kazuki Sakamoto
2017-07-31 11:12:18 -07:00
22 changed files with 1294 additions and 291 deletions
-1
View File
@@ -200,7 +200,6 @@ SRC_ALL = \
src/libvterm/.gitignore \
src/libvterm/LICENSE \
src/libvterm/Makefile \
src/libvterm/Makefile.msc \
src/libvterm/README \
src/libvterm/tbl2inc_c.pl \
src/libvterm/vterm.pc.in \
+108 -19
View File
@@ -1,4 +1,4 @@
*eval.txt* For Vim version 8.0. Last change: 2017 Jul 28
*eval.txt* For Vim version 8.0. Last change: 2017 Jul 30
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -2369,12 +2369,18 @@ tagfiles() List tags files used
tan({expr}) Float tangent of {expr}
tanh({expr}) Float hyperbolic tangent of {expr}
tempname() String name for a temporary file
term_getsize() Dict get the size of a terminal
term_open() Job open a terminal window and run a job
term_scrape() List inspect terminal screen
term_sendkeys() Number send keystrokes to a terminal
term_setsize() Number set the size of a terminal
term_wait() Number wait for screen to be updated
term_getattr({attr}, {what} Number get the value of attribute {what}
term_getcursor({buf}) List get the cursor position of a terminal
term_getjob({buf}) Job get the job associated with a terminal
term_getline({buf}[, {row}]) String get a line of text from a terminal
term_getsize({buf}) List get the size of a terminal
term_getstatus({buf}) String get the status of a terminal
term_gettitle({buf}) String get the title of a terminal
term_list() List get the list of terminal buffers
term_scrape({buf}[, {row}]) List get row of a terminal screen
term_sendkeys({buf}, {keys}) none send keystrokes to a terminal
term_start({cmd}, {options}) Job open a terminal window and run a job
term_wait({buf}) Number wait for screen to be updated
test_alloc_fail({id}, {countdown}, {repeat})
none make memory allocation fail
test_autochdir() none enable 'autochdir' during startup
@@ -7898,23 +7904,106 @@ tempname() *tempname()* *temp-file-name*
For MS-Windows forward slashes are used when the 'shellslash'
option is set or when 'shellcmdflag' starts with '-'.
term_getsize() *term_getsize()*
Get the size of a terminal. NOT IMPLEMENTED YET
term_getattr({attr}, {what}) *term_getattr()*
Given {attr}, a value returned by term_scrape() in the "attr"
item, return whether {what} is on. {what} can be one of:
bold
italic
underline
strike
reverse
term_open() *term_open()*
Open a terminal window and run a job. NOT IMPLEMENTED YET
term_getcursor({buf}) *term_getcursor()*
Get the cusor position of terminal {buf}. Returns a list with
three numbers: [rows, cols, visible]. "rows" and "cols" are
zero based. "visible" is one when the cursor is visible, zero
when it is hidden.
This is the cursor position of the terminal itself, not of the
Vim window.
term_scrape() *term_scrape()*
Inspect terminal screen. NOT IMPLEMENTED YET
{buf} must be the buffer number of a terminal window. If the
buffer does not exist or is not a terminal window, an empty
list is returned.
term_sendkeys() *term_sendkeys()*
Send keystrokes to a terminal. NOT IMPLEMENTED YET
term_getjob({buf}) *term_getjob()*
Get the Job associated with terminal window {buf}.
{buf} is used as with |term_getsize()|.
term_setsize() *term_setsize()*
Set the size of a terminal. NOT IMPLEMENTED YET
term_getline({buf} [, {row}]) *term_getline()*
Get a line of text from the terminal window of {buf}.
{buf} is used as with |term_getsize()|.
term_wait() *term_wait()*
Wait for screen to be updated. NOT IMPLEMENTED YET
The first line has {row} zero. When {row} is invalid an empty
string is returned. When {row} is omitted, the cursor line is
used.
term_getsize({buf}) *term_getsize()*
Get the size of terminal {buf}. Returns a list with two
numbers: [rows, cols]. This is the size of the terminal, not
the window containing the terminal.
{buf} must be the buffer number of a terminal window. If the
buffer does not exist or is not a terminal window, an empty
list is returned.
term_getstatus({buf}) *term_getstatus()*
Get the status of terminal {buf}. This returns a comma
separated list of these items:
running job is running
finished job has finished
terminal in Terminal-Normal mode
One of "running" or "finished" is always present.
{buf} must be the buffer number of a terminal window. If the
buffer does not exist or is not a terminal window, an empty
string is returned.
term_gettitle({buf}) *term_gettitle()*
Get the title of terminal {buf}. This is the title that the
job in the terminal has set.
{buf} must be the buffer number of a terminal window. If the
buffer does not exist or is not a terminal window, an empty
string is returned.
term_list() *term_list()*
Return a list with the buffer numbers of all buffers for
terminal windows.
term_scrape({buf} [, {row}]) *term_scrape()*
Get the contents of {row} of terminal screen of {buf}.
For {buf} see |term_getsize()|.
The first {row} is zero. When {row} is invalid an empty list
is returned. When {row} is omitted the cursor line is used.
Return a List containing a Dict for each screen cell:
"chars" character(s) at the cell
"fg" foreground color as #rrggbb
"bg" background color as #rrggbb
"attr" attributes of the cell, use term_getattr()
to get the individual flags
"width" cell width: 1 or 2
term_sendkeys({buf}, {keys}) *term_sendkeys()*
Send keystrokes {keys} to terminal {buf}.
{buf} is used as with |term_getsize()|.
{keys} are translated as key sequences. For example, "\<c-x>"
means the character CTRL-X.
term_start({cmd}, {options}) *term_start()*
Open a terminal window and run {cmd} in it.
Returns the buffer number of the terminal window.
When opening the window fails zero is returned.
{options} are not implemented yet.
term_wait({buf}) *term_wait()*
Wait for pending updates of {buf} to be handled.
{buf} is used as with |term_getsize()|.
test_alloc_fail({id}, {countdown}, {repeat}) *test_alloc_fail()*
This is for testing: If the memory allocation with {id} is
+40 -6
View File
@@ -1,4 +1,4 @@
*terminal.txt* For Vim version 8.0. Last change: 2017 Jul 28
*terminal.txt* For Vim version 8.0. Last change: 2017 Jul 30
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -33,24 +33,39 @@ Or to run a debugger: >
The job runs asynchronously from Vim, the window will be updated to show
output from the job, also while editing in any other window.
Typing ~
When the keyboard focus is in the terminal window, typed keys will be send to
the job. This uses a pty when possible. You can click outside of the
terminal window to move keyboard focus elsewhere.
Navigate between windows with CTRL-W commands. E.g. CTRL-W CTRL-W moves focus
to the next window. Use "CTRL-W :" to edit an Ex command. Use "CTRL-W ." to
send a CTRL-W to the job in the terminal.
CTRL-W can be used to navigate between windows and other CTRL-W commands, e.g.:
CTRL-W CTRL-W move focus to the next window
CTRL-W : enter an Ex command
See |CTRL-W| for more commands.
Special in the terminal window: *CTRL-W_.* *CTRL-W_N*
CTRL-W . send a CTRL-W to the job in the terminal
CTRL-W N go to Terminal Normal mode, see |Terminal-mode|
See option 'termkey' for specifying another key instead of CTRL-W that
will work like CTRL-W. However, typing 'termkey' twice sends 'termkey' to
the job. For example:
'termkey' CTRL-W move focus to the next window
'termkey' : enter an Ex command
'termkey' 'termkey' send 'termkey' to the job in the terminal
'termkey' . send a CTRL-W to the job in the terminal
'termkey' N go to terminal Normal mode, see below
'termkey' CTRL-N same as CTRL-W N
See option 'termkey' for specifying another key that precedes a Vim command.
Typing 'termkey' twice sends 'termkey' to the job.
Size ~
See option 'termsize' for controlling the size of the terminal window.
(TODO: scrolling when the terminal is larger than the window)
Syntax ~
:ter[minal] [command] *:ter* *:terminal*
@@ -99,6 +114,25 @@ terminal. |term_setsize()| can be used only when in the first or second mode,
not when 'termsize' is "rowsXcols".
Terminal Normal mode ~
*Terminal-mode*
When the job is running the contents of the terminal is under control of the
job. That includes the cursor position. The terminal contents can change at
any time.
Use CTRL-W N (or 'termkey' N) to go to Terminal Normal mode. Now the contents
of the terminal window is under control of Vim, the job output is suspended.
*E946*
In this mode you can move the cursor around with the usual Vim commands,
Visually mark text, yank text, etc. But you cannot change the contents of the
buffer. The commands that would start insert mode, such as 'i' and 'a',
return control of the window to the job. Any pending output will now be
displayed.
In Terminal mode the statusline and window title show "(Terminal)". If the
job ends while in Terminal mode this changes to "(Terminal-finished)".
Unix ~
On Unix a pty is used to make it possible to run all kinds of commands. You
+1
View File
@@ -2273,6 +2273,7 @@ test_arglist \
test_tagjump \
test_taglist \
test_tcl \
test_terminal \
test_textobjects \
test_timers \
test_true_false \
+3 -2
View File
@@ -8070,8 +8070,9 @@ get_user_input(
rettv->vval.v_string = NULL;
#ifdef NO_CONSOLE_INPUT
/* While starting up, there is no place to enter text. */
if (no_console_input())
/* While starting up, there is no place to enter text. When running tests
* with --not-a-term we assume feedkeys() will be used. */
if (no_console_input() && !is_not_a_term())
return;
#endif
+18 -3
View File
@@ -830,6 +830,20 @@ static struct fst
{"tanh", 1, 1, f_tanh},
#endif
{"tempname", 0, 0, f_tempname},
#ifdef FEAT_TERMINAL
{"term_getattr", 2, 2, f_term_getattr},
{"term_getcursor", 1, 1, f_term_getcursor},
{"term_getjob", 1, 1, f_term_getjob},
{"term_getline", 1, 2, f_term_getline},
{"term_getsize", 1, 1, f_term_getsize},
{"term_getstatus", 1, 1, f_term_getstatus},
{"term_gettitle", 1, 1, f_term_gettitle},
{"term_list", 0, 0, f_term_list},
{"term_scrape", 1, 2, f_term_scrape},
{"term_sendkeys", 2, 2, f_term_sendkeys},
{"term_start", 1, 2, f_term_start},
{"term_wait", 1, 1, f_term_wait},
#endif
{"test_alloc_fail", 3, 3, f_test_alloc_fail},
{"test_autochdir", 0, 0, f_test_autochdir},
{"test_garbagecollect_now", 0, 0, f_test_garbagecollect_now},
@@ -1540,7 +1554,7 @@ buflist_find_by_name(char_u *name, int curtab_only)
/*
* Get buffer by number or pattern.
*/
static buf_T *
buf_T *
get_buf_tv(typval_T *tv, int curtab_only)
{
char_u *name = tv->vval.v_string;
@@ -6490,8 +6504,9 @@ f_inputlist(typval_T *argvars, typval_T *rettv)
int mouse_used;
#ifdef NO_CONSOLE_INPUT
/* While starting up, there is no place to enter text. */
if (no_console_input())
/* While starting up, there is no place to enter text. When running tests
* with --not-a-term we assume feedkeys() will be used. */
if (no_console_input() && !is_not_a_term())
return;
#endif
if (argvars[0].v_type != VAR_LIST || argvars[0].vval.v_list == NULL)
+1 -1
View File
@@ -106,7 +106,7 @@ static void setpenattr(VTermState *state, VTermAttr attr, VTermValueType type UN
{
#ifdef DEBUG
if(type != vterm_get_attr_type(attr)) {
DEBUG_LOG("Cannot set attr %d as it has type %d, not type %d\n",
DEBUG_LOG3("Cannot set attr %d as it has type %d, not type %d\n",
attr, vterm_get_attr_type(attr), type);
return;
}
+10 -4
View File
@@ -1425,11 +1425,17 @@ main_loop(
else
{
#ifdef FEAT_TERMINAL
if (curbuf->b_term != NULL && oa.op_type == OP_NOP
&& oa.regname == NUL)
terminal_loop();
if (term_use_loop() && oa.op_type == OP_NOP && oa.regname == NUL)
{
/* If terminal_loop() returns OK we got a key that is handled
* in Normal model. With FAIL the terminal was closed and the
* screen needs to be redrawn. */
if (terminal_loop() == OK)
normal_cmd(&oa, TRUE);
}
else
#endif
normal_cmd(&oa, TRUE);
normal_cmd(&oa, TRUE);
}
#ifdef FEAT_GUI_MACVIM
+8
View File
@@ -9071,6 +9071,14 @@ nv_esc(cmdarg_T *cap)
static void
nv_edit(cmdarg_T *cap)
{
#ifdef FEAT_TERMINAL
if (term_in_terminal_mode())
{
term_leave_terminal_mode();
return;
}
#endif
/* <Insert> is equal to "i" */
if (cap->cmdchar == K_INS || cap->cmdchar == K_KINS)
cap->cmdchar = 'i';
+11 -1
View File
@@ -8359,12 +8359,22 @@ set_bool_option(
}
#endif
#ifdef FEAT_TITLE
/* when 'modifiable' is changed, redraw the window title */
else if ((int *)varp == &curbuf->b_p_ma)
{
# ifdef FEAT_TERMINAL
/* Cannot set 'modifiable' when in Terminal mode. */
if (term_in_terminal_mode())
{
curbuf->b_p_ma = FALSE;
return (char_u *)N_("E946: Cannot make a terminal with running job modifiable");
}
# endif
# ifdef FEAT_TITLE
redraw_titles();
# endif
}
#ifdef FEAT_TITLE
/* when 'endofline' is changed, redraw the window title */
else if ((int *)varp == &curbuf->b_p_eol)
{
+1
View File
@@ -1,4 +1,5 @@
/* evalfunc.c */
buf_T* get_buf_tv(typval_T *tv, int curtab_only);
char_u *get_function_name(expand_T *xp, int idx);
char_u *get_expr_name(expand_T *xp, int idx);
int find_internal_func(char_u *name);
+17
View File
@@ -2,12 +2,29 @@
void ex_terminal(exarg_T *eap);
void free_terminal(buf_T *buf);
void write_to_term(buf_T *buffer, char_u *msg, channel_T *channel);
int term_in_terminal_mode(void);
void term_leave_terminal_mode(void);
int term_use_loop(void);
int terminal_loop(void);
void term_job_ended(job_T *job);
void term_channel_closed(channel_T *ch);
int term_update_window(win_T *wp);
int term_is_finished(buf_T *buf);
int term_show_buffer(buf_T *buf);
void term_change_in_curbuf(void);
int term_get_attr(buf_T *buf, linenr_T lnum, int col);
char_u *term_get_status_text(term_T *term);
int set_ref_in_term(int copyID);
void f_term_getattr(typval_T *argvars, typval_T *rettv);
void f_term_getcursor(typval_T *argvars, typval_T *rettv);
void f_term_getjob(typval_T *argvars, typval_T *rettv);
void f_term_getline(typval_T *argvars, typval_T *rettv);
void f_term_getsize(typval_T *argvars, typval_T *rettv);
void f_term_getstatus(typval_T *argvars, typval_T *rettv);
void f_term_gettitle(typval_T *argvars, typval_T *rettv);
void f_term_list(typval_T *argvars, typval_T *rettv);
void f_term_scrape(typval_T *argvars, typval_T *rettv);
void f_term_sendkeys(typval_T *argvars, typval_T *rettv);
void f_term_start(typval_T *argvars, typval_T *rettv);
void f_term_wait(typval_T *argvars, typval_T *rettv);
/* vim: set ft=c : */
+2 -2
View File
@@ -3245,7 +3245,7 @@ win_line(
#endif
#ifdef FEAT_TERMINAL
if (term_is_finished(wp->w_buffer))
if (term_show_buffer(wp->w_buffer))
{
extra_check = TRUE;
get_term_attr = TRUE;
@@ -4541,7 +4541,7 @@ win_line(
#ifdef FEAT_TERMINAL
if (get_term_attr)
{
syntax_attr = term_get_attr(wp->w_buffer, lnum, col);
syntax_attr = term_get_attr(wp->w_buffer, lnum, vcol);
if (!attr_pri)
char_attr = syntax_attr;
+931 -250
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -197,6 +197,7 @@ NEW_TESTS = test_arabic.res \
test_syntax.res \
test_system.res \
test_tcl.res \
test_terminal.res \
test_textobjects.res \
test_undo.res \
test_usercommands.res \
+2
View File
@@ -54,6 +54,7 @@ $(TEST_OUTFILES): $(DOSTMP)\$(*B).in
-@if exist test.ok del test.ok
-@if exist Xdir1 rd /s /q Xdir1
-@if exist Xfind rd /s /q Xfind
-@if exist XfakeHOME rd /s /q XfakeHOME
-@del X*
-@if exist viminfo del viminfo
$(VIMPROG) -u dos.vim $(NO_INITS) "+set ff=unix|f test.out|wq" \
@@ -89,6 +90,7 @@ clean:
-if exist lua.vim del lua.vim
-if exist Xdir1 rd /s /q Xdir1
-if exist Xfind rd /s /q Xfind
-if exist XfakeHOME rd /s /q XfakeHOME
-del X*
-for /d %i in (X*) do @rmdir /s/q %i
-if exist viminfo del viminfo
+2
View File
@@ -84,6 +84,7 @@ clean:
-@if exist lua.vim $(DEL) lua.vim
-@if exist Xdir1 $(DELDIR) Xdir1
-@if exist Xfind $(DELDIR) Xfind
-@if exist XfakeHOME $(DELDIR) XfakeHOME
-@if exist X* $(DEL) X*
-@if exist viminfo $(DEL) viminfo
-@if exist test.log $(DEL) test.log
@@ -98,6 +99,7 @@ clean:
@$(MV) test.out $*.out
-@if exist Xdir1 $(DELDIR) Xdir1
-@if exist Xfind $(DELDIR) Xfind
-@if exist XfakeHOME $(DELDIR) XfakeHOME
-@if exist X* $(DEL) X*
-@if exist test.ok $(DEL) test.ok
-@if exist viminfo $(DEL) viminfo
+4
View File
@@ -158,6 +158,9 @@ func FinishTesting()
" Don't write viminfo on exit.
set viminfo=
" Clean up files created by setup.vim
call delete('XfakeHOME', 'rf')
if s:fail == 0
" Success, create the .res file so that make knows it's done.
exe 'split ' . fnamemodify(g:testname, ':r') . '.res'
@@ -230,6 +233,7 @@ let s:flaky = [
\ 'Test_quoteplus()',
\ 'Test_quotestar()',
\ 'Test_reltime()',
\ 'Test_with_partial_callback()',
\ ]
" Locate Test_ functions and execute them.
+13 -1
View File
@@ -1,5 +1,13 @@
" Common preparations for running tests.
" Only load this once.
if 1
if exists('s:did_load')
finish
endif
let s:did_load = 1
endif
" Make sure 'runtimepath' and 'packpath' does not include $HOME.
set rtp=$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after
if has('packages')
@@ -14,5 +22,9 @@ if 1
endif
" Make sure $HOME does not get read or written.
let $HOME = '/does/not/exist'
" It must exist, gnome tries to create $HOME/.gnome2
let $HOME = getcwd() . '/XfakeHOME'
if !isdirectory($HOME)
call mkdir($HOME)
endif
endif
+2 -1
View File
@@ -6,7 +6,8 @@ func s:test_expand_dllpath(optname)
execute 'call assert_equal("' . $TEST_EXPAND_DLLPATH . '", &' . a:optname . ')'
execute 'set ' . a:optname . '=~' . $TEST_EXPAND_DLLPATH
execute 'call assert_equal("' . $HOME . $TEST_EXPAND_DLLPATH . '", &' . a:optname . ')'
let home = substitute($HOME, '\\', '/', 'g')
execute 'call assert_equal("' . home . $TEST_EXPAND_DLLPATH . '", &' . a:optname . ')'
finally
execute 'let &' . a:optname . ' = dllpath_save'
let $TEST_EXPAND_DLLPATH = ''
+71
View File
@@ -0,0 +1,71 @@
" Tests for the terminal window.
if !exists('*term_start')
finish
endif
source shared.vim
func Test_terminal_basic()
let buf = term_start(&shell)
let termlist = term_list()
call assert_equal(1, len(termlist))
call assert_equal(buf, termlist[0])
let g:job = term_getjob(buf)
call assert_equal(v:t_job, type(g:job))
call term_sendkeys(buf, "exit\r")
call WaitFor('job_status(g:job) == "dead"')
call assert_equal('dead', job_status(g:job))
exe buf . 'bwipe'
unlet g:job
endfunc
func Check_123(buf)
let l = term_scrape(a:buf, 0)
call assert_true(len(l) > 0)
call assert_equal('1', l[0].chars)
call assert_equal('2', l[1].chars)
call assert_equal('3', l[2].chars)
call assert_equal('#00e000', l[0].fg)
if &background == 'light'
call assert_equal('#ffffff', l[0].bg)
else
call assert_equal('#000000', l[0].bg)
endif
let l = term_getline(a:buf, 0)
call assert_equal('123', l)
endfunc
func Test_terminal_scrape()
if has('win32')
let cmd = 'cmd /c "cls && color 2 && echo 123"'
else
call writefile(["\<Esc>[32m123"], 'Xtext')
let cmd = "cat Xtext"
endif
let buf = term_start(cmd)
let termlist = term_list()
call assert_equal(1, len(termlist))
call assert_equal(buf, termlist[0])
" Nothing happens with invalid buffer number
call term_wait(1234)
call term_wait(buf)
call Check_123(buf)
" Must still work after the job ended.
let g:job = term_getjob(buf)
call WaitFor('job_status(g:job) == "dead"')
call term_wait(buf)
call Check_123(buf)
exe buf . 'bwipe'
call delete('Xtext')
endfunc
+48
View File
@@ -784,6 +784,54 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
823,
/**/
822,
/**/
821,
/**/
820,
/**/
819,
/**/
818,
/**/
817,
/**/
816,
/**/
815,
/**/
814,
/**/
813,
/**/
812,
/**/
811,
/**/
810,
/**/
809,
/**/
808,
/**/
807,
/**/
806,
/**/
805,
/**/
804,
/**/
803,
/**/
802,
/**/
801,
/**/
800,
/**/
799,
/**/