aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Hinz <mh.codebro@gmail.com>2015-11-11 04:27:50 +0100
committerMarco Hinz <mh.codebro@gmail.com>2015-11-15 15:10:02 +0100
commit9fcd444036e687a3c5c9aa75fa29b6251b3ad431 (patch)
treea13e600a19081542277cdeb35d1de186197d9a90
parentac4db4b814dae6cd9004276d1330702663256491 (diff)
downloadrneovim-9fcd444036e687a3c5c9aa75fa29b6251b3ad431.tar.gz
rneovim-9fcd444036e687a3c5c9aa75fa29b6251b3ad431.tar.bz2
rneovim-9fcd444036e687a3c5c9aa75fa29b6251b3ad431.zip
Add TermClose event
A terminal buffer now exits with: [Process exited <return value>] You can hook into it. E.g. :au TermClose * call feedkeys('<cr>') Closes #2293.
-rw-r--r--runtime/doc/autocmd.txt3
-rw-r--r--runtime/doc/nvim_terminal_emulator.txt2
-rw-r--r--runtime/doc/vim_diff.txt2
-rw-r--r--src/nvim/auevents.lua6
-rw-r--r--src/nvim/eval.c6
-rw-r--r--test/functional/terminal/ex_terminal_spec.lua6
-rw-r--r--test/functional/terminal/scrollback_spec.lua2
-rw-r--r--test/functional/terminal/tui_spec.lua2
8 files changed, 20 insertions, 9 deletions
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index 7b53bd64ca..a0ed91c95d 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -251,6 +251,7 @@ Name triggered by ~
|SwapExists| detected an existing swap file
|TermOpen| when a terminal buffer is starting
+|TermClose| when a terminal buffer ends
Options
|FileType| when the 'filetype' option has been set
@@ -871,6 +872,8 @@ TermChanged After the value of 'term' has changed. Useful
for re-loading the syntax file to update the
colors, fonts and other terminal-dependent
settings. Executed for all loaded buffers.
+ {Nvim} *TermClose*
+TermClose When a terminal buffer ends.
{Nvim} *TermOpen*
TermOpen When a terminal buffer is starting. This can
be used to configure the terminal emulator by
diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/nvim_terminal_emulator.txt
index 701c6dc274..6ef3aaebaa 100644
--- a/runtime/doc/nvim_terminal_emulator.txt
+++ b/runtime/doc/nvim_terminal_emulator.txt
@@ -105,6 +105,8 @@ The configuration variables are only processed when the terminal starts, which
is why it needs to be done with the |TermOpen| autocmd or setting global
variables before the terminal is started.
+There is also a corresponding |TermClose| event.
+
The terminal cursor can be highlighted via |hl-TermCursor| and
|hl-TermCursorNC|.
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index 927dc55d01..6cbc2aef59 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -143,6 +143,8 @@ Events:
|TabNew|
|TabNewEntered|
|TabClosed|
+ |TermOpen|
+ |TermClose|
Highlight groups:
|hl-EndOfBuffer|
diff --git a/src/nvim/auevents.lua b/src/nvim/auevents.lua
index 7c6ecf5708..7624dd2303 100644
--- a/src/nvim/auevents.lua
+++ b/src/nvim/auevents.lua
@@ -77,8 +77,9 @@ return {
'TabNew', -- when creating a new tab
'TabNewEntered', -- after entering a new tab
'TermChanged', -- after changing 'term'
- 'TermResponse', -- after setting "v:termresponse"
+ 'TermClose', -- after the processs exits
'TermOpen', -- after opening a terminal buffer
+ 'TermResponse', -- after setting "v:termresponse"
'TextChanged', -- text was modified
'TextChangedI', -- text was modified in Insert mode
'User', -- user defined autocommand
@@ -98,9 +99,10 @@ return {
-- List of neovim-specific events or aliases for the purpose of generating
-- syntax file
neovim_specific = {
+ TabClosed=true,
TabNew=true,
TabNewEntered=true,
- TabClosed=true,
+ TermClose=true,
TermOpen=true,
},
}
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index e1fa76c526..9581b81456 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -21781,8 +21781,10 @@ static void on_process_exit(Process *proc, int status, void *d)
TerminalJobData *data = d;
if (data->term && !data->exited) {
data->exited = true;
- terminal_close(data->term,
- _("\r\n[Program exited, press any key to close]"));
+ char msg[22];
+ snprintf(msg, sizeof msg, "\r\n[Process exited %d]", proc->status);
+ terminal_close(data->term, msg);
+ apply_autocmds(EVENT_TERMCLOSE, NULL, NULL, false, curbuf);
}
if (data->status_ptr) {
diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua
index 3855cf4b65..611ba55793 100644
--- a/test/functional/terminal/ex_terminal_spec.lua
+++ b/test/functional/terminal/ex_terminal_spec.lua
@@ -22,7 +22,7 @@ describe(':terminal', function()
wait()
screen:expect([[
ready $ |
- [Program exited, press any key to close] |
+ [Process exited 0] |
|
|
|
@@ -37,7 +37,7 @@ describe(':terminal', function()
screen:expect([[
ready $ echo hi |
|
- [Program exited, press any key to close] |
+ [Process exited 0] |
|
|
|
@@ -51,7 +51,7 @@ describe(':terminal', function()
screen:expect([[
ready $ echo 'hello' \ "world" |
|
- [Program exited, press any key to close] |
+ [Process exited 0] |
|
|
|
diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua
index 87cc9a8266..4b56698520 100644
--- a/test/functional/terminal/scrollback_spec.lua
+++ b/test/functional/terminal/scrollback_spec.lua
@@ -340,7 +340,7 @@ describe('terminal prints more lines than the screen height and exits', function
line8 |
line9 |
|
- [Program exited, press any key to close] |
+ [Process exited 0] |
-- TERMINAL -- |
]])
feed('<cr>')
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 0c4b80fdd2..ba0c531c7e 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -167,7 +167,7 @@ describe('tui with non-tty file descriptors', function()
:q |
abc |
|
- [Program exited, press any key to close] |
+ [Process exited 0] |
|
-- TERMINAL -- |
]])