Mercurial > vim
annotate src/terminal.c @ 12367:7ae2b2c84ec5 v8.0.1063
patch 8.0.1063: Coverity warns for NULL check and array use
commit https://github.com/vim/vim/commit/28550b74bb4373417eb6fbf132bd4211b7b92afa
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Sep 5 23:31:01 2017 +0200
patch 8.0.1063: Coverity warns for NULL check and array use
Problem: Coverity warns for NULL check and using variable pointer as an
array.
Solution: Remove the NULL check. Make "argvar" an array.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 05 Sep 2017 23:45:04 +0200 |
parents | 85fef6805d73 |
children | d0cf7f71b95b |
rev | line source |
---|---|
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 * |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 * |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 /* |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 * Terminal window support, see ":help :terminal". |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 * |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
13 * There are three parts: |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
14 * 1. Generic code for all systems. |
11741
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
15 * Uses libvterm for the terminal emulator. |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
16 * 2. The MS-Windows implementation. |
11741
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
17 * Uses winpty. |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
18 * 3. The Unix-like implementation. |
11741
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
19 * Uses pseudo-tty's (pty's). |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
20 * |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
21 * For each terminal one VTerm is constructed. This uses libvterm. A copy of |
11836
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
22 * this library is in the libvterm directory. |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 * |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
24 * When a terminal window is opened, a job is started that will be connected to |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
25 * the terminal emulator. |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 * |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 * If the terminal window has keyboard focus, typed keys are converted to the |
11774
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
28 * terminal encoding and writing to the job over a channel. |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 * |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
30 * If the job produces output, it is written to the terminal emulator. The |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
31 * terminal emulator invokes callbacks when its screen content changes. The |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
32 * line range is stored in tl_dirty_row_start and tl_dirty_row_end. Once in a |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
33 * while, if the terminal window is visible, the screen contents is drawn. |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 * |
11836
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
35 * When the job ends the text is put in a buffer. Redrawing then happens from |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
36 * that buffer, attributes come from the scrollback buffer tl_scrollback. |
12086
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
37 * When the buffer is changed it is turned into a normal buffer, the attributes |
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
38 * in tl_scrollback are no longer used. |
11836
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
39 * |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 * TODO: |
12363
85fef6805d73
patch 8.0.1061: Coverity: no check for NULL command
Christian Brabandt <cb@256bit.org>
parents:
12345
diff
changeset
|
41 * - ":term NONE" does not work on MS-Windows. |
85fef6805d73
patch 8.0.1061: Coverity: no check for NULL command
Christian Brabandt <cb@256bit.org>
parents:
12345
diff
changeset
|
42 * https://github.com/vim/vim/pull/2056 |
85fef6805d73
patch 8.0.1061: Coverity: no check for NULL command
Christian Brabandt <cb@256bit.org>
parents:
12345
diff
changeset
|
43 * - Redirecting output does not work on MS-Windows. |
11917
00836eb177cb
patch 8.0.0838: buffer hangs around whem terminal window is closed
Christian Brabandt <cb@256bit.org>
parents:
11912
diff
changeset
|
44 * - implement term_setsize() |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
45 * - add test for giving error for invalid 'termsize' value. |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 * - support minimal size when 'termsize' is "rows*cols". |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
47 * - support minimal size when 'termsize' is empty? |
12220
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
48 * - GUI: when using tabs, focus in terminal, click on tab does not work. |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
49 * - GUI: when 'confirm' is set and trying to exit Vim, dialog offers to save |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
50 * changes to "!shell". |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
51 * (justrajdeep, 2017 Aug 22) |
12104
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
52 * - For the GUI fill termios with default values, perhaps like pangoterm: |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
53 * http://bazaar.launchpad.net/~leonerd/pangoterm/trunk/view/head:/main.c#L134 |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
54 * - if the job in the terminal does not support the mouse, we can use the |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
55 * mouse in the Terminal window for copy/paste. |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
56 * - when 'encoding' is not utf-8, or the job is using another encoding, setup |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
57 * conversions. |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
58 * - In the GUI use a terminal emulator for :!cmd. |
11902
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11888
diff
changeset
|
59 * - Copy text in the vterm to the Vim buffer once in a while, so that |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11888
diff
changeset
|
60 * completion works. |
12363
85fef6805d73
patch 8.0.1061: Coverity: no check for NULL command
Christian Brabandt <cb@256bit.org>
parents:
12345
diff
changeset
|
61 * - add an optional limit for the scrollback size. When reaching it remove |
85fef6805d73
patch 8.0.1061: Coverity: no check for NULL command
Christian Brabandt <cb@256bit.org>
parents:
12345
diff
changeset
|
62 * 10% at the start. |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 #include "vim.h" |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
67 #if defined(FEAT_TERMINAL) || defined(PROTO) |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 |
11971
2baa88d64217
patch 8.0.0866: Solaris also doesn't have MIN and MAX
Christian Brabandt <cb@256bit.org>
parents:
11967
diff
changeset
|
69 #ifndef MIN |
2baa88d64217
patch 8.0.0866: Solaris also doesn't have MIN and MAX
Christian Brabandt <cb@256bit.org>
parents:
11967
diff
changeset
|
70 # define MIN(x,y) ((x) < (y) ? (x) : (y)) |
2baa88d64217
patch 8.0.0866: Solaris also doesn't have MIN and MAX
Christian Brabandt <cb@256bit.org>
parents:
11967
diff
changeset
|
71 #endif |
2baa88d64217
patch 8.0.0866: Solaris also doesn't have MIN and MAX
Christian Brabandt <cb@256bit.org>
parents:
11967
diff
changeset
|
72 #ifndef MAX |
2baa88d64217
patch 8.0.0866: Solaris also doesn't have MIN and MAX
Christian Brabandt <cb@256bit.org>
parents:
11967
diff
changeset
|
73 # define MAX(x,y) ((x) > (y) ? (x) : (y)) |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
74 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
76 #include "libvterm/include/vterm.h" |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
77 |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
78 /* This is VTermScreenCell without the characters, thus much smaller. */ |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
79 typedef struct { |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
80 VTermScreenCellAttrs attrs; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
81 char width; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
82 VTermColor fg, bg; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
83 } cellattr_T; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
84 |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
85 typedef struct sb_line_S { |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
86 int sb_cols; /* can differ per line */ |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
87 cellattr_T *sb_cells; /* allocated */ |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
88 } sb_line_T; |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
89 |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 /* typedef term_T in structs.h */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 struct terminal_S { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 term_T *tl_next; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
94 VTerm *tl_vterm; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
95 job_T *tl_job; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
96 buf_T *tl_buffer; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
97 |
11933
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
98 /* used when tl_job is NULL and only a pty was created */ |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
99 int tl_tty_fd; |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
100 char_u *tl_tty_name; |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
101 |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
102 int tl_normal_mode; /* TRUE: Terminal-Normal mode */ |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
103 int tl_channel_closed; |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
104 int tl_finish; /* 'c' for ++close, 'o' for ++open */ |
12072
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12066
diff
changeset
|
105 char_u *tl_opencmd; |
12313
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
106 char_u *tl_eof_chars; |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
107 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
108 #ifdef WIN3264 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
109 void *tl_winpty_config; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
110 void *tl_winpty; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
111 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
112 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
113 /* last known vterm size */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
114 int tl_rows; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
115 int tl_cols; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
116 /* vterm size does not follow window size */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
117 int tl_rows_fixed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
118 int tl_cols_fixed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
119 |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
120 char_u *tl_title; /* NULL or allocated */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
121 char_u *tl_status_text; /* NULL or allocated */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
122 |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
123 /* Range of screen rows to update. Zero based. */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
124 int tl_dirty_row_start; /* -1 if nothing dirty */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
125 int tl_dirty_row_end; /* row below last one to update */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
126 |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
127 garray_T tl_scrollback; |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
128 int tl_scrollback_scrolled; |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
129 |
11874
d444e087b8fd
patch 8.0.0817: cannot get the terminal line at the cursor
Christian Brabandt <cb@256bit.org>
parents:
11872
diff
changeset
|
130 VTermPos tl_cursor_pos; |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
131 int tl_cursor_visible; |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
132 int tl_cursor_blink; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
133 int tl_cursor_shape; /* 1: block, 2: underline, 3: bar */ |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
134 char_u *tl_cursor_color; /* NULL or allocated */ |
12035
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
135 |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
136 int tl_using_altscreen; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
137 }; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
138 |
11985
d036c1c8537d
patch 8.0.0873: in terminal cannot use CTRL- CTRL-N to start Visual mode
Christian Brabandt <cb@256bit.org>
parents:
11983
diff
changeset
|
139 #define TMODE_ONCE 1 /* CTRL-\ CTRL-N used */ |
d036c1c8537d
patch 8.0.0873: in terminal cannot use CTRL- CTRL-N to start Visual mode
Christian Brabandt <cb@256bit.org>
parents:
11983
diff
changeset
|
140 #define TMODE_LOOP 2 /* CTRL-W N used */ |
d036c1c8537d
patch 8.0.0873: in terminal cannot use CTRL- CTRL-N to start Visual mode
Christian Brabandt <cb@256bit.org>
parents:
11983
diff
changeset
|
141 |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
142 /* |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
143 * List of all active terminals. |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
144 */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
145 static term_T *first_term = NULL; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
146 |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
147 /* Terminal active in terminal_loop(). */ |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
148 static term_T *in_terminal_loop = NULL; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
149 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
150 #define MAX_ROW 999999 /* used for tl_dirty_row_end to update all rows */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
151 #define KEY_BUF_LEN 200 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
152 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
153 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
154 * Functions with separate implementation for MS-Windows and Unix-like systems. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
155 */ |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
156 static int term_and_job_init(term_T *term, typval_T *argvar, jobopt_T *opt); |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
157 static int create_pty_only(term_T *term, jobopt_T *opt); |
11753
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
158 static void term_report_winsize(term_T *term, int rows, int cols); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
159 static void term_free_vterm(term_T *term); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
160 |
12104
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
161 /* The characters that we know (or assume) that the terminal expects for the |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
162 * backspace and enter keys. */ |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
163 static int term_backspace_char = BS; |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
164 static int term_enter_char = CAR; |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
165 static int term_nl_does_cr = FALSE; |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
166 |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
167 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
168 /************************************** |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
169 * 1. Generic code for all systems. |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
170 */ |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
171 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
172 /* |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
173 * Determine the terminal size from 'termsize' and the current window. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
174 * Assumes term->tl_rows and term->tl_cols are zero. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
175 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
176 static void |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
177 set_term_and_win_size(term_T *term) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
178 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
179 if (*curwin->w_p_tms != NUL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
180 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
181 char_u *p = vim_strchr(curwin->w_p_tms, 'x') + 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
182 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
183 term->tl_rows = atoi((char *)curwin->w_p_tms); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
184 term->tl_cols = atoi((char *)p); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
185 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
186 if (term->tl_rows == 0) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
187 term->tl_rows = curwin->w_height; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
188 else |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
189 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
190 win_setheight_win(term->tl_rows, curwin); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
191 term->tl_rows_fixed = TRUE; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
192 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
193 if (term->tl_cols == 0) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
194 term->tl_cols = curwin->w_width; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
195 else |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
196 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
197 win_setwidth_win(term->tl_cols, curwin); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
198 term->tl_cols_fixed = TRUE; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
199 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
200 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
201 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
202 /* |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
203 * Initialize job options for a terminal job. |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
204 * Caller may overrule some of them. |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
205 */ |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
206 static void |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
207 init_job_options(jobopt_T *opt) |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
208 { |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
209 clear_job_options(opt); |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
210 |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
211 opt->jo_mode = MODE_RAW; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
212 opt->jo_out_mode = MODE_RAW; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
213 opt->jo_err_mode = MODE_RAW; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
214 opt->jo_set = JO_MODE | JO_OUT_MODE | JO_ERR_MODE; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
215 } |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
216 |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
217 /* |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
218 * Set job options mandatory for a terminal job. |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
219 */ |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
220 static void |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
221 setup_job_options(jobopt_T *opt, int rows, int cols) |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
222 { |
12345
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
223 if (!(opt->jo_set & JO_OUT_IO)) |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
224 { |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
225 /* Connect stdout to the terminal. */ |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
226 opt->jo_io[PART_OUT] = JIO_BUFFER; |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
227 opt->jo_io_buf[PART_OUT] = curbuf->b_fnum; |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
228 opt->jo_modifiable[PART_OUT] = 0; |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
229 opt->jo_set |= JO_OUT_IO + JO_OUT_BUF + JO_OUT_MODIFIABLE; |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
230 } |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
231 |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
232 if (!(opt->jo_set & JO_ERR_IO)) |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
233 { |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
234 /* Connect stderr to the terminal. */ |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
235 opt->jo_io[PART_ERR] = JIO_BUFFER; |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
236 opt->jo_io_buf[PART_ERR] = curbuf->b_fnum; |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
237 opt->jo_modifiable[PART_ERR] = 0; |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
238 opt->jo_set |= JO_ERR_IO + JO_ERR_BUF + JO_ERR_MODIFIABLE; |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
239 } |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
240 |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
241 opt->jo_pty = TRUE; |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
242 if ((opt->jo_set2 & JO2_TERM_ROWS) == 0) |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
243 opt->jo_term_rows = rows; |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
244 if ((opt->jo_set2 & JO2_TERM_COLS) == 0) |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
245 opt->jo_term_cols = cols; |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
246 } |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
247 |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
248 static void |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
249 term_start(typval_T *argvar, jobopt_T *opt, int forceit) |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
250 { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
251 exarg_T split_ea; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
252 win_T *old_curwin = curwin; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
253 term_T *term; |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
254 buf_T *old_curbuf = NULL; |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
255 int res; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
256 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
257 if (check_restricted() || check_secure()) |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
258 return; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
259 |
12345
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
260 if ((opt->jo_set & (JO_IN_IO + JO_OUT_IO + JO_ERR_IO)) |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
261 == (JO_IN_IO + JO_OUT_IO + JO_ERR_IO) |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
262 || (!(opt->jo_set & JO_OUT_IO) && (opt->jo_set & JO_OUT_BUF)) |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
263 || (!(opt->jo_set & JO_ERR_IO) && (opt->jo_set & JO_ERR_BUF))) |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
264 { |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
265 EMSG(_(e_invarg)); |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
266 return; |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
267 } |
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
268 |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
269 term = (term_T *)alloc_clear(sizeof(term_T)); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
270 if (term == NULL) |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
271 return; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
272 term->tl_dirty_row_end = MAX_ROW; |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
273 term->tl_cursor_visible = TRUE; |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
274 term->tl_cursor_shape = VTERM_PROP_CURSORSHAPE_BLOCK; |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
275 term->tl_finish = opt->jo_term_finish; |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
276 ga_init2(&term->tl_scrollback, sizeof(sb_line_T), 300); |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
277 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
278 vim_memset(&split_ea, 0, sizeof(split_ea)); |
12060
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
279 if (opt->jo_curwin) |
11975
5cc005cf312f
patch 8.0.0868: cannot specify the terminal size on the command line
Christian Brabandt <cb@256bit.org>
parents:
11971
diff
changeset
|
280 { |
12060
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
281 /* Create a new buffer in the current window. */ |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
282 if (!can_abandon(curbuf, forceit)) |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
283 { |
12146
59c1e09cf1a9
patch 8.0.0953: get "no write since last change" error in terminal window
Christian Brabandt <cb@256bit.org>
parents:
12144
diff
changeset
|
284 no_write_message(); |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
285 vim_free(term); |
12060
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
286 return; |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
287 } |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
288 if (do_ecmd(0, NULL, NULL, &split_ea, ECMD_ONE, |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
289 ECMD_HIDE + (forceit ? ECMD_FORCEIT : 0), curwin) == FAIL) |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
290 { |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
291 vim_free(term); |
12060
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
292 return; |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
293 } |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
294 } |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
295 else if (opt->jo_hidden) |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
296 { |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
297 buf_T *buf; |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
298 |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
299 /* Create a new buffer without a window. Make it the current buffer for |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
300 * a moment to be able to do the initialisations. */ |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
301 buf = buflist_new((char_u *)"", NULL, (linenr_T)0, |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
302 BLN_NEW | BLN_LISTED); |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
303 if (buf == NULL || ml_open(buf) == FAIL) |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
304 { |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
305 vim_free(term); |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
306 return; |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
307 } |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
308 old_curbuf = curbuf; |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
309 --curbuf->b_nwindows; |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
310 curbuf = buf; |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
311 curwin->w_buffer = buf; |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
312 ++curbuf->b_nwindows; |
11975
5cc005cf312f
patch 8.0.0868: cannot specify the terminal size on the command line
Christian Brabandt <cb@256bit.org>
parents:
11971
diff
changeset
|
313 } |
12060
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
314 else |
11975
5cc005cf312f
patch 8.0.0868: cannot specify the terminal size on the command line
Christian Brabandt <cb@256bit.org>
parents:
11971
diff
changeset
|
315 { |
12060
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
316 /* Open a new window or tab. */ |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
317 split_ea.cmdidx = CMD_new; |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
318 split_ea.cmd = (char_u *)"new"; |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
319 split_ea.arg = (char_u *)""; |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
320 if (opt->jo_term_rows > 0 && !(cmdmod.split & WSP_VERT)) |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
321 { |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
322 split_ea.line2 = opt->jo_term_rows; |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
323 split_ea.addr_count = 1; |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
324 } |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
325 if (opt->jo_term_cols > 0 && (cmdmod.split & WSP_VERT)) |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
326 { |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
327 split_ea.line2 = opt->jo_term_cols; |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
328 split_ea.addr_count = 1; |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
329 } |
11975
5cc005cf312f
patch 8.0.0868: cannot specify the terminal size on the command line
Christian Brabandt <cb@256bit.org>
parents:
11971
diff
changeset
|
330 |
12060
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
331 ex_splitview(&split_ea); |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
332 if (curwin == old_curwin) |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
333 { |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
334 /* split failed */ |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
335 vim_free(term); |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
336 return; |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
337 } |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
338 } |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
339 term->tl_buffer = curbuf; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
340 curbuf->b_term = term; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
341 |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
342 if (!opt->jo_hidden) |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
343 { |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
344 /* only one size was taken care of with :new, do the other one */ |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
345 if (opt->jo_term_rows > 0 && (cmdmod.split & WSP_VERT)) |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
346 win_setheight(opt->jo_term_rows); |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
347 if (opt->jo_term_cols > 0 && !(cmdmod.split & WSP_VERT)) |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
348 win_setwidth(opt->jo_term_cols); |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
349 } |
11975
5cc005cf312f
patch 8.0.0868: cannot specify the terminal size on the command line
Christian Brabandt <cb@256bit.org>
parents:
11971
diff
changeset
|
350 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
351 /* Link the new terminal in the list of active terminals. */ |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
352 term->tl_next = first_term; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
353 first_term = term; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
354 |
11967
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11965
diff
changeset
|
355 if (opt->jo_term_name != NULL) |
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11965
diff
changeset
|
356 curbuf->b_ffname = vim_strsave(opt->jo_term_name); |
12833414cc02
patch 8.0.0864: cannot specify the name of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11965
diff
changeset
|
357 else |
11757
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
358 { |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
359 int i; |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
360 size_t len; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
361 char_u *cmd, *p; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
362 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
363 if (argvar->v_type == VAR_STRING) |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
364 { |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
365 cmd = argvar->vval.v_string; |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
366 if (cmd == NULL) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
367 cmd = (char_u *)""; |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
368 else if (STRCMP(cmd, "NONE") == 0) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
369 cmd = (char_u *)"pty"; |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
370 } |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
371 else if (argvar->v_type != VAR_LIST |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
372 || argvar->vval.v_list == NULL |
12363
85fef6805d73
patch 8.0.1061: Coverity: no check for NULL command
Christian Brabandt <cb@256bit.org>
parents:
12345
diff
changeset
|
373 || argvar->vval.v_list->lv_len < 1 |
85fef6805d73
patch 8.0.1061: Coverity: no check for NULL command
Christian Brabandt <cb@256bit.org>
parents:
12345
diff
changeset
|
374 || (cmd = get_tv_string_chk( |
85fef6805d73
patch 8.0.1061: Coverity: no check for NULL command
Christian Brabandt <cb@256bit.org>
parents:
12345
diff
changeset
|
375 &argvar->vval.v_list->lv_first->li_tv)) == NULL) |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
376 cmd = (char_u*)""; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
377 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
378 len = STRLEN(cmd) + 10; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
379 p = alloc((int)len); |
11757
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
380 |
11912
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
381 for (i = 0; p != NULL; ++i) |
11757
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
382 { |
11912
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
383 /* Prepend a ! to the command name to avoid the buffer name equals |
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
384 * the executable, otherwise ":w!" would overwrite it. */ |
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
385 if (i == 0) |
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
386 vim_snprintf((char *)p, len, "!%s", cmd); |
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
387 else |
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
388 vim_snprintf((char *)p, len, "!%s (%d)", cmd, i); |
11757
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
389 if (buflist_findname(p) == NULL) |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
390 { |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
391 curbuf->b_ffname = p; |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
392 break; |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
393 } |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
394 } |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
395 } |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
396 curbuf->b_fname = curbuf->b_ffname; |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
397 |
12072
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12066
diff
changeset
|
398 if (opt->jo_term_opencmd != NULL) |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12066
diff
changeset
|
399 term->tl_opencmd = vim_strsave(opt->jo_term_opencmd); |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12066
diff
changeset
|
400 |
12309
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12277
diff
changeset
|
401 if (opt->jo_eof_chars != NULL) |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12277
diff
changeset
|
402 term->tl_eof_chars = vim_strsave(opt->jo_eof_chars); |
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12277
diff
changeset
|
403 |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11953
diff
changeset
|
404 set_string_option_direct((char_u *)"buftype", -1, |
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11953
diff
changeset
|
405 (char_u *)"terminal", OPT_FREE|OPT_LOCAL, 0); |
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11953
diff
changeset
|
406 |
11912
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
407 /* Mark the buffer as not modifiable. It can only be made modifiable after |
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
408 * the job finished. */ |
11757
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
409 curbuf->b_p_ma = FALSE; |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11953
diff
changeset
|
410 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
411 set_term_and_win_size(term); |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
412 setup_job_options(opt, term->tl_rows, term->tl_cols); |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
413 |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
414 /* System dependent: setup the vterm and maybe start the job in it. */ |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
415 if (argvar->v_type == VAR_STRING |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
416 && argvar->vval.v_string != NULL |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
417 && STRCMP(argvar->vval.v_string, "NONE") == 0) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
418 res = create_pty_only(term, opt); |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
419 else |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
420 res = term_and_job_init(term, argvar, opt); |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
421 |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
422 if (res == OK) |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
423 { |
12023
0197e3f52192
patch 8.0.0892: when opening a terminal the pty size doesn't always match
Christian Brabandt <cb@256bit.org>
parents:
12021
diff
changeset
|
424 /* Get and remember the size we ended up with. Update the pty. */ |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
425 vterm_get_size(term->tl_vterm, &term->tl_rows, &term->tl_cols); |
12023
0197e3f52192
patch 8.0.0892: when opening a terminal the pty size doesn't always match
Christian Brabandt <cb@256bit.org>
parents:
12021
diff
changeset
|
426 term_report_winsize(term, term->tl_rows, term->tl_cols); |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
427 |
12154
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12152
diff
changeset
|
428 /* Make sure we don't get stuck on sending keys to the job, it leads to |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12152
diff
changeset
|
429 * a deadlock if the job is waiting for Vim to read. */ |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12152
diff
changeset
|
430 channel_set_nonblock(term->tl_job->jv_channel, PART_IN); |
71e10b81226d
patch 8.0.0957: a terminal job can deadlock when sending many keys
Christian Brabandt <cb@256bit.org>
parents:
12152
diff
changeset
|
431 |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
432 if (old_curbuf != NULL) |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
433 { |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
434 --curbuf->b_nwindows; |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
435 curbuf = old_curbuf; |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
436 curwin->w_buffer = curbuf; |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
437 ++curbuf->b_nwindows; |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
438 } |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
439 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
440 else |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
441 { |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
442 buf_T *buf = curbuf; |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
443 |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
444 free_terminal(curbuf); |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
445 if (old_curbuf != NULL) |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
446 { |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
447 --curbuf->b_nwindows; |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
448 curbuf = old_curbuf; |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
449 curwin->w_buffer = curbuf; |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
450 ++curbuf->b_nwindows; |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
451 } |
11727
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11725
diff
changeset
|
452 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
453 /* Wiping out the buffer will also close the window and call |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
454 * free_terminal(). */ |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
455 do_buffer(DOBUF_WIPE, DOBUF_FIRST, FORWARD, buf->b_fnum, TRUE); |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
456 } |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
457 } |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
458 |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
459 /* |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
460 * ":terminal": open a terminal window and execute a job in it. |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
461 */ |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
462 void |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
463 ex_terminal(exarg_T *eap) |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
464 { |
12367
7ae2b2c84ec5
patch 8.0.1063: Coverity warns for NULL check and array use
Christian Brabandt <cb@256bit.org>
parents:
12363
diff
changeset
|
465 typval_T argvar[2]; |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
466 jobopt_T opt; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
467 char_u *cmd; |
12124
4e9c14cb1f5d
patch 8.0.0942: using freed memory with ":terminal"
Christian Brabandt <cb@256bit.org>
parents:
12116
diff
changeset
|
468 char_u *tofree = NULL; |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
469 |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
470 init_job_options(&opt); |
11975
5cc005cf312f
patch 8.0.0868: cannot specify the terminal size on the command line
Christian Brabandt <cb@256bit.org>
parents:
11971
diff
changeset
|
471 |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
472 cmd = eap->arg; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
473 while (*cmd && *cmd == '+' && *(cmd + 1) == '+') |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
474 { |
12192
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
475 char_u *p, *ep; |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
476 |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
477 cmd += 2; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
478 p = skiptowhite(cmd); |
12192
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
479 ep = vim_strchr(cmd, '='); |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
480 if (ep != NULL && ep < p) |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
481 p = ep; |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
482 |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
483 if ((int)(p - cmd) == 5 && STRNICMP(cmd, "close", 5) == 0) |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
484 opt.jo_term_finish = 'c'; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
485 else if ((int)(p - cmd) == 4 && STRNICMP(cmd, "open", 4) == 0) |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
486 opt.jo_term_finish = 'o'; |
12060
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
487 else if ((int)(p - cmd) == 6 && STRNICMP(cmd, "curwin", 6) == 0) |
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
488 opt.jo_curwin = 1; |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
489 else if ((int)(p - cmd) == 6 && STRNICMP(cmd, "hidden", 6) == 0) |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
490 opt.jo_hidden = 1; |
12192
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
491 else if ((int)(p - cmd) == 4 && STRNICMP(cmd, "rows", 4) == 0 |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
492 && ep != NULL && isdigit(ep[1])) |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
493 { |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
494 opt.jo_set2 |= JO2_TERM_ROWS; |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
495 opt.jo_term_rows = atoi((char *)ep + 1); |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
496 p = skiptowhite(cmd); |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
497 } |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
498 else if ((int)(p - cmd) == 4 && STRNICMP(cmd, "cols", 4) == 0 |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
499 && ep != NULL && isdigit(ep[1])) |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
500 { |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
501 opt.jo_set2 |= JO2_TERM_COLS; |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
502 opt.jo_term_cols = atoi((char *)ep + 1); |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
503 p = skiptowhite(cmd); |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
504 } |
12311
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
505 else if ((int)(p - cmd) == 3 && STRNICMP(cmd, "eof", 3) == 0 |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
506 && ep != NULL) |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
507 { |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
508 char_u *buf = NULL; |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
509 char_u *keys; |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
510 |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
511 p = skiptowhite(cmd); |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
512 *p = NUL; |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
513 keys = replace_termcodes(ep + 1, &buf, TRUE, TRUE, TRUE); |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
514 opt.jo_set2 |= JO2_EOF_CHARS; |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
515 opt.jo_eof_chars = vim_strsave(keys); |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
516 vim_free(buf); |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
517 *p = ' '; |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
518 } |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
519 else |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
520 { |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
521 if (*p) |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
522 *p = NUL; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
523 EMSG2(_("E181: Invalid attribute: %s"), cmd); |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
524 return; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
525 } |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
526 cmd = skipwhite(p); |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
527 } |
12367
7ae2b2c84ec5
patch 8.0.1063: Coverity warns for NULL check and array use
Christian Brabandt <cb@256bit.org>
parents:
12363
diff
changeset
|
528 if (*cmd == NUL) |
7ae2b2c84ec5
patch 8.0.1063: Coverity warns for NULL check and array use
Christian Brabandt <cb@256bit.org>
parents:
12363
diff
changeset
|
529 /* Make a copy of 'shell', an autocommand may change the option. */ |
12124
4e9c14cb1f5d
patch 8.0.0942: using freed memory with ":terminal"
Christian Brabandt <cb@256bit.org>
parents:
12116
diff
changeset
|
530 tofree = cmd = vim_strsave(p_sh); |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
531 |
12192
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
532 if (eap->addr_count > 0) |
11975
5cc005cf312f
patch 8.0.0868: cannot specify the terminal size on the command line
Christian Brabandt <cb@256bit.org>
parents:
11971
diff
changeset
|
533 { |
12192
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
534 /* Write lines from current buffer to the job. */ |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
535 opt.jo_set |= JO_IN_IO | JO_IN_BUF | JO_IN_TOP | JO_IN_BOT; |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
536 opt.jo_io[PART_IN] = JIO_BUFFER; |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
537 opt.jo_io_buf[PART_IN] = curbuf->b_fnum; |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
538 opt.jo_in_top = eap->line1; |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
539 opt.jo_in_bot = eap->line2; |
11975
5cc005cf312f
patch 8.0.0868: cannot specify the terminal size on the command line
Christian Brabandt <cb@256bit.org>
parents:
11971
diff
changeset
|
540 } |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
541 |
12367
7ae2b2c84ec5
patch 8.0.1063: Coverity warns for NULL check and array use
Christian Brabandt <cb@256bit.org>
parents:
12363
diff
changeset
|
542 argvar[0].v_type = VAR_STRING; |
7ae2b2c84ec5
patch 8.0.1063: Coverity warns for NULL check and array use
Christian Brabandt <cb@256bit.org>
parents:
12363
diff
changeset
|
543 argvar[0].vval.v_string = cmd; |
7ae2b2c84ec5
patch 8.0.1063: Coverity warns for NULL check and array use
Christian Brabandt <cb@256bit.org>
parents:
12363
diff
changeset
|
544 argvar[1].v_type = VAR_UNKNOWN; |
7ae2b2c84ec5
patch 8.0.1063: Coverity warns for NULL check and array use
Christian Brabandt <cb@256bit.org>
parents:
12363
diff
changeset
|
545 term_start(argvar, &opt, eap->forceit); |
12124
4e9c14cb1f5d
patch 8.0.0942: using freed memory with ":terminal"
Christian Brabandt <cb@256bit.org>
parents:
12116
diff
changeset
|
546 vim_free(tofree); |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
547 } |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
548 |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
549 /* |
11836
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
550 * Free the scrollback buffer for "term". |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
551 */ |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
552 static void |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
553 free_scrollback(term_T *term) |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
554 { |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
555 int i; |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
556 |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
557 for (i = 0; i < term->tl_scrollback.ga_len; ++i) |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
558 vim_free(((sb_line_T *)term->tl_scrollback.ga_data + i)->sb_cells); |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
559 ga_clear(&term->tl_scrollback); |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
560 } |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
561 |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
562 /* |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
563 * Free a terminal and everything it refers to. |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
564 * Kills the job if there is one. |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
565 * Called when wiping out a buffer. |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
566 */ |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
567 void |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
568 free_terminal(buf_T *buf) |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
569 { |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
570 term_T *term = buf->b_term; |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
571 term_T *tp; |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
572 |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
573 if (term == NULL) |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
574 return; |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
575 if (first_term == term) |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
576 first_term = term->tl_next; |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
577 else |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
578 for (tp = first_term; tp->tl_next != NULL; tp = tp->tl_next) |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
579 if (tp->tl_next == term) |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
580 { |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
581 tp->tl_next = term->tl_next; |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
582 break; |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
583 } |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
584 |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
585 if (term->tl_job != NULL) |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
586 { |
11727
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11725
diff
changeset
|
587 if (term->tl_job->jv_status != JOB_ENDED |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
588 && term->tl_job->jv_status != JOB_FINISHED |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
589 && term->tl_job->jv_status != JOB_FAILED) |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
590 job_stop(term->tl_job, NULL, "kill"); |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
591 job_unref(term->tl_job); |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
592 } |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
593 |
11836
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
594 free_scrollback(term); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
595 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
596 term_free_vterm(term); |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
597 vim_free(term->tl_title); |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
598 vim_free(term->tl_status_text); |
12072
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12066
diff
changeset
|
599 vim_free(term->tl_opencmd); |
12309
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12277
diff
changeset
|
600 vim_free(term->tl_eof_chars); |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
601 vim_free(term->tl_cursor_color); |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
602 vim_free(term); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
603 buf->b_term = NULL; |
12086
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
604 if (in_terminal_loop == term) |
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
605 in_terminal_loop = NULL; |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
606 } |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
607 |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
608 /* |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
609 * Write job output "msg[len]" to the vterm. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
610 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
611 static void |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
612 term_write_job_output(term_T *term, char_u *msg, size_t len) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
613 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
614 VTerm *vterm = term->tl_vterm; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
615 char_u *p; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
616 size_t done; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
617 size_t len_now; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
618 |
12104
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
619 if (term_nl_does_cr) |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
620 vterm_input_write(vterm, (char *)msg, len); |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
621 else |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
622 /* need to convert NL to CR-NL */ |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
623 for (done = 0; done < len; done += len_now) |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
624 { |
12104
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
625 for (p = msg + done; p < msg + len; ) |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
626 { |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
627 if (*p == NL) |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
628 break; |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
629 p += utf_ptr2len_len(p, (int)(len - (p - msg))); |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
630 } |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
631 len_now = p - msg - done; |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
632 vterm_input_write(vterm, (char *)msg + done, len_now); |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
633 if (p < msg + len && *p == NL) |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
634 { |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
635 vterm_input_write(vterm, "\r\n", 2); |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
636 ++len_now; |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
637 } |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
638 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
639 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
640 /* this invokes the damage callbacks */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
641 vterm_screen_flush_damage(vterm_obtain_screen(vterm)); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
642 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
643 |
11778
e8005055f845
patch 8.0.0771: cursor in terminal window not always updated in GUI
Christian Brabandt <cb@256bit.org>
parents:
11774
diff
changeset
|
644 static void |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
645 update_cursor(term_T *term, int redraw) |
11778
e8005055f845
patch 8.0.0771: cursor in terminal window not always updated in GUI
Christian Brabandt <cb@256bit.org>
parents:
11774
diff
changeset
|
646 { |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
647 if (term->tl_normal_mode) |
11888
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
648 return; |
11778
e8005055f845
patch 8.0.0771: cursor in terminal window not always updated in GUI
Christian Brabandt <cb@256bit.org>
parents:
11774
diff
changeset
|
649 setcursor(); |
12088
ca1e425a5fbf
patch 8.0.0924: terminal window not updated after using term_sendkeys()
Christian Brabandt <cb@256bit.org>
parents:
12086
diff
changeset
|
650 if (redraw) |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
651 { |
12088
ca1e425a5fbf
patch 8.0.0924: terminal window not updated after using term_sendkeys()
Christian Brabandt <cb@256bit.org>
parents:
12086
diff
changeset
|
652 if (term->tl_buffer == curbuf && term->tl_cursor_visible) |
11792
4bc1f94afc34
patch 8.0.0778: in a terminal the cursor may be hidden
Christian Brabandt <cb@256bit.org>
parents:
11790
diff
changeset
|
653 cursor_on(); |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
654 out_flush(); |
11778
e8005055f845
patch 8.0.0771: cursor in terminal window not always updated in GUI
Christian Brabandt <cb@256bit.org>
parents:
11774
diff
changeset
|
655 #ifdef FEAT_GUI |
11880
45558e0507e8
patch 8.0.0820: GUI: cursor in terminal window lags behind
Christian Brabandt <cb@256bit.org>
parents:
11878
diff
changeset
|
656 if (gui.in_use) |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
657 gui_update_cursor(FALSE, FALSE); |
11778
e8005055f845
patch 8.0.0771: cursor in terminal window not always updated in GUI
Christian Brabandt <cb@256bit.org>
parents:
11774
diff
changeset
|
658 #endif |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
659 } |
11778
e8005055f845
patch 8.0.0771: cursor in terminal window not always updated in GUI
Christian Brabandt <cb@256bit.org>
parents:
11774
diff
changeset
|
660 } |
e8005055f845
patch 8.0.0771: cursor in terminal window not always updated in GUI
Christian Brabandt <cb@256bit.org>
parents:
11774
diff
changeset
|
661 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
662 /* |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
663 * Invoked when "msg" output from a job was received. Write it to the terminal |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
664 * of "buffer". |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
665 */ |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
666 void |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
667 write_to_term(buf_T *buffer, char_u *msg, channel_T *channel) |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
668 { |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
669 size_t len = STRLEN(msg); |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
670 term_T *term = buffer->b_term; |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
671 |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
672 if (term->tl_vterm == NULL) |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
673 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
674 ch_log(channel, "NOT writing %d bytes to terminal", (int)len); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
675 return; |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
676 } |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
677 ch_log(channel, "writing %d bytes to terminal", (int)len); |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
678 term_write_job_output(term, msg, len); |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
679 |
12088
ca1e425a5fbf
patch 8.0.0924: terminal window not updated after using term_sendkeys()
Christian Brabandt <cb@256bit.org>
parents:
12086
diff
changeset
|
680 /* In Terminal-Normal mode we are displaying the buffer, not the terminal |
ca1e425a5fbf
patch 8.0.0924: terminal window not updated after using term_sendkeys()
Christian Brabandt <cb@256bit.org>
parents:
12086
diff
changeset
|
681 * contents, thus no screen update is needed. */ |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
682 if (!term->tl_normal_mode) |
11888
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
683 { |
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
684 /* TODO: only update once in a while. */ |
12088
ca1e425a5fbf
patch 8.0.0924: terminal window not updated after using term_sendkeys()
Christian Brabandt <cb@256bit.org>
parents:
12086
diff
changeset
|
685 ch_log(term->tl_job->jv_channel, "updating screen"); |
ca1e425a5fbf
patch 8.0.0924: terminal window not updated after using term_sendkeys()
Christian Brabandt <cb@256bit.org>
parents:
12086
diff
changeset
|
686 if (buffer == curbuf) |
ca1e425a5fbf
patch 8.0.0924: terminal window not updated after using term_sendkeys()
Christian Brabandt <cb@256bit.org>
parents:
12086
diff
changeset
|
687 { |
ca1e425a5fbf
patch 8.0.0924: terminal window not updated after using term_sendkeys()
Christian Brabandt <cb@256bit.org>
parents:
12086
diff
changeset
|
688 update_screen(0); |
ca1e425a5fbf
patch 8.0.0924: terminal window not updated after using term_sendkeys()
Christian Brabandt <cb@256bit.org>
parents:
12086
diff
changeset
|
689 update_cursor(term, TRUE); |
ca1e425a5fbf
patch 8.0.0924: terminal window not updated after using term_sendkeys()
Christian Brabandt <cb@256bit.org>
parents:
12086
diff
changeset
|
690 } |
ca1e425a5fbf
patch 8.0.0924: terminal window not updated after using term_sendkeys()
Christian Brabandt <cb@256bit.org>
parents:
12086
diff
changeset
|
691 else |
12244
d0b039e2ed56
patch 8.0.1002: unnecessarily updating screen after timer callback
Christian Brabandt <cb@256bit.org>
parents:
12240
diff
changeset
|
692 redraw_after_callback(TRUE); |
11888
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
693 } |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
694 } |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
695 |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
696 /* |
11854
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
697 * Send a mouse position and click to the vterm |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
698 */ |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
699 static int |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
700 term_send_mouse(VTerm *vterm, int button, int pressed) |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
701 { |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
702 VTermModifier mod = VTERM_MOD_NONE; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
703 |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
704 vterm_mouse_move(vterm, mouse_row - W_WINROW(curwin), |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
705 mouse_col - W_WINCOL(curwin), mod); |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
706 vterm_mouse_button(vterm, button, pressed, mod); |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
707 return TRUE; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
708 } |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
709 |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
710 /* |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
711 * Convert typed key "c" into bytes to send to the job. |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
712 * Return the number of bytes in "buf". |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
713 */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
714 static int |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
715 term_convert_key(term_T *term, int c, char *buf) |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
716 { |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
717 VTerm *vterm = term->tl_vterm; |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
718 VTermKey key = VTERM_KEY_NONE; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
719 VTermModifier mod = VTERM_MOD_NONE; |
11854
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
720 int mouse = FALSE; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
721 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
722 switch (c) |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
723 { |
12104
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
724 case CAR: c = term_enter_char; break; |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
725 /* don't use VTERM_KEY_BACKSPACE, it always |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
726 * becomes 0x7f DEL */ |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
727 case K_BS: c = term_backspace_char; break; |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
728 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
729 case ESC: key = VTERM_KEY_ESCAPE; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
730 case K_DEL: key = VTERM_KEY_DEL; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
731 case K_DOWN: key = VTERM_KEY_DOWN; break; |
11854
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
732 case K_S_DOWN: mod = VTERM_MOD_SHIFT; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
733 key = VTERM_KEY_DOWN; break; |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
734 case K_END: key = VTERM_KEY_END; break; |
11854
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
735 case K_S_END: mod = VTERM_MOD_SHIFT; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
736 key = VTERM_KEY_END; break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
737 case K_C_END: mod = VTERM_MOD_CTRL; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
738 key = VTERM_KEY_END; break; |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
739 case K_F10: key = VTERM_KEY_FUNCTION(10); break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
740 case K_F11: key = VTERM_KEY_FUNCTION(11); break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
741 case K_F12: key = VTERM_KEY_FUNCTION(12); break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
742 case K_F1: key = VTERM_KEY_FUNCTION(1); break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
743 case K_F2: key = VTERM_KEY_FUNCTION(2); break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
744 case K_F3: key = VTERM_KEY_FUNCTION(3); break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
745 case K_F4: key = VTERM_KEY_FUNCTION(4); break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
746 case K_F5: key = VTERM_KEY_FUNCTION(5); break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
747 case K_F6: key = VTERM_KEY_FUNCTION(6); break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
748 case K_F7: key = VTERM_KEY_FUNCTION(7); break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
749 case K_F8: key = VTERM_KEY_FUNCTION(8); break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
750 case K_F9: key = VTERM_KEY_FUNCTION(9); break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
751 case K_HOME: key = VTERM_KEY_HOME; break; |
11854
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
752 case K_S_HOME: mod = VTERM_MOD_SHIFT; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
753 key = VTERM_KEY_HOME; break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
754 case K_C_HOME: mod = VTERM_MOD_CTRL; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
755 key = VTERM_KEY_HOME; break; |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
756 case K_INS: key = VTERM_KEY_INS; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
757 case K_K0: key = VTERM_KEY_KP_0; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
758 case K_K1: key = VTERM_KEY_KP_1; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
759 case K_K2: key = VTERM_KEY_KP_2; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
760 case K_K3: key = VTERM_KEY_KP_3; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
761 case K_K4: key = VTERM_KEY_KP_4; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
762 case K_K5: key = VTERM_KEY_KP_5; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
763 case K_K6: key = VTERM_KEY_KP_6; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
764 case K_K7: key = VTERM_KEY_KP_7; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
765 case K_K8: key = VTERM_KEY_KP_8; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
766 case K_K9: key = VTERM_KEY_KP_9; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
767 case K_KDEL: key = VTERM_KEY_DEL; break; /* TODO */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
768 case K_KDIVIDE: key = VTERM_KEY_KP_DIVIDE; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
769 case K_KEND: key = VTERM_KEY_KP_1; break; /* TODO */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
770 case K_KENTER: key = VTERM_KEY_KP_ENTER; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
771 case K_KHOME: key = VTERM_KEY_KP_7; break; /* TODO */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
772 case K_KINS: key = VTERM_KEY_KP_0; break; /* TODO */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
773 case K_KMINUS: key = VTERM_KEY_KP_MINUS; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
774 case K_KMULTIPLY: key = VTERM_KEY_KP_MULT; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
775 case K_KPAGEDOWN: key = VTERM_KEY_KP_3; break; /* TODO */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
776 case K_KPAGEUP: key = VTERM_KEY_KP_9; break; /* TODO */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
777 case K_KPLUS: key = VTERM_KEY_KP_PLUS; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
778 case K_KPOINT: key = VTERM_KEY_KP_PERIOD; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
779 case K_LEFT: key = VTERM_KEY_LEFT; break; |
11854
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
780 case K_S_LEFT: mod = VTERM_MOD_SHIFT; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
781 key = VTERM_KEY_LEFT; break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
782 case K_C_LEFT: mod = VTERM_MOD_CTRL; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
783 key = VTERM_KEY_LEFT; break; |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
784 case K_PAGEDOWN: key = VTERM_KEY_PAGEDOWN; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
785 case K_PAGEUP: key = VTERM_KEY_PAGEUP; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
786 case K_RIGHT: key = VTERM_KEY_RIGHT; break; |
11854
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
787 case K_S_RIGHT: mod = VTERM_MOD_SHIFT; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
788 key = VTERM_KEY_RIGHT; break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
789 case K_C_RIGHT: mod = VTERM_MOD_CTRL; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
790 key = VTERM_KEY_RIGHT; break; |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
791 case K_UP: key = VTERM_KEY_UP; break; |
11854
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
792 case K_S_UP: mod = VTERM_MOD_SHIFT; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
793 key = VTERM_KEY_UP; break; |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
794 case TAB: key = VTERM_KEY_TAB; break; |
11711
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
795 |
11854
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
796 case K_MOUSEUP: mouse = term_send_mouse(vterm, 5, 1); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
797 case K_MOUSEDOWN: mouse = term_send_mouse(vterm, 4, 1); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
798 case K_MOUSELEFT: /* TODO */ return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
799 case K_MOUSERIGHT: /* TODO */ return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
800 |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
801 case K_LEFTMOUSE: |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
802 case K_LEFTMOUSE_NM: mouse = term_send_mouse(vterm, 1, 1); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
803 case K_LEFTDRAG: mouse = term_send_mouse(vterm, 1, 1); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
804 case K_LEFTRELEASE: |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
805 case K_LEFTRELEASE_NM: mouse = term_send_mouse(vterm, 1, 0); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
806 case K_MIDDLEMOUSE: mouse = term_send_mouse(vterm, 2, 1); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
807 case K_MIDDLEDRAG: mouse = term_send_mouse(vterm, 2, 1); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
808 case K_MIDDLERELEASE: mouse = term_send_mouse(vterm, 2, 0); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
809 case K_RIGHTMOUSE: mouse = term_send_mouse(vterm, 3, 1); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
810 case K_RIGHTDRAG: mouse = term_send_mouse(vterm, 3, 1); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
811 case K_RIGHTRELEASE: mouse = term_send_mouse(vterm, 3, 0); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
812 case K_X1MOUSE: /* TODO */ return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
813 case K_X1DRAG: /* TODO */ return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
814 case K_X1RELEASE: /* TODO */ return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
815 case K_X2MOUSE: /* TODO */ return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
816 case K_X2DRAG: /* TODO */ return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
817 case K_X2RELEASE: /* TODO */ return 0; |
11711
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
818 |
11854
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
819 case K_IGNORE: return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
820 case K_NOP: return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
821 case K_UNDO: return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
822 case K_HELP: return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
823 case K_XF1: key = VTERM_KEY_FUNCTION(1); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
824 case K_XF2: key = VTERM_KEY_FUNCTION(2); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
825 case K_XF3: key = VTERM_KEY_FUNCTION(3); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
826 case K_XF4: key = VTERM_KEY_FUNCTION(4); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
827 case K_SELECT: return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
828 #ifdef FEAT_GUI |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
829 case K_VER_SCROLLBAR: return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
830 case K_HOR_SCROLLBAR: return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
831 #endif |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
832 #ifdef FEAT_GUI_TABLINE |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
833 case K_TABLINE: return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
834 case K_TABMENU: return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
835 #endif |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
836 #ifdef FEAT_NETBEANS_INTG |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
837 case K_F21: key = VTERM_KEY_FUNCTION(21); break; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
838 #endif |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
839 #ifdef FEAT_DND |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
840 case K_DROP: return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
841 #endif |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
842 #ifdef FEAT_AUTOCMD |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
843 case K_CURSORHOLD: return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
844 #endif |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
845 case K_PS: vterm_keyboard_start_paste(vterm); return 0; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
846 case K_PE: vterm_keyboard_end_paste(vterm); return 0; |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
847 } |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
848 |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
849 /* |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
850 * Convert special keys to vterm keys: |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
851 * - Write keys to vterm: vterm_keyboard_key() |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
852 * - Write output to channel. |
11854
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
853 * TODO: use mod_mask |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
854 */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
855 if (key != VTERM_KEY_NONE) |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
856 /* Special key, let vterm convert it. */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
857 vterm_keyboard_key(vterm, key, mod); |
11854
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
858 else if (!mouse) |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
859 /* Normal character, let vterm convert it. */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
860 vterm_keyboard_unichar(vterm, c, mod); |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
861 |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
862 /* Read back the converted escape sequence. */ |
11790
4dfebc1b2674
patch 8.0.0777: compiler warnings with 64 bit compiler
Christian Brabandt <cb@256bit.org>
parents:
11786
diff
changeset
|
863 return (int)vterm_output_read(vterm, buf, KEY_BUF_LEN); |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
864 } |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
865 |
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
866 /* |
11882
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
867 * Return TRUE if the job for "term" is still running. |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
868 */ |
11917
00836eb177cb
patch 8.0.0838: buffer hangs around whem terminal window is closed
Christian Brabandt <cb@256bit.org>
parents:
11912
diff
changeset
|
869 int |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
870 term_job_running(term_T *term) |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
871 { |
11842
6bfcedcc0262
patch 8.0.0801: terminal window title says "running" after job exits
Christian Brabandt <cb@256bit.org>
parents:
11840
diff
changeset
|
872 /* Also consider the job finished when the channel is closed, to avoid a |
6bfcedcc0262
patch 8.0.0801: terminal window title says "running" after job exits
Christian Brabandt <cb@256bit.org>
parents:
11840
diff
changeset
|
873 * race condition when updating the title. */ |
11947
8b9a1be7bb82
patch 8.0.0853: crash when running terminal with unknown command
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
874 return term != NULL |
8b9a1be7bb82
patch 8.0.0853: crash when running terminal with unknown command
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
875 && term->tl_job != NULL |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
876 && channel_is_open(term->tl_job->jv_channel) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
877 && (term->tl_job->jv_status == JOB_STARTED |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
878 || term->tl_job->jv_channel->ch_keep_open); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
879 } |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
880 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
881 /* |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
882 * Add the last line of the scrollback buffer to the buffer in the window. |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
883 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
884 static void |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
885 add_scrollback_line_to_buffer(term_T *term, char_u *text, int len) |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
886 { |
12011
1f4e7361ce89
patch 8.0.0886: crash when using ":term ls"
Christian Brabandt <cb@256bit.org>
parents:
12009
diff
changeset
|
887 buf_T *buf = term->tl_buffer; |
1f4e7361ce89
patch 8.0.0886: crash when using ":term ls"
Christian Brabandt <cb@256bit.org>
parents:
12009
diff
changeset
|
888 int empty = (buf->b_ml.ml_flags & ML_EMPTY); |
1f4e7361ce89
patch 8.0.0886: crash when using ":term ls"
Christian Brabandt <cb@256bit.org>
parents:
12009
diff
changeset
|
889 linenr_T lnum = buf->b_ml.ml_line_count; |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
890 |
12208
48394f51e6af
patch 8.0.0984: terminal blinking cursor not correct in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12204
diff
changeset
|
891 #ifdef WIN3264 |
12204
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
892 if (!enc_utf8 && enc_codepage > 0) |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
893 { |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
894 WCHAR *ret = NULL; |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
895 int length = 0; |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
896 |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
897 MultiByteToWideChar_alloc(CP_UTF8, 0, (char*)text, len + 1, |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
898 &ret, &length); |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
899 if (ret != NULL) |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
900 { |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
901 WideCharToMultiByte_alloc(enc_codepage, 0, |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
902 ret, length, (char **)&text, &len, 0, 0); |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
903 vim_free(ret); |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
904 ml_append_buf(term->tl_buffer, lnum, text, len, FALSE); |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
905 vim_free(text); |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
906 } |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
907 } |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
908 else |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
909 #endif |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
910 ml_append_buf(term->tl_buffer, lnum, text, len + 1, FALSE); |
12011
1f4e7361ce89
patch 8.0.0886: crash when using ":term ls"
Christian Brabandt <cb@256bit.org>
parents:
12009
diff
changeset
|
911 if (empty) |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
912 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
913 /* Delete the empty line that was in the empty buffer. */ |
12011
1f4e7361ce89
patch 8.0.0886: crash when using ":term ls"
Christian Brabandt <cb@256bit.org>
parents:
12009
diff
changeset
|
914 curbuf = buf; |
1f4e7361ce89
patch 8.0.0886: crash when using ":term ls"
Christian Brabandt <cb@256bit.org>
parents:
12009
diff
changeset
|
915 ml_delete(1, FALSE); |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
916 curbuf = curwin->w_buffer; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
917 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
918 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
919 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
920 /* |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
921 * Add the current lines of the terminal to scrollback and to the buffer. |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
922 * Called after the job has ended and when switching to Terminal-Normal mode. |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
923 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
924 static void |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
925 move_terminal_to_buffer(term_T *term) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
926 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
927 win_T *wp; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
928 int len; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
929 int lines_skipped = 0; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
930 VTermPos pos; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
931 VTermScreenCell cell; |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
932 cellattr_T *p; |
11958
052270a67371
patch 8.0.0859: NULL pointer access when term_free_vterm called twice
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
933 VTermScreen *screen; |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
934 |
11958
052270a67371
patch 8.0.0859: NULL pointer access when term_free_vterm called twice
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
935 if (term->tl_vterm == NULL) |
052270a67371
patch 8.0.0859: NULL pointer access when term_free_vterm called twice
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
936 return; |
052270a67371
patch 8.0.0859: NULL pointer access when term_free_vterm called twice
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
937 screen = vterm_obtain_screen(term->tl_vterm); |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
938 for (pos.row = 0; pos.row < term->tl_rows; ++pos.row) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
939 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
940 len = 0; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
941 for (pos.col = 0; pos.col < term->tl_cols; ++pos.col) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
942 if (vterm_screen_get_cell(screen, pos, &cell) != 0 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
943 && cell.chars[0] != NUL) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
944 len = pos.col + 1; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
945 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
946 if (len == 0) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
947 ++lines_skipped; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
948 else |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
949 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
950 while (lines_skipped > 0) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
951 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
952 /* Line was skipped, add an empty line. */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
953 --lines_skipped; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
954 if (ga_grow(&term->tl_scrollback, 1) == OK) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
955 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
956 sb_line_T *line = (sb_line_T *)term->tl_scrollback.ga_data |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
957 + term->tl_scrollback.ga_len; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
958 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
959 line->sb_cols = 0; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
960 line->sb_cells = NULL; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
961 ++term->tl_scrollback.ga_len; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
962 |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
963 add_scrollback_line_to_buffer(term, (char_u *)"", 0); |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
964 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
965 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
966 |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
967 p = (cellattr_T *)alloc((int)sizeof(cellattr_T) * len); |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
968 if (p != NULL && ga_grow(&term->tl_scrollback, 1) == OK) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
969 { |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
970 garray_T ga; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
971 int width; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
972 sb_line_T *line = (sb_line_T *)term->tl_scrollback.ga_data |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
973 + term->tl_scrollback.ga_len; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
974 |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
975 ga_init2(&ga, 1, 100); |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
976 for (pos.col = 0; pos.col < len; pos.col += width) |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
977 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
978 if (vterm_screen_get_cell(screen, pos, &cell) == 0) |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
979 { |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
980 width = 1; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
981 vim_memset(p + pos.col, 0, sizeof(cellattr_T)); |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
982 if (ga_grow(&ga, 1) == OK) |
12222
43f03e584002
patch 8.0.0991: using wrong character conversion for DBCS
Christian Brabandt <cb@256bit.org>
parents:
12220
diff
changeset
|
983 ga.ga_len += utf_char2bytes(' ', |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
984 (char_u *)ga.ga_data + ga.ga_len); |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
985 } |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
986 else |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
987 { |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
988 width = cell.width; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
989 |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
990 p[pos.col].width = cell.width; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
991 p[pos.col].attrs = cell.attrs; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
992 p[pos.col].fg = cell.fg; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
993 p[pos.col].bg = cell.bg; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
994 |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
995 if (ga_grow(&ga, MB_MAXBYTES) == OK) |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
996 { |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
997 int i; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
998 int c; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
999 |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1000 for (i = 0; (c = cell.chars[i]) > 0 || i == 0; ++i) |
12204
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
1001 ga.ga_len += utf_char2bytes(c == NUL ? ' ' : c, |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1002 (char_u *)ga.ga_data + ga.ga_len); |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1003 } |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1004 } |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1005 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1006 line->sb_cols = len; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1007 line->sb_cells = p; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1008 ++term->tl_scrollback.ga_len; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1009 |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1010 if (ga_grow(&ga, 1) == FAIL) |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1011 add_scrollback_line_to_buffer(term, (char_u *)"", 0); |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1012 else |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1013 { |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1014 *((char_u *)ga.ga_data + ga.ga_len) = NUL; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1015 add_scrollback_line_to_buffer(term, ga.ga_data, ga.ga_len); |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1016 } |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1017 ga_clear(&ga); |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1018 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1019 else |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1020 vim_free(p); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1021 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1022 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1023 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1024 FOR_ALL_WINDOWS(wp) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1025 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1026 if (wp->w_buffer == term->tl_buffer) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1027 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1028 wp->w_cursor.lnum = term->tl_buffer->b_ml.ml_line_count; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1029 wp->w_cursor.col = 0; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1030 wp->w_valid = 0; |
12092
bf3a61119baf
patch 8.0.0926: when job in terminal window ends topline is wrong
Christian Brabandt <cb@256bit.org>
parents:
12088
diff
changeset
|
1031 if (wp->w_cursor.lnum >= wp->w_height) |
bf3a61119baf
patch 8.0.0926: when job in terminal window ends topline is wrong
Christian Brabandt <cb@256bit.org>
parents:
12088
diff
changeset
|
1032 { |
bf3a61119baf
patch 8.0.0926: when job in terminal window ends topline is wrong
Christian Brabandt <cb@256bit.org>
parents:
12088
diff
changeset
|
1033 linenr_T min_topline = wp->w_cursor.lnum - wp->w_height + 1; |
bf3a61119baf
patch 8.0.0926: when job in terminal window ends topline is wrong
Christian Brabandt <cb@256bit.org>
parents:
12088
diff
changeset
|
1034 |
bf3a61119baf
patch 8.0.0926: when job in terminal window ends topline is wrong
Christian Brabandt <cb@256bit.org>
parents:
12088
diff
changeset
|
1035 if (wp->w_topline < min_topline) |
bf3a61119baf
patch 8.0.0926: when job in terminal window ends topline is wrong
Christian Brabandt <cb@256bit.org>
parents:
12088
diff
changeset
|
1036 wp->w_topline = min_topline; |
bf3a61119baf
patch 8.0.0926: when job in terminal window ends topline is wrong
Christian Brabandt <cb@256bit.org>
parents:
12088
diff
changeset
|
1037 } |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1038 redraw_win_later(wp, NOT_VALID); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1039 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1040 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1041 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1042 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1043 static void |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1044 set_terminal_mode(term_T *term, int normal_mode) |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1045 { |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1046 term->tl_normal_mode = normal_mode; |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1047 vim_free(term->tl_status_text); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1048 term->tl_status_text = NULL; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1049 if (term->tl_buffer == curbuf) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1050 maketitle(); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1051 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1052 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1053 /* |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1054 * Called after the job if finished and Terminal mode is not active: |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1055 * Move the vterm contents into the scrollback buffer and free the vterm. |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1056 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1057 static void |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1058 cleanup_vterm(term_T *term) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1059 { |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
1060 if (term->tl_finish != 'c') |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
1061 move_terminal_to_buffer(term); |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1062 term_free_vterm(term); |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1063 set_terminal_mode(term, FALSE); |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1064 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1065 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1066 /* |
11985
d036c1c8537d
patch 8.0.0873: in terminal cannot use CTRL- CTRL-N to start Visual mode
Christian Brabandt <cb@256bit.org>
parents:
11983
diff
changeset
|
1067 * Switch from Terminal-Job mode to Terminal-Normal mode. |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1068 * Suspends updating the terminal window. |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1069 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1070 static void |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1071 term_enter_normal_mode(void) |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1072 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1073 term_T *term = curbuf->b_term; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1074 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1075 /* Append the current terminal contents to the buffer. */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1076 move_terminal_to_buffer(term); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1077 |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1078 set_terminal_mode(term, TRUE); |
11985
d036c1c8537d
patch 8.0.0873: in terminal cannot use CTRL- CTRL-N to start Visual mode
Christian Brabandt <cb@256bit.org>
parents:
11983
diff
changeset
|
1079 |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1080 /* Move the window cursor to the position of the cursor in the |
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1081 * terminal. */ |
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1082 curwin->w_cursor.lnum = term->tl_scrollback_scrolled |
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1083 + term->tl_cursor_pos.row + 1; |
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1084 check_cursor(); |
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1085 coladvance(term->tl_cursor_pos.col); |
11985
d036c1c8537d
patch 8.0.0873: in terminal cannot use CTRL- CTRL-N to start Visual mode
Christian Brabandt <cb@256bit.org>
parents:
11983
diff
changeset
|
1086 |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1087 /* Display the same lines as in the terminal. */ |
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1088 curwin->w_topline = term->tl_scrollback_scrolled + 1; |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1089 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1090 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1091 /* |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1092 * Returns TRUE if the current window contains a terminal and we are in |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1093 * Terminal-Normal mode. |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1094 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1095 int |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1096 term_in_normal_mode(void) |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1097 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1098 term_T *term = curbuf->b_term; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1099 |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1100 return term != NULL && term->tl_normal_mode; |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1101 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1102 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1103 /* |
11985
d036c1c8537d
patch 8.0.0873: in terminal cannot use CTRL- CTRL-N to start Visual mode
Christian Brabandt <cb@256bit.org>
parents:
11983
diff
changeset
|
1104 * Switch from Terminal-Normal mode to Terminal-Job mode. |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1105 * Restores updating the terminal window. |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1106 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1107 void |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1108 term_enter_job_mode() |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1109 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1110 term_T *term = curbuf->b_term; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1111 sb_line_T *line; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1112 garray_T *gap; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1113 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1114 /* Remove the terminal contents from the scrollback and the buffer. */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1115 gap = &term->tl_scrollback; |
12176
782a06ba2187
patch 8.0.0968: crash when switching terminal modes
Christian Brabandt <cb@256bit.org>
parents:
12170
diff
changeset
|
1116 while (curbuf->b_ml.ml_line_count > term->tl_scrollback_scrolled |
782a06ba2187
patch 8.0.0968: crash when switching terminal modes
Christian Brabandt <cb@256bit.org>
parents:
12170
diff
changeset
|
1117 && gap->ga_len > 0) |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1118 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1119 ml_delete(curbuf->b_ml.ml_line_count, FALSE); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1120 line = (sb_line_T *)gap->ga_data + gap->ga_len - 1; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1121 vim_free(line->sb_cells); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1122 --gap->ga_len; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1123 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1124 check_cursor(); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1125 |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1126 set_terminal_mode(term, FALSE); |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1127 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1128 if (term->tl_channel_closed) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1129 cleanup_vterm(term); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1130 redraw_buf_and_status_later(curbuf, NOT_VALID); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1131 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1132 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1133 /* |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1134 * Get a key from the user without mapping. |
12086
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
1135 * Note: while waiting a terminal may be closed and freed if the channel is |
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
1136 * closed and ++close was used. |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1137 * TODO: use terminal mode mappings. |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1138 */ |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1139 static int |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1140 term_vgetc() |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1141 { |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1142 int c; |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1143 |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1144 ++no_mapping; |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1145 ++allow_keys; |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1146 got_int = FALSE; |
12066
8ad282dee649
patch 8.0.0913: MS-Windows: CTRL-C kills shell in terminal window
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
1147 #ifdef WIN3264 |
8ad282dee649
patch 8.0.0913: MS-Windows: CTRL-C kills shell in terminal window
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
1148 ctrl_break_was_pressed = FALSE; |
8ad282dee649
patch 8.0.0913: MS-Windows: CTRL-C kills shell in terminal window
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
1149 #endif |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1150 c = vgetc(); |
11870
c29e498aa77d
patch 8.0.0815: terminal window not correctly updated
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
1151 got_int = FALSE; |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1152 --no_mapping; |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1153 --allow_keys; |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1154 return c; |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1155 } |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1156 |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1157 /* |
12192
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1158 * Get the part that is connected to the tty. Normally this is PART_IN, but |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1159 * when writing buffer lines to the job it can be another. This makes it |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1160 * possible to do "1,5term vim -". |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1161 */ |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1162 static ch_part_T |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1163 get_tty_part(term_T *term) |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1164 { |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1165 #ifdef UNIX |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1166 ch_part_T parts[3] = {PART_IN, PART_OUT, PART_ERR}; |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1167 int i; |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1168 |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1169 for (i = 0; i < 3; ++i) |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1170 { |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1171 int fd = term->tl_job->jv_channel->ch_part[parts[i]].ch_fd; |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1172 |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1173 if (isatty(fd)) |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1174 return parts[i]; |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1175 } |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1176 #endif |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1177 return PART_IN; |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1178 } |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1179 |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1180 /* |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1181 * Send keys to terminal. |
11965
a932d3da41c8
patch 8.0.0863: a remote command does not work in the terminal window
Christian Brabandt <cb@256bit.org>
parents:
11958
diff
changeset
|
1182 * Return FAIL when the key needs to be handled in Normal mode. |
a932d3da41c8
patch 8.0.0863: a remote command does not work in the terminal window
Christian Brabandt <cb@256bit.org>
parents:
11958
diff
changeset
|
1183 * Return OK when the key was dropped or sent to the terminal. |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1184 */ |
11983
448635f73e09
patch 8.0.0872: no mouse scroll with a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11979
diff
changeset
|
1185 int |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1186 send_keys_to_term(term_T *term, int c, int typed) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1187 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1188 char msg[KEY_BUF_LEN]; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1189 size_t len; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1190 static int mouse_was_outside = FALSE; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1191 int dragging_outside = FALSE; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1192 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1193 /* Catch keys that need to be handled as in Normal mode. */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1194 switch (c) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1195 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1196 case NUL: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1197 case K_ZERO: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1198 if (typed) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1199 stuffcharReadbuff(c); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1200 return FAIL; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1201 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1202 case K_IGNORE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1203 return FAIL; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1204 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1205 case K_LEFTDRAG: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1206 case K_MIDDLEDRAG: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1207 case K_RIGHTDRAG: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1208 case K_X1DRAG: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1209 case K_X2DRAG: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1210 dragging_outside = mouse_was_outside; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1211 /* FALLTHROUGH */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1212 case K_LEFTMOUSE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1213 case K_LEFTMOUSE_NM: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1214 case K_LEFTRELEASE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1215 case K_LEFTRELEASE_NM: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1216 case K_MIDDLEMOUSE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1217 case K_MIDDLERELEASE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1218 case K_RIGHTMOUSE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1219 case K_RIGHTRELEASE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1220 case K_X1MOUSE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1221 case K_X1RELEASE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1222 case K_X2MOUSE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1223 case K_X2RELEASE: |
11983
448635f73e09
patch 8.0.0872: no mouse scroll with a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11979
diff
changeset
|
1224 |
448635f73e09
patch 8.0.0872: no mouse scroll with a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11979
diff
changeset
|
1225 case K_MOUSEUP: |
448635f73e09
patch 8.0.0872: no mouse scroll with a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11979
diff
changeset
|
1226 case K_MOUSEDOWN: |
448635f73e09
patch 8.0.0872: no mouse scroll with a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11979
diff
changeset
|
1227 case K_MOUSELEFT: |
448635f73e09
patch 8.0.0872: no mouse scroll with a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11979
diff
changeset
|
1228 case K_MOUSERIGHT: |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1229 if (mouse_row < W_WINROW(curwin) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1230 || mouse_row >= (W_WINROW(curwin) + curwin->w_height) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1231 || mouse_col < W_WINCOL(curwin) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1232 || mouse_col >= W_ENDCOL(curwin) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1233 || dragging_outside) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1234 { |
11983
448635f73e09
patch 8.0.0872: no mouse scroll with a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11979
diff
changeset
|
1235 /* click or scroll outside the current window */ |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1236 if (typed) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1237 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1238 stuffcharReadbuff(c); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1239 mouse_was_outside = TRUE; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1240 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1241 return FAIL; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1242 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1243 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1244 if (typed) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1245 mouse_was_outside = FALSE; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1246 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1247 /* Convert the typed key to a sequence of bytes for the job. */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1248 len = term_convert_key(term, c, msg); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1249 if (len > 0) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1250 /* TODO: if FAIL is returned, stop? */ |
12192
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1251 channel_send(term->tl_job->jv_channel, get_tty_part(term), |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1252 (char_u *)msg, (int)len, NULL); |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1253 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1254 return OK; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1255 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1256 |
11878
a83b19a8d7e4
patch 8.0.0819: cursor not positioned in terminal window
Christian Brabandt <cb@256bit.org>
parents:
11876
diff
changeset
|
1257 static void |
a83b19a8d7e4
patch 8.0.0819: cursor not positioned in terminal window
Christian Brabandt <cb@256bit.org>
parents:
11876
diff
changeset
|
1258 position_cursor(win_T *wp, VTermPos *pos) |
a83b19a8d7e4
patch 8.0.0819: cursor not positioned in terminal window
Christian Brabandt <cb@256bit.org>
parents:
11876
diff
changeset
|
1259 { |
a83b19a8d7e4
patch 8.0.0819: cursor not positioned in terminal window
Christian Brabandt <cb@256bit.org>
parents:
11876
diff
changeset
|
1260 wp->w_wrow = MIN(pos->row, MAX(0, wp->w_height - 1)); |
a83b19a8d7e4
patch 8.0.0819: cursor not positioned in terminal window
Christian Brabandt <cb@256bit.org>
parents:
11876
diff
changeset
|
1261 wp->w_wcol = MIN(pos->col, MAX(0, wp->w_width - 1)); |
a83b19a8d7e4
patch 8.0.0819: cursor not positioned in terminal window
Christian Brabandt <cb@256bit.org>
parents:
11876
diff
changeset
|
1262 wp->w_valid |= (VALID_WCOL|VALID_WROW); |
a83b19a8d7e4
patch 8.0.0819: cursor not positioned in terminal window
Christian Brabandt <cb@256bit.org>
parents:
11876
diff
changeset
|
1263 } |
a83b19a8d7e4
patch 8.0.0819: cursor not positioned in terminal window
Christian Brabandt <cb@256bit.org>
parents:
11876
diff
changeset
|
1264 |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1265 /* |
11886
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1266 * Handle CTRL-W "": send register contents to the job. |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1267 */ |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1268 static void |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1269 term_paste_register(int prev_c UNUSED) |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1270 { |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1271 int c; |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1272 list_T *l; |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1273 listitem_T *item; |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1274 long reglen = 0; |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1275 int type; |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1276 |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1277 #ifdef FEAT_CMDL_INFO |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1278 if (add_to_showcmd(prev_c)) |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1279 if (add_to_showcmd('"')) |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1280 out_flush(); |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1281 #endif |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1282 c = term_vgetc(); |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1283 #ifdef FEAT_CMDL_INFO |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1284 clear_showcmd(); |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1285 #endif |
12086
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
1286 if (!term_use_loop()) |
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
1287 /* job finished while waiting for a character */ |
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
1288 return; |
11886
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1289 |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1290 /* CTRL-W "= prompt for expression to evaluate. */ |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1291 if (c == '=' && get_expr_register() != '=') |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1292 return; |
12086
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
1293 if (!term_use_loop()) |
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
1294 /* job finished while waiting for a character */ |
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
1295 return; |
11886
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1296 |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1297 l = (list_T *)get_reg_contents(c, GREG_LIST); |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1298 if (l != NULL) |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1299 { |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1300 type = get_reg_type(c, ®len); |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1301 for (item = l->lv_first; item != NULL; item = item->li_next) |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1302 { |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1303 char_u *s = get_tv_string(&item->li_tv); |
12220
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1304 #ifdef WIN3264 |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1305 char_u *tmp = s; |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1306 |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1307 if (!enc_utf8 && enc_codepage > 0) |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1308 { |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1309 WCHAR *ret = NULL; |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1310 int length = 0; |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1311 |
12277
8b453c1299f7
patch 8.0.1018: warnings from 64-bit compiler
Christian Brabandt <cb@256bit.org>
parents:
12267
diff
changeset
|
1312 MultiByteToWideChar_alloc(enc_codepage, 0, (char *)s, |
8b453c1299f7
patch 8.0.1018: warnings from 64-bit compiler
Christian Brabandt <cb@256bit.org>
parents:
12267
diff
changeset
|
1313 (int)STRLEN(s), &ret, &length); |
12220
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1314 if (ret != NULL) |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1315 { |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1316 WideCharToMultiByte_alloc(CP_UTF8, 0, |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1317 ret, length, (char **)&s, &length, 0, 0); |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1318 vim_free(ret); |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1319 } |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1320 } |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1321 #endif |
11886
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1322 channel_send(curbuf->b_term->tl_job->jv_channel, PART_IN, |
12277
8b453c1299f7
patch 8.0.1018: warnings from 64-bit compiler
Christian Brabandt <cb@256bit.org>
parents:
12267
diff
changeset
|
1323 s, (int)STRLEN(s), NULL); |
12220
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1324 #ifdef WIN3264 |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1325 if (tmp != s) |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1326 vim_free(s); |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1327 #endif |
0ecfee22a2e2
patch 8.0.0990: with DBCS 'encoding' wrong pasting register into terminal
Christian Brabandt <cb@256bit.org>
parents:
12214
diff
changeset
|
1328 |
11886
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1329 if (item->li_next != NULL || type == MLINE) |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1330 channel_send(curbuf->b_term->tl_job->jv_channel, PART_IN, |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1331 (char_u *)"\r", 1, NULL); |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1332 } |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1333 list_free(l); |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1334 } |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1335 } |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1336 |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1337 #if defined(FEAT_GUI) || defined(PROTO) |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1338 /* |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1339 * Return TRUE when the cursor of the terminal should be displayed. |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1340 */ |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1341 int |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1342 use_terminal_cursor() |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1343 { |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1344 return in_terminal_loop != NULL; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1345 } |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1346 |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1347 cursorentry_T * |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1348 term_get_cursor_shape(guicolor_T *fg, guicolor_T *bg) |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1349 { |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1350 term_T *term = in_terminal_loop; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1351 static cursorentry_T entry; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1352 |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1353 vim_memset(&entry, 0, sizeof(entry)); |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1354 entry.shape = entry.mshape = |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1355 term->tl_cursor_shape == VTERM_PROP_CURSORSHAPE_UNDERLINE ? SHAPE_HOR : |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1356 term->tl_cursor_shape == VTERM_PROP_CURSORSHAPE_BAR_LEFT ? SHAPE_VER : |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1357 SHAPE_BLOCK; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1358 entry.percentage = 20; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1359 if (term->tl_cursor_blink) |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1360 { |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1361 entry.blinkwait = 700; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1362 entry.blinkon = 400; |
12208
48394f51e6af
patch 8.0.0984: terminal blinking cursor not correct in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12204
diff
changeset
|
1363 entry.blinkoff = 250; |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1364 } |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1365 *fg = gui.back_pixel; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1366 if (term->tl_cursor_color == NULL) |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1367 *bg = gui.norm_pixel; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1368 else |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1369 *bg = color_name2handle(term->tl_cursor_color); |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1370 entry.name = "n"; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1371 entry.used_for = SHAPE_CURSOR; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1372 |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1373 return &entry; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1374 } |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1375 #endif |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1376 |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1377 static int did_change_cursor = FALSE; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1378 |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1379 static void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1380 may_set_cursor_props(term_T *term) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1381 { |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1382 #ifdef FEAT_GUI |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1383 /* For the GUI the cursor properties are obtained with |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1384 * term_get_cursor_shape(). */ |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1385 if (gui.in_use) |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1386 return; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1387 #endif |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1388 if (in_terminal_loop == term) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1389 { |
12080
93024e778745
patch 8.0.0920: cursor wrong after switching altscreen in terminal
Christian Brabandt <cb@256bit.org>
parents:
12076
diff
changeset
|
1390 did_change_cursor = TRUE; |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1391 if (term->tl_cursor_color != NULL) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1392 term_cursor_color(term->tl_cursor_color); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1393 else |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1394 term_cursor_color((char_u *)""); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1395 term_cursor_shape(term->tl_cursor_shape, term->tl_cursor_blink); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1396 } |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1397 } |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1398 |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1399 static void |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1400 may_restore_cursor_props(void) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1401 { |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1402 #ifdef FEAT_GUI |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1403 if (gui.in_use) |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1404 return; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1405 #endif |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1406 if (did_change_cursor) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1407 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1408 did_change_cursor = FALSE; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1409 term_cursor_color((char_u *)""); |
12170
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12160
diff
changeset
|
1410 /* this will restore the initial cursor style, if possible */ |
1345621ecdfb
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12160
diff
changeset
|
1411 ui_cursor_shape_forced(TRUE); |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1412 } |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1413 } |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1414 |
11886
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1415 /* |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1416 * Returns TRUE if the current window contains a terminal and we are sending |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1417 * keys to the job. |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1418 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1419 int |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1420 term_use_loop(void) |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1421 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1422 term_T *term = curbuf->b_term; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1423 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1424 return term != NULL |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1425 && !term->tl_normal_mode |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1426 && term->tl_vterm != NULL |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1427 && term_job_running(term); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1428 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1429 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1430 /* |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1431 * Wait for input and send it to the job. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1432 * Return when the start of a CTRL-W command is typed or anything else that |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1433 * should be handled as a Normal mode command. |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1434 * Returns OK if a typed character is to be handled in Normal mode, FAIL if |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1435 * the terminal was closed. |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1436 */ |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1437 int |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1438 terminal_loop(void) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1439 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1440 int c; |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1441 int termkey = 0; |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1442 int ret; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1443 |
12086
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
1444 /* Remember the terminal we are sending keys to. However, the terminal |
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
1445 * might be closed while waiting for a character, e.g. typing "exit" in a |
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
1446 * shell and ++close was used. Therefore use curbuf->b_term instead of a |
69f2392e6cfb
patch 8.0.0923: crash in GUI when terminal job exits
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
1447 * stored reference. */ |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1448 in_terminal_loop = curbuf->b_term; |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1449 |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1450 if (*curwin->w_p_tk != NUL) |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1451 termkey = string_to_key(curwin->w_p_tk, TRUE); |
11878
a83b19a8d7e4
patch 8.0.0819: cursor not positioned in terminal window
Christian Brabandt <cb@256bit.org>
parents:
11876
diff
changeset
|
1452 position_cursor(curwin, &curbuf->b_term->tl_cursor_pos); |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1453 may_set_cursor_props(curbuf->b_term); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1454 |
12104
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1455 #ifdef UNIX |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1456 { |
12192
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1457 int part = get_tty_part(curbuf->b_term); |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
1458 int fd = curbuf->b_term->tl_job->jv_channel->ch_part[part].ch_fd; |
12104
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1459 |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1460 if (isatty(fd)) |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1461 { |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1462 ttyinfo_T info; |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1463 |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1464 /* Get the current backspace and enter characters of the pty. */ |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1465 if (get_tty_info(fd, &info) == OK) |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1466 { |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1467 term_backspace_char = info.backspace; |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1468 term_enter_char = info.enter; |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1469 term_nl_does_cr = info.nl_does_cr; |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1470 } |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1471 } |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1472 } |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1473 #endif |
3bf5fe164a9f
patch 8.0.0932: terminal may not use right characters for BS and Enter
Christian Brabandt <cb@256bit.org>
parents:
12098
diff
changeset
|
1474 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1475 for (;;) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1476 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1477 /* TODO: skip screen update when handling a sequence of keys. */ |
11870
c29e498aa77d
patch 8.0.0815: terminal window not correctly updated
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
1478 /* Repeat redrawing in case a message is received while redrawing. */ |
c29e498aa77d
patch 8.0.0815: terminal window not correctly updated
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
1479 while (curwin->w_redr_type != 0) |
c29e498aa77d
patch 8.0.0815: terminal window not correctly updated
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
1480 update_screen(0); |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1481 update_cursor(curbuf->b_term, FALSE); |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1482 |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1483 c = term_vgetc(); |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1484 if (!term_use_loop()) |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1485 /* job finished while waiting for a character */ |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1486 break; |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1487 if (c == K_IGNORE) |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1488 continue; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1489 |
11919
cca097489de5
patch 8.0.0839: cannot kill a job in a terminal with CTRL-C
Christian Brabandt <cb@256bit.org>
parents:
11917
diff
changeset
|
1490 #ifdef WIN3264 |
12074
ca55e69d9d1b
patch 8.0.0917: MS-Windows:CTRL-C handling in terminal window is wrong
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
1491 /* On Windows winpty handles CTRL-C, don't send a CTRL_C_EVENT. |
12066
8ad282dee649
patch 8.0.0913: MS-Windows: CTRL-C kills shell in terminal window
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
1492 * Use CTRL-BREAK to kill the job. */ |
8ad282dee649
patch 8.0.0913: MS-Windows: CTRL-C kills shell in terminal window
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
1493 if (ctrl_break_was_pressed) |
8ad282dee649
patch 8.0.0913: MS-Windows: CTRL-C kills shell in terminal window
Christian Brabandt <cb@256bit.org>
parents:
12064
diff
changeset
|
1494 mch_signal_job(curbuf->b_term->tl_job, (char_u *)"kill"); |
11919
cca097489de5
patch 8.0.0839: cannot kill a job in a terminal with CTRL-C
Christian Brabandt <cb@256bit.org>
parents:
11917
diff
changeset
|
1495 #endif |
cca097489de5
patch 8.0.0839: cannot kill a job in a terminal with CTRL-C
Christian Brabandt <cb@256bit.org>
parents:
11917
diff
changeset
|
1496 |
11965
a932d3da41c8
patch 8.0.0863: a remote command does not work in the terminal window
Christian Brabandt <cb@256bit.org>
parents:
11958
diff
changeset
|
1497 if (c == (termkey == 0 ? Ctrl_W : termkey) || c == Ctrl_BSL) |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1498 { |
11886
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1499 int prev_c = c; |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1500 |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1501 #ifdef FEAT_CMDL_INFO |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1502 if (add_to_showcmd(c)) |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1503 out_flush(); |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1504 #endif |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1505 c = term_vgetc(); |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1506 #ifdef FEAT_CMDL_INFO |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1507 clear_showcmd(); |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1508 #endif |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1509 if (!term_use_loop()) |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1510 /* job finished while waiting for a character */ |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1511 break; |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1512 |
11965
a932d3da41c8
patch 8.0.0863: a remote command does not work in the terminal window
Christian Brabandt <cb@256bit.org>
parents:
11958
diff
changeset
|
1513 if (prev_c == Ctrl_BSL) |
a932d3da41c8
patch 8.0.0863: a remote command does not work in the terminal window
Christian Brabandt <cb@256bit.org>
parents:
11958
diff
changeset
|
1514 { |
a932d3da41c8
patch 8.0.0863: a remote command does not work in the terminal window
Christian Brabandt <cb@256bit.org>
parents:
11958
diff
changeset
|
1515 if (c == Ctrl_N) |
11985
d036c1c8537d
patch 8.0.0873: in terminal cannot use CTRL- CTRL-N to start Visual mode
Christian Brabandt <cb@256bit.org>
parents:
11983
diff
changeset
|
1516 { |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1517 /* CTRL-\ CTRL-N : go to Terminal-Normal mode. */ |
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1518 term_enter_normal_mode(); |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1519 ret = FAIL; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1520 goto theend; |
11985
d036c1c8537d
patch 8.0.0873: in terminal cannot use CTRL- CTRL-N to start Visual mode
Christian Brabandt <cb@256bit.org>
parents:
11983
diff
changeset
|
1521 } |
11965
a932d3da41c8
patch 8.0.0863: a remote command does not work in the terminal window
Christian Brabandt <cb@256bit.org>
parents:
11958
diff
changeset
|
1522 /* Send both keys to the terminal. */ |
a932d3da41c8
patch 8.0.0863: a remote command does not work in the terminal window
Christian Brabandt <cb@256bit.org>
parents:
11958
diff
changeset
|
1523 send_keys_to_term(curbuf->b_term, prev_c, TRUE); |
a932d3da41c8
patch 8.0.0863: a remote command does not work in the terminal window
Christian Brabandt <cb@256bit.org>
parents:
11958
diff
changeset
|
1524 } |
12160
b80c0172d1a8
patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents:
12154
diff
changeset
|
1525 else if (c == Ctrl_C) |
b80c0172d1a8
patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents:
12154
diff
changeset
|
1526 { |
b80c0172d1a8
patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents:
12154
diff
changeset
|
1527 /* "CTRL-W CTRL-C" or 'termkey' CTRL-C: end the job */ |
b80c0172d1a8
patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents:
12154
diff
changeset
|
1528 mch_signal_job(curbuf->b_term->tl_job, (char_u *)"kill"); |
b80c0172d1a8
patch 8.0.0960: job in terminal does not get CTRL-C
Christian Brabandt <cb@256bit.org>
parents:
12154
diff
changeset
|
1529 } |
11965
a932d3da41c8
patch 8.0.0863: a remote command does not work in the terminal window
Christian Brabandt <cb@256bit.org>
parents:
11958
diff
changeset
|
1530 else if (termkey == 0 && c == '.') |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1531 { |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1532 /* "CTRL-W .": send CTRL-W to the job */ |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1533 c = Ctrl_W; |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1534 } |
11886
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1535 else if (c == 'N') |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1536 { |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1537 /* CTRL-W N : go to Terminal-Normal mode. */ |
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1538 term_enter_normal_mode(); |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1539 ret = FAIL; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1540 goto theend; |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1541 } |
11886
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1542 else if (c == '"') |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1543 { |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1544 term_paste_register(prev_c); |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1545 continue; |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1546 } |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1547 else if (termkey == 0 || c != termkey) |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1548 { |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1549 stuffcharReadbuff(Ctrl_W); |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1550 stuffcharReadbuff(c); |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1551 ret = OK; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1552 goto theend; |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1553 } |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1554 } |
12208
48394f51e6af
patch 8.0.0984: terminal blinking cursor not correct in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12204
diff
changeset
|
1555 # ifdef WIN3264 |
12204
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
1556 if (!enc_utf8 && has_mbyte && c >= 0x80) |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
1557 { |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
1558 WCHAR wc; |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
1559 char_u mb[3]; |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
1560 |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
1561 mb[0] = (unsigned)c >> 8; |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
1562 mb[1] = c; |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
1563 if (MultiByteToWideChar(GetACP(), 0, (char*)mb, 2, &wc, 1) > 0) |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
1564 c = wc; |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
1565 } |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
1566 # endif |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1567 if (send_keys_to_term(curbuf->b_term, c, TRUE) != OK) |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1568 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1569 ret = OK; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1570 goto theend; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1571 } |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1572 } |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1573 ret = FAIL; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1574 |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1575 theend: |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1576 in_terminal_loop = NULL; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1577 may_restore_cursor_props(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1578 return ret; |
11757
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
1579 } |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
1580 |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1581 /* |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1582 * Called when a job has finished. |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
1583 * This updates the title and status, but does not close the vterm, because |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1584 * there might still be pending output in the channel. |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1585 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1586 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1587 term_job_ended(job_T *job) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1588 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1589 term_T *term; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1590 int did_one = FALSE; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1591 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1592 for (term = first_term; term != NULL; term = term->tl_next) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1593 if (term->tl_job == job) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1594 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1595 vim_free(term->tl_title); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1596 term->tl_title = NULL; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1597 vim_free(term->tl_status_text); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1598 term->tl_status_text = NULL; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1599 redraw_buf_and_status_later(term->tl_buffer, VALID); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1600 did_one = TRUE; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1601 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1602 if (did_one) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1603 redraw_statuslines(); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1604 if (curbuf->b_term != NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1605 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1606 if (curbuf->b_term->tl_job == job) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1607 maketitle(); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1608 update_cursor(curbuf->b_term, TRUE); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1609 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1610 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1611 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1612 static void |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1613 may_toggle_cursor(term_T *term) |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1614 { |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1615 if (in_terminal_loop == term) |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1616 { |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1617 if (term->tl_cursor_visible) |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1618 cursor_on(); |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1619 else |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1620 cursor_off(); |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1621 } |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1622 } |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1623 |
12152
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1624 /* |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1625 * Reverse engineer the RGB value into a cterm color index. |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1626 * First color is 1. Return 0 if no match found. |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1627 */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1628 static int |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1629 color2index(VTermColor *color, int fg, int *boldp) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1630 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1631 int red = color->red; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1632 int blue = color->blue; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1633 int green = color->green; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1634 |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1635 /* The argument for lookup_color() is for the color_names[] table. */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1636 if (red == 0) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1637 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1638 if (green == 0) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1639 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1640 if (blue == 0) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1641 return lookup_color(0, fg, boldp) + 1; /* black */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1642 if (blue == 224) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1643 return lookup_color(1, fg, boldp) + 1; /* dark blue */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1644 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1645 else if (green == 224) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1646 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1647 if (blue == 0) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1648 return lookup_color(2, fg, boldp) + 1; /* dark green */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1649 if (blue == 224) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1650 return lookup_color(3, fg, boldp) + 1; /* dark cyan */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1651 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1652 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1653 else if (red == 224) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1654 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1655 if (green == 0) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1656 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1657 if (blue == 0) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1658 return lookup_color(4, fg, boldp) + 1; /* dark red */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1659 if (blue == 224) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1660 return lookup_color(5, fg, boldp) + 1; /* dark magenta */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1661 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1662 else if (green == 224) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1663 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1664 if (blue == 0) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1665 return lookup_color(6, fg, boldp) + 1; /* dark yellow / brown */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1666 if (blue == 224) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1667 return lookup_color(8, fg, boldp) + 1; /* white / light grey */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1668 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1669 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1670 else if (red == 128) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1671 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1672 if (green == 128 && blue == 128) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1673 return lookup_color(12, fg, boldp) + 1; /* high intensity black / dark grey */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1674 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1675 else if (red == 255) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1676 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1677 if (green == 64) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1678 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1679 if (blue == 64) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1680 return lookup_color(20, fg, boldp) + 1; /* light red */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1681 if (blue == 255) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1682 return lookup_color(22, fg, boldp) + 1; /* light magenta */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1683 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1684 else if (green == 255) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1685 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1686 if (blue == 64) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1687 return lookup_color(24, fg, boldp) + 1; /* yellow */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1688 if (blue == 255) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1689 return lookup_color(26, fg, boldp) + 1; /* white */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1690 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1691 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1692 else if (red == 64) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1693 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1694 if (green == 64) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1695 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1696 if (blue == 255) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1697 return lookup_color(14, fg, boldp) + 1; /* light blue */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1698 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1699 else if (green == 255) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1700 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1701 if (blue == 64) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1702 return lookup_color(16, fg, boldp) + 1; /* light green */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1703 if (blue == 255) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1704 return lookup_color(18, fg, boldp) + 1; /* light cyan */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1705 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1706 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1707 if (t_colors >= 256) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1708 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1709 if (red == blue && red == green) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1710 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1711 /* 24-color greyscale */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1712 static int cutoff[23] = { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1713 0x05, 0x10, 0x1B, 0x26, 0x31, 0x3C, 0x47, 0x52, |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1714 0x5D, 0x68, 0x73, 0x7F, 0x8A, 0x95, 0xA0, 0xAB, |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1715 0xB6, 0xC1, 0xCC, 0xD7, 0xE2, 0xED, 0xF9}; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1716 int i; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1717 |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1718 for (i = 0; i < 23; ++i) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1719 if (red < cutoff[i]) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1720 return i + 233; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1721 return 256; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1722 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1723 |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1724 /* 216-color cube */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1725 return 17 + ((red + 25) / 0x33) * 36 |
12204
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
1726 + ((green + 25) / 0x33) * 6 |
12152
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1727 + (blue + 25) / 0x33; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1728 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1729 return 0; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1730 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1731 |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1732 /* |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1733 * Convert the attributes of a vterm cell into an attribute index. |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1734 */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1735 static int |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1736 cell2attr(VTermScreenCellAttrs cellattrs, VTermColor cellfg, VTermColor cellbg) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1737 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1738 int attr = 0; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1739 |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1740 if (cellattrs.bold) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1741 attr |= HL_BOLD; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1742 if (cellattrs.underline) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1743 attr |= HL_UNDERLINE; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1744 if (cellattrs.italic) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1745 attr |= HL_ITALIC; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1746 if (cellattrs.strike) |
12317
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
1747 attr |= HL_STRIKETHROUGH; |
12152
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1748 if (cellattrs.reverse) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1749 attr |= HL_INVERSE; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1750 |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1751 #ifdef FEAT_GUI |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1752 if (gui.in_use) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1753 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1754 guicolor_T fg, bg; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1755 |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1756 fg = gui_mch_get_rgb_color(cellfg.red, cellfg.green, cellfg.blue); |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1757 bg = gui_mch_get_rgb_color(cellbg.red, cellbg.green, cellbg.blue); |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1758 return get_gui_attr_idx(attr, fg, bg); |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1759 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1760 else |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1761 #endif |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1762 #ifdef FEAT_TERMGUICOLORS |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1763 if (p_tgc) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1764 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1765 guicolor_T fg, bg; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1766 |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1767 fg = gui_get_rgb_color_cmn(cellfg.red, cellfg.green, cellfg.blue); |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1768 bg = gui_get_rgb_color_cmn(cellbg.red, cellbg.green, cellbg.blue); |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1769 |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1770 return get_tgc_attr_idx(attr, fg, bg); |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1771 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1772 else |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1773 #endif |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1774 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1775 int bold = MAYBE; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1776 int fg = color2index(&cellfg, TRUE, &bold); |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1777 int bg = color2index(&cellbg, FALSE, &bold); |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1778 |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1779 /* with 8 colors set the bold attribute to get a bright foreground */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1780 if (bold == TRUE) |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1781 attr |= HL_BOLD; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1782 return get_cterm_attr_idx(attr, fg, bg); |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1783 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1784 return 0; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1785 } |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1786 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1787 static int |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1788 handle_damage(VTermRect rect, void *user) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1789 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1790 term_T *term = (term_T *)user; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1791 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1792 term->tl_dirty_row_start = MIN(term->tl_dirty_row_start, rect.start_row); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1793 term->tl_dirty_row_end = MAX(term->tl_dirty_row_end, rect.end_row); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1794 redraw_buf_later(term->tl_buffer, NOT_VALID); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1795 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1796 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1797 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1798 static int |
12116
237bb67962a0
patch 8.0.0938: scrolling in terminal window is inefficient
Christian Brabandt <cb@256bit.org>
parents:
12104
diff
changeset
|
1799 handle_moverect(VTermRect dest, VTermRect src, void *user) |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1800 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1801 term_T *term = (term_T *)user; |
12152
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1802 |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1803 /* Scrolling up is done much more efficiently by deleting lines instead of |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1804 * redrawing the text. */ |
12116
237bb67962a0
patch 8.0.0938: scrolling in terminal window is inefficient
Christian Brabandt <cb@256bit.org>
parents:
12104
diff
changeset
|
1805 if (dest.start_col == src.start_col |
237bb67962a0
patch 8.0.0938: scrolling in terminal window is inefficient
Christian Brabandt <cb@256bit.org>
parents:
12104
diff
changeset
|
1806 && dest.end_col == src.end_col |
237bb67962a0
patch 8.0.0938: scrolling in terminal window is inefficient
Christian Brabandt <cb@256bit.org>
parents:
12104
diff
changeset
|
1807 && dest.start_row < src.start_row) |
12152
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1808 { |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1809 win_T *wp; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1810 VTermColor fg, bg; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1811 VTermScreenCellAttrs attr; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1812 int clear_attr; |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1813 |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1814 /* Set the color to clear lines with. */ |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1815 vterm_state_get_default_colors(vterm_obtain_state(term->tl_vterm), |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1816 &fg, &bg); |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1817 vim_memset(&attr, 0, sizeof(attr)); |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1818 clear_attr = cell2attr(attr, fg, bg); |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1819 |
12116
237bb67962a0
patch 8.0.0938: scrolling in terminal window is inefficient
Christian Brabandt <cb@256bit.org>
parents:
12104
diff
changeset
|
1820 FOR_ALL_WINDOWS(wp) |
237bb67962a0
patch 8.0.0938: scrolling in terminal window is inefficient
Christian Brabandt <cb@256bit.org>
parents:
12104
diff
changeset
|
1821 { |
237bb67962a0
patch 8.0.0938: scrolling in terminal window is inefficient
Christian Brabandt <cb@256bit.org>
parents:
12104
diff
changeset
|
1822 if (wp->w_buffer == term->tl_buffer) |
237bb67962a0
patch 8.0.0938: scrolling in terminal window is inefficient
Christian Brabandt <cb@256bit.org>
parents:
12104
diff
changeset
|
1823 win_del_lines(wp, dest.start_row, |
12152
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1824 src.start_row - dest.start_row, FALSE, FALSE, |
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1825 clear_attr); |
12116
237bb67962a0
patch 8.0.0938: scrolling in terminal window is inefficient
Christian Brabandt <cb@256bit.org>
parents:
12104
diff
changeset
|
1826 } |
12152
69af108df70e
patch 8.0.0956: scrolling in a terminal window has flicker
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
1827 } |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1828 redraw_buf_later(term->tl_buffer, NOT_VALID); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1829 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1830 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1831 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1832 static int |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1833 handle_movecursor( |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1834 VTermPos pos, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1835 VTermPos oldpos UNUSED, |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1836 int visible, |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1837 void *user) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1838 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1839 term_T *term = (term_T *)user; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1840 win_T *wp; |
11874
d444e087b8fd
patch 8.0.0817: cannot get the terminal line at the cursor
Christian Brabandt <cb@256bit.org>
parents:
11872
diff
changeset
|
1841 |
d444e087b8fd
patch 8.0.0817: cannot get the terminal line at the cursor
Christian Brabandt <cb@256bit.org>
parents:
11872
diff
changeset
|
1842 term->tl_cursor_pos = pos; |
d444e087b8fd
patch 8.0.0817: cannot get the terminal line at the cursor
Christian Brabandt <cb@256bit.org>
parents:
11872
diff
changeset
|
1843 term->tl_cursor_visible = visible; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1844 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1845 FOR_ALL_WINDOWS(wp) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1846 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1847 if (wp->w_buffer == term->tl_buffer) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1848 position_cursor(wp, &pos); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1849 } |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
1850 if (term->tl_buffer == curbuf && !term->tl_normal_mode) |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1851 { |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1852 may_toggle_cursor(term); |
11880
45558e0507e8
patch 8.0.0820: GUI: cursor in terminal window lags behind
Christian Brabandt <cb@256bit.org>
parents:
11878
diff
changeset
|
1853 update_cursor(term, term->tl_cursor_visible); |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1854 } |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1855 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1856 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1857 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1858 |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1859 static int |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1860 handle_settermprop( |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1861 VTermProp prop, |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1862 VTermValue *value, |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1863 void *user) |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1864 { |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1865 term_T *term = (term_T *)user; |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1866 |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1867 switch (prop) |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1868 { |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1869 case VTERM_PROP_TITLE: |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1870 vim_free(term->tl_title); |
12094
125994e132c7
patch 8.0.0927: if a terminal job sends a blank title "running" is not shown
Christian Brabandt <cb@256bit.org>
parents:
12092
diff
changeset
|
1871 /* a blank title isn't useful, make it empty, so that "running" is |
125994e132c7
patch 8.0.0927: if a terminal job sends a blank title "running" is not shown
Christian Brabandt <cb@256bit.org>
parents:
12092
diff
changeset
|
1872 * displayed */ |
125994e132c7
patch 8.0.0927: if a terminal job sends a blank title "running" is not shown
Christian Brabandt <cb@256bit.org>
parents:
12092
diff
changeset
|
1873 if (*skipwhite((char_u *)value->string) == NUL) |
125994e132c7
patch 8.0.0927: if a terminal job sends a blank title "running" is not shown
Christian Brabandt <cb@256bit.org>
parents:
12092
diff
changeset
|
1874 term->tl_title = NULL; |
12224
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1875 #ifdef WIN3264 |
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1876 else if (!enc_utf8 && enc_codepage > 0) |
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1877 { |
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1878 WCHAR *ret = NULL; |
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1879 int length = 0; |
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1880 |
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1881 MultiByteToWideChar_alloc(CP_UTF8, 0, |
12277
8b453c1299f7
patch 8.0.1018: warnings from 64-bit compiler
Christian Brabandt <cb@256bit.org>
parents:
12267
diff
changeset
|
1882 (char*)value->string, (int)STRLEN(value->string), |
12224
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1883 &ret, &length); |
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1884 if (ret != NULL) |
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1885 { |
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1886 WideCharToMultiByte_alloc(enc_codepage, 0, |
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1887 ret, length, (char**)&term->tl_title, |
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1888 &length, 0, 0); |
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1889 vim_free(ret); |
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1890 } |
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1891 } |
bccf3de74724
patch 8.0.0992: terminal title is wrong when 'encoding' is DBCS
Christian Brabandt <cb@256bit.org>
parents:
12222
diff
changeset
|
1892 #endif |
12094
125994e132c7
patch 8.0.0927: if a terminal job sends a blank title "running" is not shown
Christian Brabandt <cb@256bit.org>
parents:
12092
diff
changeset
|
1893 else |
125994e132c7
patch 8.0.0927: if a terminal job sends a blank title "running" is not shown
Christian Brabandt <cb@256bit.org>
parents:
12092
diff
changeset
|
1894 term->tl_title = vim_strsave((char_u *)value->string); |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1895 vim_free(term->tl_status_text); |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1896 term->tl_status_text = NULL; |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1897 if (term == curbuf->b_term) |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1898 maketitle(); |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1899 break; |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1900 |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1901 case VTERM_PROP_CURSORVISIBLE: |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1902 term->tl_cursor_visible = value->boolean; |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1903 may_toggle_cursor(term); |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1904 out_flush(); |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1905 break; |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1906 |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1907 case VTERM_PROP_CURSORBLINK: |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1908 term->tl_cursor_blink = value->boolean; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1909 may_set_cursor_props(term); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1910 break; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1911 |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1912 case VTERM_PROP_CURSORSHAPE: |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1913 term->tl_cursor_shape = value->number; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1914 may_set_cursor_props(term); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1915 break; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1916 |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1917 case VTERM_PROP_CURSORCOLOR: |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1918 vim_free(term->tl_cursor_color); |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1919 if (*value->string == NUL) |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1920 term->tl_cursor_color = NULL; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1921 else |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12080
diff
changeset
|
1922 term->tl_cursor_color = vim_strsave((char_u *)value->string); |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1923 may_set_cursor_props(term); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1924 break; |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
1925 |
12035
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
1926 case VTERM_PROP_ALTSCREEN: |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
1927 /* TODO: do anything else? */ |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
1928 term->tl_using_altscreen = value->boolean; |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
1929 break; |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
1930 |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1931 default: |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1932 break; |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1933 } |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1934 /* Always return 1, otherwise vterm doesn't store the value internally. */ |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1935 return 1; |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1936 } |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1937 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1938 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1939 * The job running in the terminal resized the terminal. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1940 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1941 static int |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1942 handle_resize(int rows, int cols, void *user) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1943 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1944 term_T *term = (term_T *)user; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1945 win_T *wp; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1946 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1947 term->tl_rows = rows; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1948 term->tl_cols = cols; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1949 FOR_ALL_WINDOWS(wp) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1950 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1951 if (wp->w_buffer == term->tl_buffer) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1952 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1953 win_setheight_win(rows, wp); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1954 win_setwidth_win(cols, wp); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1955 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1956 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1957 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1958 redraw_buf_later(term->tl_buffer, NOT_VALID); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1959 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1960 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1961 |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1962 /* |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1963 * Handle a line that is pushed off the top of the screen. |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1964 */ |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1965 static int |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1966 handle_pushline(int cols, const VTermScreenCell *cells, void *user) |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1967 { |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1968 term_T *term = (term_T *)user; |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1969 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1970 /* TODO: Limit the number of lines that are stored. */ |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1971 if (ga_grow(&term->tl_scrollback, 1) == OK) |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1972 { |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1973 cellattr_T *p = NULL; |
11840
3c1f89d85151
patch 8.0.0800 Problem: Terminal window scrollback contents is wrong. Solution: Fix handling of multi-byte characters (Yasuhiro Matsumoto) Handle empty lines correctly. (closes #1891)
Christian Brabandt <cb@256bit.org>
parents:
11838
diff
changeset
|
1974 int len = 0; |
3c1f89d85151
patch 8.0.0800 Problem: Terminal window scrollback contents is wrong. Solution: Fix handling of multi-byte characters (Yasuhiro Matsumoto) Handle empty lines correctly. (closes #1891)
Christian Brabandt <cb@256bit.org>
parents:
11838
diff
changeset
|
1975 int i; |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1976 int c; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1977 int col; |
11840
3c1f89d85151
patch 8.0.0800 Problem: Terminal window scrollback contents is wrong. Solution: Fix handling of multi-byte characters (Yasuhiro Matsumoto) Handle empty lines correctly. (closes #1891)
Christian Brabandt <cb@256bit.org>
parents:
11838
diff
changeset
|
1978 sb_line_T *line; |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1979 garray_T ga; |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1980 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1981 /* do not store empty cells at the end */ |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1982 for (i = 0; i < cols; ++i) |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1983 if (cells[i].chars[0] != 0) |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1984 len = i + 1; |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1985 |
12021
a7457aed7e80
patch 8.0.0891: uninitialized memory use with empty line in terminal
Christian Brabandt <cb@256bit.org>
parents:
12017
diff
changeset
|
1986 ga_init2(&ga, 1, 100); |
11840
3c1f89d85151
patch 8.0.0800 Problem: Terminal window scrollback contents is wrong. Solution: Fix handling of multi-byte characters (Yasuhiro Matsumoto) Handle empty lines correctly. (closes #1891)
Christian Brabandt <cb@256bit.org>
parents:
11838
diff
changeset
|
1987 if (len > 0) |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1988 p = (cellattr_T *)alloc((int)sizeof(cellattr_T) * len); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1989 if (p != NULL) |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1990 { |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1991 for (col = 0; col < len; col += cells[col].width) |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1992 { |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1993 if (ga_grow(&ga, MB_MAXBYTES) == FAIL) |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1994 { |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1995 ga.ga_len = 0; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1996 break; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1997 } |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
1998 for (i = 0; (c = cells[col].chars[i]) > 0 || i == 0; ++i) |
12222
43f03e584002
patch 8.0.0991: using wrong character conversion for DBCS
Christian Brabandt <cb@256bit.org>
parents:
12220
diff
changeset
|
1999 ga.ga_len += utf_char2bytes(c == NUL ? ' ' : c, |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2000 (char_u *)ga.ga_data + ga.ga_len); |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2001 p[col].width = cells[col].width; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2002 p[col].attrs = cells[col].attrs; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2003 p[col].fg = cells[col].fg; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2004 p[col].bg = cells[col].bg; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2005 } |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2006 } |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2007 if (ga_grow(&ga, 1) == FAIL) |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2008 add_scrollback_line_to_buffer(term, (char_u *)"", 0); |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2009 else |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2010 { |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2011 *((char_u *)ga.ga_data + ga.ga_len) = NUL; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2012 add_scrollback_line_to_buffer(term, ga.ga_data, ga.ga_len); |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2013 } |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2014 ga_clear(&ga); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2015 |
11840
3c1f89d85151
patch 8.0.0800 Problem: Terminal window scrollback contents is wrong. Solution: Fix handling of multi-byte characters (Yasuhiro Matsumoto) Handle empty lines correctly. (closes #1891)
Christian Brabandt <cb@256bit.org>
parents:
11838
diff
changeset
|
2016 line = (sb_line_T *)term->tl_scrollback.ga_data |
3c1f89d85151
patch 8.0.0800 Problem: Terminal window scrollback contents is wrong. Solution: Fix handling of multi-byte characters (Yasuhiro Matsumoto) Handle empty lines correctly. (closes #1891)
Christian Brabandt <cb@256bit.org>
parents:
11838
diff
changeset
|
2017 + term->tl_scrollback.ga_len; |
3c1f89d85151
patch 8.0.0800 Problem: Terminal window scrollback contents is wrong. Solution: Fix handling of multi-byte characters (Yasuhiro Matsumoto) Handle empty lines correctly. (closes #1891)
Christian Brabandt <cb@256bit.org>
parents:
11838
diff
changeset
|
2018 line->sb_cols = len; |
3c1f89d85151
patch 8.0.0800 Problem: Terminal window scrollback contents is wrong. Solution: Fix handling of multi-byte characters (Yasuhiro Matsumoto) Handle empty lines correctly. (closes #1891)
Christian Brabandt <cb@256bit.org>
parents:
11838
diff
changeset
|
2019 line->sb_cells = p; |
3c1f89d85151
patch 8.0.0800 Problem: Terminal window scrollback contents is wrong. Solution: Fix handling of multi-byte characters (Yasuhiro Matsumoto) Handle empty lines correctly. (closes #1891)
Christian Brabandt <cb@256bit.org>
parents:
11838
diff
changeset
|
2020 ++term->tl_scrollback.ga_len; |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2021 ++term->tl_scrollback_scrolled; |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2022 } |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2023 return 0; /* ignored */ |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2024 } |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2025 |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2026 static VTermScreenCallbacks screen_callbacks = { |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2027 handle_damage, /* damage */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2028 handle_moverect, /* moverect */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2029 handle_movecursor, /* movecursor */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2030 handle_settermprop, /* settermprop */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2031 NULL, /* bell */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2032 handle_resize, /* resize */ |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2033 handle_pushline, /* sb_pushline */ |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2034 NULL /* sb_popline */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2035 }; |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2036 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2037 /* |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2038 * Called when a channel has been closed. |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2039 * If this was a channel for a terminal window then finish it up. |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2040 */ |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2041 void |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2042 term_channel_closed(channel_T *ch) |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2043 { |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2044 term_T *term; |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2045 int did_one = FALSE; |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2046 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2047 for (term = first_term; term != NULL; term = term->tl_next) |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2048 if (term->tl_job == ch->ch_job) |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2049 { |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2050 term->tl_channel_closed = TRUE; |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2051 did_one = TRUE; |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2052 |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2053 vim_free(term->tl_title); |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2054 term->tl_title = NULL; |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2055 vim_free(term->tl_status_text); |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2056 term->tl_status_text = NULL; |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2057 |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2058 /* Unless in Terminal-Normal mode: clear the vterm. */ |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
2059 if (!term->tl_normal_mode) |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2060 { |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2061 int fnum = term->tl_buffer->b_fnum; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2062 |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2063 cleanup_vterm(term); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2064 |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2065 if (term->tl_finish == 'c') |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2066 { |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2067 /* ++close or term_finish == "close" */ |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
2068 ch_log(NULL, "terminal job finished, closing window"); |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2069 curbuf = term->tl_buffer; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2070 do_bufdel(DOBUF_WIPE, (char_u *)"", 1, fnum, fnum, FALSE); |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2071 break; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2072 } |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2073 if (term->tl_finish == 'o' && term->tl_buffer->b_nwindows == 0) |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2074 { |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2075 char buf[50]; |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2076 |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2077 /* TODO: use term_opencmd */ |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
2078 ch_log(NULL, "terminal job finished, opening window"); |
12072
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12066
diff
changeset
|
2079 vim_snprintf(buf, sizeof(buf), |
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12066
diff
changeset
|
2080 term->tl_opencmd == NULL |
12074
ca55e69d9d1b
patch 8.0.0917: MS-Windows:CTRL-C handling in terminal window is wrong
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
2081 ? "botright sbuf %d" |
ca55e69d9d1b
patch 8.0.0917: MS-Windows:CTRL-C handling in terminal window is wrong
Christian Brabandt <cb@256bit.org>
parents:
12072
diff
changeset
|
2082 : (char *)term->tl_opencmd, fnum); |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2083 do_cmdline_cmd((char_u *)buf); |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2084 } |
12064
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
2085 else |
407a475c67fd
patch 8.0.0912: cannot run a job in a hidden terminal
Christian Brabandt <cb@256bit.org>
parents:
12060
diff
changeset
|
2086 ch_log(NULL, "terminal job finished"); |
12031
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2087 } |
9897241c08b5
patch 8.0.0896: cannot close a terminal window when the job ends
Christian Brabandt <cb@256bit.org>
parents:
12025
diff
changeset
|
2088 |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2089 redraw_buf_and_status_later(term->tl_buffer, NOT_VALID); |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2090 } |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2091 if (did_one) |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2092 { |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2093 redraw_statuslines(); |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2094 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2095 /* Need to break out of vgetc(). */ |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2096 ins_char_typebuf(K_IGNORE); |
11949
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2097 typebuf_was_filled = TRUE; |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2098 |
11880
45558e0507e8
patch 8.0.0820: GUI: cursor in terminal window lags behind
Christian Brabandt <cb@256bit.org>
parents:
11878
diff
changeset
|
2099 term = curbuf->b_term; |
45558e0507e8
patch 8.0.0820: GUI: cursor in terminal window lags behind
Christian Brabandt <cb@256bit.org>
parents:
11878
diff
changeset
|
2100 if (term != NULL) |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2101 { |
11880
45558e0507e8
patch 8.0.0820: GUI: cursor in terminal window lags behind
Christian Brabandt <cb@256bit.org>
parents:
11878
diff
changeset
|
2102 if (term->tl_job == ch->ch_job) |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2103 maketitle(); |
11880
45558e0507e8
patch 8.0.0820: GUI: cursor in terminal window lags behind
Christian Brabandt <cb@256bit.org>
parents:
11878
diff
changeset
|
2104 update_cursor(term, term->tl_cursor_visible); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2105 } |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2106 } |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2107 } |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2108 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2109 /* |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
2110 * Called to update a window that contains an active terminal. |
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
2111 * Returns FAIL when there is no terminal running in this window or in |
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
2112 * Terminal-Normal mode. |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2113 */ |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2114 int |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2115 term_update_window(win_T *wp) |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
2116 { |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2117 term_T *term = wp->w_buffer->b_term; |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2118 VTerm *vterm; |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2119 VTermScreen *screen; |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2120 VTermState *state; |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
2121 VTermPos pos; |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
2122 |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
2123 if (term == NULL || term->tl_vterm == NULL || term->tl_normal_mode) |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2124 return FAIL; |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2125 |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2126 vterm = term->tl_vterm; |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2127 screen = vterm_obtain_screen(vterm); |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2128 state = vterm_obtain_state(vterm); |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2129 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2130 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2131 * If the window was resized a redraw will be triggered and we get here. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2132 * Adjust the size of the vterm unless 'termsize' specifies a fixed size. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2133 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2134 if ((!term->tl_rows_fixed && term->tl_rows != wp->w_height) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2135 || (!term->tl_cols_fixed && term->tl_cols != wp->w_width)) |
11741
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
2136 { |
11818
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2137 int rows = term->tl_rows_fixed ? term->tl_rows : wp->w_height; |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2138 int cols = term->tl_cols_fixed ? term->tl_cols : wp->w_width; |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2139 win_T *twp; |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2140 |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2141 FOR_ALL_WINDOWS(twp) |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2142 { |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2143 /* When more than one window shows the same terminal, use the |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2144 * smallest size. */ |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2145 if (twp->w_buffer == term->tl_buffer) |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2146 { |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2147 if (!term->tl_rows_fixed && rows > twp->w_height) |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2148 rows = twp->w_height; |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2149 if (!term->tl_cols_fixed && cols > twp->w_width) |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2150 cols = twp->w_width; |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2151 } |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
2152 } |
11741
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
2153 |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
2154 vterm_set_size(vterm, rows, cols); |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
2155 ch_log(term->tl_job->jv_channel, "Resizing terminal to %d lines", |
11741
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
2156 rows); |
11753
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2157 term_report_winsize(term, rows, cols); |
11741
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
2158 } |
11713
2ec27561dd76
patch 8.0.0739: terminal resizing doesn't work well.
Christian Brabandt <cb@256bit.org>
parents:
11711
diff
changeset
|
2159 |
2ec27561dd76
patch 8.0.0739: terminal resizing doesn't work well.
Christian Brabandt <cb@256bit.org>
parents:
11711
diff
changeset
|
2160 /* The cursor may have been moved when resizing. */ |
2ec27561dd76
patch 8.0.0739: terminal resizing doesn't work well.
Christian Brabandt <cb@256bit.org>
parents:
11711
diff
changeset
|
2161 vterm_state_get_cursorpos(state, &pos); |
2ec27561dd76
patch 8.0.0739: terminal resizing doesn't work well.
Christian Brabandt <cb@256bit.org>
parents:
11711
diff
changeset
|
2162 position_cursor(wp, &pos); |
2ec27561dd76
patch 8.0.0739: terminal resizing doesn't work well.
Christian Brabandt <cb@256bit.org>
parents:
11711
diff
changeset
|
2163 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
2164 /* TODO: Only redraw what changed. */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
2165 for (pos.row = 0; pos.row < wp->w_height; ++pos.row) |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
2166 { |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
2167 int off = screen_get_current_line_off(); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2168 int max_col = MIN(wp->w_width, term->tl_cols); |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2169 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2170 if (pos.row < term->tl_rows) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2171 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2172 for (pos.col = 0; pos.col < max_col; ) |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
2173 { |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
2174 VTermScreenCell cell; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2175 int c; |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
2176 |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2177 if (vterm_screen_get_cell(screen, pos, &cell) == 0) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2178 vim_memset(&cell, 0, sizeof(cell)); |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2179 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2180 /* TODO: composing chars */ |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2181 c = cell.chars[0]; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2182 if (c == NUL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2183 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2184 ScreenLines[off] = ' '; |
11774
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
2185 if (enc_utf8) |
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
2186 ScreenLinesUC[off] = NUL; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2187 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2188 else |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2189 { |
12204
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2190 if (enc_utf8) |
11725
22cef8face93
patch 8.0.0745: multi-byte characters in a terminal don't display well
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
2191 { |
12204
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2192 if (c >= 0x80) |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2193 { |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2194 ScreenLines[off] = ' '; |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2195 ScreenLinesUC[off] = c; |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2196 } |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2197 else |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2198 { |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2199 ScreenLines[off] = c; |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2200 ScreenLinesUC[off] = NUL; |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2201 } |
11725
22cef8face93
patch 8.0.0745: multi-byte characters in a terminal don't display well
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
2202 } |
12212
3ed8bcc9a013
patch 8.0.0986: terminal feature always requires multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
12208
diff
changeset
|
2203 #ifdef WIN3264 |
12204
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2204 else if (has_mbyte && c >= 0x80) |
11725
22cef8face93
patch 8.0.0745: multi-byte characters in a terminal don't display well
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
2205 { |
12204
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2206 char_u mb[MB_MAXBYTES+1]; |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2207 WCHAR wc = c; |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2208 |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2209 if (WideCharToMultiByte(GetACP(), 0, &wc, 1, |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2210 (char*)mb, 2, 0, 0) > 1) |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2211 { |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2212 ScreenLines[off] = mb[0]; |
12214
d2eea20ee14a
patch 8.0.0987: terminal: second byte of double-byte char wrong
Christian Brabandt <cb@256bit.org>
parents:
12212
diff
changeset
|
2213 ScreenLines[off + 1] = mb[1]; |
12204
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2214 cell.width = mb_ptr2cells(mb); |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2215 } |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2216 else |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2217 ScreenLines[off] = c; |
11725
22cef8face93
patch 8.0.0745: multi-byte characters in a terminal don't display well
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
2218 } |
12212
3ed8bcc9a013
patch 8.0.0986: terminal feature always requires multi-byte feature
Christian Brabandt <cb@256bit.org>
parents:
12208
diff
changeset
|
2219 #endif |
12204
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2220 else |
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2221 ScreenLines[off] = c; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2222 } |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2223 ScreenAttrs[off] = cell2attr(cell.attrs, cell.fg, cell.bg); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2224 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2225 ++pos.col; |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
2226 ++off; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2227 if (cell.width == 2) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2228 { |
11774
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
2229 if (enc_utf8) |
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
2230 ScreenLinesUC[off] = NUL; |
12214
d2eea20ee14a
patch 8.0.0987: terminal: second byte of double-byte char wrong
Christian Brabandt <cb@256bit.org>
parents:
12212
diff
changeset
|
2231 |
d2eea20ee14a
patch 8.0.0987: terminal: second byte of double-byte char wrong
Christian Brabandt <cb@256bit.org>
parents:
12212
diff
changeset
|
2232 /* don't set the second byte to NUL for a DBCS encoding, it |
d2eea20ee14a
patch 8.0.0987: terminal: second byte of double-byte char wrong
Christian Brabandt <cb@256bit.org>
parents:
12212
diff
changeset
|
2233 * has been set above */ |
d2eea20ee14a
patch 8.0.0987: terminal: second byte of double-byte char wrong
Christian Brabandt <cb@256bit.org>
parents:
12212
diff
changeset
|
2234 if (enc_utf8 || !has_mbyte) |
12204
b49b03085f39
patch 8.0.0982: cannot use a terminal when 'encoding' is non-utf8 multi-byte
Christian Brabandt <cb@256bit.org>
parents:
12202
diff
changeset
|
2235 ScreenLines[off] = NUL; |
12214
d2eea20ee14a
patch 8.0.0987: terminal: second byte of double-byte char wrong
Christian Brabandt <cb@256bit.org>
parents:
12212
diff
changeset
|
2236 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2237 ++pos.col; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2238 ++off; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2239 } |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
2240 } |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2241 } |
11711
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
2242 else |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
2243 pos.col = 0; |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
2244 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2245 screen_line(wp->w_winrow + pos.row, wp->w_wincol, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2246 pos.col, wp->w_width, FALSE); |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
2247 } |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2248 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
2249 return OK; |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
2250 } |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2251 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2252 /* |
11836
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2253 * Return TRUE if "wp" is a terminal window where the job has finished. |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2254 */ |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2255 int |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2256 term_is_finished(buf_T *buf) |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2257 { |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2258 return buf->b_term != NULL && buf->b_term->tl_vterm == NULL; |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2259 } |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2260 |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2261 /* |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2262 * Return TRUE if "wp" is a terminal window where the job has finished or we |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
2263 * are in Terminal-Normal mode, thus we show the buffer contents. |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2264 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2265 int |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2266 term_show_buffer(buf_T *buf) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2267 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2268 term_T *term = buf->b_term; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2269 |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
2270 return term != NULL && (term->tl_vterm == NULL || term->tl_normal_mode); |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2271 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2272 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2273 /* |
11836
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2274 * The current buffer is going to be changed. If there is terminal |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2275 * highlighting remove it now. |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2276 */ |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2277 void |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2278 term_change_in_curbuf(void) |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2279 { |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2280 term_T *term = curbuf->b_term; |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2281 |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2282 if (term_is_finished(curbuf) && term->tl_scrollback.ga_len > 0) |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2283 { |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2284 free_scrollback(term); |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2285 redraw_buf_later(term->tl_buffer, NOT_VALID); |
11912
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
2286 |
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
2287 /* The buffer is now like a normal buffer, it cannot be easily |
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
2288 * abandoned when changed. */ |
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
2289 set_string_option_direct((char_u *)"buftype", -1, |
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
2290 (char_u *)"", OPT_FREE|OPT_LOCAL, 0); |
11836
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2291 } |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2292 } |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2293 |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2294 /* |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2295 * Get the screen attribute for a position in the buffer. |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2296 */ |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2297 int |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2298 term_get_attr(buf_T *buf, linenr_T lnum, int col) |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2299 { |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2300 term_T *term = buf->b_term; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2301 sb_line_T *line; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2302 cellattr_T *cellattr; |
11836
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2303 |
11844
42585fee5e66
patch 8.0.0802: last line of terminal window has no color
Christian Brabandt <cb@256bit.org>
parents:
11842
diff
changeset
|
2304 if (lnum > term->tl_scrollback.ga_len) |
11836
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2305 return 0; |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2306 line = (sb_line_T *)term->tl_scrollback.ga_data + lnum - 1; |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2307 if (col >= line->sb_cols) |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2308 return 0; |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2309 cellattr = line->sb_cells + col; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2310 return cell2attr(cellattr->attrs, cellattr->fg, cellattr->bg); |
11836
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2311 } |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2312 |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
2313 /* |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2314 * Create a new vterm and initialize it. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2315 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2316 static void |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2317 create_vterm(term_T *term, int rows, int cols) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2318 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2319 VTerm *vterm; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2320 VTermScreen *screen; |
12202
4e0f699582cf
patch 8.0.0981: cursor in terminal window blinks by default
Christian Brabandt <cb@256bit.org>
parents:
12194
diff
changeset
|
2321 VTermValue value; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2322 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2323 vterm = vterm_new(rows, cols); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2324 term->tl_vterm = vterm; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2325 screen = vterm_obtain_screen(vterm); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2326 vterm_screen_set_callbacks(screen, &screen_callbacks, term); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2327 /* TODO: depends on 'encoding'. */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2328 vterm_set_utf8(vterm, 1); |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2329 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2330 /* Vterm uses a default black background. Set it to white when |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2331 * 'background' is "light". */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2332 if (*p_bg == 'l') |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2333 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2334 VTermColor fg, bg; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2335 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2336 fg.red = fg.green = fg.blue = 0; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2337 bg.red = bg.green = bg.blue = 255; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2338 vterm_state_set_default_colors(vterm_obtain_state(vterm), &fg, &bg); |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2339 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
2340 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2341 /* Required to initialize most things. */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2342 vterm_screen_reset(screen, 1 /* hard */); |
12035
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2343 |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2344 /* Allow using alternate screen. */ |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2345 vterm_screen_enable_altscreen(screen, 1); |
12202
4e0f699582cf
patch 8.0.0981: cursor in terminal window blinks by default
Christian Brabandt <cb@256bit.org>
parents:
12194
diff
changeset
|
2346 |
12208
48394f51e6af
patch 8.0.0984: terminal blinking cursor not correct in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12204
diff
changeset
|
2347 /* For unix do not use a blinking cursor. In an xterm this causes the |
48394f51e6af
patch 8.0.0984: terminal blinking cursor not correct in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12204
diff
changeset
|
2348 * cursor to blink if it's blinking in the xterm. |
12228
2e47dc775ec1
patch 8.0.0994: MS-Windows: cursor in terminal blinks undesirably
Christian Brabandt <cb@256bit.org>
parents:
12224
diff
changeset
|
2349 * For Windows we respect the system wide setting. */ |
12208
48394f51e6af
patch 8.0.0984: terminal blinking cursor not correct in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12204
diff
changeset
|
2350 #ifdef WIN3264 |
12228
2e47dc775ec1
patch 8.0.0994: MS-Windows: cursor in terminal blinks undesirably
Christian Brabandt <cb@256bit.org>
parents:
12224
diff
changeset
|
2351 if (GetCaretBlinkTime() == INFINITE) |
2e47dc775ec1
patch 8.0.0994: MS-Windows: cursor in terminal blinks undesirably
Christian Brabandt <cb@256bit.org>
parents:
12224
diff
changeset
|
2352 value.boolean = 0; |
2e47dc775ec1
patch 8.0.0994: MS-Windows: cursor in terminal blinks undesirably
Christian Brabandt <cb@256bit.org>
parents:
12224
diff
changeset
|
2353 else |
2e47dc775ec1
patch 8.0.0994: MS-Windows: cursor in terminal blinks undesirably
Christian Brabandt <cb@256bit.org>
parents:
12224
diff
changeset
|
2354 value.boolean = 1; |
12208
48394f51e6af
patch 8.0.0984: terminal blinking cursor not correct in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12204
diff
changeset
|
2355 #else |
12202
4e0f699582cf
patch 8.0.0981: cursor in terminal window blinks by default
Christian Brabandt <cb@256bit.org>
parents:
12194
diff
changeset
|
2356 value.boolean = 0; |
12208
48394f51e6af
patch 8.0.0984: terminal blinking cursor not correct in the GUI
Christian Brabandt <cb@256bit.org>
parents:
12204
diff
changeset
|
2357 #endif |
12202
4e0f699582cf
patch 8.0.0981: cursor in terminal window blinks by default
Christian Brabandt <cb@256bit.org>
parents:
12194
diff
changeset
|
2358 vterm_state_set_termprop(vterm_obtain_state(vterm), |
4e0f699582cf
patch 8.0.0981: cursor in terminal window blinks by default
Christian Brabandt <cb@256bit.org>
parents:
12194
diff
changeset
|
2359 VTERM_PROP_CURSORBLINK, &value); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2360 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2361 |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2362 /* |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2363 * Return the text to show for the buffer name and status. |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2364 */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2365 char_u * |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2366 term_get_status_text(term_T *term) |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2367 { |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2368 if (term->tl_status_text == NULL) |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2369 { |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2370 char_u *txt; |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2371 size_t len; |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2372 |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
2373 if (term->tl_normal_mode) |
11866
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2374 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2375 if (term_job_running(term)) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2376 txt = (char_u *)_("Terminal"); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2377 else |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2378 txt = (char_u *)_("Terminal-finished"); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2379 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
2380 else if (term->tl_title != NULL) |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2381 txt = term->tl_title; |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2382 else if (term_job_running(term)) |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2383 txt = (char_u *)_("running"); |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2384 else |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2385 txt = (char_u *)_("finished"); |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2386 len = 9 + STRLEN(term->tl_buffer->b_fname) + STRLEN(txt); |
11790
4dfebc1b2674
patch 8.0.0777: compiler warnings with 64 bit compiler
Christian Brabandt <cb@256bit.org>
parents:
11786
diff
changeset
|
2387 term->tl_status_text = alloc((int)len); |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2388 if (term->tl_status_text != NULL) |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2389 vim_snprintf((char *)term->tl_status_text, len, "%s [%s]", |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2390 term->tl_buffer->b_fname, txt); |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2391 } |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2392 return term->tl_status_text; |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2393 } |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
2394 |
11816
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2395 /* |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2396 * Mark references in jobs of terminals. |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2397 */ |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2398 int |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2399 set_ref_in_term(int copyID) |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2400 { |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2401 int abort = FALSE; |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2402 term_T *term; |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2403 typval_T tv; |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2404 |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2405 for (term = first_term; term != NULL; term = term->tl_next) |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2406 if (term->tl_job != NULL) |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2407 { |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2408 tv.v_type = VAR_JOB; |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2409 tv.vval.v_job = term->tl_job; |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2410 abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2411 } |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2412 return abort; |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2413 } |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
2414 |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2415 /* |
11876
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2416 * Get the buffer from the first argument in "argvars". |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2417 * Returns NULL when the buffer is not for a terminal window. |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2418 */ |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2419 static buf_T * |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2420 term_get_buf(typval_T *argvars) |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2421 { |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2422 buf_T *buf; |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2423 |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2424 (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2425 ++emsg_off; |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2426 buf = get_buf_tv(&argvars[0], FALSE); |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2427 --emsg_off; |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2428 if (buf == NULL || buf->b_term == NULL) |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2429 return NULL; |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2430 return buf; |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2431 } |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2432 |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2433 /* |
12035
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2434 * "term_getaltscreen(buf)" function |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2435 */ |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2436 void |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2437 f_term_getaltscreen(typval_T *argvars, typval_T *rettv) |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2438 { |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2439 buf_T *buf = term_get_buf(argvars); |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2440 |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2441 if (buf == NULL) |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2442 return; |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2443 rettv->vval.v_number = buf->b_term->tl_using_altscreen; |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2444 } |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2445 |
a3ed3d236839
patch 8.0.0898: can't use the alternate screen in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12031
diff
changeset
|
2446 /* |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2447 * "term_getattr(attr, name)" function |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2448 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2449 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2450 f_term_getattr(typval_T *argvars, typval_T *rettv) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2451 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2452 int attr; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2453 size_t i; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2454 char_u *name; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2455 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2456 static struct { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2457 char *name; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2458 int attr; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2459 } attrs[] = { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2460 {"bold", HL_BOLD}, |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2461 {"italic", HL_ITALIC}, |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2462 {"underline", HL_UNDERLINE}, |
12317
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12313
diff
changeset
|
2463 {"strike", HL_STRIKETHROUGH}, |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2464 {"reverse", HL_INVERSE}, |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2465 }; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2466 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2467 attr = get_tv_number(&argvars[0]); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2468 name = get_tv_string_chk(&argvars[1]); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2469 if (name == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2470 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2471 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2472 for (i = 0; i < sizeof(attrs)/sizeof(attrs[0]); ++i) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2473 if (STRCMP(name, attrs[i].name) == 0) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2474 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2475 rettv->vval.v_number = (attr & attrs[i].attr) != 0 ? 1 : 0; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2476 break; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2477 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2478 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2479 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2480 /* |
11876
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2481 * "term_getcursor(buf)" function |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2482 */ |
11876
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2483 void |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2484 f_term_getcursor(typval_T *argvars, typval_T *rettv) |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2485 { |
11876
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2486 buf_T *buf = term_get_buf(argvars); |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
2487 term_T *term; |
11876
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2488 list_T *l; |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
2489 dict_T *d; |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2490 |
11876
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2491 if (rettv_list_alloc(rettv) == FAIL) |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2492 return; |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2493 if (buf == NULL) |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2494 return; |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
2495 term = buf->b_term; |
11876
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2496 |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
2497 l = rettv->vval.v_list; |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
2498 list_append_number(l, term->tl_cursor_pos.row + 1); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
2499 list_append_number(l, term->tl_cursor_pos.col + 1); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
2500 |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
2501 d = dict_alloc(); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
2502 if (d != NULL) |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
2503 { |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
2504 dict_add_nr_str(d, "visible", term->tl_cursor_visible, NULL); |
12259
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12244
diff
changeset
|
2505 dict_add_nr_str(d, "blink", blink_state_is_inverted() |
48eac9bc2f82
patch 8.0.1009: Xterm cursor blinking status may be inverted
Christian Brabandt <cb@256bit.org>
parents:
12244
diff
changeset
|
2506 ? !term->tl_cursor_blink : term->tl_cursor_blink, NULL); |
12076
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
2507 dict_add_nr_str(d, "shape", term->tl_cursor_shape, NULL); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
2508 dict_add_nr_str(d, "color", 0L, term->tl_cursor_color == NULL |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
2509 ? (char_u *)"" : term->tl_cursor_color); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
2510 list_append_dict(l, d); |
ca4931a20f8c
patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents:
12074
diff
changeset
|
2511 } |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2512 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2513 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2514 /* |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2515 * "term_getjob(buf)" function |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2516 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2517 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2518 f_term_getjob(typval_T *argvars, typval_T *rettv) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2519 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2520 buf_T *buf = term_get_buf(argvars); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2521 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2522 rettv->v_type = VAR_JOB; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2523 rettv->vval.v_job = NULL; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2524 if (buf == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2525 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2526 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2527 rettv->vval.v_job = buf->b_term->tl_job; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2528 if (rettv->vval.v_job != NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2529 ++rettv->vval.v_job->jv_refcount; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2530 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2531 |
11904
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
2532 static int |
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
2533 get_row_number(typval_T *tv, term_T *term) |
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
2534 { |
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
2535 if (tv->v_type == VAR_STRING |
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
2536 && tv->vval.v_string != NULL |
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
2537 && STRCMP(tv->vval.v_string, ".") == 0) |
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
2538 return term->tl_cursor_pos.row; |
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
2539 return (int)get_tv_number(tv) - 1; |
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
2540 } |
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
2541 |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2542 /* |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2543 * "term_getline(buf, row)" function |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2544 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2545 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2546 f_term_getline(typval_T *argvars, typval_T *rettv) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2547 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2548 buf_T *buf = term_get_buf(argvars); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2549 term_T *term; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2550 int row; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2551 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2552 rettv->v_type = VAR_STRING; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2553 if (buf == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2554 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2555 term = buf->b_term; |
11904
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
2556 row = get_row_number(&argvars[1], term); |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2557 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2558 if (term->tl_vterm == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2559 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2560 linenr_T lnum = row + term->tl_scrollback_scrolled + 1; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2561 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2562 /* vterm is finished, get the text from the buffer */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2563 if (lnum > 0 && lnum <= buf->b_ml.ml_line_count) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2564 rettv->vval.v_string = vim_strsave(ml_get_buf(buf, lnum, FALSE)); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2565 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2566 else |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2567 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2568 VTermScreen *screen = vterm_obtain_screen(term->tl_vterm); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2569 VTermRect rect; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2570 int len; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2571 char_u *p; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2572 |
11923
c9da7b42fdf5
patch 8.0.0841: term_getline() may cause a crash
Christian Brabandt <cb@256bit.org>
parents:
11919
diff
changeset
|
2573 if (row < 0 || row >= term->tl_rows) |
c9da7b42fdf5
patch 8.0.0841: term_getline() may cause a crash
Christian Brabandt <cb@256bit.org>
parents:
11919
diff
changeset
|
2574 return; |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2575 len = term->tl_cols * MB_MAXBYTES + 1; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2576 p = alloc(len); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2577 if (p == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2578 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2579 rettv->vval.v_string = p; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2580 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2581 rect.start_col = 0; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2582 rect.end_col = term->tl_cols; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2583 rect.start_row = row; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2584 rect.end_row = row + 1; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2585 p[vterm_screen_get_text(screen, (char *)p, len, rect)] = NUL; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2586 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2587 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2588 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2589 /* |
12025
c0ee48f48a2b
patch 8.0.0893: cannot get the scroll count of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12023
diff
changeset
|
2590 * "term_getscrolled(buf)" function |
c0ee48f48a2b
patch 8.0.0893: cannot get the scroll count of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12023
diff
changeset
|
2591 */ |
c0ee48f48a2b
patch 8.0.0893: cannot get the scroll count of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12023
diff
changeset
|
2592 void |
c0ee48f48a2b
patch 8.0.0893: cannot get the scroll count of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12023
diff
changeset
|
2593 f_term_getscrolled(typval_T *argvars, typval_T *rettv) |
c0ee48f48a2b
patch 8.0.0893: cannot get the scroll count of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12023
diff
changeset
|
2594 { |
c0ee48f48a2b
patch 8.0.0893: cannot get the scroll count of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12023
diff
changeset
|
2595 buf_T *buf = term_get_buf(argvars); |
c0ee48f48a2b
patch 8.0.0893: cannot get the scroll count of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12023
diff
changeset
|
2596 |
c0ee48f48a2b
patch 8.0.0893: cannot get the scroll count of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12023
diff
changeset
|
2597 if (buf == NULL) |
c0ee48f48a2b
patch 8.0.0893: cannot get the scroll count of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12023
diff
changeset
|
2598 return; |
c0ee48f48a2b
patch 8.0.0893: cannot get the scroll count of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12023
diff
changeset
|
2599 rettv->vval.v_number = buf->b_term->tl_scrollback_scrolled; |
c0ee48f48a2b
patch 8.0.0893: cannot get the scroll count of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12023
diff
changeset
|
2600 } |
c0ee48f48a2b
patch 8.0.0893: cannot get the scroll count of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12023
diff
changeset
|
2601 |
c0ee48f48a2b
patch 8.0.0893: cannot get the scroll count of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12023
diff
changeset
|
2602 /* |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2603 * "term_getsize(buf)" function |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2604 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2605 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2606 f_term_getsize(typval_T *argvars, typval_T *rettv) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2607 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2608 buf_T *buf = term_get_buf(argvars); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2609 list_T *l; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2610 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2611 if (rettv_list_alloc(rettv) == FAIL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2612 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2613 if (buf == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2614 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2615 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2616 l = rettv->vval.v_list; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2617 list_append_number(l, buf->b_term->tl_rows); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2618 list_append_number(l, buf->b_term->tl_cols); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2619 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2620 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2621 /* |
11882
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2622 * "term_getstatus(buf)" function |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2623 */ |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2624 void |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2625 f_term_getstatus(typval_T *argvars, typval_T *rettv) |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2626 { |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2627 buf_T *buf = term_get_buf(argvars); |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2628 term_T *term; |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2629 char_u val[100]; |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2630 |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2631 rettv->v_type = VAR_STRING; |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2632 if (buf == NULL) |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2633 return; |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2634 term = buf->b_term; |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2635 |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2636 if (term_job_running(term)) |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2637 STRCPY(val, "running"); |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2638 else |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2639 STRCPY(val, "finished"); |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
2640 if (term->tl_normal_mode) |
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11985
diff
changeset
|
2641 STRCAT(val, ",normal"); |
11882
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2642 rettv->vval.v_string = vim_strsave(val); |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2643 } |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2644 |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2645 /* |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2646 * "term_gettitle(buf)" function |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2647 */ |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2648 void |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2649 f_term_gettitle(typval_T *argvars, typval_T *rettv) |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2650 { |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2651 buf_T *buf = term_get_buf(argvars); |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2652 |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2653 rettv->v_type = VAR_STRING; |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2654 if (buf == NULL) |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2655 return; |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2656 |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2657 if (buf->b_term->tl_title != NULL) |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2658 rettv->vval.v_string = vim_strsave(buf->b_term->tl_title); |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2659 } |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2660 |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
2661 /* |
11933
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2662 * "term_gettty(buf)" function |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2663 */ |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2664 void |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2665 f_term_gettty(typval_T *argvars, typval_T *rettv) |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2666 { |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2667 buf_T *buf = term_get_buf(argvars); |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2668 char_u *p; |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2669 |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2670 rettv->v_type = VAR_STRING; |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2671 if (buf == NULL) |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2672 return; |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2673 if (buf->b_term->tl_job != NULL) |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2674 p = buf->b_term->tl_job->jv_tty_name; |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2675 else |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2676 p = buf->b_term->tl_tty_name; |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2677 if (p != NULL) |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2678 rettv->vval.v_string = vim_strsave(p); |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2679 } |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2680 |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
2681 /* |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2682 * "term_list()" function |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2683 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2684 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2685 f_term_list(typval_T *argvars UNUSED, typval_T *rettv) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2686 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2687 term_T *tp; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2688 list_T *l; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2689 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2690 if (rettv_list_alloc(rettv) == FAIL || first_term == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2691 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2692 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2693 l = rettv->vval.v_list; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2694 for (tp = first_term; tp != NULL; tp = tp->tl_next) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2695 if (tp != NULL && tp->tl_buffer != NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2696 if (list_append_number(l, |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2697 (varnumber_T)tp->tl_buffer->b_fnum) == FAIL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2698 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2699 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2700 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2701 /* |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2702 * "term_scrape(buf, row)" function |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2703 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2704 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2705 f_term_scrape(typval_T *argvars, typval_T *rettv) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2706 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2707 buf_T *buf = term_get_buf(argvars); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2708 VTermScreen *screen = NULL; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2709 VTermPos pos; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2710 list_T *l; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2711 term_T *term; |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2712 char_u *p; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2713 sb_line_T *line; |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2714 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2715 if (rettv_list_alloc(rettv) == FAIL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2716 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2717 if (buf == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2718 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2719 term = buf->b_term; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2720 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2721 l = rettv->vval.v_list; |
11904
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
2722 pos.row = get_row_number(&argvars[1], term); |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2723 |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2724 if (term->tl_vterm != NULL) |
12017
e30f3d1fdea7
patch 8.0.0889: gcc gives warnings for uninitialized variables
Christian Brabandt <cb@256bit.org>
parents:
12011
diff
changeset
|
2725 { |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2726 screen = vterm_obtain_screen(term->tl_vterm); |
12017
e30f3d1fdea7
patch 8.0.0889: gcc gives warnings for uninitialized variables
Christian Brabandt <cb@256bit.org>
parents:
12011
diff
changeset
|
2727 p = NULL; |
e30f3d1fdea7
patch 8.0.0889: gcc gives warnings for uninitialized variables
Christian Brabandt <cb@256bit.org>
parents:
12011
diff
changeset
|
2728 line = NULL; |
e30f3d1fdea7
patch 8.0.0889: gcc gives warnings for uninitialized variables
Christian Brabandt <cb@256bit.org>
parents:
12011
diff
changeset
|
2729 } |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2730 else |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2731 { |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2732 linenr_T lnum = pos.row + term->tl_scrollback_scrolled; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2733 |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2734 if (lnum < 0 || lnum >= term->tl_scrollback.ga_len) |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2735 return; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2736 p = ml_get_buf(buf, lnum + 1, FALSE); |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2737 line = (sb_line_T *)term->tl_scrollback.ga_data + lnum; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2738 } |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2739 |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2740 for (pos.col = 0; pos.col < term->tl_cols; ) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2741 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2742 dict_T *dcell; |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2743 int width; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2744 VTermScreenCellAttrs attrs; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2745 VTermColor fg, bg; |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2746 char_u rgb[8]; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2747 char_u mbs[MB_MAXBYTES * VTERM_MAX_CHARS_PER_CELL + 1]; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2748 int off = 0; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2749 int i; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2750 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2751 if (screen == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2752 { |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2753 cellattr_T *cellattr; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2754 int len; |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2755 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2756 /* vterm has finished, get the cell from scrollback */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2757 if (pos.col >= line->sb_cols) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2758 break; |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2759 cellattr = line->sb_cells + pos.col; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2760 width = cellattr->width; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2761 attrs = cellattr->attrs; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2762 fg = cellattr->fg; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2763 bg = cellattr->bg; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2764 len = MB_PTR2LEN(p); |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2765 mch_memmove(mbs, p, len); |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2766 mbs[len] = NUL; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2767 p += len; |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2768 } |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2769 else |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2770 { |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2771 VTermScreenCell cell; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2772 if (vterm_screen_get_cell(screen, pos, &cell) == 0) |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2773 break; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2774 for (i = 0; i < VTERM_MAX_CHARS_PER_CELL; ++i) |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2775 { |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2776 if (cell.chars[i] == 0) |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2777 break; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2778 off += (*utf_char2bytes)((int)cell.chars[i], mbs + off); |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2779 } |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2780 mbs[off] = NUL; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2781 width = cell.width; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2782 attrs = cell.attrs; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2783 fg = cell.fg; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2784 bg = cell.bg; |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2785 } |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2786 dcell = dict_alloc(); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2787 list_append_dict(l, dcell); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2788 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2789 dict_add_nr_str(dcell, "chars", 0, mbs); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2790 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2791 vim_snprintf((char *)rgb, 8, "#%02x%02x%02x", |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2792 fg.red, fg.green, fg.blue); |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2793 dict_add_nr_str(dcell, "fg", 0, rgb); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2794 vim_snprintf((char *)rgb, 8, "#%02x%02x%02x", |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2795 bg.red, bg.green, bg.blue); |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2796 dict_add_nr_str(dcell, "bg", 0, rgb); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2797 |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2798 dict_add_nr_str(dcell, "attr", |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2799 cell2attr(attrs, fg, bg), NULL); |
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2800 dict_add_nr_str(dcell, "width", width, NULL); |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2801 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2802 ++pos.col; |
12009
0d9bfdb3f6f7
patch 8.0.0885: terminal window scrollback is stored inefficiently
Christian Brabandt <cb@256bit.org>
parents:
12007
diff
changeset
|
2803 if (width == 2) |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2804 ++pos.col; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2805 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2806 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2807 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2808 /* |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2809 * "term_sendkeys(buf, keys)" function |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2810 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2811 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2812 f_term_sendkeys(typval_T *argvars, typval_T *rettv) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2813 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2814 buf_T *buf = term_get_buf(argvars); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2815 char_u *msg; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2816 term_T *term; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2817 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2818 rettv->v_type = VAR_UNKNOWN; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2819 if (buf == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2820 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2821 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2822 msg = get_tv_string_chk(&argvars[1]); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2823 if (msg == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2824 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2825 term = buf->b_term; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2826 if (term->tl_vterm == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2827 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2828 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2829 while (*msg != NUL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2830 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2831 send_keys_to_term(term, PTR2CHAR(msg), FALSE); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2832 msg += MB_PTR2LEN(msg); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2833 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2834 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2835 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2836 /* |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2837 * "term_start(command, options)" function |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2838 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2839 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2840 f_term_start(typval_T *argvars, typval_T *rettv) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2841 { |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2842 jobopt_T opt; |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2843 |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2844 init_job_options(&opt); |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2845 if (argvars[1].v_type != VAR_UNKNOWN |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2846 && get_job_options(&argvars[1], &opt, |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2847 JO_TIMEOUT_ALL + JO_STOPONEXIT |
12345
76ab57a79183
patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
2848 + JO_EXIT_CB + JO_CLOSE_CALLBACK + JO_OUT_IO, |
12072
f4e1e1e6886b
patch 8.0.0916: cannot specify properties of window for terminal open
Christian Brabandt <cb@256bit.org>
parents:
12066
diff
changeset
|
2849 JO2_TERM_NAME + JO2_TERM_FINISH + JO2_HIDDEN + JO2_TERM_OPENCMD |
12060
a879814b8a37
patch 8.0.0910: cannot create a terminal in the current window
Christian Brabandt <cb@256bit.org>
parents:
12056
diff
changeset
|
2850 + JO2_TERM_COLS + JO2_TERM_ROWS + JO2_VERTICAL + JO2_CURWIN |
12309
e1f44e4afe67
patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12277
diff
changeset
|
2851 + JO2_CWD + JO2_ENV + JO2_EOF_CHARS) == FAIL) |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2852 return; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2853 |
12056
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2854 if (opt.jo_vertical) |
0498547dace0
patch 8.0.0908: cannot set terminal size with options
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2855 cmdmod.split = WSP_VERT; |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
2856 term_start(&argvars[0], &opt, FALSE); |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2857 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2858 if (curbuf->b_term != NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2859 rettv->vval.v_number = curbuf->b_fnum; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2860 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2861 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2862 /* |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2863 * "term_wait" function |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2864 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2865 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2866 f_term_wait(typval_T *argvars, typval_T *rettv UNUSED) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2867 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2868 buf_T *buf = term_get_buf(argvars); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2869 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2870 if (buf == NULL) |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2871 { |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2872 ch_log(NULL, "term_wait(): invalid argument"); |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2873 return; |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2874 } |
11949
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2875 if (buf->b_term->tl_job == NULL) |
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2876 { |
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2877 ch_log(NULL, "term_wait(): no job to wait for"); |
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2878 return; |
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2879 } |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
2880 if (buf->b_term->tl_job->jv_channel == NULL) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
2881 /* channel is closed, nothing to do */ |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
2882 return; |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2883 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2884 /* Get the job status, this will detect a job that finished. */ |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
2885 if ((buf->b_term->tl_job->jv_channel == NULL |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
2886 || !buf->b_term->tl_job->jv_channel->ch_keep_open) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
2887 && STRCMP(job_status(buf->b_term->tl_job), "dead") == 0) |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2888 { |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2889 /* The job is dead, keep reading channel I/O until the channel is |
12367
7ae2b2c84ec5
patch 8.0.1063: Coverity warns for NULL check and array use
Christian Brabandt <cb@256bit.org>
parents:
12363
diff
changeset
|
2890 * closed. buf->b_term may become NULL if the terminal was closed while |
7ae2b2c84ec5
patch 8.0.1063: Coverity warns for NULL check and array use
Christian Brabandt <cb@256bit.org>
parents:
12363
diff
changeset
|
2891 * waiting. */ |
11949
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2892 ch_log(NULL, "term_wait(): waiting for channel to close"); |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2893 while (buf->b_term != NULL && !buf->b_term->tl_channel_closed) |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2894 { |
11949
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2895 mch_check_messages(); |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2896 parse_queued_messages(); |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2897 ui_delay(10L, FALSE); |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2898 } |
11949
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2899 mch_check_messages(); |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2900 parse_queued_messages(); |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2901 } |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2902 else |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2903 { |
12007
64b822c4f7ae
patch 8.0.0884: can't specify the wait time for term_wait()
Christian Brabandt <cb@256bit.org>
parents:
11993
diff
changeset
|
2904 long wait = 10L; |
64b822c4f7ae
patch 8.0.0884: can't specify the wait time for term_wait()
Christian Brabandt <cb@256bit.org>
parents:
11993
diff
changeset
|
2905 |
11949
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2906 mch_check_messages(); |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2907 parse_queued_messages(); |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2908 |
12007
64b822c4f7ae
patch 8.0.0884: can't specify the wait time for term_wait()
Christian Brabandt <cb@256bit.org>
parents:
11993
diff
changeset
|
2909 /* Wait for some time for any channel I/O. */ |
64b822c4f7ae
patch 8.0.0884: can't specify the wait time for term_wait()
Christian Brabandt <cb@256bit.org>
parents:
11993
diff
changeset
|
2910 if (argvars[1].v_type != VAR_UNKNOWN) |
64b822c4f7ae
patch 8.0.0884: can't specify the wait time for term_wait()
Christian Brabandt <cb@256bit.org>
parents:
11993
diff
changeset
|
2911 wait = get_tv_number(&argvars[1]); |
64b822c4f7ae
patch 8.0.0884: can't specify the wait time for term_wait()
Christian Brabandt <cb@256bit.org>
parents:
11993
diff
changeset
|
2912 ui_delay(wait, TRUE); |
11949
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2913 mch_check_messages(); |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2914 |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2915 /* Flushing messages on channels is hopefully sufficient. |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2916 * TODO: is there a better way? */ |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2917 parse_queued_messages(); |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2918 } |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2919 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2920 |
12313
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2921 /* |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2922 * Called when a channel has sent all the lines to a terminal. |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2923 * Send a CTRL-D to mark the end of the text. |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2924 */ |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2925 void |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2926 term_send_eof(channel_T *ch) |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2927 { |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2928 term_T *term; |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2929 |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2930 for (term = first_term; term != NULL; term = term->tl_next) |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2931 if (term->tl_job == ch->ch_job) |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2932 { |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2933 if (term->tl_eof_chars != NULL) |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2934 { |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2935 channel_send(ch, PART_IN, term->tl_eof_chars, |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2936 (int)STRLEN(term->tl_eof_chars), NULL); |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2937 channel_send(ch, PART_IN, (char_u *)"\r", 1, NULL); |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2938 } |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2939 # ifdef WIN3264 |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2940 else |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2941 /* Default: CTRL-D */ |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2942 channel_send(ch, PART_IN, (char_u *)"\004\r", 2, NULL); |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2943 # endif |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2944 } |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2945 } |
44f3c9b7eec4
patch 8.0.1036: ++eof argument for terminal only available on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12311
diff
changeset
|
2946 |
12144
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
2947 # if defined(WIN3264) || defined(PROTO) |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2948 |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2949 /************************************** |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2950 * 2. MS-Windows implementation. |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2951 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2952 |
12144
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
2953 # ifndef PROTO |
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
2954 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2955 #define WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN 1ul |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2956 #define WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN 2ull |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2957 |
11774
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
2958 void* (*winpty_config_new)(UINT64, void*); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2959 void* (*winpty_open)(void*, void*); |
11774
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
2960 void* (*winpty_spawn_config_new)(UINT64, void*, LPCWSTR, void*, void*, void*); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2961 BOOL (*winpty_spawn)(void*, void*, HANDLE*, HANDLE*, DWORD*, void*); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2962 void (*winpty_config_set_initial_size)(void*, int, int); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2963 LPCWSTR (*winpty_conin_name)(void*); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2964 LPCWSTR (*winpty_conout_name)(void*); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2965 LPCWSTR (*winpty_conerr_name)(void*); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2966 void (*winpty_free)(void*); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2967 void (*winpty_config_free)(void*); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2968 void (*winpty_spawn_config_free)(void*); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2969 void (*winpty_error_free)(void*); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2970 LPCWSTR (*winpty_error_msg)(void*); |
11753
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2971 BOOL (*winpty_set_size)(void*, int, int, void*); |
11951
e8b1ef40324a
patch 8.0.0855: MS-Windows: can't get tty name of terminal
Christian Brabandt <cb@256bit.org>
parents:
11949
diff
changeset
|
2972 HANDLE (*winpty_agent_process)(void*); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2973 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2974 #define WINPTY_DLL "winpty.dll" |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2975 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2976 static HINSTANCE hWinPtyDLL = NULL; |
12144
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
2977 # endif |
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
2978 |
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
2979 static int |
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
2980 dyn_winpty_init(int verbose) |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2981 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2982 int i; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2983 static struct |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2984 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2985 char *name; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2986 FARPROC *ptr; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2987 } winpty_entry[] = |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2988 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2989 {"winpty_conerr_name", (FARPROC*)&winpty_conerr_name}, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2990 {"winpty_config_free", (FARPROC*)&winpty_config_free}, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2991 {"winpty_config_new", (FARPROC*)&winpty_config_new}, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2992 {"winpty_config_set_initial_size", (FARPROC*)&winpty_config_set_initial_size}, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2993 {"winpty_conin_name", (FARPROC*)&winpty_conin_name}, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2994 {"winpty_conout_name", (FARPROC*)&winpty_conout_name}, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2995 {"winpty_error_free", (FARPROC*)&winpty_error_free}, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2996 {"winpty_free", (FARPROC*)&winpty_free}, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2997 {"winpty_open", (FARPROC*)&winpty_open}, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2998 {"winpty_spawn", (FARPROC*)&winpty_spawn}, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2999 {"winpty_spawn_config_free", (FARPROC*)&winpty_spawn_config_free}, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3000 {"winpty_spawn_config_new", (FARPROC*)&winpty_spawn_config_new}, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3001 {"winpty_error_msg", (FARPROC*)&winpty_error_msg}, |
11753
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3002 {"winpty_set_size", (FARPROC*)&winpty_set_size}, |
11951
e8b1ef40324a
patch 8.0.0855: MS-Windows: can't get tty name of terminal
Christian Brabandt <cb@256bit.org>
parents:
11949
diff
changeset
|
3003 {"winpty_agent_process", (FARPROC*)&winpty_agent_process}, |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3004 {NULL, NULL} |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3005 }; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3006 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3007 /* No need to initialize twice. */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3008 if (hWinPtyDLL) |
12144
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3009 return OK; |
12138
bee3751f3d4e
patch 8.0.0949: winpty.dll name is fixed
Christian Brabandt <cb@256bit.org>
parents:
12124
diff
changeset
|
3010 /* Load winpty.dll, prefer using the 'winptydll' option, fall back to just |
bee3751f3d4e
patch 8.0.0949: winpty.dll name is fixed
Christian Brabandt <cb@256bit.org>
parents:
12124
diff
changeset
|
3011 * winpty.dll. */ |
bee3751f3d4e
patch 8.0.0949: winpty.dll name is fixed
Christian Brabandt <cb@256bit.org>
parents:
12124
diff
changeset
|
3012 if (*p_winptydll != NUL) |
bee3751f3d4e
patch 8.0.0949: winpty.dll name is fixed
Christian Brabandt <cb@256bit.org>
parents:
12124
diff
changeset
|
3013 hWinPtyDLL = vimLoadLib((char *)p_winptydll); |
bee3751f3d4e
patch 8.0.0949: winpty.dll name is fixed
Christian Brabandt <cb@256bit.org>
parents:
12124
diff
changeset
|
3014 if (!hWinPtyDLL) |
bee3751f3d4e
patch 8.0.0949: winpty.dll name is fixed
Christian Brabandt <cb@256bit.org>
parents:
12124
diff
changeset
|
3015 hWinPtyDLL = vimLoadLib(WINPTY_DLL); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3016 if (!hWinPtyDLL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3017 { |
12144
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3018 if (verbose) |
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3019 EMSG2(_(e_loadlib), *p_winptydll != NUL ? p_winptydll |
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3020 : (char_u *)WINPTY_DLL); |
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3021 return FAIL; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3022 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3023 for (i = 0; winpty_entry[i].name != NULL |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3024 && winpty_entry[i].ptr != NULL; ++i) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3025 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3026 if ((*winpty_entry[i].ptr = (FARPROC)GetProcAddress(hWinPtyDLL, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3027 winpty_entry[i].name)) == NULL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3028 { |
12144
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3029 if (verbose) |
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3030 EMSG2(_(e_loadfunc), winpty_entry[i].name); |
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3031 return FAIL; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3032 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3033 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3034 |
12144
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3035 return OK; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3036 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3037 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3038 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3039 * Create a new terminal of "rows" by "cols" cells. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3040 * Store a reference in "term". |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3041 * Return OK or FAIL. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3042 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3043 static int |
12192
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
3044 term_and_job_init( |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
3045 term_T *term, |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
3046 typval_T *argvar, |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
3047 jobopt_T *opt) |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3048 { |
12194
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3049 WCHAR *cmd_wchar = NULL; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3050 channel_T *channel = NULL; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3051 job_T *job = NULL; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3052 DWORD error; |
12194
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3053 HANDLE jo = NULL; |
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3054 HANDLE child_process_handle; |
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3055 HANDLE child_thread_handle; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3056 void *winpty_err; |
11798
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
3057 void *spawn_config = NULL; |
11951
e8b1ef40324a
patch 8.0.0855: MS-Windows: can't get tty name of terminal
Christian Brabandt <cb@256bit.org>
parents:
11949
diff
changeset
|
3058 char buf[MAX_PATH]; |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
3059 garray_T ga; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
3060 char_u *cmd; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3061 |
12144
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3062 if (dyn_winpty_init(TRUE) == FAIL) |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3063 return FAIL; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3064 |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
3065 if (argvar->v_type == VAR_STRING) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
3066 cmd = argvar->vval.v_string; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
3067 else |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
3068 { |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
3069 ga_init2(&ga, (int)sizeof(char*), 20); |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
3070 if (win32_build_cmd(argvar->vval.v_list, &ga) == FAIL) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
3071 goto failed; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
3072 cmd = ga.ga_data; |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
3073 } |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
3074 |
12194
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3075 cmd_wchar = enc_to_utf16(cmd, NULL); |
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3076 if (cmd_wchar == NULL) |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3077 return FAIL; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3078 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3079 job = job_alloc(); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3080 if (job == NULL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3081 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3082 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3083 channel = add_channel(); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3084 if (channel == NULL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3085 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3086 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3087 term->tl_winpty_config = winpty_config_new(0, &winpty_err); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3088 if (term->tl_winpty_config == NULL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3089 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3090 |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3091 winpty_config_set_initial_size(term->tl_winpty_config, |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3092 term->tl_cols, term->tl_rows); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3093 term->tl_winpty = winpty_open(term->tl_winpty_config, &winpty_err); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3094 if (term->tl_winpty == NULL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3095 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3096 |
11933
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
3097 /* TODO: if the command is "NONE" only create a pty. */ |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3098 spawn_config = winpty_spawn_config_new( |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3099 WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN | |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3100 WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3101 NULL, |
12194
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3102 cmd_wchar, |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3103 NULL, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3104 NULL, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3105 &winpty_err); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3106 if (spawn_config == NULL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3107 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3108 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3109 channel = add_channel(); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3110 if (channel == NULL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3111 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3112 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3113 job = job_alloc(); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3114 if (job == NULL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3115 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3116 |
12194
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3117 if (opt->jo_set & JO_IN_BUF) |
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3118 job->jv_in_buf = buflist_findnr(opt->jo_io_buf[PART_IN]); |
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3119 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3120 if (!winpty_spawn(term->tl_winpty, spawn_config, &child_process_handle, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3121 &child_thread_handle, &error, &winpty_err)) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3122 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3123 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3124 channel_set_pipes(channel, |
12194
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3125 (sock_T)CreateFileW( |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3126 winpty_conin_name(term->tl_winpty), |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3127 GENERIC_WRITE, 0, NULL, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3128 OPEN_EXISTING, 0, NULL), |
12194
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3129 (sock_T)CreateFileW( |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3130 winpty_conout_name(term->tl_winpty), |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3131 GENERIC_READ, 0, NULL, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3132 OPEN_EXISTING, 0, NULL), |
12194
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3133 (sock_T)CreateFileW( |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3134 winpty_conerr_name(term->tl_winpty), |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3135 GENERIC_READ, 0, NULL, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3136 OPEN_EXISTING, 0, NULL)); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3137 |
12311
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
3138 /* Write lines with CR instead of NL. */ |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
3139 channel->ch_write_text_mode = TRUE; |
66fa8eabbd6e
patch 8.0.1035: sending buffer lines to terminal doesn't work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12309
diff
changeset
|
3140 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3141 jo = CreateJobObject(NULL, NULL); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3142 if (jo == NULL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3143 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3144 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3145 if (!AssignProcessToJobObject(jo, child_process_handle)) |
11798
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
3146 { |
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
3147 /* Failed, switch the way to terminate process with TerminateProcess. */ |
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
3148 CloseHandle(jo); |
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
3149 jo = NULL; |
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
3150 } |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3151 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3152 winpty_spawn_config_free(spawn_config); |
12194
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3153 vim_free(cmd_wchar); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3154 |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3155 create_vterm(term, term->tl_rows, term->tl_cols); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3156 |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
3157 channel_set_job(channel, job, opt); |
11953
fd714bb0ae24
patch 8.0.0856: MS-Windows: terminal job doesn't take options
Christian Brabandt <cb@256bit.org>
parents:
11951
diff
changeset
|
3158 job_set_options(job, opt); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3159 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3160 job->jv_channel = channel; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3161 job->jv_proc_info.hProcess = child_process_handle; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3162 job->jv_proc_info.dwProcessId = GetProcessId(child_process_handle); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3163 job->jv_job_object = jo; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3164 job->jv_status = JOB_STARTED; |
11951
e8b1ef40324a
patch 8.0.0855: MS-Windows: can't get tty name of terminal
Christian Brabandt <cb@256bit.org>
parents:
11949
diff
changeset
|
3165 sprintf(buf, "winpty://%lu", |
e8b1ef40324a
patch 8.0.0855: MS-Windows: can't get tty name of terminal
Christian Brabandt <cb@256bit.org>
parents:
11949
diff
changeset
|
3166 GetProcessId(winpty_agent_process(term->tl_winpty))); |
e8b1ef40324a
patch 8.0.0855: MS-Windows: can't get tty name of terminal
Christian Brabandt <cb@256bit.org>
parents:
11949
diff
changeset
|
3167 job->jv_tty_name = vim_strsave((char_u*)buf); |
11802
b1fd49b4eea7
patch 8.0.0783: job of terminal may be freed too early
Christian Brabandt <cb@256bit.org>
parents:
11798
diff
changeset
|
3168 ++job->jv_refcount; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3169 term->tl_job = job; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3170 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3171 return OK; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3172 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3173 failed: |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
3174 if (argvar->v_type == VAR_LIST) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
3175 vim_free(ga.ga_data); |
12194
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3176 if (cmd_wchar != NULL) |
53987de2115d
patch 8.0.0977: cannot send lines to a terminal job on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
12192
diff
changeset
|
3177 vim_free(cmd_wchar); |
11798
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
3178 if (spawn_config != NULL) |
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
3179 winpty_spawn_config_free(spawn_config); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3180 if (channel != NULL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3181 channel_clear(channel); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3182 if (job != NULL) |
11751
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
3183 { |
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
3184 job->jv_channel = NULL; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3185 job_cleanup(job); |
11751
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
3186 } |
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
3187 term->tl_job = NULL; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3188 if (jo != NULL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3189 CloseHandle(jo); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3190 if (term->tl_winpty != NULL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3191 winpty_free(term->tl_winpty); |
11751
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
3192 term->tl_winpty = NULL; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3193 if (term->tl_winpty_config != NULL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3194 winpty_config_free(term->tl_winpty_config); |
11751
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
3195 term->tl_winpty_config = NULL; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3196 if (winpty_err != NULL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3197 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3198 char_u *msg = utf16_to_enc( |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3199 (short_u *)winpty_error_msg(winpty_err), NULL); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3200 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3201 EMSG(msg); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3202 winpty_error_free(winpty_err); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3203 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3204 return FAIL; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3205 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3206 |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3207 static int |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3208 create_pty_only(term_T *term, jobopt_T *opt) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3209 { |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3210 /* TODO: implement this */ |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3211 return FAIL; |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3212 } |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3213 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3214 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3215 * Free the terminal emulator part of "term". |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3216 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3217 static void |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
3218 term_free_vterm(term_T *term) |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3219 { |
11751
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
3220 if (term->tl_winpty != NULL) |
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
3221 winpty_free(term->tl_winpty); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
3222 term->tl_winpty = NULL; |
11751
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
3223 if (term->tl_winpty_config != NULL) |
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
3224 winpty_config_free(term->tl_winpty_config); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
3225 term->tl_winpty_config = NULL; |
11751
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
3226 if (term->tl_vterm != NULL) |
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
3227 vterm_free(term->tl_vterm); |
11838
e6080ed193f6
patch 8.0.0799: missing semicolon
Christian Brabandt <cb@256bit.org>
parents:
11836
diff
changeset
|
3228 term->tl_vterm = NULL; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3229 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3230 |
11753
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3231 /* |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3232 * Request size to terminal. |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3233 */ |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3234 static void |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3235 term_report_winsize(term_T *term, int rows, int cols) |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3236 { |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3237 winpty_set_size(term->tl_winpty, cols, rows, NULL); |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3238 } |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3239 |
12144
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3240 int |
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3241 terminal_enabled(void) |
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3242 { |
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3243 return dyn_winpty_init(FALSE) == OK; |
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3244 } |
abd69cea3459
patch 8.0.0952: has('terminal') does not check existence of dll file
Christian Brabandt <cb@256bit.org>
parents:
12138
diff
changeset
|
3245 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3246 # else |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3247 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3248 /************************************** |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3249 * 3. Unix-like implementation. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3250 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3251 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3252 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3253 * Create a new terminal of "rows" by "cols" cells. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3254 * Start job for "cmd". |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3255 * Store the pointers in "term". |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3256 * Return OK or FAIL. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3257 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3258 static int |
12192
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
3259 term_and_job_init( |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
3260 term_T *term, |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
3261 typval_T *argvar, |
6947d5bcf57f
patch 8.0.0976: cannot send lines to a terminal job
Christian Brabandt <cb@256bit.org>
parents:
12186
diff
changeset
|
3262 jobopt_T *opt) |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3263 { |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3264 create_vterm(term, term->tl_rows, term->tl_cols); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3265 |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12094
diff
changeset
|
3266 term->tl_job = job_start(argvar, opt); |
11802
b1fd49b4eea7
patch 8.0.0783: job of terminal may be freed too early
Christian Brabandt <cb@256bit.org>
parents:
11798
diff
changeset
|
3267 if (term->tl_job != NULL) |
b1fd49b4eea7
patch 8.0.0783: job of terminal may be freed too early
Christian Brabandt <cb@256bit.org>
parents:
11798
diff
changeset
|
3268 ++term->tl_job->jv_refcount; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3269 |
11727
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11725
diff
changeset
|
3270 return term->tl_job != NULL |
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11725
diff
changeset
|
3271 && term->tl_job->jv_channel != NULL |
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11725
diff
changeset
|
3272 && term->tl_job->jv_status != JOB_FAILED ? OK : FAIL; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3273 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3274 |
12240
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3275 static int |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3276 create_pty_only(term_T *term, jobopt_T *opt) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3277 { |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3278 int ret; |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3279 |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3280 create_vterm(term, term->tl_rows, term->tl_cols); |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3281 |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3282 term->tl_job = job_alloc(); |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3283 if (term->tl_job == NULL) |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3284 return FAIL; |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3285 ++term->tl_job->jv_refcount; |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3286 |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3287 /* behave like the job is already finished */ |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3288 term->tl_job->jv_status = JOB_FINISHED; |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3289 |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3290 ret = mch_create_pty_channel(term->tl_job, opt); |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3291 |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3292 return ret; |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3293 } |
24abce52ad20
patch 8.0.1000: cannot open a terminal without running a job in it
Christian Brabandt <cb@256bit.org>
parents:
12228
diff
changeset
|
3294 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3295 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3296 * Free the terminal emulator part of "term". |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3297 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3298 static void |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
3299 term_free_vterm(term_T *term) |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3300 { |
11751
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
3301 if (term->tl_vterm != NULL) |
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
3302 vterm_free(term->tl_vterm); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
3303 term->tl_vterm = NULL; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3304 } |
11753
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3305 |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3306 /* |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3307 * Request size to terminal. |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3308 */ |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3309 static void |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3310 term_report_winsize(term_T *term, int rows, int cols) |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3311 { |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3312 /* Use an ioctl() to report the new window size to the job. */ |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3313 if (term->tl_job != NULL && term->tl_job->jv_channel != NULL) |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3314 { |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3315 int fd = -1; |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3316 int part; |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3317 |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3318 for (part = PART_OUT; part < PART_COUNT; ++part) |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3319 { |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3320 fd = term->tl_job->jv_channel->ch_part[part].ch_fd; |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3321 if (isatty(fd)) |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3322 break; |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3323 } |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3324 if (part < PART_COUNT && mch_report_winsize(fd, rows, cols) == OK) |
12037
85f0f557661e
patch 8.0.0899: function name mch_stop_job() is confusing
Christian Brabandt <cb@256bit.org>
parents:
12035
diff
changeset
|
3325 mch_signal_job(term->tl_job, (char_u *)"winch"); |
11753
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3326 } |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3327 } |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
3328 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
3329 # endif |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
3330 |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3331 #endif /* FEAT_TERMINAL */ |