Mercurial > vim
annotate src/terminal.c @ 11743:6141a21dd232 v8.0.0754
patch 8.0.0754: terminal window does not support colors
commit https://github.com/vim/vim/commit/eeac67788677a9ea81bcab69f81b4fc22c2adc00
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 23 15:48:37 2017 +0200
patch 8.0.0754: terminal window does not support colors
Problem: Terminal window does not support colors.
Solution: Lookup the color attribute.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 23 Jul 2017 16:00:04 +0200 |
parents | b4d8f956eb18 |
children | 5a5709918a98 |
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 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
22 * that 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 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 * terminal encoding and writting to the job over a channel. |
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 * |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 * TODO: |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
36 * - color for GUI |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
37 * - color for 'termguicolors' |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
38 * - cursor flickers when moving the cursor |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 * - set buffer options to be scratch, hidden, nomodifiable, etc. |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 * - set buffer name to command, add (1) to avoid duplicates. |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
41 * - Add a scrollback buffer (contains lines to scroll off the top). |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
42 * Can use the buf_T lines, store attributes somewhere else? |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
43 * - When the job ends: |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
44 * - Write "-- JOB ENDED --" in the terminal. |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
45 * - Put the terminal contents in the scrollback buffer. |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
46 * - Free the terminal emulator. |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
47 * - Display the scrollback buffer (but with attributes). |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
48 * Make the buffer not modifiable, drop attributes when making changes. |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
49 * - when closing window and job has not ended, make terminal hidden? |
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
|
50 * - don't allow exiting Vim when a terminal is still running a job |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
51 * - use win_del_lines() to make scroll-up efficient. |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
52 * - command line completion for :terminal |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
53 * - 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
|
54 * - 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
|
55 * - 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
|
56 * - 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
|
57 * terminal. |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 * - implement ":buf {term-buf-name}" |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
59 * - implement term_list() list of buffers with a terminal |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
60 * - implement term_getsize(buf) |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
61 * - implement term_setsize(buf) |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
62 * - implement term_sendkeys(buf, keys) send keystrokes to a terminal |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
63 * - implement term_wait(buf) wait for screen to be updated |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
64 * - implement term_scrape(buf, row) inspect terminal screen |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
65 * - implement term_open(command, options) open terminal window |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
66 * - implement term_getjob(buf) |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
67 * - implement 'termkey' |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
68 * - 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
|
69 * conversions. |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 #include "vim.h" |
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 #ifdef FEAT_TERMINAL |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
76 #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
|
77 # 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
|
78 # 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
|
79 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
81 #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
|
82 |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 /* typedef term_T in structs.h */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 struct terminal_S { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 term_T *tl_next; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
87 #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
|
88 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
|
89 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
|
90 #endif |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 VTerm *tl_vterm; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 job_T *tl_job; |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
93 buf_T *tl_buffer; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
95 /* 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
|
96 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
|
97 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
|
98 /* 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
|
99 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
|
100 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
|
101 |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
102 /* 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
|
103 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
|
104 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
|
105 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
106 pos_T tl_cursor; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
107 }; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
108 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
109 /* |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
110 * List of all active terminals. |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
111 */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
112 static term_T *first_term = NULL; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
113 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
114 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
115 #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
|
116 #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
|
117 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
118 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
119 * 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
|
120 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
121 static int 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
|
122 static void term_free(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
|
123 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
124 /************************************** |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
125 * 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
|
126 */ |
11621
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 /* |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
129 * 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
|
130 * 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
|
131 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
132 static void |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
133 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
|
134 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
135 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
|
136 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
137 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
|
138 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
139 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
|
140 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
|
141 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
142 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
|
143 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
|
144 else |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
145 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
146 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
|
147 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
|
148 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
149 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
|
150 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
|
151 else |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
152 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
153 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
|
154 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
|
155 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
156 } |
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 /* |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
159 * ":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
|
160 */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
161 void |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
162 ex_terminal(exarg_T *eap) |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
163 { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
164 exarg_T split_ea; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
165 win_T *old_curwin = curwin; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
166 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
|
167 char_u *cmd = eap->arg; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
168 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
169 if (check_restricted() || check_secure()) |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
170 return; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
171 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
172 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
|
173 if (term == NULL) |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
174 return; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
175 term->tl_dirty_row_end = MAX_ROW; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
176 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
177 /* Open a new window or tab. */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
178 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
|
179 split_ea.cmdidx = CMD_new; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
180 split_ea.cmd = (char_u *)"new"; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
181 split_ea.arg = (char_u *)""; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
182 ex_splitview(&split_ea); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
183 if (curwin == old_curwin) |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
184 { |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
185 /* split failed */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
186 vim_free(term); |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
187 return; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
188 } |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
189 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
|
190 curbuf->b_term = term; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
191 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
192 /* 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
|
193 term->tl_next = first_term; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
194 first_term = term; |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
195 |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
196 /* TODO: set buffer type, hidden, etc. */ |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
197 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
198 set_term_and_win_size(term); |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
199 |
11729
1c8ec1029233
patch 8.0.0747: :terminal without an argument doesn't work
Christian Brabandt <cb@256bit.org>
parents:
11727
diff
changeset
|
200 if (cmd == NULL || *cmd == NUL) |
1c8ec1029233
patch 8.0.0747: :terminal without an argument doesn't work
Christian Brabandt <cb@256bit.org>
parents:
11727
diff
changeset
|
201 cmd = p_sh; |
1c8ec1029233
patch 8.0.0747: :terminal without an argument doesn't work
Christian Brabandt <cb@256bit.org>
parents:
11727
diff
changeset
|
202 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
203 /* 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
|
204 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
|
205 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
206 /* 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
|
207 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
|
208 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
209 else |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
210 { |
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
|
211 free_terminal(term); |
cb1dc90d22cc
patch 8.0.0746: when :term fails the job is not properly cleaned up
Christian Brabandt <cb@256bit.org>
parents:
11725
diff
changeset
|
212 curbuf->b_term = 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
|
213 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
214 /* 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
|
215 * free_terminal(). */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
216 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
|
217 } |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
218 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
219 /* TODO: Setup pty, see mch_call_shell(). */ |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
220 } |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
221 |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
222 /* |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
223 * 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
|
224 * 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
|
225 * 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
|
226 */ |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
227 void |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
228 free_terminal(term_T *term) |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
229 { |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
230 term_T *tp; |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
231 |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
232 if (term == NULL) |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
233 return; |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
234 if (first_term == term) |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
235 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
|
236 else |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
237 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
|
238 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
|
239 { |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
240 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
|
241 break; |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
242 } |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
243 |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
244 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
|
245 { |
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
|
246 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
|
247 && 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
|
248 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
|
249 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
|
250 } |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
251 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
252 term_free(term); |
11690
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
253 vim_free(term); |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
254 } |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
255 |
ce434212d682
patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents:
11684
diff
changeset
|
256 /* |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
257 * 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
|
258 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
259 static void |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
260 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
|
261 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
262 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
|
263 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
|
264 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
|
265 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
|
266 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
267 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
|
268 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
269 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
|
270 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
271 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
|
272 break; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
273 p += utf_ptr2len_len(p, len - (p - msg)); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
274 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
275 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
|
276 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
|
277 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
|
278 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
279 /* 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
|
280 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
|
281 ++len_now; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
282 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
283 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
284 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
285 /* 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
|
286 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
|
287 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
288 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
289 /* |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
290 * 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
|
291 * of "buffer". |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
292 */ |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
293 void |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
294 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
|
295 { |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
296 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
|
297 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
|
298 |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
299 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
|
300 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
|
301 |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
302 /* TODO: only update once in a while. */ |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
303 update_screen(0); |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
304 setcursor(); |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
305 out_flush(); |
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
306 } |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
307 |
11670
3b2afa2b77b3
patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents:
11668
diff
changeset
|
308 /* |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
309 * 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
|
310 * 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
|
311 */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
312 static int |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
313 term_convert_key(int c, char *buf) |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
314 { |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
315 VTerm *vterm = curbuf->b_term->tl_vterm; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
316 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
|
317 VTermModifier mod = VTERM_MOD_NONE; |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
318 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
319 switch (c) |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
320 { |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
321 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
|
322 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
|
323 /* 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
|
324 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
|
325 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
|
326 case K_DOWN: key = VTERM_KEY_DOWN; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
327 case K_END: key = VTERM_KEY_END; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
328 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
|
329 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
|
330 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
|
331 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
|
332 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
|
333 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
|
334 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
|
335 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
|
336 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
|
337 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
|
338 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
|
339 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
|
340 case K_HOME: key = VTERM_KEY_HOME; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
341 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
|
342 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
|
343 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
|
344 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
|
345 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
|
346 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
|
347 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
|
348 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
|
349 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
|
350 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
|
351 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
|
352 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
|
353 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
|
354 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
|
355 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
|
356 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
|
357 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
|
358 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
|
359 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
|
360 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
|
361 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
|
362 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
|
363 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
|
364 case K_LEFT: key = VTERM_KEY_LEFT; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
365 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
|
366 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
|
367 case K_RIGHT: key = VTERM_KEY_RIGHT; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
368 case K_UP: key = VTERM_KEY_UP; break; |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
369 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
|
370 |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
371 case K_MOUSEUP: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
372 case K_MOUSEDOWN: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
373 case K_MOUSELEFT: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
374 case K_MOUSERIGHT: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
375 |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
376 case K_LEFTMOUSE: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
377 case K_LEFTMOUSE_NM: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
378 case K_LEFTDRAG: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
379 case K_LEFTRELEASE: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
380 case K_LEFTRELEASE_NM: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
381 case K_MIDDLEMOUSE: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
382 case K_MIDDLEDRAG: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
383 case K_MIDDLERELEASE: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
384 case K_RIGHTMOUSE: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
385 case K_RIGHTDRAG: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
386 case K_RIGHTRELEASE: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
387 case K_X1MOUSE: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
388 case K_X1DRAG: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
389 case K_X1RELEASE: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
390 case K_X2MOUSE: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
391 case K_X2DRAG: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
392 case K_X2RELEASE: /* TODO */ break; |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
393 |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
394 /* TODO: handle all special keys and modifiers that terminal_loop() |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
395 * does not handle. */ |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
396 } |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
397 |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
398 /* |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
399 * 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
|
400 * - 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
|
401 * - Write output to channel. |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
402 */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
403 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
|
404 /* 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
|
405 vterm_keyboard_key(vterm, key, mod); |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
406 else |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
407 /* 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
|
408 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
|
409 |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
410 /* Read back the converted escape sequence. */ |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
411 return vterm_output_read(vterm, buf, KEY_BUF_LEN); |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
412 } |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
413 |
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
414 /* |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
415 * 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
|
416 * 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
|
417 * should be handled as a Normal mode command. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
418 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
419 void |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
420 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
|
421 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
422 char buf[KEY_BUF_LEN]; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
423 int c; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
424 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
|
425 static int mouse_was_outside = FALSE; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
426 int dragging_outside = FALSE; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
427 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
428 for (;;) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
429 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
430 /* TODO: skip screen update when handling a sequence of keys. */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
431 update_screen(0); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
432 setcursor(); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
433 out_flush(); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
434 ++no_mapping; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
435 ++allow_keys; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
436 got_int = FALSE; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
437 c = vgetc(); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
438 --no_mapping; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
439 --allow_keys; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
440 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
441 /* Catch keys that need to be handled as in Normal mode. */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
442 switch (c) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
443 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
444 case Ctrl_W: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
445 case NUL: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
446 case K_ZERO: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
447 stuffcharReadbuff(c); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
448 return; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
449 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
450 case K_IGNORE: continue; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
451 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
452 case K_LEFTDRAG: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
453 case K_MIDDLEDRAG: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
454 case K_RIGHTDRAG: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
455 case K_X1DRAG: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
456 case K_X2DRAG: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
457 dragging_outside = mouse_was_outside; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
458 /* FALLTHROUGH */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
459 case K_LEFTMOUSE: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
460 case K_LEFTMOUSE_NM: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
461 case K_LEFTRELEASE: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
462 case K_LEFTRELEASE_NM: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
463 case K_MIDDLEMOUSE: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
464 case K_MIDDLERELEASE: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
465 case K_RIGHTMOUSE: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
466 case K_RIGHTRELEASE: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
467 case K_X1MOUSE: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
468 case K_X1RELEASE: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
469 case K_X2MOUSE: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
470 case K_X2RELEASE: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
471 if (mouse_row < W_WINROW(curwin) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
472 || mouse_row >= (W_WINROW(curwin) + 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
|
473 || mouse_col < W_WINCOL(curwin) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
474 || mouse_col >= W_ENDCOL(curwin) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
475 || dragging_outside) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
476 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
477 /* click outside 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
|
478 stuffcharReadbuff(c); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
479 mouse_was_outside = TRUE; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
480 return; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
481 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
482 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
483 mouse_was_outside = FALSE; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
484 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
485 /* Convert the typed key to a sequence of bytes for the job. */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
486 len = term_convert_key(c, buf); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
487 if (len > 0) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
488 /* TODO: if FAIL is returned, stop? */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
489 channel_send(curbuf->b_term->tl_job->jv_channel, PART_IN, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
490 (char_u *)buf, len, NULL); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
491 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
492 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
493 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
494 static void |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
495 position_cursor(win_T *wp, VTermPos *pos) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
496 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
497 wp->w_wrow = MIN(pos->row, MAX(0, wp->w_height - 1)); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
498 wp->w_wcol = MIN(pos->col, MAX(0, wp->w_width - 1)); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
499 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
500 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
501 static int 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
|
502 static int handle_moverect(VTermRect dest, VTermRect src, void *user); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
503 static int handle_movecursor(VTermPos pos, VTermPos oldpos, int visible, void *user); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
504 static int 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
|
505 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
506 static VTermScreenCallbacks screen_callbacks = { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
507 handle_damage, /* damage */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
508 handle_moverect, /* moverect */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
509 handle_movecursor, /* movecursor */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
510 NULL, /* settermprop */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
511 NULL, /* bell */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
512 handle_resize, /* resize */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
513 NULL, /* sb_pushline */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
514 NULL /* sb_popline */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
515 }; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
516 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
517 static int |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
518 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
|
519 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
520 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
|
521 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
522 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
|
523 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
|
524 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
|
525 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
526 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
527 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
528 static int |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
529 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
|
530 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
531 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
|
532 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
533 /* TODO */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
534 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
|
535 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
536 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
537 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
538 static int |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
539 handle_movecursor( |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
540 VTermPos pos, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
541 VTermPos oldpos UNUSED, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
542 int visible UNUSED, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
543 void *user) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
544 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
545 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
|
546 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
|
547 int is_current = FALSE; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
548 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
549 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
|
550 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
551 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
|
552 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
553 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
|
554 if (wp == curwin) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
555 is_current = TRUE; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
556 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
557 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
558 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
559 if (is_current) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
560 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
561 setcursor(); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
562 out_flush(); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
563 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
564 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
565 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
566 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
567 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
568 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
569 * 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
|
570 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
571 static int |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
572 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
|
573 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
574 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
|
575 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
|
576 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
577 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
|
578 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
|
579 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
|
580 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
581 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
|
582 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
583 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
|
584 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
|
585 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
586 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
587 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
588 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
|
589 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
590 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
591 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
592 /* |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
593 * 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
|
594 * 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
|
595 */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
596 static int |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
597 color2index(VTermColor *color) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
598 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
599 int red = color->red; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
600 int blue = color->blue; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
601 int green = color->green; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
602 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
603 if (red == 0) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
604 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
605 if (green == 0) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
606 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
607 if (blue == 0) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
608 return 1; /* black */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
609 if (blue == 224) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
610 return 5; /* blue */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
611 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
612 else if (green == 224) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
613 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
614 if (blue == 0) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
615 return 3; /* green */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
616 if (blue == 224) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
617 return 7; /* cyan */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
618 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
619 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
620 else if (red == 224) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
621 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
622 if (green == 0) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
623 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
624 if (blue == 0) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
625 return 2; /* red */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
626 if (blue == 224) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
627 return 6; /* magenta */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
628 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
629 else if (green == 224) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
630 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
631 if (blue == 0) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
632 return 4; /* yellow */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
633 if (blue == 224) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
634 return 8; /* white */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
635 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
636 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
637 else if (red == 128) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
638 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
639 if (green == 128 && blue == 128) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
640 return 9; /* high intensity bladk */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
641 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
642 else if (red == 255) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
643 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
644 if (green == 64) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
645 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
646 if (blue == 64) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
647 return 10; /* high intensity red */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
648 if (blue == 255) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
649 return 14; /* high intensity magenta */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
650 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
651 else if (green == 255) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
652 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
653 if (blue == 64) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
654 return 12; /* high intensity yellow */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
655 if (blue == 255) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
656 return 16; /* high intensity white */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
657 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
658 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
659 else if (red == 64) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
660 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
661 if (green == 64) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
662 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
663 if (blue == 255) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
664 return 13; /* high intensity blue */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
665 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
666 else if (green == 255) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
667 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
668 if (blue == 64) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
669 return 11; /* high intensity green */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
670 if (blue == 255) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
671 return 15; /* high intensity cyan */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
672 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
673 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
674 if (t_colors >= 256) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
675 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
676 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
|
677 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
678 /* 24-color greyscale */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
679 static int cutoff[23] = { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
680 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
|
681 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
|
682 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
|
683 int i; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
684 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
685 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
|
686 if (red < cutoff[i]) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
687 return i + 233; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
688 return 256; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
689 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
690 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
691 /* 216-color cube */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
692 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
|
693 + ((green + 25) / 0x33) * 6 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
694 + (blue + 25) / 0x33; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
695 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
696 return 0; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
697 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
698 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
699 /* |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
700 * 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
|
701 */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
702 static int |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
703 cell2attr(VTermScreenCell *cell) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
704 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
705 int attr = 0; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
706 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
707 if (cell->attrs.bold) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
708 attr |= HL_BOLD; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
709 if (cell->attrs.underline) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
710 attr |= HL_UNDERLINE; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
711 if (cell->attrs.italic) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
712 attr |= HL_ITALIC; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
713 if (cell->attrs.strike) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
714 attr |= HL_STANDOUT; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
715 if (cell->attrs.reverse) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
716 attr |= HL_INVERSE; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
717 if (cell->attrs.strike) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
718 attr |= HL_UNDERLINE; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
719 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
720 #ifdef FEAT_GUI |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
721 if (gui.in_use) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
722 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
723 /* TODO */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
724 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
725 else |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
726 #endif |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
727 #ifdef FEAT_TERMGUICOLORS |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
728 if (p_tgc) |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
729 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
730 /* TODO */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
731 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
732 #endif |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
733 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
734 return get_cterm_attr_idx(attr, color2index(&cell->fg), |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
735 color2index(&cell->bg)); |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
736 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
737 return 0; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
738 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
739 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
740 /* |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
741 * Called to update the window that contains the terminal. |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
742 */ |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
743 void |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
744 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
|
745 { |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
746 term_T *term = wp->w_buffer->b_term; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
747 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
|
748 VTermScreen *screen = vterm_obtain_screen(vterm); |
11713
2ec27561dd76
patch 8.0.0739: terminal resizing doesn't work well.
Christian Brabandt <cb@256bit.org>
parents:
11711
diff
changeset
|
749 VTermState *state = vterm_obtain_state(vterm); |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
750 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
|
751 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
752 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
753 * 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
|
754 * 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
|
755 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
756 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
|
757 || (!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
|
758 { |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
759 int rows = term->tl_rows_fixed ? term->tl_rows : wp->w_height; |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
760 int cols = term->tl_cols_fixed ? term->tl_cols : wp->w_width; |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
761 |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
762 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
|
763 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
|
764 rows); |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
765 |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
766 #if defined(UNIX) |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
767 /* Use an ioctl() to report the new window size to the job. */ |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
768 if (term->tl_job != NULL && term->tl_job->jv_channel != NULL) |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
769 { |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
770 int fd = -1; |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
771 int part; |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
772 |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
773 for (part = PART_OUT; part < PART_COUNT; ++part) |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
774 { |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
775 fd = term->tl_job->jv_channel->ch_part[part].ch_fd; |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
776 if (isatty(fd)) |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
777 break; |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
778 } |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
779 if (part < PART_COUNT && mch_report_winsize(fd, rows, cols) == OK) |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
780 mch_stop_job(term->tl_job, (char_u *)"winch"); |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
781 } |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
782 #endif |
b4d8f956eb18
patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents:
11729
diff
changeset
|
783 } |
11713
2ec27561dd76
patch 8.0.0739: terminal resizing doesn't work well.
Christian Brabandt <cb@256bit.org>
parents:
11711
diff
changeset
|
784 |
2ec27561dd76
patch 8.0.0739: terminal resizing doesn't work well.
Christian Brabandt <cb@256bit.org>
parents:
11711
diff
changeset
|
785 /* 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
|
786 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
|
787 position_cursor(wp, &pos); |
2ec27561dd76
patch 8.0.0739: terminal resizing doesn't work well.
Christian Brabandt <cb@256bit.org>
parents:
11711
diff
changeset
|
788 |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
789 /* 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
|
790 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
|
791 { |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
792 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
|
793 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
|
794 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
795 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
|
796 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
797 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
|
798 { |
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
799 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
|
800 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
|
801 |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
802 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
|
803 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
|
804 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
805 /* 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
|
806 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
|
807 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
|
808 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
809 ScreenLines[off] = ' '; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
810 ScreenLinesUC[off] = NUL; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
811 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
812 else |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
813 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
814 #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
|
815 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
|
816 { |
22cef8face93
patch 8.0.0745: multi-byte characters in a terminal don't display well
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
817 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
|
818 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
|
819 } |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
820 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
|
821 { |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
822 ScreenLines[off] = c; |
11725
22cef8face93
patch 8.0.0745: multi-byte characters in a terminal don't display well
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
823 ScreenLinesUC[off] = NUL; |
22cef8face93
patch 8.0.0745: multi-byte characters in a terminal don't display well
Christian Brabandt <cb@256bit.org>
parents:
11723
diff
changeset
|
824 } |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
825 #else |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
826 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
|
827 #endif |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
828 } |
11743
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
829 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
|
830 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
831 ++pos.col; |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
832 ++off; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
833 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
|
834 { |
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
|
835 ScreenLines[off] = NUL; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
836 ScreenLinesUC[off] = NUL; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
837 ++pos.col; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
838 ++off; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
839 } |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
840 } |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
841 } |
11711
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
842 else |
dac96f8800be
patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents:
11694
diff
changeset
|
843 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
|
844 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
845 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
|
846 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
|
847 } |
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11670
diff
changeset
|
848 } |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
849 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
850 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
851 * 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
|
852 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
853 static void |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
854 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
|
855 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
856 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
|
857 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
|
858 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
|
859 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
|
860 opt->jo_set = JO_MODE | JO_OUT_MODE | JO_ERR_MODE; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
861 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
|
862 opt->jo_io[PART_ERR] = JIO_BUFFER; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
863 opt->jo_set |= JO_OUT_IO + (JO_OUT_IO << (PART_ERR - PART_OUT)); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
864 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
|
865 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
|
866 opt->jo_pty = TRUE; |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
867 opt->jo_set |= JO_OUT_BUF + (JO_OUT_BUF << (PART_ERR - PART_OUT)); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
868 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
|
869 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
|
870 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
871 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
872 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
873 * 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
|
874 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
875 static void |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
876 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
|
877 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
878 VTerm *vterm; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
879 VTermScreen *screen; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
880 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
881 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
|
882 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
|
883 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
|
884 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
|
885 /* 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
|
886 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
|
887 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
888 /* 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
|
889 * 'background' is "light". */ |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
890 if (*p_bg == 'l') |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
891 { |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
892 VTermColor fg, bg; |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
893 |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
894 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
|
895 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
|
896 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
|
897 } |
6141a21dd232
patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents:
11741
diff
changeset
|
898 |
11719
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
899 /* 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
|
900 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
|
901 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
902 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
903 # ifdef WIN3264 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
904 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
905 #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
|
906 #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
|
907 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
908 void* (*winpty_config_new)(int, void*); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
909 void* (*winpty_open)(void*, void*); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
910 void* (*winpty_spawn_config_new)(int, void*, LPCWSTR, void*, void*, void*); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
911 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
|
912 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
|
913 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
|
914 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
|
915 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
|
916 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
|
917 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
|
918 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
|
919 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
|
920 LPCWSTR (*winpty_error_msg)(void*); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
921 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
922 /************************************** |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
923 * 2. MS-Windows implementation. |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
924 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
925 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
926 #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
|
927 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
928 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
|
929 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
930 int |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
931 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
|
932 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
933 int i; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
934 static struct |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
935 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
936 char *name; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
937 FARPROC *ptr; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
938 } winpty_entry[] = |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
939 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
940 {"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
|
941 {"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
|
942 {"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
|
943 {"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
|
944 {"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
|
945 {"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
|
946 {"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
|
947 {"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
|
948 {"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
|
949 {"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
|
950 {"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
|
951 {"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
|
952 {"winpty_error_msg", (FARPROC*)&winpty_error_msg}, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
953 {NULL, NULL} |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
954 }; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
955 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
956 /* 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
|
957 if (hWinPtyDLL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
958 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
959 /* 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
|
960 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
|
961 if (!hWinPtyDLL) |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
962 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
963 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
|
964 return 0; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
965 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
966 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
|
967 && 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
|
968 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
969 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
|
970 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
|
971 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
972 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
|
973 return 0; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
974 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
975 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
976 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
977 return 1; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
978 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
979 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
980 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
981 * 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
|
982 * 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
|
983 * 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
|
984 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
985 static int |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
986 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
|
987 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
988 WCHAR *p = enc_to_utf16(cmd, NULL); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
989 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
|
990 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
|
991 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
|
992 DWORD error; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
993 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
|
994 void *winpty_err; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
995 void *spawn_config; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
996 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
997 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
|
998 return FAIL; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
999 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1000 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
|
1001 return FAIL; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1002 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1003 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
|
1004 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
|
1005 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1006 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1007 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
|
1008 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
|
1009 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1010 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1011 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
|
1012 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
|
1013 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1014 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1015 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
|
1016 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
|
1017 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
|
1018 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1019 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1020 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
|
1021 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
|
1022 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
|
1023 NULL, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1024 p, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1025 NULL, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1026 NULL, |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1027 &winpty_err); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1028 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
|
1029 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1030 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1031 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
|
1032 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
|
1033 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1034 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1035 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
|
1036 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
|
1037 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1038 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1039 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
|
1040 &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
|
1041 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1042 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1043 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
|
1044 (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
|
1045 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
|
1046 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
|
1047 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
|
1048 (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
|
1049 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
|
1050 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
|
1051 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
|
1052 (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
|
1053 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
|
1054 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
|
1055 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
|
1056 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1057 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
|
1058 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
|
1059 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1060 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1061 if (!AssignProcessToJobObject(jo, 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
|
1062 goto failed; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1063 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1064 winpty_spawn_config_free(spawn_config); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1065 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1066 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
|
1067 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1068 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
|
1069 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
|
1070 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1071 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
|
1072 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
|
1073 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
|
1074 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
|
1075 job->jv_status = JOB_STARTED; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1076 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
|
1077 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1078 return OK; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1079 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1080 failed: |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1081 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
|
1082 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
|
1083 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
|
1084 job_cleanup(job); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1085 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
|
1086 CloseHandle(jo); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1087 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
|
1088 winpty_free(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
|
1089 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
|
1090 winpty_config_free(term->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
|
1091 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
|
1092 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1093 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
|
1094 (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
|
1095 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1096 EMSG(msg); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1097 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
|
1098 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1099 return FAIL; |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1100 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1101 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1102 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1103 * 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
|
1104 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1105 static void |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1106 term_free(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
|
1107 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1108 winpty_free(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
|
1109 winpty_config_free(term->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
|
1110 vterm_free(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
|
1111 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1112 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1113 # else |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1114 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1115 /************************************** |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1116 * 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
|
1117 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1118 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1119 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1120 * 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
|
1121 * 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
|
1122 * 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
|
1123 * 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
|
1124 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1125 static int |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1126 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
|
1127 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1128 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
|
1129 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
|
1130 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1131 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
|
1132 |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1133 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
|
1134 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
|
1135 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
|
1136 term->tl_job = job_start(argvars, &opt); |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1137 |
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
|
1138 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
|
1139 && 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
|
1140 && 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
|
1141 } |
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 /* |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1144 * 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
|
1145 */ |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1146 static void |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1147 term_free(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
|
1148 { |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1149 vterm_free(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
|
1150 } |
13ecb3e64399
patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11715
diff
changeset
|
1151 # endif |
11694
8f5840a59b31
patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents:
11690
diff
changeset
|
1152 |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1153 #endif /* FEAT_TERMINAL */ |