Skip to content

Commit 1c8be13

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 36913ec + 82b9ca0 commit 1c8be13

6 files changed

Lines changed: 47 additions & 2 deletions

File tree

runtime/doc/eval.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,6 +2373,7 @@ term_getattr({attr}, {what}) Number get the value of attribute {what}
23732373
term_getcursor({buf}) List get the cursor position of a terminal
23742374
term_getjob({buf}) Job get the job associated with a terminal
23752375
term_getline({buf}, {row}) String get a line of text from a terminal
2376+
term_getscrolled({buf}) Number get the scroll count of a terminal
23762377
term_getsize({buf}) List get the size of a terminal
23772378
term_getstatus({buf}) String get the status of a terminal
23782379
term_gettitle({buf}) String get the title of a terminal
@@ -2984,6 +2985,11 @@ ch_logfile({fname} [, {mode}]) *ch_logfile()*
29842985
The file is flushed after every message, on Unix you can use
29852986
"tail -f" to see what is going on in real time.
29862987

2988+
This function is not available in the |sandbox|.
2989+
NOTE: the channel communication is stored in the file, be
2990+
aware that this may contain confidential and privacy sensitive
2991+
information, e.g. a password you type in a terminal window.
2992+
29872993

29882994
ch_open({address} [, {options}]) *ch_open()*
29892995
Open a channel to {address}. See |channel|.
@@ -7948,6 +7954,18 @@ term_getline({buf}, {row}) *term_getline()*
79487954
returned.
79497955
{only available when compiled with the |+terminal| feature}
79507956

7957+
term_getscrolled({buf}) *term_getscrolled()*
7958+
Return the number of lines that scrolled to above the top of
7959+
terminal {buf}. This is the offset between the row number
7960+
used for |term_getline()| and |getline()|, so that: >
7961+
term_getline(buf, N)
7962+
< is equal to: >
7963+
`getline(N + term_getscrolled(buf))
7964+
< (if that line exists).
7965+
7966+
{buf} is used as with |term_getsize()|.
7967+
{only available when compiled with the |+terminal| feature}
7968+
79517969
term_getsize({buf}) *term_getsize()*
79527970
Get the size of terminal {buf}. Returns a list with two
79537971
numbers: [rows, cols]. This is the size of the terminal, not

src/evalfunc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ static struct fst
835835
{"term_getcursor", 1, 1, f_term_getcursor},
836836
{"term_getjob", 1, 1, f_term_getjob},
837837
{"term_getline", 2, 2, f_term_getline},
838+
{"term_getscrolled", 1, 1, f_term_getscrolled},
838839
{"term_getsize", 1, 1, f_term_getsize},
839840
{"term_getstatus", 1, 1, f_term_getstatus},
840841
{"term_gettitle", 1, 1, f_term_gettitle},

src/proto/terminal.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ void f_term_getattr(typval_T *argvars, typval_T *rettv);
2121
void f_term_getcursor(typval_T *argvars, typval_T *rettv);
2222
void f_term_getjob(typval_T *argvars, typval_T *rettv);
2323
void f_term_getline(typval_T *argvars, typval_T *rettv);
24+
void f_term_getscrolled(typval_T *argvars, typval_T *rettv);
2425
void f_term_getsize(typval_T *argvars, typval_T *rettv);
2526
void f_term_getstatus(typval_T *argvars, typval_T *rettv);
2627
void f_term_gettitle(typval_T *argvars, typval_T *rettv);

src/terminal.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@
4040
* - Need an option or argument to drop the window+buffer right away, to be
4141
* used for a shell or Vim. 'termfinish'; "close", "open" (open window when
4242
* job finishes).
43+
* patch by Yasuhiro: #1950
4344
* - add option values to the command:
4445
* :term <24x80> <close> vim notes.txt
46+
* or use:
47+
* :term ++24x80 ++close vim notes.txt
4548
* - support different cursor shapes, colors and attributes
46-
* - MS-Windows: no redraw for 'updatetime' #1915
4749
* - make term_getcursor() return type (none/block/bar/underline) and
4850
* attributes (color, blink, etc.)
51+
* - MS-Windows: no redraw for 'updatetime' #1915
4952
* - To set BS correctly, check get_stty(); Pass the fd of the pty.
5053
* For the GUI fill termios with default values, perhaps like pangoterm:
5154
* http://bazaar.launchpad.net/~leonerd/pangoterm/trunk/view/head:/main.c#L134
@@ -337,8 +340,9 @@ term_start(char_u *cmd, jobopt_T *opt)
337340
/* System dependent: setup the vterm and start the job in it. */
338341
if (term_and_job_init(term, term->tl_rows, term->tl_cols, cmd, opt) == OK)
339342
{
340-
/* store the size we ended up with */
343+
/* Get and remember the size we ended up with. Update the pty. */
341344
vterm_get_size(term->tl_vterm, &term->tl_rows, &term->tl_cols);
345+
term_report_winsize(term, term->tl_rows, term->tl_cols);
342346
}
343347
else
344348
{
@@ -2027,6 +2031,19 @@ f_term_getline(typval_T *argvars, typval_T *rettv)
20272031
}
20282032
}
20292033

2034+
/*
2035+
* "term_getscrolled(buf)" function
2036+
*/
2037+
void
2038+
f_term_getscrolled(typval_T *argvars, typval_T *rettv)
2039+
{
2040+
buf_T *buf = term_get_buf(argvars);
2041+
2042+
if (buf == NULL)
2043+
return;
2044+
rettv->vval.v_number = buf->b_term->tl_scrollback_scrolled;
2045+
}
2046+
20302047
/*
20312048
* "term_getsize(buf)" function
20322049
*/

src/testdir/test_terminal.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,13 @@ func Test_terminal_scroll()
227227
sleep 100m
228228
endif
229229

230+
let scrolled = term_getscrolled(buf)
230231
call assert_equal('1', getline(1))
232+
call assert_equal('1', term_getline(buf, 1 - scrolled))
231233
call assert_equal('49', getline(49))
234+
call assert_equal('49', term_getline(buf, 49 - scrolled))
232235
call assert_equal('200', getline(200))
236+
call assert_equal('200', term_getline(buf, 200 - scrolled))
233237

234238
exe buf . 'bwipe'
235239
call delete('Xtext')

src/version.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,10 @@ static char *(features[]) =
784784

785785
static int included_patches[] =
786786
{ /* Add new patch number below this line */
787+
/**/
788+
893,
789+
/**/
790+
892,
787791
/**/
788792
891,
789793
/**/

0 commit comments

Comments
 (0)