Permalink
Browse files

patch 8.0.0817: cannot get the terminal line at the cursor

Problem:    Cannot get the line of a terminal window at the cursor.
Solution:   Make the row argunt optionsl. (Yasuhiro Matsumoto, closes #1898)
  • Loading branch information...
brammool committed Jul 30, 2017
1 parent f144a3f commit 22aad2f8806acf390568b8e524e53260a322aaa5
Showing with 28 additions and 22 deletions.
  1. +10 −9 runtime/doc/eval.txt
  2. +2 −2 src/evalfunc.c
  3. +14 −11 src/terminal.c
  4. +2 −0 src/version.c
View
@@ -1,4 +1,4 @@
*eval.txt* For Vim version 8.0. Last change: 2017 Jul 29
*eval.txt* For Vim version 8.0. Last change: 2017 Jul 30
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -2371,10 +2371,10 @@ tanh({expr}) Float hyperbolic tangent of {expr}
tempname() String name for a temporary file
term_getattr({attr}, {what} Number get the value of attribute {what}
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_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_start({cmd}, {options}) Job open a terminal window and run a job
term_wait({buf}) Number wait for screen to be updated
@@ -7914,12 +7914,13 @@ term_getjob({buf}) *term_getjob()*
Get the Job associated with terminal window {buf}.
{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}.
{buf} is used as with |term_getsize()|.
The first line has {row} zero. When {row} is invalid an empty
string is returned.
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
@@ -7930,17 +7931,17 @@ term_getsize({buf}) *term_getsize()*
buffer does not exist or is not a terminal window, an empty
list is returned.
term_list(}) *term_list()*
term_list() *term_list()*
Return a list with the buffer numbers of all buffers for
terminal windows.
term_scrape({buf}, {row}) *term_scrape()*
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.
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
View
@@ -833,10 +833,10 @@ static struct fst
#ifdef FEAT_TERMINAL
{"term_getattr", 2, 2, f_term_getattr},
{"term_getjob", 1, 1, f_term_getjob},
{"term_getline", 2, 2, f_term_getline},
{"term_getline", 1, 2, f_term_getline},
{"term_getsize", 1, 1, f_term_getsize},
{"term_list", 0, 0, f_term_list},
{"term_scrape", 2, 2, f_term_scrape},
{"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},
View
@@ -53,6 +53,7 @@
* :term <24x80> <close> vim notes.txt
* - To set BS correctly, check get_stty(); Pass the fd of the pty.
* - do not store terminal window in viminfo. Or prefix term:// ?
* - add term_getcursor() - return cursor position: [row, col, visible]
* - add a character in :ls output
* - add 't' to mode()
* - when closing window and job has not ended, make terminal hidden?
@@ -120,7 +121,7 @@ struct terminal_S {
garray_T tl_scrollback;
int tl_scrollback_scrolled;
pos_T tl_cursor;
VTermPos tl_cursor_pos;
int tl_cursor_visible;
};
@@ -1020,20 +1021,16 @@ handle_movecursor(
{
term_T *term = (term_T *)user;
win_T *wp;
int is_current = FALSE;
term->tl_cursor_pos = pos;
term->tl_cursor_visible = visible;
FOR_ALL_WINDOWS(wp)
{
if (wp->w_buffer == term->tl_buffer)
{
position_cursor(wp, &pos);
if (wp == curwin)
is_current = TRUE;
}
}
term->tl_cursor_visible = visible;
if (is_current)
if (term->tl_buffer == curbuf)
{
may_toggle_cursor(term);
update_cursor(term, TRUE);
@@ -1723,7 +1720,10 @@ f_term_getline(typval_T *argvars, typval_T *rettv)
if (buf == NULL)
return;
term = buf->b_term;
row = (int)get_tv_number(&argvars[1]);
if (argvars[1].v_type == VAR_UNKNOWN)
row = term->tl_cursor_pos.row;
else
row = (int)get_tv_number(&argvars[1]);
if (term->tl_vterm == NULL)
{
@@ -1814,7 +1814,10 @@ f_term_scrape(typval_T *argvars, typval_T *rettv)
screen = vterm_obtain_screen(term->tl_vterm);
l = rettv->vval.v_list;
pos.row = (int)get_tv_number(&argvars[1]);
if (argvars[1].v_type == VAR_UNKNOWN)
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; )
{
dict_T *dcell;
View
@@ -769,6 +769,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
817,
/**/
816,
/**/

0 comments on commit 22aad2f

Please sign in to comment.