0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.0.0832: terminal function arguments are not consistent

Problem:    Terminal function arguments are not consistent.
Solution:   Use one-based instead of zero-based rows and cols.  Use "." for
            the current row.
This commit is contained in:
Bram Moolenaar
2017-08-01 18:35:38 +02:00
parent 12d853fae1
commit c2ce52c011
3 changed files with 30 additions and 25 deletions

View File

@@ -1,4 +1,4 @@
*eval.txt* For Vim version 8.0. Last change: 2017 Jul 30 *eval.txt* For Vim version 8.0. Last change: 2017 Aug 01
VIM REFERENCE MANUAL by Bram Moolenaar VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1815,7 +1815,7 @@ v:scrollstart String describing the script or function that caused the
hit-enter prompt. hit-enter prompt.
*v:servername* *servername-variable* *v:servername* *servername-variable*
v:servername The resulting registered |x11-clientserver| name if any. v:servername The resulting registered |client-server-name| if any.
Read-only. Read-only.
@@ -2372,12 +2372,12 @@ tempname() String name for a temporary file
term_getattr({attr}, {what} Number get the value of attribute {what} term_getattr({attr}, {what} Number get the value of attribute {what}
term_getcursor({buf}) List get the cursor position of a terminal term_getcursor({buf}) List get the cursor position of a terminal
term_getjob({buf}) Job get the job associated with 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_getline({buf}, {row}) String get a line of text from a terminal
term_getsize({buf}) List get the size of a terminal term_getsize({buf}) List get the size of a terminal
term_getstatus({buf}) String get the status of a terminal term_getstatus({buf}) String get the status of a terminal
term_gettitle({buf}) String get the title of a terminal term_gettitle({buf}) String get the title of a terminal
term_list() List get the list of terminal buffers term_list() List get the list of terminal buffers
term_scrape({buf}[, {row}]) List get row of a terminal screen term_scrape({buf}, {row}) List get row of a terminal screen
term_sendkeys({buf}, {keys}) none send keystrokes to a terminal term_sendkeys({buf}, {keys}) none send keystrokes to a terminal
term_start({cmd}, {options}) Job open a terminal window and run a job term_start({cmd}, {options}) Job open a terminal window and run a job
term_wait({buf}) Number wait for screen to be updated term_wait({buf}) Number wait for screen to be updated
@@ -7916,8 +7916,9 @@ term_getattr({attr}, {what}) *term_getattr()*
term_getcursor({buf}) *term_getcursor()* term_getcursor({buf}) *term_getcursor()*
Get the cusor position of terminal {buf}. Returns a list with Get the cusor position of terminal {buf}. Returns a list with
three numbers: [rows, cols, visible]. "rows" and "cols" are three numbers: [rows, cols, visible]. "rows" and "cols" are
zero based. "visible" is one when the cursor is visible, zero one based, the first sceen cell is row 1, column 1.
when it is hidden. "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 This is the cursor position of the terminal itself, not of the
Vim window. Vim window.
@@ -7930,13 +7931,12 @@ term_getjob({buf}) *term_getjob()*
Get the Job associated with terminal window {buf}. Get the Job associated with terminal window {buf}.
{buf} is used as with |term_getsize()|. {buf} is used as with |term_getsize()|.
term_getline({buf} [, {row}]) *term_getline()* term_getline({buf}, {row}) *term_getline()*
Get a line of text from the terminal window of {buf}. Get a line of text from the terminal window of {buf}.
{buf} is used as with |term_getsize()|. {buf} is used as with |term_getsize()|.
The first line has {row} zero. When {row} is invalid an empty The first line has {row} one. When {row} "." the cursor line
string is returned. When {row} is omitted, the cursor line is is used. When {row} is invalid an empty string is returned.
used.
term_getsize({buf}) *term_getsize()* term_getsize({buf}) *term_getsize()*
Get the size of terminal {buf}. Returns a list with two Get the size of terminal {buf}. Returns a list with two
@@ -7971,12 +7971,12 @@ term_list() *term_list()*
Return a list with the buffer numbers of all buffers for Return a list with the buffer numbers of all buffers for
terminal windows. terminal windows.
term_scrape({buf} [, {row}]) *term_scrape()* term_scrape({buf}, {row}) *term_scrape()*
Get the contents of {row} of terminal screen of {buf}. Get the contents of {row} of terminal screen of {buf}.
For {buf} see |term_getsize()|. For {buf} see |term_getsize()|.
The first {row} is zero. When {row} is invalid an empty list The first line has {row} one. When {row} "." the cursor line
is returned. When {row} is omitted the cursor line is used. is used. When {row} is invalid an empty string is returned.
Return a List containing a Dict for each screen cell: Return a List containing a Dict for each screen cell:
"chars" character(s) at the cell "chars" character(s) at the cell
@@ -8728,6 +8728,7 @@ tag_any_white Compiled with support for any white characters in tags
files |tag-any-white|. files |tag-any-white|.
tcl Compiled with Tcl interface. tcl Compiled with Tcl interface.
termguicolors Compiled with true color in terminal support. termguicolors Compiled with true color in terminal support.
terminal Compiled with |terminal| support.
terminfo Compiled with terminfo instead of termcap. terminfo Compiled with terminfo instead of termcap.
termresponse Compiled with support for |t_RV| and |v:termresponse|. termresponse Compiled with support for |t_RV| and |v:termresponse|.
textobjects Compiled with support for |text-objects|. textobjects Compiled with support for |text-objects|.

View File

@@ -36,8 +36,6 @@
* that buffer, attributes come from the scrollback buffer tl_scrollback. * that buffer, attributes come from the scrollback buffer tl_scrollback.
* *
* TODO: * TODO:
* - Use "." for current line instead of optional argument.
* - make row and cols one-based instead of zero-based in term_ functions.
* - Add StatusLineTerm highlighting * - Add StatusLineTerm highlighting
* - in bash mouse clicks are inserting characters. * - in bash mouse clicks are inserting characters.
* - mouse scroll: when over other window, scroll that window. * - mouse scroll: when over other window, scroll that window.
@@ -1773,8 +1771,8 @@ f_term_getcursor(typval_T *argvars, typval_T *rettv)
return; return;
l = rettv->vval.v_list; l = rettv->vval.v_list;
list_append_number(l, buf->b_term->tl_cursor_pos.row); list_append_number(l, buf->b_term->tl_cursor_pos.row + 1);
list_append_number(l, buf->b_term->tl_cursor_pos.col); list_append_number(l, buf->b_term->tl_cursor_pos.col + 1);
list_append_number(l, buf->b_term->tl_cursor_visible); list_append_number(l, buf->b_term->tl_cursor_visible);
} }
@@ -1796,6 +1794,16 @@ f_term_getjob(typval_T *argvars, typval_T *rettv)
++rettv->vval.v_job->jv_refcount; ++rettv->vval.v_job->jv_refcount;
} }
static int
get_row_number(typval_T *tv, term_T *term)
{
if (tv->v_type == VAR_STRING
&& tv->vval.v_string != NULL
&& STRCMP(tv->vval.v_string, ".") == 0)
return term->tl_cursor_pos.row;
return (int)get_tv_number(tv) - 1;
}
/* /*
* "term_getline(buf, row)" function * "term_getline(buf, row)" function
*/ */
@@ -1810,10 +1818,7 @@ f_term_getline(typval_T *argvars, typval_T *rettv)
if (buf == NULL) if (buf == NULL)
return; return;
term = buf->b_term; term = buf->b_term;
if (argvars[1].v_type == VAR_UNKNOWN) row = get_row_number(&argvars[1], term);
row = term->tl_cursor_pos.row;
else
row = (int)get_tv_number(&argvars[1]);
if (term->tl_vterm == NULL) if (term->tl_vterm == NULL)
{ {
@@ -1944,10 +1949,7 @@ f_term_scrape(typval_T *argvars, typval_T *rettv)
screen = vterm_obtain_screen(term->tl_vterm); screen = vterm_obtain_screen(term->tl_vterm);
l = rettv->vval.v_list; l = rettv->vval.v_list;
if (argvars[1].v_type == VAR_UNKNOWN) pos.row = get_row_number(&argvars[1], term);
pos.row = term->tl_cursor_pos.row;
else
pos.row = (int)get_tv_number(&argvars[1]);
for (pos.col = 0; pos.col < term->tl_cols; ) for (pos.col = 0; pos.col < term->tl_cols; )
{ {
dict_T *dcell; dict_T *dcell;

View File

@@ -769,6 +769,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
832,
/**/ /**/
831, 831,
/**/ /**/