Mercurial > vim
annotate src/terminal.c @ 11958:052270a67371
patch 8.0.0859: NULL pointer access when term_free_vterm called twice
commit https://github.com/vim/vim/commit/8e5eece8c5f22a2235edeb743d06253f6c54cfdc
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 4 20:29:53 2017 +0200
patch 8.0.0859: NULL pointer access when term_free_vterm called twice
Problem: NULL pointer access when term_free_vterm called twice.
Solution: Return when tl_vterm is NULL. (Yasuhiro Matsumoto, closes https://github.com/vim/vim/issues/1934)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 04 Aug 2017 20:30:04 +0200 |
parents | bc0fee081e1e |
children | a932d3da41c8 |
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. |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
37 * |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 * TODO: |
11931
689bcb8f241c
patch 8.0.0845: MS-Windows: missing semicolon in terminal code
Christian Brabandt <cb@256bit.org>
parents:
11927
diff
changeset
|
39 * - MS-Windows: no redraw for 'updatetime' #1915 |
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
|
40 * - in bash mouse clicks are inserting characters. |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
41 * - mouse scroll: when over other window, scroll that window. |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
42 * - add argument to term_wait() for waiting time. |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
43 * - For the scrollback buffer store lines in the buffer, only attributes in |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
44 * tl_scrollback. |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
45 * - When the job ends: |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
46 * - Need an option or argument to drop the window+buffer right away, to be |
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
|
47 * used for a shell or Vim. 'termfinish'; "close", "open" (open window when |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
48 * job finishes). |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
49 * - add option values to the command: |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
50 * :term <24x80> <close> vim notes.txt |
11880
45558e0507e8
patch 8.0.0820: GUI: cursor in terminal window lags behind
Christian Brabandt <cb@256bit.org>
parents:
11878
diff
changeset
|
51 * - support different cursor shapes, colors and attributes |
45558e0507e8
patch 8.0.0820: GUI: cursor in terminal window lags behind
Christian Brabandt <cb@256bit.org>
parents:
11878
diff
changeset
|
52 * - make term_getcursor() return type (none/block/bar/underline) and |
45558e0507e8
patch 8.0.0820: GUI: cursor in terminal window lags behind
Christian Brabandt <cb@256bit.org>
parents:
11878
diff
changeset
|
53 * attributes (color, blink, etc.) |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
54 * - To set BS correctly, check get_stty(); Pass the fd of the pty. |
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
|
55 * - do not store terminal window in viminfo. Or prefix term:// ? |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
56 * - add a character in :ls output |
11870
c29e498aa77d
patch 8.0.0815: terminal window not correctly updated
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
57 * - add 't' to mode() |
11931
689bcb8f241c
patch 8.0.0845: MS-Windows: missing semicolon in terminal code
Christian Brabandt <cb@256bit.org>
parents:
11927
diff
changeset
|
58 * - set 'filetype' to "terminal"? |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
59 * - use win_del_lines() to make scroll-up efficient. |
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
|
60 * - Make StatusLineTerm adjust UserN highlighting like StatusLineNC does, see |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
61 * use of hightlight_stlnc[]. |
11917
00836eb177cb
patch 8.0.0838: buffer hangs around whem terminal window is closed
Christian Brabandt <cb@256bit.org>
parents:
11912
diff
changeset
|
62 * - 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
|
63 * - 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
|
64 * - 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
|
65 * - support minimal size when 'termsize' is empty? |
11723
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
66 * - implement "term" for job_start(): more job options when starting a |
1922710ee8fa
patch 8.0.0744: terminal window does not use a pty
Christian Brabandt <cb@256bit.org>
parents:
11719
diff
changeset
|
67 * terminal. |
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
|
68 * - support ":term NONE" to open a terminal with a pty but not running a job |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
69 * in it. The pty can be passed to gdb to run the executable in. |
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
|
70 * - 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
|
71 * 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
|
72 * - 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
|
73 * conversions. |
11886
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
74 * - update ":help function-list" for terminal functions. |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
75 * - 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
|
76 * - 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
|
77 * completion works. |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 #include "vim.h" |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
82 #if defined(FEAT_TERMINAL) || defined(PROTO) |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
84 #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
|
85 # define MIN(x,y) (x < y ? x : y) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
86 # 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
|
87 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
89 #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
|
90 |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
91 typedef struct sb_line_S { |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
92 int sb_cols; /* can differ per line */ |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
93 VTermScreenCell *sb_cells; /* allocated */ |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
94 } 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
|
95 |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 /* typedef term_T in structs.h */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 struct terminal_S { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 term_T *tl_next; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 |
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
|
100 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
|
101 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
|
102 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
|
103 |
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
|
104 /* 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
|
105 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
|
106 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
|
107 |
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
|
108 int tl_terminal_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
|
109 int 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
|
110 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
111 #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
|
112 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
|
113 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
|
114 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
115 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
116 /* 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
|
117 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
|
118 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
|
119 /* 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
|
120 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
|
121 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
|
122 |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
123 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
|
124 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
|
125 |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
126 /* 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
|
127 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
|
128 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
|
129 |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
130 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
|
131 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
|
132 |
11874
d444e087b8fd
patch 8.0.0817: cannot get the terminal line at the cursor
Christian Brabandt <cb@256bit.org>
parents:
11872
diff
changeset
|
133 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
|
134 int tl_cursor_visible; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
135 }; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
136 |
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 * List of all active terminals. |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
139 */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
140 static term_T *first_term = NULL; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
141 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
142 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
143 #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
|
144 #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
|
145 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
146 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
147 * 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
|
148 */ |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
149 static int term_and_job_init(term_T *term, int rows, int cols, char_u *cmd, 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
|
150 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
|
151 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
|
152 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
153 /************************************** |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
154 * 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
|
155 */ |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
156 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
157 /* |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
158 * 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
|
159 * 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
|
160 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
161 static void |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
162 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
|
163 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
164 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
|
165 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
166 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
|
167 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
168 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
|
169 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
|
170 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
171 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
|
172 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
|
173 else |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
174 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
175 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
|
176 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
|
177 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
178 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
|
179 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
|
180 else |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
181 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
182 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
|
183 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
|
184 } |
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 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
187 /* |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
188 * 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
|
189 * Caller may overrule some of them. |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
190 */ |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
191 static void |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
192 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
|
193 { |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
194 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
|
195 |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
196 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
|
197 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
|
198 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
|
199 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
|
200 |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
201 opt->jo_io[PART_OUT] = JIO_BUFFER; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
202 opt->jo_io[PART_ERR] = JIO_BUFFER; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
203 opt->jo_set |= JO_OUT_IO + JO_ERR_IO; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
204 |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
205 opt->jo_modifiable[PART_OUT] = 0; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
206 opt->jo_modifiable[PART_ERR] = 0; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
207 opt->jo_set |= JO_OUT_MODIFIABLE + JO_ERR_MODIFIABLE; |
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 opt->jo_set |= JO_OUT_BUF + JO_ERR_BUF; |
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 |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
212 /* |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
213 * 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
|
214 */ |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
215 static void |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
216 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
|
217 { |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
218 opt->jo_io_buf[PART_OUT] = curbuf->b_fnum; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
219 opt->jo_io_buf[PART_ERR] = curbuf->b_fnum; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
220 opt->jo_pty = TRUE; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
221 opt->jo_term_rows = rows; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
222 opt->jo_term_cols = cols; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
223 } |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
224 |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
225 static void |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
226 term_start(char_u *cmd, jobopt_T *opt) |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
227 { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
228 exarg_T split_ea; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
229 win_T *old_curwin = curwin; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
230 term_T *term; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
231 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
232 if (check_restricted() || check_secure()) |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
233 return; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
234 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
235 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
|
236 if (term == NULL) |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
237 return; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
238 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
|
239 term->tl_cursor_visible = TRUE; |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
240 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
|
241 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
242 /* Open a new window or tab. */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
243 vim_memset(&split_ea, 0, sizeof(split_ea)); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
244 split_ea.cmdidx = CMD_new; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
245 split_ea.cmd = (char_u *)"new"; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
246 split_ea.arg = (char_u *)""; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
247 ex_splitview(&split_ea); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
248 if (curwin == old_curwin) |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
249 { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
250 /* split failed */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
251 vim_free(term); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
252 return; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
253 } |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
254 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
|
255 curbuf->b_term = term; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
256 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
257 /* 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
|
258 term->tl_next = first_term; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
259 first_term = term; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
260 |
11794
2e7e77e28063
patch 8.0.0779: :term without an argument uses empty buffer name
Christian Brabandt <cb@256bit.org>
parents:
11792
diff
changeset
|
261 if (cmd == NULL || *cmd == NUL) |
2e7e77e28063
patch 8.0.0779: :term without an argument uses empty buffer name
Christian Brabandt <cb@256bit.org>
parents:
11792
diff
changeset
|
262 cmd = p_sh; |
2e7e77e28063
patch 8.0.0779: :term without an argument uses empty buffer name
Christian Brabandt <cb@256bit.org>
parents:
11792
diff
changeset
|
263 |
11757
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
264 { |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
265 int i; |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
266 size_t len = STRLEN(cmd) + 10; |
11790
4dfebc1b2674
patch 8.0.0777: compiler warnings with 64 bit compiler
Christian Brabandt <cb@256bit.org>
parents:
11786
diff
changeset
|
267 char_u *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
|
268 |
11912
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
269 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
|
270 { |
11912
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
271 /* 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
|
272 * 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
|
273 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
|
274 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
|
275 else |
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
276 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
|
277 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
|
278 { |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
279 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
|
280 break; |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
281 } |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
282 } |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
283 } |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
284 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
|
285 |
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
|
286 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
|
287 (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
|
288 |
11912
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
289 /* 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
|
290 * 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
|
291 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
|
292 |
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11953
diff
changeset
|
293 /* Set 'bufhidden' to "hide": allow closing the window. */ |
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11953
diff
changeset
|
294 set_string_option_direct((char_u *)"bufhidden", -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
|
295 (char_u *)"hide", OPT_FREE|OPT_LOCAL, 0); |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
296 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
297 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
|
298 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
|
299 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
300 /* System dependent: setup the vterm and start the job in it. */ |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
301 if (term_and_job_init(term, term->tl_rows, term->tl_cols, cmd, opt) == OK) |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
302 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
303 /* store the size we ended up with */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
304 vterm_get_size(term->tl_vterm, &term->tl_rows, &term->tl_cols); |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
305 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
306 else |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
307 { |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
308 free_terminal(curbuf); |
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
|
309 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
310 /* 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
|
311 * free_terminal(). */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
312 do_buffer(DOBUF_WIPE, DOBUF_CURRENT, FORWARD, 0, TRUE); |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
313 } |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
314 } |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
315 |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
316 /* |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
317 * ":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
|
318 */ |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
319 void |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
320 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
|
321 { |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
322 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
|
323 |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
324 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
|
325 /* TODO: get options from before the command */ |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
326 |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
327 term_start(eap->arg, &opt); |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
328 } |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
329 |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
330 /* |
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
|
331 * 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
|
332 */ |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
333 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
|
334 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
|
335 { |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
336 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
|
337 |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
338 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
|
339 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
|
340 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
|
341 } |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
342 |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
343 /* |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
344 * 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
|
345 * 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
|
346 * 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
|
347 */ |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
348 void |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
349 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
|
350 { |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
351 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
|
352 term_T *tp; |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
353 |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
354 if (term == NULL) |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
355 return; |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
356 if (first_term == term) |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
357 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
|
358 else |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
359 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
|
360 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
|
361 { |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
362 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
|
363 break; |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
364 } |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
365 |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
366 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
|
367 { |
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
|
368 if (term->tl_job->jv_status != JOB_ENDED |
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11725
diff
changeset
|
369 && 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
|
370 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
|
371 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
|
372 } |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
373 |
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
|
374 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
|
375 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
376 term_free_vterm(term); |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
377 vim_free(term->tl_title); |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
378 vim_free(term->tl_status_text); |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
379 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
|
380 buf->b_term = NULL; |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
381 } |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
382 |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
383 /* |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
384 * 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
|
385 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
386 static void |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
387 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
|
388 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
389 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
|
390 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
|
391 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
|
392 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
|
393 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
394 for (done = 0; done < len; done += len_now) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
395 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
396 for (p = msg + done; p < msg + len; ) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
397 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
398 if (*p == NL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
399 break; |
11790
4dfebc1b2674
patch 8.0.0777: compiler warnings with 64 bit compiler
Christian Brabandt <cb@256bit.org>
parents:
11786
diff
changeset
|
400 p += utf_ptr2len_len(p, (int)(len - (p - msg))); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
401 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
402 len_now = p - msg - done; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
403 vterm_input_write(vterm, (char *)msg + done, len_now); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
404 if (p < msg + len && *p == NL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
405 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
406 /* Convert NL to CR-NL, that appears to work best. */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
407 vterm_input_write(vterm, "\r\n", 2); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
408 ++len_now; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
409 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
410 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
411 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
412 /* 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
|
413 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
|
414 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
415 |
11778
e8005055f845
patch 8.0.0771: cursor in terminal window not always updated in GUI
Christian Brabandt <cb@256bit.org>
parents:
11774
diff
changeset
|
416 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
|
417 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
|
418 { |
11888
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
419 if (term->tl_terminal_mode) |
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
420 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
|
421 setcursor(); |
11792
4bc1f94afc34
patch 8.0.0778: in a terminal the cursor may be hidden
Christian Brabandt <cb@256bit.org>
parents:
11790
diff
changeset
|
422 if (redraw && term->tl_buffer == curbuf) |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
423 { |
11792
4bc1f94afc34
patch 8.0.0778: in a terminal the cursor may be hidden
Christian Brabandt <cb@256bit.org>
parents:
11790
diff
changeset
|
424 if (term->tl_cursor_visible) |
4bc1f94afc34
patch 8.0.0778: in a terminal the cursor may be hidden
Christian Brabandt <cb@256bit.org>
parents:
11790
diff
changeset
|
425 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
|
426 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
|
427 #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
|
428 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
|
429 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
|
430 #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
|
431 } |
11778
e8005055f845
patch 8.0.0771: cursor in terminal window not always updated in GUI
Christian Brabandt <cb@256bit.org>
parents:
11774
diff
changeset
|
432 } |
e8005055f845
patch 8.0.0771: cursor in terminal window not always updated in GUI
Christian Brabandt <cb@256bit.org>
parents:
11774
diff
changeset
|
433 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
434 /* |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
435 * 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
|
436 * of "buffer". |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
437 */ |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
438 void |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
439 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
|
440 { |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
441 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
|
442 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
|
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 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
|
445 { |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
446 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
|
447 return; |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
448 } |
11937
c893d6c00497
patch 8.0.0848: using multiple ch_log functions is clumsy
Christian Brabandt <cb@256bit.org>
parents:
11933
diff
changeset
|
449 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
|
450 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
|
451 |
11888
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
452 if (!term->tl_terminal_mode) |
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
453 { |
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
454 /* TODO: only update once in a while. */ |
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
455 update_screen(0); |
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
456 update_cursor(term, TRUE); |
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
457 } |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
458 } |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
459 |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
460 /* |
11854
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
461 * 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
|
462 */ |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
463 static int |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
464 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
|
465 { |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
466 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
|
467 |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
468 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
|
469 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
|
470 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
|
471 return TRUE; |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
472 } |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
473 |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
474 /* |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
475 * 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
|
476 * 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
|
477 */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
478 static int |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
479 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
|
480 { |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
481 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
|
482 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
|
483 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
|
484 int mouse = FALSE; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
485 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
486 switch (c) |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
487 { |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
488 case CAR: key = VTERM_KEY_ENTER; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
489 case ESC: key = VTERM_KEY_ESCAPE; break; |
11715
d7430b56c9ed
patch 8.0.0740: cannot resize a terminal window by the command
Christian Brabandt <cb@256bit.org>
parents:
11713
diff
changeset
|
490 /* VTERM_KEY_BACKSPACE becomes 0x7f DEL */ |
d7430b56c9ed
patch 8.0.0740: cannot resize a terminal window by the command
Christian Brabandt <cb@256bit.org>
parents:
11713
diff
changeset
|
491 case K_BS: c = BS; break; |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
492 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
|
493 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
|
494 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
|
495 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
|
496 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
|
497 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
|
498 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
|
499 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
|
500 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
|
501 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
|
502 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
|
503 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
|
504 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
|
505 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
|
506 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
|
507 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
|
508 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
|
509 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
|
510 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
|
511 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
|
512 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
|
513 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
|
514 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
|
515 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
|
516 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
|
517 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
|
518 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
|
519 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
|
520 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
|
521 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
|
522 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
|
523 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
|
524 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
|
525 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
|
526 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
|
527 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
|
528 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
|
529 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
|
530 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
|
531 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
|
532 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
|
533 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
|
534 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
|
535 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
|
536 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
|
537 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
|
538 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
|
539 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
|
540 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
|
541 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
|
542 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
|
543 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
|
544 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
|
545 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
|
546 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
|
547 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
|
548 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
|
549 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
|
550 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
|
551 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
|
552 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
|
553 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
|
554 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
|
555 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
|
556 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
|
557 |
11854
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
558 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
|
559 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
|
560 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
|
561 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
|
562 |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
563 case K_LEFTMOUSE: |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
564 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
|
565 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
|
566 case K_LEFTRELEASE: |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
567 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
|
568 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
|
569 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
|
570 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
|
571 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
|
572 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
|
573 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
|
574 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
|
575 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
|
576 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
|
577 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
|
578 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
|
579 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
|
580 |
11854
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
581 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
|
582 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
|
583 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
|
584 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
|
585 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
|
586 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
|
587 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
|
588 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
|
589 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
|
590 #ifdef FEAT_GUI |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
591 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
|
592 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
|
593 #endif |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
594 #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
|
595 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
|
596 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
|
597 #endif |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
598 #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
|
599 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
|
600 #endif |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
601 #ifdef FEAT_DND |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
602 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
|
603 #endif |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
604 #ifdef FEAT_AUTOCMD |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
605 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
|
606 #endif |
092dd1ef0eda
patch 8.0.0807: terminal window can't handle mouse buttons
Christian Brabandt <cb@256bit.org>
parents:
11846
diff
changeset
|
607 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
|
608 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
|
609 } |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
610 |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
611 /* |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
612 * 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
|
613 * - 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
|
614 * - 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
|
615 * 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
|
616 */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
617 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
|
618 /* 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
|
619 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
|
620 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
|
621 /* 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
|
622 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
|
623 |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
624 /* 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
|
625 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
|
626 } |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
627 |
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
628 /* |
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
|
629 * 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
|
630 */ |
11917
00836eb177cb
patch 8.0.0838: buffer hangs around whem terminal window is closed
Christian Brabandt <cb@256bit.org>
parents:
11912
diff
changeset
|
631 int |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
632 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
|
633 { |
11842
6bfcedcc0262
patch 8.0.0801: terminal window title says "running" after job exits
Christian Brabandt <cb@256bit.org>
parents:
11840
diff
changeset
|
634 /* 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
|
635 * 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
|
636 return term != NULL |
8b9a1be7bb82
patch 8.0.0853: crash when running terminal with unknown command
Christian Brabandt <cb@256bit.org>
parents:
11939
diff
changeset
|
637 && term->tl_job != NULL |
11842
6bfcedcc0262
patch 8.0.0801: terminal window title says "running" after job exits
Christian Brabandt <cb@256bit.org>
parents:
11840
diff
changeset
|
638 && term->tl_job->jv_status == JOB_STARTED |
6bfcedcc0262
patch 8.0.0801: terminal window title says "running" after job exits
Christian Brabandt <cb@256bit.org>
parents:
11840
diff
changeset
|
639 && channel_is_open(term->tl_job->jv_channel); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
640 } |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
641 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
642 /* |
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
|
643 * 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
|
644 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
645 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
|
646 add_scrollback_line_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
|
647 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
648 linenr_T lnum = term->tl_scrollback.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
|
649 sb_line_T *line = (sb_line_T *)term->tl_scrollback.ga_data + lnum; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
650 garray_T ga; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
651 int c; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
652 int 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
|
653 int i; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
654 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
655 ga_init2(&ga, 1, 100); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
656 for (col = 0; col < line->sb_cols; col += line->sb_cells[col].width) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
657 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
658 if (ga_grow(&ga, MB_MAXBYTES) == FAIL) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
659 goto failed; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
660 for (i = 0; (c = line->sb_cells[col].chars[i]) > 0 || i == 0; ++i) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
661 ga.ga_len += mb_char2bytes(c == NUL ? ' ' : c, |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
662 (char_u *)ga.ga_data + ga.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
|
663 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
664 if (ga_grow(&ga, 1) == FAIL) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
665 goto failed; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
666 *((char_u *)ga.ga_data + ga.ga_len) = 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
|
667 ml_append_buf(term->tl_buffer, lnum, ga.ga_data, ga.ga_len + 1, 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
|
668 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
669 if (lnum == 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
|
670 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
671 /* Delete the empty line that was in the empty 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
|
672 curbuf = 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
|
673 ml_delete(2, 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
|
674 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
|
675 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
676 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
677 failed: |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
678 ga_clear(&ga); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
679 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
680 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
681 /* |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
682 * Add the current lines of the terminal to scrollback and 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
|
683 * Called after the job has ended and when switching to Terminal 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
|
684 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
685 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
|
686 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
|
687 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
688 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
|
689 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
|
690 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
|
691 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
|
692 VTermScreenCell cell; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
693 VTermScreenCell *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
|
694 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
|
695 |
11958
052270a67371
patch 8.0.0859: NULL pointer access when term_free_vterm called twice
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
696 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
|
697 return; |
052270a67371
patch 8.0.0859: NULL pointer access when term_free_vterm called twice
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
698 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
|
699 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
|
700 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
701 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
|
702 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
|
703 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
|
704 && 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
|
705 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
|
706 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
707 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
|
708 ++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
|
709 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
|
710 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
711 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
|
712 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
713 /* 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
|
714 --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
|
715 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
|
716 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
717 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
|
718 + 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
|
719 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
720 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
|
721 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
|
722 ++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
|
723 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
724 add_scrollback_line_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
|
725 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
726 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
727 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
728 p = (VTermScreenCell *)alloc((int)sizeof(VTermScreenCell) * 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
|
729 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
|
730 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
731 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
|
732 + 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
|
733 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
734 for (pos.col = 0; pos.col < len; ++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
|
735 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
736 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
|
737 vim_memset(p + pos.col, 0, sizeof(cell)); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
738 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
|
739 p[pos.col] = cell; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
740 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
741 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
|
742 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
|
743 ++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
|
744 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
745 add_scrollback_line_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
|
746 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
747 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
|
748 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
|
749 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
750 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
751 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
752 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
|
753 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
754 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
|
755 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
756 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
|
757 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
|
758 wp->w_valid = 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
|
759 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
|
760 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
761 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
762 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
763 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
764 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
|
765 set_terminal_mode(term_T *term, int on) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
766 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
767 term->tl_terminal_mode = on; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
768 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
|
769 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
|
770 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
|
771 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
|
772 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
773 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
774 /* |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
775 * 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
|
776 * 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
|
777 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
778 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
|
779 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
|
780 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
781 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
|
782 term_free_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
|
783 set_terminal_mode(term, 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
|
784 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
785 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
786 /* |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
787 * Switch from sending keys to the job to 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
|
788 * 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
|
789 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
790 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
|
791 term_enter_terminal_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
|
792 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
793 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
|
794 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
795 /* 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
|
796 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
|
797 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
798 set_terminal_mode(term, TRUE); |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
799 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
800 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
801 /* |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
802 * 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
|
803 * 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
|
804 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
805 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
|
806 term_in_terminal_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
|
807 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
808 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
|
809 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
810 return term != NULL && term->tl_terminal_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
|
811 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
812 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
813 /* |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
814 * Switch from Terminal-Normal mode to sending 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
|
815 * 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
|
816 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
817 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
|
818 term_leave_terminal_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
|
819 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
820 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
|
821 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
|
822 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
|
823 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
824 /* 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
|
825 gap = &term->tl_scrollback; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
826 while (curbuf->b_ml.ml_line_count > term->tl_scrollback_scrolled) |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
827 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
828 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
|
829 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
|
830 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
|
831 --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
|
832 if (gap->ga_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
|
833 break; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
834 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
835 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
|
836 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
837 set_terminal_mode(term, 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
|
838 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
839 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
|
840 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
|
841 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
|
842 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
843 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
844 /* |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
845 * Get a key from the user without mapping. |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
846 * 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
|
847 */ |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
848 static int |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
849 term_vgetc() |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
850 { |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
851 int c; |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
852 |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
853 ++no_mapping; |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
854 ++allow_keys; |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
855 got_int = FALSE; |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
856 c = vgetc(); |
11870
c29e498aa77d
patch 8.0.0815: terminal window not correctly updated
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
857 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
|
858 --no_mapping; |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
859 --allow_keys; |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
860 return c; |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
861 } |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
862 |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
863 /* |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
864 * Send keys to terminal. |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
865 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
866 static int |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
867 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
|
868 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
869 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
|
870 size_t len; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
871 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
|
872 int dragging_outside = FALSE; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
873 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
874 /* 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
|
875 switch (c) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
876 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
877 case NUL: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
878 case K_ZERO: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
879 if (typed) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
880 stuffcharReadbuff(c); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
881 return FAIL; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
882 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
883 case K_IGNORE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
884 return FAIL; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
885 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
886 case K_LEFTDRAG: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
887 case K_MIDDLEDRAG: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
888 case K_RIGHTDRAG: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
889 case K_X1DRAG: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
890 case K_X2DRAG: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
891 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
|
892 /* FALLTHROUGH */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
893 case K_LEFTMOUSE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
894 case K_LEFTMOUSE_NM: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
895 case K_LEFTRELEASE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
896 case K_LEFTRELEASE_NM: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
897 case K_MIDDLEMOUSE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
898 case K_MIDDLERELEASE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
899 case K_RIGHTMOUSE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
900 case K_RIGHTRELEASE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
901 case K_X1MOUSE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
902 case K_X1RELEASE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
903 case K_X2MOUSE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
904 case K_X2RELEASE: |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
905 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
|
906 || 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
|
907 || 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
|
908 || 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
|
909 || dragging_outside) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
910 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
911 /* click outside the current window */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
912 if (typed) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
913 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
914 stuffcharReadbuff(c); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
915 mouse_was_outside = TRUE; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
916 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
917 return FAIL; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
918 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
919 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
920 if (typed) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
921 mouse_was_outside = FALSE; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
922 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
923 /* 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
|
924 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
|
925 if (len > 0) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
926 /* TODO: if FAIL is returned, stop? */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
927 channel_send(term->tl_job->jv_channel, PART_IN, |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
928 (char_u *)msg, (int)len, NULL); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
929 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
930 return OK; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
931 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
932 |
11878
a83b19a8d7e4
patch 8.0.0819: cursor not positioned in terminal window
Christian Brabandt <cb@256bit.org>
parents:
11876
diff
changeset
|
933 static void |
a83b19a8d7e4
patch 8.0.0819: cursor not positioned in terminal window
Christian Brabandt <cb@256bit.org>
parents:
11876
diff
changeset
|
934 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
|
935 { |
a83b19a8d7e4
patch 8.0.0819: cursor not positioned in terminal window
Christian Brabandt <cb@256bit.org>
parents:
11876
diff
changeset
|
936 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
|
937 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
|
938 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
|
939 } |
a83b19a8d7e4
patch 8.0.0819: cursor not positioned in terminal window
Christian Brabandt <cb@256bit.org>
parents:
11876
diff
changeset
|
940 |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
941 /* |
11886
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
942 * 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
|
943 */ |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
944 static void |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
945 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
|
946 { |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
947 int c; |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
948 list_T *l; |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
949 listitem_T *item; |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
950 long reglen = 0; |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
951 int type; |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
952 |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
953 #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
|
954 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
|
955 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
|
956 out_flush(); |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
957 #endif |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
958 c = term_vgetc(); |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
959 #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
|
960 clear_showcmd(); |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
961 #endif |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
962 |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
963 /* 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
|
964 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
|
965 return; |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
966 |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
967 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
|
968 if (l != NULL) |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
969 { |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
970 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
|
971 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
|
972 { |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
973 char_u *s = get_tv_string(&item->li_tv); |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
974 |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
975 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
|
976 s, STRLEN(s), NULL); |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
977 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
|
978 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
|
979 (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
|
980 } |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
981 list_free(l); |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
982 } |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
983 } |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
984 |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
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 * 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
|
987 * 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
|
988 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
989 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
|
990 term_use_loop() |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
991 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
992 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
|
993 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
994 return term != 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
|
995 && !term->tl_terminal_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
|
996 && 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
|
997 && 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
|
998 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
999 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1000 /* |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1001 * 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
|
1002 * 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
|
1003 * 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
|
1004 * 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
|
1005 * 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
|
1006 */ |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1007 int |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1008 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
|
1009 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1010 int c; |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1011 int termkey = 0; |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1012 |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1013 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
|
1014 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
|
1015 position_cursor(curwin, &curbuf->b_term->tl_cursor_pos); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1016 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1017 for (;;) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1018 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1019 /* 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
|
1020 /* 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
|
1021 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
|
1022 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
|
1023 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
|
1024 |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1025 c = term_vgetc(); |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
1026 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
|
1027 /* 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
|
1028 break; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1029 |
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
|
1030 #ifdef UNIX |
cca097489de5
patch 8.0.0839: cannot kill a job in a terminal with CTRL-C
Christian Brabandt <cb@256bit.org>
parents:
11917
diff
changeset
|
1031 may_send_sigint(c, curbuf->b_term->tl_job->jv_pid, 0); |
cca097489de5
patch 8.0.0839: cannot kill a job in a terminal with CTRL-C
Christian Brabandt <cb@256bit.org>
parents:
11917
diff
changeset
|
1032 #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
|
1033 #ifdef WIN3264 |
cca097489de5
patch 8.0.0839: cannot kill a job in a terminal with CTRL-C
Christian Brabandt <cb@256bit.org>
parents:
11917
diff
changeset
|
1034 if (c == Ctrl_C) |
cca097489de5
patch 8.0.0839: cannot kill a job in a terminal with CTRL-C
Christian Brabandt <cb@256bit.org>
parents:
11917
diff
changeset
|
1035 /* We don't know if the job can handle CTRL-C itself or not, this |
cca097489de5
patch 8.0.0839: cannot kill a job in a terminal with CTRL-C
Christian Brabandt <cb@256bit.org>
parents:
11917
diff
changeset
|
1036 * may kill the shell instead of killing the command running in the |
cca097489de5
patch 8.0.0839: cannot kill a job in a terminal with CTRL-C
Christian Brabandt <cb@256bit.org>
parents:
11917
diff
changeset
|
1037 * shell. */ |
11931
689bcb8f241c
patch 8.0.0845: MS-Windows: missing semicolon in terminal code
Christian Brabandt <cb@256bit.org>
parents:
11927
diff
changeset
|
1038 mch_stop_job(curbuf->b_term->tl_job, (char_u *)"quit"); |
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
|
1039 #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
|
1040 |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1041 if (c == (termkey == 0 ? Ctrl_W : termkey)) |
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1042 { |
11886
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1043 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
|
1044 |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1045 #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
|
1046 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
|
1047 out_flush(); |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1048 #endif |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1049 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
|
1050 #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
|
1051 clear_showcmd(); |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1052 #endif |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
1053 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
|
1054 /* 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
|
1055 break; |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1056 |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1057 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
|
1058 { |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1059 /* "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
|
1060 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
|
1061 } |
11886
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1062 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
|
1063 { |
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 term_enter_terminal_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
|
1065 return FAIL; |
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 } |
11886
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1067 else if (c == '"') |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1068 { |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1069 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
|
1070 continue; |
7928d62d29ee
patch 8.0.0823: cannot paste text into a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11882
diff
changeset
|
1071 } |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1072 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
|
1073 { |
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1074 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
|
1075 stuffcharReadbuff(c); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1076 return OK; |
11814
d3d0db111d17
patch 8.0.0787: cannot send CTRL-W command to terminal job
Christian Brabandt <cb@256bit.org>
parents:
11804
diff
changeset
|
1077 } |
11764
b82dad3fa176
patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
1078 } |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1079 if (send_keys_to_term(curbuf->b_term, c, TRUE) != OK) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1080 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
|
1081 } |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1082 return FAIL; |
11757
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
1083 } |
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11755
diff
changeset
|
1084 |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1085 /* |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1086 * Called when a job has finished. |
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
|
1087 * This updates the title and status, but does not close the vter, because |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1088 * 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
|
1089 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1090 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1091 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
|
1092 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1093 term_T *term; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1094 int did_one = FALSE; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1095 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1096 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
|
1097 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
|
1098 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1099 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
|
1100 term->tl_title = NULL; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1101 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
|
1102 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
|
1103 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
|
1104 did_one = TRUE; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1105 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1106 if (did_one) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1107 redraw_statuslines(); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1108 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
|
1109 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1110 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
|
1111 maketitle(); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1112 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
|
1113 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1114 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1115 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1116 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
|
1117 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
|
1118 { |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1119 if (curbuf == term->tl_buffer) |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1120 { |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1121 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
|
1122 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
|
1123 else |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1124 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
|
1125 } |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1126 } |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1127 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1128 static int |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1129 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
|
1130 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1131 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
|
1132 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1133 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
|
1134 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
|
1135 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
|
1136 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1137 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1138 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1139 static int |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1140 handle_moverect(VTermRect dest UNUSED, VTermRect src UNUSED, void *user) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1141 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1142 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
|
1143 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1144 /* TODO */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1145 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
|
1146 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1147 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1148 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1149 static int |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1150 handle_movecursor( |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1151 VTermPos pos, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1152 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
|
1153 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
|
1154 void *user) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1155 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1156 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
|
1157 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
|
1158 |
d444e087b8fd
patch 8.0.0817: cannot get the terminal line at the cursor
Christian Brabandt <cb@256bit.org>
parents:
11872
diff
changeset
|
1159 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
|
1160 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
|
1161 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1162 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
|
1163 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1164 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
|
1165 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
|
1166 } |
11888
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
1167 if (term->tl_buffer == curbuf && !term->tl_terminal_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
|
1168 { |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1169 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
|
1170 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
|
1171 } |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1172 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1173 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1174 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1175 |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1176 static int |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1177 handle_settermprop( |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1178 VTermProp prop, |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1179 VTermValue *value, |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1180 void *user) |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1181 { |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1182 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
|
1183 |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1184 switch (prop) |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1185 { |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1186 case VTERM_PROP_TITLE: |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1187 vim_free(term->tl_title); |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1188 term->tl_title = vim_strsave((char_u *)value->string); |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1189 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
|
1190 term->tl_status_text = NULL; |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1191 if (term == curbuf->b_term) |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1192 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
|
1193 break; |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1194 |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1195 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
|
1196 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
|
1197 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
|
1198 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
|
1199 break; |
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1200 |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1201 default: |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1202 break; |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1203 } |
11786
98154b91e43a
patch 8.0.0775: in a terminal the cursor is updated too often
Christian Brabandt <cb@256bit.org>
parents:
11778
diff
changeset
|
1204 /* 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
|
1205 return 1; |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1206 } |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1207 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1208 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1209 * 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
|
1210 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1211 static int |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1212 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
|
1213 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1214 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
|
1215 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
|
1216 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1217 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
|
1218 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
|
1219 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
|
1220 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1221 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
|
1222 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1223 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
|
1224 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
|
1225 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1226 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1227 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1228 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
|
1229 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1230 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1231 |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1232 /* |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1233 * 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
|
1234 */ |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1235 static int |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1236 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
|
1237 { |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1238 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
|
1239 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1240 /* 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
|
1241 /* TODO: put the text in the buffer. */ |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1242 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
|
1243 { |
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
|
1244 VTermScreenCell *p = NULL; |
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
|
1245 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
|
1246 int i; |
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
|
1247 sb_line_T *line; |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1248 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1249 /* 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
|
1250 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
|
1251 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
|
1252 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
|
1253 |
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
|
1254 if (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
|
1255 p = (VTermScreenCell *)alloc((int)sizeof(VTermScreenCell) * len); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1256 if (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
|
1257 mch_memmove(p, cells, sizeof(VTermScreenCell) * len); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1258 |
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
|
1259 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
|
1260 + 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
|
1261 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
|
1262 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
|
1263 ++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
|
1264 ++term->tl_scrollback_scrolled; |
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
|
1265 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1266 add_scrollback_line_to_buffer(term); |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1267 } |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1268 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
|
1269 } |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1270 |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1271 static VTermScreenCallbacks screen_callbacks = { |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1272 handle_damage, /* damage */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1273 handle_moverect, /* moverect */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1274 handle_movecursor, /* movecursor */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1275 handle_settermprop, /* settermprop */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1276 NULL, /* bell */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1277 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
|
1278 handle_pushline, /* sb_pushline */ |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1279 NULL /* sb_popline */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1280 }; |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1281 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1282 /* |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1283 * 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
|
1284 * 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
|
1285 */ |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1286 void |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1287 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
|
1288 { |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1289 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
|
1290 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
|
1291 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1292 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
|
1293 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
|
1294 { |
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
|
1295 term->tl_channel_closed = TRUE; |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1296 |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1297 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
|
1298 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
|
1299 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
|
1300 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
|
1301 |
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
|
1302 /* Unless in Terminal-Normal mode: clear 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
|
1303 if (!term->tl_terminal_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
|
1304 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
|
1305 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1306 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
|
1307 did_one = TRUE; |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1308 } |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1309 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
|
1310 { |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1311 redraw_statuslines(); |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1312 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1313 /* 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
|
1314 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
|
1315 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
|
1316 |
11880
45558e0507e8
patch 8.0.0820: GUI: cursor in terminal window lags behind
Christian Brabandt <cb@256bit.org>
parents:
11878
diff
changeset
|
1317 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
|
1318 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
|
1319 { |
11880
45558e0507e8
patch 8.0.0820: GUI: cursor in terminal window lags behind
Christian Brabandt <cb@256bit.org>
parents:
11878
diff
changeset
|
1320 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
|
1321 maketitle(); |
11880
45558e0507e8
patch 8.0.0820: GUI: cursor in terminal window lags behind
Christian Brabandt <cb@256bit.org>
parents:
11878
diff
changeset
|
1322 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
|
1323 } |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1324 } |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1325 } |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1326 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1327 /* |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1328 * Reverse engineer the RGB value into a cterm color index. |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1329 * First color is 1. Return 0 if no match found. |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1330 */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1331 static int |
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
|
1332 color2index(VTermColor *color, int fg, int *boldp) |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1333 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1334 int red = color->red; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1335 int blue = color->blue; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1336 int green = color->green; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1337 |
11822
1e237c5994fc
patch 8.0.0791: terminal colors depend on the system
Christian Brabandt <cb@256bit.org>
parents:
11818
diff
changeset
|
1338 /* The argument for lookup_color() is for the color_names[] table. */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1339 if (red == 0) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1340 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1341 if (green == 0) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1342 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1343 if (blue == 0) |
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
|
1344 return lookup_color(0, fg, boldp) + 1; /* black */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1345 if (blue == 224) |
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
|
1346 return lookup_color(1, fg, boldp) + 1; /* dark blue */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1347 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1348 else if (green == 224) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1349 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1350 if (blue == 0) |
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
|
1351 return lookup_color(2, fg, boldp) + 1; /* dark green */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1352 if (blue == 224) |
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
|
1353 return lookup_color(3, fg, boldp) + 1; /* dark cyan */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1354 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1355 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1356 else if (red == 224) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1357 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1358 if (green == 0) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1359 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1360 if (blue == 0) |
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
|
1361 return lookup_color(4, fg, boldp) + 1; /* dark red */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1362 if (blue == 224) |
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
|
1363 return lookup_color(5, fg, boldp) + 1; /* dark magenta */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1364 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1365 else if (green == 224) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1366 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1367 if (blue == 0) |
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
|
1368 return lookup_color(6, fg, boldp) + 1; /* dark yellow / brown */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1369 if (blue == 224) |
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
|
1370 return lookup_color(8, fg, boldp) + 1; /* white / light grey */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1371 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1372 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1373 else if (red == 128) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1374 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1375 if (green == 128 && blue == 128) |
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
|
1376 return lookup_color(12, fg, boldp) + 1; /* high intensity black / dark grey */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1377 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1378 else if (red == 255) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1379 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1380 if (green == 64) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1381 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1382 if (blue == 64) |
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
|
1383 return lookup_color(20, fg, boldp) + 1; /* light red */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1384 if (blue == 255) |
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
|
1385 return lookup_color(22, fg, boldp) + 1; /* light magenta */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1386 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1387 else if (green == 255) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1388 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1389 if (blue == 64) |
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
|
1390 return lookup_color(24, fg, boldp) + 1; /* yellow */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1391 if (blue == 255) |
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
|
1392 return lookup_color(26, fg, boldp) + 1; /* white */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1393 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1394 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1395 else if (red == 64) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1396 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1397 if (green == 64) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1398 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1399 if (blue == 255) |
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
|
1400 return lookup_color(14, fg, boldp) + 1; /* light blue */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1401 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1402 else if (green == 255) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1403 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1404 if (blue == 64) |
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
|
1405 return lookup_color(16, fg, boldp) + 1; /* light green */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1406 if (blue == 255) |
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
|
1407 return lookup_color(18, fg, boldp) + 1; /* light cyan */ |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1408 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1409 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1410 if (t_colors >= 256) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1411 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1412 if (red == blue && red == green) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1413 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1414 /* 24-color greyscale */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1415 static int cutoff[23] = { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1416 0x05, 0x10, 0x1B, 0x26, 0x31, 0x3C, 0x47, 0x52, |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1417 0x5D, 0x68, 0x73, 0x7F, 0x8A, 0x95, 0xA0, 0xAB, |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1418 0xB6, 0xC1, 0xCC, 0xD7, 0xE2, 0xED, 0xF9}; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1419 int i; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1420 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1421 for (i = 0; i < 23; ++i) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1422 if (red < cutoff[i]) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1423 return i + 233; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1424 return 256; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1425 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1426 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1427 /* 216-color cube */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1428 return 17 + ((red + 25) / 0x33) * 36 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1429 + ((green + 25) / 0x33) * 6 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1430 + (blue + 25) / 0x33; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1431 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1432 return 0; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1433 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1434 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1435 /* |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1436 * Convert the attributes of a vterm cell into an attribute index. |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1437 */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1438 static int |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1439 cell2attr(VTermScreenCell *cell) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1440 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1441 int attr = 0; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1442 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1443 if (cell->attrs.bold) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1444 attr |= HL_BOLD; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1445 if (cell->attrs.underline) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1446 attr |= HL_UNDERLINE; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1447 if (cell->attrs.italic) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1448 attr |= HL_ITALIC; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1449 if (cell->attrs.strike) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1450 attr |= HL_STANDOUT; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1451 if (cell->attrs.reverse) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1452 attr |= HL_INVERSE; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1453 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1454 #ifdef FEAT_GUI |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1455 if (gui.in_use) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1456 { |
11745
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
1457 guicolor_T fg, bg; |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
1458 |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
1459 fg = gui_mch_get_rgb_color(cell->fg.red, cell->fg.green, cell->fg.blue); |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
1460 bg = gui_mch_get_rgb_color(cell->bg.red, cell->bg.green, cell->bg.blue); |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11743
diff
changeset
|
1461 return get_gui_attr_idx(attr, fg, bg); |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1462 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1463 else |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1464 #endif |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1465 #ifdef FEAT_TERMGUICOLORS |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1466 if (p_tgc) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1467 { |
11755
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11753
diff
changeset
|
1468 guicolor_T fg, bg; |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11753
diff
changeset
|
1469 |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11753
diff
changeset
|
1470 fg = gui_get_rgb_color_cmn(cell->fg.red, cell->fg.green, cell->fg.blue); |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11753
diff
changeset
|
1471 bg = gui_get_rgb_color_cmn(cell->bg.red, cell->bg.green, cell->bg.blue); |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11753
diff
changeset
|
1472 |
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11753
diff
changeset
|
1473 return get_tgc_attr_idx(attr, fg, bg); |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1474 } |
11755
12fa6072977a
patch 8.0.0760: terminal window colors wrong with 'termguicolors'
Christian Brabandt <cb@256bit.org>
parents:
11753
diff
changeset
|
1475 else |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1476 #endif |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1477 { |
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
|
1478 int bold = MAYBE; |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11888
diff
changeset
|
1479 int fg = color2index(&cell->fg, TRUE, &bold); |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11888
diff
changeset
|
1480 int bg = color2index(&cell->bg, FALSE, &bold); |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11888
diff
changeset
|
1481 |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11888
diff
changeset
|
1482 /* with 8 colors set the bold attribute to get a bright foreground */ |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11888
diff
changeset
|
1483 if (bold == TRUE) |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11888
diff
changeset
|
1484 attr |= HL_BOLD; |
35d7459251fd
patch 8.0.0831: with 8 colors the bold attribute is not set properly
Christian Brabandt <cb@256bit.org>
parents:
11888
diff
changeset
|
1485 return get_cterm_attr_idx(attr, fg, bg); |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1486 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1487 return 0; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1488 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1489 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1490 /* |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1491 * Called to update the window that contains a terminal. |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1492 * Returns FAIL when there is no terminal running in this window. |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1493 */ |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1494 int |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1495 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
|
1496 { |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1497 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
|
1498 VTerm *vterm; |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1499 VTermScreen *screen; |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1500 VTermState *state; |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
1501 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
|
1502 |
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
|
1503 if (term == NULL || term->tl_vterm == NULL || term->tl_terminal_mode) |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1504 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
|
1505 |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1506 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
|
1507 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
|
1508 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
|
1509 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1510 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1511 * 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
|
1512 * 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
|
1513 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1514 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
|
1515 || (!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
|
1516 { |
11818
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
1517 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
|
1518 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
|
1519 win_T *twp; |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
1520 |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
1521 FOR_ALL_WINDOWS(twp) |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
1522 { |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
1523 /* 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
|
1524 * smallest size. */ |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
1525 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
|
1526 { |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
1527 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
|
1528 rows = twp->w_height; |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
1529 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
|
1530 cols = twp->w_width; |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
1531 } |
0f9780ee4207
patch 8.0.0789: splitting terminal window has resizing problems
Christian Brabandt <cb@256bit.org>
parents:
11816
diff
changeset
|
1532 } |
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
|
1533 |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
1534 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
|
1535 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
|
1536 rows); |
11753
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
1537 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
|
1538 } |
11713
2ec27561dd76
patch 8.0.0739: terminal resizing doesn't work well.
Christian Brabandt <cb@256bit.org>
parents:
11711
diff
changeset
|
1539 |
2ec27561dd76
patch 8.0.0739: terminal resizing doesn't work well.
Christian Brabandt <cb@256bit.org>
parents:
11711
diff
changeset
|
1540 /* 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
|
1541 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
|
1542 position_cursor(wp, &pos); |
2ec27561dd76
patch 8.0.0739: terminal resizing doesn't work well.
Christian Brabandt <cb@256bit.org>
parents:
11711
diff
changeset
|
1543 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
1544 /* 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
|
1545 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
|
1546 { |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
1547 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
|
1548 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
|
1549 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1550 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
|
1551 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1552 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
|
1553 { |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
1554 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
|
1555 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
|
1556 |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1557 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
|
1558 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
|
1559 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1560 /* 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
|
1561 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
|
1562 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
|
1563 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1564 ScreenLines[off] = ' '; |
11774
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
1565 #if defined(FEAT_MBYTE) |
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
1566 if (enc_utf8) |
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
1567 ScreenLinesUC[off] = NUL; |
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
1568 #endif |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1569 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1570 else |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1571 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1572 #if defined(FEAT_MBYTE) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1573 if (enc_utf8 && 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
|
1574 { |
22cef8face93
patch 8.0.0745: multi-byte characters in a terminal don't display well
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
1575 ScreenLines[off] = ' '; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1576 ScreenLinesUC[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
|
1577 } |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1578 else |
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
|
1579 { |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1580 ScreenLines[off] = c; |
11774
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
1581 if (enc_utf8) |
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
1582 ScreenLinesUC[off] = NUL; |
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
|
1583 } |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1584 #else |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1585 ScreenLines[off] = c; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1586 #endif |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1587 } |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1588 ScreenAttrs[off] = cell2attr(&cell); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1589 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1590 ++pos.col; |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
1591 ++off; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1592 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
|
1593 { |
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
|
1594 ScreenLines[off] = NUL; |
11774
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
1595 #if defined(FEAT_MBYTE) |
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
1596 if (enc_utf8) |
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
1597 ScreenLinesUC[off] = NUL; |
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
1598 #endif |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1599 ++pos.col; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1600 ++off; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1601 } |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
1602 } |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1603 } |
11711
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
1604 else |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
1605 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
|
1606 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1607 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
|
1608 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
|
1609 } |
11834
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1610 |
0cfe4a07c2ad
patch 8.0.0797: finished job in terminal window is not handled
Christian Brabandt <cb@256bit.org>
parents:
11822
diff
changeset
|
1611 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
|
1612 } |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1613 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1614 /* |
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
|
1615 * 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
|
1616 */ |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1617 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
|
1618 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
|
1619 { |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1620 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
|
1621 } |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1622 |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1623 /* |
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
|
1624 * Return TRUE if "wp" is a terminal window where the job has finished or we |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1625 * are in 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
|
1626 */ |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1627 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
|
1628 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
|
1629 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1630 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
|
1631 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1632 return term != NULL && (term->tl_vterm == NULL || term->tl_terminal_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
|
1633 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1634 |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1635 /* |
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
|
1636 * 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
|
1637 * 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
|
1638 */ |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1639 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
|
1640 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
|
1641 { |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1642 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
|
1643 |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1644 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
|
1645 { |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1646 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
|
1647 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
|
1648 |
22658e33203f
patch 8.0.0836: can abandon a terminal buffer after making a change
Christian Brabandt <cb@256bit.org>
parents:
11904
diff
changeset
|
1649 /* 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
|
1650 * 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
|
1651 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
|
1652 (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
|
1653 } |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1654 } |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1655 |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1656 /* |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1657 * 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
|
1658 */ |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1659 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
|
1660 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
|
1661 { |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1662 term_T *term = buf->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
|
1663 sb_line_T *line; |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1664 |
11844
42585fee5e66
patch 8.0.0802: last line of terminal window has no color
Christian Brabandt <cb@256bit.org>
parents:
11842
diff
changeset
|
1665 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
|
1666 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
|
1667 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
|
1668 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
|
1669 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
|
1670 return cell2attr(line->sb_cells + 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
|
1671 } |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1672 |
f080b225a2a4
patch 8.0.0798: no highlighting in a terminal window with a finished job
Christian Brabandt <cb@256bit.org>
parents:
11834
diff
changeset
|
1673 /* |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1674 * 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
|
1675 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1676 static void |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1677 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
|
1678 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1679 VTerm *vterm; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1680 VTermScreen *screen; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1681 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1682 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
|
1683 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
|
1684 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
|
1685 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
|
1686 /* 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
|
1687 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
|
1688 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1689 /* 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
|
1690 * 'background' is "light". */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1691 if (*p_bg == 'l') |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1692 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1693 VTermColor fg, bg; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1694 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1695 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
|
1696 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
|
1697 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
|
1698 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
1699 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1700 /* 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
|
1701 vterm_screen_reset(screen, 1 /* hard */); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1702 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1703 |
11772
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1704 /* |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1705 * 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
|
1706 */ |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1707 char_u * |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1708 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
|
1709 { |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1710 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
|
1711 { |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1712 char_u *txt; |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1713 size_t len; |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1714 |
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
|
1715 if (term->tl_terminal_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
|
1716 { |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1717 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
|
1718 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
|
1719 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
|
1720 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
|
1721 } |
be40c8a9240d
patch 8.0.0813: cannot use a terminal window while the job is running
Christian Brabandt <cb@256bit.org>
parents:
11854
diff
changeset
|
1722 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
|
1723 txt = term->tl_title; |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1724 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
|
1725 txt = (char_u *)_("running"); |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1726 else |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1727 txt = (char_u *)_("finished"); |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1728 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
|
1729 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
|
1730 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
|
1731 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
|
1732 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
|
1733 } |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1734 return term->tl_status_text; |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1735 } |
f33b9375ba03
patch 8.0.0768: terminal window status shows "[Scratch]"
Christian Brabandt <cb@256bit.org>
parents:
11764
diff
changeset
|
1736 |
11816
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
1737 /* |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
1738 * 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
|
1739 */ |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
1740 int |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
1741 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
|
1742 { |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
1743 int abort = FALSE; |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
1744 term_T *term; |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
1745 typval_T tv; |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
1746 |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
1747 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
|
1748 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
|
1749 { |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
1750 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
|
1751 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
|
1752 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
|
1753 } |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
1754 return abort; |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
1755 } |
f6575adc6ee8
patch 8.0.0788: MS-Windows: cannot build with terminal feature
Christian Brabandt <cb@256bit.org>
parents:
11814
diff
changeset
|
1756 |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1757 /* |
11876
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1758 * 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
|
1759 * 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
|
1760 */ |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1761 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
|
1762 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
|
1763 { |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1764 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
|
1765 |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1766 (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
|
1767 ++emsg_off; |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1768 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
|
1769 --emsg_off; |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1770 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
|
1771 return NULL; |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1772 return buf; |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1773 } |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1774 |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1775 /* |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1776 * "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
|
1777 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1778 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1779 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
|
1780 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1781 int attr; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1782 size_t i; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1783 char_u *name; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1784 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1785 static struct { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1786 char *name; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1787 int attr; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1788 } attrs[] = { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1789 {"bold", HL_BOLD}, |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1790 {"italic", HL_ITALIC}, |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1791 {"underline", HL_UNDERLINE}, |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1792 {"strike", HL_STANDOUT}, |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1793 {"reverse", HL_INVERSE}, |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1794 }; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1795 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1796 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
|
1797 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
|
1798 if (name == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1799 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1800 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1801 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
|
1802 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
|
1803 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1804 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
|
1805 break; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1806 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1807 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1808 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1809 /* |
11876
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1810 * "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
|
1811 */ |
11876
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1812 void |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1813 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
|
1814 { |
11876
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1815 buf_T *buf = term_get_buf(argvars); |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1816 list_T *l; |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1817 |
11876
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1818 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
|
1819 return; |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1820 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
|
1821 return; |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1822 |
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1823 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
|
1824 list_append_number(l, buf->b_term->tl_cursor_pos.row + 1); |
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
1825 list_append_number(l, buf->b_term->tl_cursor_pos.col + 1); |
11876
3704ca24c9a2
patch 8.0.0818: cannot get the cursor position of a terminal
Christian Brabandt <cb@256bit.org>
parents:
11874
diff
changeset
|
1826 list_append_number(l, buf->b_term->tl_cursor_visible); |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1827 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1828 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1829 /* |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1830 * "term_getjob(buf)" function |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1831 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1832 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1833 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
|
1834 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1835 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
|
1836 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1837 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
|
1838 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
|
1839 if (buf == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1840 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1841 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1842 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
|
1843 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
|
1844 ++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
|
1845 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1846 |
11904
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
1847 static int |
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
1848 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
|
1849 { |
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
1850 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
|
1851 && 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
|
1852 && 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
|
1853 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
|
1854 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
|
1855 } |
40322e8f07e7
patch 8.0.0832: terminal function arguments are not consistent
Christian Brabandt <cb@256bit.org>
parents:
11902
diff
changeset
|
1856 |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1857 /* |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1858 * "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
|
1859 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1860 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1861 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
|
1862 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1863 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
|
1864 term_T *term; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1865 int row; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1866 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1867 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
|
1868 if (buf == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1869 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1870 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
|
1871 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
|
1872 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1873 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
|
1874 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1875 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
|
1876 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1877 /* 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
|
1878 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
|
1879 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
|
1880 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1881 else |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1882 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1883 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
|
1884 VTermRect rect; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1885 int len; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1886 char_u *p; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1887 |
11923
c9da7b42fdf5
patch 8.0.0841: term_getline() may cause a crash
Christian Brabandt <cb@256bit.org>
parents:
11919
diff
changeset
|
1888 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
|
1889 return; |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1890 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
|
1891 p = alloc(len); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1892 if (p == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1893 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1894 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
|
1895 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1896 rect.start_col = 0; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1897 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
|
1898 rect.start_row = row; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1899 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
|
1900 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
|
1901 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1902 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1903 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1904 /* |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1905 * "term_getsize(buf)" function |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1906 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1907 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1908 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
|
1909 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1910 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
|
1911 list_T *l; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1912 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1913 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
|
1914 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1915 if (buf == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1916 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1917 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1918 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
|
1919 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
|
1920 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
|
1921 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1922 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1923 /* |
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
|
1924 * "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
|
1925 */ |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1926 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
|
1927 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
|
1928 { |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1929 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
|
1930 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
|
1931 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
|
1932 |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1933 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
|
1934 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
|
1935 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
|
1936 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
|
1937 |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1938 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
|
1939 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
|
1940 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
|
1941 STRCPY(val, "finished"); |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1942 if (term->tl_terminal_mode) |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1943 STRCAT(val, ",terminal"); |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1944 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
|
1945 } |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1946 |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1947 /* |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1948 * "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
|
1949 */ |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1950 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
|
1951 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
|
1952 { |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1953 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
|
1954 |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1955 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
|
1956 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
|
1957 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
|
1958 |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1959 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
|
1960 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
|
1961 } |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1962 |
69e7379f46db
patch 8.0.0821: cannot get the title and status of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11880
diff
changeset
|
1963 /* |
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
|
1964 * "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
|
1965 */ |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
1966 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
|
1967 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
|
1968 { |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
1969 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
|
1970 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
|
1971 |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
1972 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
|
1973 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
|
1974 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
|
1975 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
|
1976 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
|
1977 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
|
1978 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
|
1979 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
|
1980 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
|
1981 } |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
1982 |
d033653d3df8
patch 8.0.0846: cannot get the name of the pty of a job
Christian Brabandt <cb@256bit.org>
parents:
11931
diff
changeset
|
1983 /* |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1984 * "term_list()" function |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1985 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1986 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1987 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
|
1988 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1989 term_T *tp; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1990 list_T *l; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1991 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1992 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
|
1993 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1994 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
1995 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
|
1996 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
|
1997 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
|
1998 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
|
1999 (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
|
2000 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2001 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2002 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2003 /* |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2004 * "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
|
2005 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2006 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2007 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
|
2008 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2009 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
|
2010 VTermScreen *screen = NULL; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2011 VTermPos pos; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2012 list_T *l; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2013 term_T *term; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2014 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2015 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
|
2016 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2017 if (buf == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2018 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2019 term = buf->b_term; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2020 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
|
2021 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
|
2022 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2023 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
|
2024 pos.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
|
2025 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
|
2026 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2027 dict_T *dcell; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2028 VTermScreenCell cell; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2029 char_u rgb[8]; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2030 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
|
2031 int off = 0; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2032 int i; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2033 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2034 if (screen == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2035 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2036 linenr_T lnum = pos.row + term->tl_scrollback_scrolled; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2037 sb_line_T *line; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2038 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2039 /* 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
|
2040 if (lnum < 0 || lnum >= term->tl_scrollback.ga_len) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2041 break; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2042 line = (sb_line_T *)term->tl_scrollback.ga_data + lnum; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2043 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
|
2044 break; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2045 cell = line->sb_cells[pos.col]; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2046 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2047 else if (vterm_screen_get_cell(screen, pos, &cell) == 0) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2048 break; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2049 dcell = dict_alloc(); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2050 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
|
2051 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2052 for (i = 0; i < VTERM_MAX_CHARS_PER_CELL; ++i) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2053 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2054 if (cell.chars[i] == 0) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2055 break; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2056 off += (*utf_char2bytes)((int)cell.chars[i], mbs + off); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2057 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2058 mbs[off] = NUL; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2059 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
|
2060 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2061 vim_snprintf((char *)rgb, 8, "#%02x%02x%02x", |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2062 cell.fg.red, cell.fg.green, cell.fg.blue); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2063 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
|
2064 vim_snprintf((char *)rgb, 8, "#%02x%02x%02x", |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2065 cell.bg.red, cell.bg.green, cell.bg.blue); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2066 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
|
2067 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2068 dict_add_nr_str(dcell, "attr", cell2attr(&cell), NULL); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2069 dict_add_nr_str(dcell, "width", cell.width, NULL); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2070 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2071 ++pos.col; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2072 if (cell.width == 2) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2073 ++pos.col; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2074 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2075 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2076 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2077 /* |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2078 * "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
|
2079 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2080 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2081 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
|
2082 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2083 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
|
2084 char_u *msg; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2085 term_T *term; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2086 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2087 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
|
2088 if (buf == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2089 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2090 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2091 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
|
2092 if (msg == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2093 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2094 term = buf->b_term; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2095 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
|
2096 return; |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2097 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2098 while (*msg != NUL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2099 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2100 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
|
2101 msg += MB_PTR2LEN(msg); |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2102 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2103 |
11888
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
2104 if (!term->tl_terminal_mode) |
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
2105 { |
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
2106 /* TODO: only update once in a while. */ |
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
2107 update_screen(0); |
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
2108 if (buf == curbuf) |
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
2109 update_cursor(term, TRUE); |
4db6c74df788
patch 8.0.0824: in Terminal mode the cursor and screen gets redrawn
Christian Brabandt <cb@256bit.org>
parents:
11886
diff
changeset
|
2110 } |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2111 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2112 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2113 /* |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2114 * "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
|
2115 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2116 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2117 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
|
2118 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2119 char_u *cmd = get_tv_string_chk(&argvars[0]); |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2120 jobopt_T opt; |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2121 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2122 if (cmd == NULL) |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2123 return; |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2124 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
|
2125 /* TODO: allow more job options */ |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2126 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
|
2127 && 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
|
2128 JO_TIMEOUT_ALL + JO_STOPONEXIT |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2129 + JO_EXIT_CB + JO_CLOSE_CALLBACK) == FAIL) |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2130 return; |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2131 |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2132 term_start(cmd, &opt); |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2133 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2134 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
|
2135 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
|
2136 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2137 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2138 /* |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2139 * "term_wait" function |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2140 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2141 void |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2142 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
|
2143 { |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2144 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
|
2145 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2146 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
|
2147 { |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2148 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
|
2149 return; |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2150 } |
11949
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2151 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
|
2152 { |
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2153 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
|
2154 return; |
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2155 } |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2156 |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2157 /* Get the job status, this will detect a job that finished. */ |
11949
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2158 if (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
|
2159 { |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2160 /* The job is dead, keep reading channel I/O until the channel is |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2161 * closed. */ |
11949
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2162 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
|
2163 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
|
2164 { |
11949
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2165 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
|
2166 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
|
2167 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
|
2168 } |
11949
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2169 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
|
2170 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
|
2171 } |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2172 else |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2173 { |
11949
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2174 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
|
2175 parse_queued_messages(); |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2176 |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2177 /* Wait for 10 msec for any channel I/O. */ |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2178 /* TODO: use delay from optional argument */ |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2179 ui_delay(10L, TRUE); |
11949
74e45c11b754
patch 8.0.0854: no redraw after terminal was closed
Christian Brabandt <cb@256bit.org>
parents:
11947
diff
changeset
|
2180 mch_check_messages(); |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2181 |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2182 /* 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
|
2183 * 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
|
2184 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
|
2185 } |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2186 } |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2187 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2188 # ifdef WIN3264 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2189 |
11846
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2190 /************************************** |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2191 * 2. MS-Windows implementation. |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2192 */ |
1c65cad8b967
patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents:
11844
diff
changeset
|
2193 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2194 #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
|
2195 #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
|
2196 |
11774
edf1a2a247fa
patch 8.0.0769: build problems with terminal on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11772
diff
changeset
|
2197 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
|
2198 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
|
2199 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
|
2200 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
|
2201 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
|
2202 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
|
2203 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
|
2204 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
|
2205 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
|
2206 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
|
2207 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
|
2208 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
|
2209 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
|
2210 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
|
2211 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
|
2212 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2213 #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
|
2214 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2215 static HINSTANCE hWinPtyDLL = NULL; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2216 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2217 int |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2218 dyn_winpty_init(void) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2219 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2220 int i; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2221 static struct |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2222 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2223 char *name; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2224 FARPROC *ptr; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2225 } winpty_entry[] = |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2226 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2227 {"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
|
2228 {"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
|
2229 {"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
|
2230 {"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
|
2231 {"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
|
2232 {"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
|
2233 {"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
|
2234 {"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
|
2235 {"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
|
2236 {"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
|
2237 {"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
|
2238 {"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
|
2239 {"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
|
2240 {"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
|
2241 {"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
|
2242 {NULL, NULL} |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2243 }; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2244 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2245 /* 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
|
2246 if (hWinPtyDLL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2247 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2248 /* Load winpty.dll */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2249 hWinPtyDLL = vimLoadLib(WINPTY_DLL); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2250 if (!hWinPtyDLL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2251 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2252 EMSG2(_(e_loadlib), WINPTY_DLL); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2253 return 0; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2254 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2255 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
|
2256 && 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
|
2257 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2258 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
|
2259 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
|
2260 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2261 EMSG2(_(e_loadfunc), winpty_entry[i].name); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2262 return 0; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2263 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2264 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2265 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2266 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2267 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2268 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2269 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2270 * 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
|
2271 * 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
|
2272 * 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
|
2273 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2274 static int |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2275 term_and_job_init(term_T *term, int rows, int cols, char_u *cmd, 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
|
2276 { |
11798
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
2277 WCHAR *p; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2278 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
|
2279 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
|
2280 DWORD error; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2281 HANDLE jo = NULL, child_process_handle, child_thread_handle; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2282 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
|
2283 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
|
2284 char buf[MAX_PATH]; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2285 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2286 if (!dyn_winpty_init()) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2287 return FAIL; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2288 |
11798
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
2289 p = enc_to_utf16(cmd, NULL); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2290 if (p == NULL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2291 return FAIL; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2292 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2293 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
|
2294 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
|
2295 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2296 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2297 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
|
2298 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
|
2299 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2300 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2301 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
|
2302 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
|
2303 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2304 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2305 winpty_config_set_initial_size(term->tl_winpty_config, cols, rows); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2306 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
|
2307 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
|
2308 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2309 |
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
|
2310 /* 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
|
2311 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
|
2312 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
|
2313 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
|
2314 NULL, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2315 p, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2316 NULL, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2317 NULL, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2318 &winpty_err); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2319 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
|
2320 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2321 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2322 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
|
2323 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
|
2324 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2325 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2326 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
|
2327 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
|
2328 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2329 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2330 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
|
2331 &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
|
2332 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2333 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2334 channel_set_pipes(channel, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2335 (sock_T) CreateFileW( |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2336 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
|
2337 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
|
2338 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
|
2339 (sock_T) CreateFileW( |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2340 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
|
2341 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
|
2342 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
|
2343 (sock_T) CreateFileW( |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2344 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
|
2345 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
|
2346 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
|
2347 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2348 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
|
2349 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
|
2350 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2351 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2352 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
|
2353 { |
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
2354 /* 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
|
2355 CloseHandle(jo); |
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
2356 jo = NULL; |
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
2357 } |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2358 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2359 winpty_spawn_config_free(spawn_config); |
11798
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
2360 vim_free(p); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2361 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2362 create_vterm(term, rows, cols); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2363 |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2364 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
|
2365 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
|
2366 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2367 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
|
2368 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
|
2369 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
|
2370 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
|
2371 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
|
2372 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
|
2373 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
|
2374 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
|
2375 ++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
|
2376 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
|
2377 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2378 return OK; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2379 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2380 failed: |
11798
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
2381 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
|
2382 winpty_spawn_config_free(spawn_config); |
4d545cd33f0a
patch 8.0.0781: MS-Windows: memory leak when using :terminal
Christian Brabandt <cb@256bit.org>
parents:
11794
diff
changeset
|
2383 vim_free(p); |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2384 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
|
2385 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
|
2386 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
|
2387 { |
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
2388 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
|
2389 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
|
2390 } |
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
2391 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
|
2392 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
|
2393 CloseHandle(jo); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2394 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
|
2395 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
|
2396 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
|
2397 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
|
2398 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
|
2399 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
|
2400 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
|
2401 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2402 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
|
2403 (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
|
2404 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2405 EMSG(msg); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2406 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
|
2407 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2408 return FAIL; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2409 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2410 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2411 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2412 * 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
|
2413 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2414 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
|
2415 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
|
2416 { |
11751
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
2417 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
|
2418 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
|
2419 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
|
2420 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
|
2421 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
|
2422 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
|
2423 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
|
2424 vterm_free(term->tl_vterm); |
11838
e6080ed193f6
patch 8.0.0799: missing semicolon
Christian Brabandt <cb@256bit.org>
parents:
11836
diff
changeset
|
2425 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
|
2426 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2427 |
11753
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2428 /* |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2429 * 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
|
2430 */ |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2431 static void |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2432 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
|
2433 { |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2434 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
|
2435 } |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2436 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2437 # else |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2438 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2439 /************************************** |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2440 * 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
|
2441 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2442 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2443 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2444 * 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
|
2445 * 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
|
2446 * 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
|
2447 * 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
|
2448 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2449 static int |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2450 term_and_job_init(term_T *term, int rows, int cols, char_u *cmd, 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
|
2451 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2452 typval_T argvars[2]; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2453 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2454 create_vterm(term, rows, cols); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2455 |
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
|
2456 /* 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
|
2457 argvars[0].v_type = VAR_STRING; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2458 argvars[0].vval.v_string = cmd; |
11939
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2459 |
ef1febf04d03
patch 8.0.0849: crash when job exit callback wipes the terminal
Christian Brabandt <cb@256bit.org>
parents:
11937
diff
changeset
|
2460 term->tl_job = job_start(argvars, opt); |
11802
b1fd49b4eea7
patch 8.0.0783: job of terminal may be freed too early
Christian Brabandt <cb@256bit.org>
parents:
11798
diff
changeset
|
2461 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
|
2462 ++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
|
2463 |
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
|
2464 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
|
2465 && 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
|
2466 && 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
|
2467 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2468 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2469 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2470 * 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
|
2471 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2472 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
|
2473 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
|
2474 { |
11751
a1815c4f8b70
patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
2475 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
|
2476 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
|
2477 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
|
2478 } |
11753
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2479 |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2480 /* |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2481 * 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
|
2482 */ |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2483 static void |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2484 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
|
2485 { |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2486 /* 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
|
2487 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
|
2488 { |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2489 int fd = -1; |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2490 int part; |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2491 |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2492 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
|
2493 { |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2494 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
|
2495 if (isatty(fd)) |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2496 break; |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2497 } |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2498 if (part < PART_COUNT && mch_report_winsize(fd, rows, cols) == OK) |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2499 mch_stop_job(term->tl_job, (char_u *)"winch"); |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2500 } |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2501 } |
f7c2473796b7
patch 8.0.0759: MS-Windows: terminal does not adjust size
Christian Brabandt <cb@256bit.org>
parents:
11751
diff
changeset
|
2502 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
2503 # endif |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
2504 |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2505 #endif /* FEAT_TERMINAL */ |