0
0
mirror of https://github.com/vim/vim.git synced 2025-10-14 07:04:10 -04:00

patch 8.1.2080: the terminal API is limited and can't be disabled

Problem:    The terminal API is limited and can't be disabled.
Solution:   Add term_setapi() to set the function prefix. (Ozaki Kiichi,
            closes #2907)
This commit is contained in:
Bram Moolenaar
2019-09-26 23:08:54 +02:00
parent d2c1fb476d
commit d2842ea60b
10 changed files with 220 additions and 35 deletions

View File

@@ -1,4 +1,4 @@
*eval.txt* For Vim version 8.1. Last change: 2019 Sep 19
*eval.txt* For Vim version 8.1. Last change: 2019 Sep 26
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -2819,6 +2819,7 @@ term_gettty({buf}, [{input}]) String get the tty name 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_setapi({buf}, {expr}) none set |terminal-api| function name prefix
term_setansicolors({buf}, {colors})
none set ANSI palette in GUI color mode
term_setkill({buf}, {how}) none set signal to stop job in terminal
@@ -3262,9 +3263,14 @@ bufnr([{expr} [, {create}]])
The result is the number of a buffer, as it is displayed by
the ":ls" command. For the use of {expr}, see |bufname()|
above.
If the buffer doesn't exist, -1 is returned. Or, if the
{create} argument is present and not zero, a new, unlisted,
buffer is created and its number is returned.
buffer is created and its number is returned. Example: >
let newbuf = bufnr('Scratch001', 1)
< Using an empty name uses the current buffer. To create a new
buffer with an empty name use |bufadd()|.
bufnr("$") is the last buffer: >
:let last_buffer = bufnr("$")
< The result is a Number, which is the highest buffer number

View File

@@ -1,4 +1,4 @@
*terminal.txt* For Vim version 8.1. Last change: 2019 Sep 20
*terminal.txt* For Vim version 8.1. Last change: 2019 Sep 26
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -222,7 +222,7 @@ Command syntax ~
Vim width (no window left or right of
the terminal window) this value is
ignored.
++eof={text} when using [range]: text to send after
++eof={text} When using [range]: text to send after
the last line was written. Cannot
contain white space. A CR is
appended. For MS-Windows the default
@@ -234,6 +234,10 @@ Command syntax ~
++type={pty} (MS-Windows only): Use {pty} as the
virtual console. See 'termwintype'
for the values.
++api={expr} Permit the function name starting with
{expr} to be called as |terminal-api|
function. If {expr} is empty then no
function can be called.
If you want to use more options use the |term_start()|
function.
@@ -701,6 +705,15 @@ term_sendkeys({buf}, {keys}) *term_sendkeys()*
GetBufnr()->term_sendkeys(keys)
term_setapi({buf}, {expr}) *term_setapi()*
Set the function name prefix to be used for the |terminal-api|
function in terminal {buf}. For example: >
:call term_setapi(buf, "Myapi_")
:call term_setapi(buf, "")
<
The default is "Tapi_". When {expr} is an empty string then
no |terminal-api| function can be used for {buf}.
term_setansicolors({buf}, {colors}) *term_setansicolors()*
Set the ANSI color palette used by terminal {buf}.
{colors} must be a List of 16 valid color names or hexadecimal
@@ -843,6 +856,9 @@ term_start({cmd} [, {options}]) *term_start()*
color modes. See |g:terminal_ansi_colors|.
"tty_type" (MS-Windows only): Specify which pty to
use. See 'termwintype' for the values.
"term_api" function name prefix for the
|terminal-api| function. See
|term_setapi()|.
Can also be used as a |method|: >
GetCommand()->term_start()
@@ -902,9 +918,9 @@ Currently supported commands:
Call a user defined function with {argument}.
The function is called with two arguments: the buffer number
of the terminal and {argument}, the decoded JSON argument.
The function name must start with "Tapi_" to avoid
By default, the function name must start with "Tapi_" to avoid
accidentally calling a function not meant to be used for the
terminal API.
terminal API. This can be changed with |term_setapi()|.
The user function should sanity check the argument.
The function can use |term_sendkeys()| to send back a reply.
Example in JSON: >