mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.0.0818: cannot get the cursor position of a terminal
Problem: Cannot get the cursor position of a terminal. Solution: Add term_getcursor().
This commit is contained in:
@@ -2370,6 +2370,7 @@ tan({expr}) Float tangent of {expr}
|
|||||||
tanh({expr}) Float hyperbolic tangent of {expr}
|
tanh({expr}) Float hyperbolic tangent of {expr}
|
||||||
tempname() String name for a temporary file
|
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_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
|
||||||
@@ -7910,6 +7911,19 @@ term_getattr({attr}, {what}) *term_getattr()*
|
|||||||
strike
|
strike
|
||||||
reverse
|
reverse
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
{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_getjob({buf}) *term_getjob()*
|
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()|.
|
||||||
|
@@ -832,6 +832,7 @@ static struct fst
|
|||||||
{"tempname", 0, 0, f_tempname},
|
{"tempname", 0, 0, f_tempname},
|
||||||
#ifdef FEAT_TERMINAL
|
#ifdef FEAT_TERMINAL
|
||||||
{"term_getattr", 2, 2, f_term_getattr},
|
{"term_getattr", 2, 2, f_term_getattr},
|
||||||
|
{"term_getcursor", 1, 1, f_term_getcursor},
|
||||||
{"term_getjob", 1, 1, f_term_getjob},
|
{"term_getjob", 1, 1, f_term_getjob},
|
||||||
{"term_getline", 1, 2, f_term_getline},
|
{"term_getline", 1, 2, f_term_getline},
|
||||||
{"term_getsize", 1, 1, f_term_getsize},
|
{"term_getsize", 1, 1, f_term_getsize},
|
||||||
|
@@ -16,6 +16,7 @@ int term_get_attr(buf_T *buf, linenr_T lnum, int col);
|
|||||||
char_u *term_get_status_text(term_T *term);
|
char_u *term_get_status_text(term_T *term);
|
||||||
int set_ref_in_term(int copyID);
|
int set_ref_in_term(int copyID);
|
||||||
void f_term_getattr(typval_T *argvars, typval_T *rettv);
|
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_getjob(typval_T *argvars, typval_T *rettv);
|
||||||
void f_term_getline(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_getsize(typval_T *argvars, typval_T *rettv);
|
||||||
|
@@ -53,7 +53,6 @@
|
|||||||
* :term <24x80> <close> vim notes.txt
|
* :term <24x80> <close> vim notes.txt
|
||||||
* - To set BS correctly, check get_stty(); Pass the fd of the pty.
|
* - To set BS correctly, check get_stty(); Pass the fd of the pty.
|
||||||
* - do not store terminal window in viminfo. Or prefix term:// ?
|
* - 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 a character in :ls output
|
||||||
* - add 't' to mode()
|
* - add 't' to mode()
|
||||||
* - when closing window and job has not ended, make terminal hidden?
|
* - when closing window and job has not ended, make terminal hidden?
|
||||||
@@ -1636,6 +1635,24 @@ set_ref_in_term(int copyID)
|
|||||||
return abort;
|
return abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the buffer from the first argument in "argvars".
|
||||||
|
* Returns NULL when the buffer is not for a terminal window.
|
||||||
|
*/
|
||||||
|
static buf_T *
|
||||||
|
term_get_buf(typval_T *argvars)
|
||||||
|
{
|
||||||
|
buf_T *buf;
|
||||||
|
|
||||||
|
(void)get_tv_number(&argvars[0]); /* issue errmsg if type error */
|
||||||
|
++emsg_off;
|
||||||
|
buf = get_buf_tv(&argvars[0], FALSE);
|
||||||
|
--emsg_off;
|
||||||
|
if (buf == NULL || buf->b_term == NULL)
|
||||||
|
return NULL;
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "term_getattr(attr, name)" function
|
* "term_getattr(attr, name)" function
|
||||||
*/
|
*/
|
||||||
@@ -1671,21 +1688,23 @@ f_term_getattr(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the buffer from the first argument in "argvars".
|
* "term_getcursor(buf)" function
|
||||||
* Returns NULL when the buffer is not for a terminal window.
|
|
||||||
*/
|
*/
|
||||||
static buf_T *
|
void
|
||||||
term_get_buf(typval_T *argvars)
|
f_term_getcursor(typval_T *argvars, typval_T *rettv)
|
||||||
{
|
{
|
||||||
buf_T *buf;
|
buf_T *buf = term_get_buf(argvars);
|
||||||
|
list_T *l;
|
||||||
|
|
||||||
(void)get_tv_number(&argvars[0]); /* issue errmsg if type error */
|
if (rettv_list_alloc(rettv) == FAIL)
|
||||||
++emsg_off;
|
return;
|
||||||
buf = get_buf_tv(&argvars[0], FALSE);
|
if (buf == NULL)
|
||||||
--emsg_off;
|
return;
|
||||||
if (buf == NULL || buf->b_term == NULL)
|
|
||||||
return NULL;
|
l = rettv->vval.v_list;
|
||||||
return buf;
|
list_append_number(l, buf->b_term->tl_cursor_pos.row);
|
||||||
|
list_append_number(l, buf->b_term->tl_cursor_pos.col);
|
||||||
|
list_append_number(l, buf->b_term->tl_cursor_visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
818,
|
||||||
/**/
|
/**/
|
||||||
817,
|
817,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user