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