annotate src/terminal.c @ 11751:a1815c4f8b70 v8.0.0758

patch 8.0.0758: possible crash when using a terminal window commit https://github.com/vim/vim/commit/cdeae99b4ef4d359e4388a72c6d35f9343ce578a Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 23 17:22:35 2017 +0200 patch 8.0.0758: possible crash when using a terminal window Problem: Possible crash when using a terminal window. Solution: Check for NULL pointers. (Yasuhiro Matsumoto, closes https://github.com/vim/vim/issues/1864)
author Christian Brabandt <cb@256bit.org>
date Sun, 23 Jul 2017 17:30:05 +0200
parents 5a5709918a98
children f7c2473796b7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 'termguicolors'
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
37 * - cursor flickers when moving the cursor
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 * - 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
39 * - 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
40 * - 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
41 * 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
42 * - 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
43 * - 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
44 * - 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
45 * - 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
46 * - 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
47 * 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
48 * - 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
49 * - 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
50 * - 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
51 * - 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
52 * - 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
53 * - 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
54 * - 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
55 * - 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
56 * terminal.
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 * - 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
58 * - 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
59 * - implement term_getsize(buf)
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
60 * - implement term_setsize(buf)
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
61 * - 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
62 * - 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
63 * - 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
64 * - 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
65 * - 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
66 * - 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
67 * - 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
68 * conversions.
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 */
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 #include "vim.h"
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 #ifdef FEAT_TERMINAL
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74
11694
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
75 #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
76 # 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
77 # 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
78 #endif
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
80 #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
81
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 /* typedef term_T in structs.h */
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 struct terminal_S {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 term_T *tl_next;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85
11694
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
86 #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
87 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
88 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
89 #endif
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 VTerm *tl_vterm;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 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
92 buf_T *tl_buffer;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
94 /* 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
95 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
96 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
97 /* 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
98 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
99 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
100
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 /* 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
102 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
103 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
104
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 pos_T tl_cursor;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 };
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 * List of all active terminals.
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 */
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 static term_T *first_term = NULL;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
113
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
114 #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
115 #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
116
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 * 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
119 */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
120 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
121 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
122
11694
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
123 /**************************************
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
124 * 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
125 */
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 /*
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
128 * 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
129 * 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
130 */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
131 static void
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
132 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
133 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
134 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
135 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
136 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
137
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
138 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
139 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
140 }
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
141 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
142 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
143 else
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
144 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
145 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
146 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
147 }
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
148 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
149 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
150 else
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
151 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
152 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
153 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
154 }
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 /*
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 * ":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
159 */
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 void
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 ex_terminal(exarg_T *eap)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 exarg_T split_ea;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 win_T *old_curwin = curwin;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 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
166 char_u *cmd = eap->arg;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 if (check_restricted() || check_secure())
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 return;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 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
172 if (term == NULL)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173 return;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 term->tl_dirty_row_end = MAX_ROW;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 /* Open a new window or tab. */
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 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
178 split_ea.cmdidx = CMD_new;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 split_ea.cmd = (char_u *)"new";
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 split_ea.arg = (char_u *)"";
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 ex_splitview(&split_ea);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 if (curwin == old_curwin)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 /* split failed */
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 vim_free(term);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 return;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 }
11670
3b2afa2b77b3 patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents: 11668
diff changeset
188 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
189 curbuf->b_term = term;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
191 /* 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
192 term->tl_next = first_term;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193 first_term = term;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195 /* TODO: set buffer type, hidden, etc. */
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
196
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
197 set_term_and_win_size(term);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
198
11729
1c8ec1029233 patch 8.0.0747: :terminal without an argument doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11727
diff changeset
199 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
200 cmd = p_sh;
1c8ec1029233 patch 8.0.0747: :terminal without an argument doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11727
diff changeset
201
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
202 /* 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
203 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
204 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
205 /* 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
206 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
207 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208 else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209 {
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
210 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
211 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
212
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
213 /* 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
214 * free_terminal(). */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
215 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
216 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217
11694
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
218 /* 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
219 }
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 /*
11690
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
222 * 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
223 * 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
224 * 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
225 */
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
226 void
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
227 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
228 {
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
229 term_T *tp;
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
230
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
231 if (term == NULL)
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
232 return;
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
233 if (first_term == term)
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
234 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
235 else
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
236 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
237 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
238 {
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
239 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
240 break;
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
241 }
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 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
244 {
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
245 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
246 && 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
247 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
248 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
249 }
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
250
11694
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
251 term_free(term);
11690
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
252 vim_free(term);
ce434212d682 patch 8.0.0728: the terminal structure is never freed
Christian Brabandt <cb@256bit.org>
parents: 11684
diff changeset
253 }
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 /*
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
256 * 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
257 */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
258 static void
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
259 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
260 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
261 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
262 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
263 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
264 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
265
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
266 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
267 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
268 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
269 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
270 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
271 break;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
272 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
273 }
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
274 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
275 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
276 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
277 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
278 /* 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
279 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
280 ++len_now;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
281 }
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 /* 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
285 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
286 }
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 /*
11670
3b2afa2b77b3 patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents: 11668
diff changeset
289 * 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
290 * of "buffer".
3b2afa2b77b3 patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents: 11668
diff changeset
291 */
3b2afa2b77b3 patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents: 11668
diff changeset
292 void
3b2afa2b77b3 patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents: 11668
diff changeset
293 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
294 {
3b2afa2b77b3 patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents: 11668
diff changeset
295 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
296 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
297
3b2afa2b77b3 patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents: 11668
diff changeset
298 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
299 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
300
3b2afa2b77b3 patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents: 11668
diff changeset
301 /* 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
302 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
303 setcursor();
3b2afa2b77b3 patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents: 11668
diff changeset
304 out_flush();
3b2afa2b77b3 patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents: 11668
diff changeset
305 }
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
306
11670
3b2afa2b77b3 patch 8.0.0718: output of job in terminal is not displayed
Christian Brabandt <cb@256bit.org>
parents: 11668
diff changeset
307 /*
11694
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
308 * 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
309 * 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
310 */
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
311 static int
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
312 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
313 {
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
314 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
315 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
316 VTermModifier mod = VTERM_MOD_NONE;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
317
11694
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
318 switch (c)
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
319 {
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
320 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
321 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
322 /* 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
323 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
324 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
325 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
326 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
327 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
328 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
329 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
330 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
331 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
332 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
333 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
334 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
335 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
336 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
337 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
338 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
339 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
340 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
341 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
342 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
343 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
344 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
345 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
346 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
347 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
348 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
349 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
350 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
351 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
352 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
353 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
354 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
355 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
356 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
357 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
358 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
359 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
360 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
361 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
362 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
363 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
364 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
365 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
366 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
367 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
368 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
369
dac96f8800be patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11694
diff changeset
370 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
371 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
372 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
373 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
374
dac96f8800be patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11694
diff changeset
375 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
376 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
377 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
378 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
379 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
380 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
381 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
382 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
383 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
384 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
385 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
386 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
387 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
388 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
389 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
390 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
391 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
392
dac96f8800be patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11694
diff changeset
393 /* 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
394 * 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
395 }
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 * 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
399 * - 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
400 * - 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
401 */
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
402 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
403 /* 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
404 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
405 else
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
406 /* 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
407 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
408
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
409 /* 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
410 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
411 }
11684
1ce1376fbbf8 patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents: 11670
diff changeset
412
1ce1376fbbf8 patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents: 11670
diff changeset
413 /*
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
414 * 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
415 * 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
416 * 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
417 */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
418 void
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
419 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
420 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
421 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
422 int c;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
423 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
424 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
425 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
426
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
427 for (;;)
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
428 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
429 /* 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
430 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
431 setcursor();
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
432 out_flush();
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
433 ++no_mapping;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
434 ++allow_keys;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
435 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
436 c = vgetc();
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
437 --no_mapping;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
438 --allow_keys;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
439
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
440 /* 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
441 switch (c)
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
442 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
443 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
444 case NUL:
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
445 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
446 stuffcharReadbuff(c);
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
447 return;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
448
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
449 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
450
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
451 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
452 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
453 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
454 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
455 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
456 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
457 /* FALLTHROUGH */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
458 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
459 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
460 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
461 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
462 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
463 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
464 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
465 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
466 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
467 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
468 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
469 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
470 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
471 || 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
472 || 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
473 || 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
474 || dragging_outside)
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
475 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
476 /* 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
477 stuffcharReadbuff(c);
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
478 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
479 return;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
480 }
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 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
483
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
484 /* 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
485 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
486 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
487 /* 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
488 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
489 (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
490 }
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 static void
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
494 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
495 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
496 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
497 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
498 }
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 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
501 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
502 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
503 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
504
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
505 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
506 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
507 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
508 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
509 NULL, /* settermprop */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
510 NULL, /* bell */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
511 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
512 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
513 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
514 };
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 static int
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
517 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
518 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
519 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
520
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
521 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
522 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
523 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
524 return 1;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
525 }
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 static int
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
528 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
529 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
530 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
531
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
532 /* TODO */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
533 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
534 return 1;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
535 }
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 static int
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
538 handle_movecursor(
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
539 VTermPos pos,
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
540 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
541 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
542 void *user)
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
543 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
544 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
545 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
546 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
547
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
548 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
549 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
550 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
551 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
552 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
553 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
554 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
555 }
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 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
559 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
560 setcursor();
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
561 out_flush();
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
562 }
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 return 1;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
565 }
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 * 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
569 */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
570 static int
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
571 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
572 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
573 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
574 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
575
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
576 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
577 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
578 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
579 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
580 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
581 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
582 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
583 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
584 }
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 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
588 return 1;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
589 }
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 /*
11743
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
592 * 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
593 * 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
594 */
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
595 static int
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
596 color2index(VTermColor *color)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
597 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
598 int red = color->red;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
599 int blue = color->blue;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
600 int green = color->green;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
601
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
602 if (red == 0)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
603 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
604 if (green == 0)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
605 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
606 if (blue == 0)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
607 return 1; /* black */
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
608 if (blue == 224)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
609 return 5; /* blue */
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
610 }
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
611 else if (green == 224)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
612 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
613 if (blue == 0)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
614 return 3; /* green */
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
615 if (blue == 224)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
616 return 7; /* cyan */
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
617 }
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 else if (red == 224)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
620 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
621 if (green == 0)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
622 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
623 if (blue == 0)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
624 return 2; /* red */
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
625 if (blue == 224)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
626 return 6; /* magenta */
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
627 }
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
628 else if (green == 224)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
629 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
630 if (blue == 0)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
631 return 4; /* yellow */
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
632 if (blue == 224)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
633 return 8; /* white */
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
634 }
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 else if (red == 128)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
637 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
638 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
639 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
640 }
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
641 else if (red == 255)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
642 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
643 if (green == 64)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
644 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
645 if (blue == 64)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
646 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
647 if (blue == 255)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
648 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
649 }
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
650 else if (green == 255)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
651 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
652 if (blue == 64)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
653 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
654 if (blue == 255)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
655 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
656 }
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 else if (red == 64)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
659 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
660 if (green == 64)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
661 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
662 if (blue == 255)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
663 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
664 }
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
665 else if (green == 255)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
666 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
667 if (blue == 64)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
668 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
669 if (blue == 255)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
670 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
671 }
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 if (t_colors >= 256)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
674 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
675 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
676 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
677 /* 24-color greyscale */
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
678 static int cutoff[23] = {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
679 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
680 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
681 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
682 int i;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
683
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
684 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
685 if (red < cutoff[i])
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
686 return i + 233;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
687 return 256;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
688 }
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 /* 216-color cube */
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
691 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
692 + ((green + 25) / 0x33) * 6
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
693 + (blue + 25) / 0x33;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
694 }
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
695 return 0;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
696 }
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 * 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
700 */
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
701 static int
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
702 cell2attr(VTermScreenCell *cell)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
703 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
704 int attr = 0;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
705
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
706 if (cell->attrs.bold)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
707 attr |= HL_BOLD;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
708 if (cell->attrs.underline)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
709 attr |= HL_UNDERLINE;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
710 if (cell->attrs.italic)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
711 attr |= HL_ITALIC;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
712 if (cell->attrs.strike)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
713 attr |= HL_STANDOUT;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
714 if (cell->attrs.reverse)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
715 attr |= HL_INVERSE;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
716 if (cell->attrs.strike)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
717 attr |= HL_UNDERLINE;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
718
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
719 #ifdef FEAT_GUI
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
720 if (gui.in_use)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
721 {
11745
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 11743
diff changeset
722 guicolor_T fg, bg;
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 11743
diff changeset
723
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 11743
diff changeset
724 fg = gui_mch_get_rgb_color(cell->fg.red, cell->fg.green, cell->fg.blue);
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 11743
diff changeset
725 bg = gui_mch_get_rgb_color(cell->bg.red, cell->bg.green, cell->bg.blue);
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 11743
diff changeset
726 return get_gui_attr_idx(attr, fg, bg);
11743
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
727 }
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
728 else
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
729 #endif
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
730 #ifdef FEAT_TERMGUICOLORS
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
731 if (p_tgc)
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
732 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
733 /* TODO */
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
734 }
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
735 #endif
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 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
738 color2index(&cell->bg));
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 return 0;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
741 }
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
742
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
743 /*
11694
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
744 * 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
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 void
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
747 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
748 {
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
749 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
750 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
751 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
752 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
753 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
754
11719
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 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
757 * 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
758 */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
759 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
760 || (!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
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 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
763 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
764
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 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
766 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
767 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
768
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 #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
770 /* 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
771 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
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 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
774 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
775
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 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
777 {
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 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
779 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
780 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
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 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
783 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
784 }
b4d8f956eb18 patch 8.0.0753: no size reports to a job running in a terminal
Christian Brabandt <cb@256bit.org>
parents: 11729
diff changeset
785 #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
786 }
11713
2ec27561dd76 patch 8.0.0739: terminal resizing doesn't work well.
Christian Brabandt <cb@256bit.org>
parents: 11711
diff changeset
787
2ec27561dd76 patch 8.0.0739: terminal resizing doesn't work well.
Christian Brabandt <cb@256bit.org>
parents: 11711
diff changeset
788 /* 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
789 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
790 position_cursor(wp, &pos);
2ec27561dd76 patch 8.0.0739: terminal resizing doesn't work well.
Christian Brabandt <cb@256bit.org>
parents: 11711
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 /* 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
793 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
794 {
11694
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
795 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
796 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
797
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
798 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
799 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
800 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
801 {
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
802 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
803 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
804
11743
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
805 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
806 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
807
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
808 /* 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
809 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
810 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
811 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
812 ScreenLines[off] = ' ';
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
813 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
814 }
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
815 else
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
816 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
817 #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
818 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
819 {
22cef8face93 patch 8.0.0745: multi-byte characters in a terminal don't display well
Christian Brabandt <cb@256bit.org>
parents: 11723
diff changeset
820 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
821 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
822 }
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
823 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
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 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
826 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
827 }
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
828 #else
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
829 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
830 #endif
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
831 }
11743
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
832 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
833
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
834 ++pos.col;
11694
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
835 ++off;
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
836 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
837 {
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
838 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
839 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
840 ++pos.col;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
841 ++off;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
842 }
11694
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
843 }
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
844 }
11711
dac96f8800be patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11694
diff changeset
845 else
dac96f8800be patch 8.0.0738: cannot use the mouse to resize a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11694
diff changeset
846 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
847
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
848 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
849 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
850 }
1ce1376fbbf8 patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents: 11670
diff changeset
851 }
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
852
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
853 /*
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
854 * 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
855 */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
856 static void
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
857 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
858 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
859 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
860 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
861 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
862 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
863 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
864 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
865 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
866 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
867 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
868 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
869 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
870 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
871 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
872 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
873 }
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 /*
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
876 * 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
877 */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
878 static void
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
879 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
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;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
882 VTermScreen *screen;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
883
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
884 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
885 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
886 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
887 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
888 /* 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
889 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
890
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
891 /* 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
892 * 'background' is "light". */
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
893 if (*p_bg == 'l')
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
894 {
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
895 VTermColor fg, bg;
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
896
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
897 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
898 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
899 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
900 }
6141a21dd232 patch 8.0.0754: terminal window does not support colors
Christian Brabandt <cb@256bit.org>
parents: 11741
diff changeset
901
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
902 /* 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
903 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
904 }
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
905
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
906 # ifdef WIN3264
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 #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
909 #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
910
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
911 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
912 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
913 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
914 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
915 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
916 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
917 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
918 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
919 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
920 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
921 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
922 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
923 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
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 * 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
927 */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
928
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
929 #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
930
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
931 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
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
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
934 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
935 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
936 int i;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
937 static struct
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
938 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
939 char *name;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
940 FARPROC *ptr;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
941 } winpty_entry[] =
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
942 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
943 {"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
944 {"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
945 {"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
946 {"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
947 {"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
948 {"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
949 {"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
950 {"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
951 {"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
952 {"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
953 {"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
954 {"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
955 {"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
956 {NULL, NULL}
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
957 };
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
958
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
959 /* 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
960 if (hWinPtyDLL)
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
961 return 1;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
962 /* 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
963 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
964 if (!hWinPtyDLL)
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 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
967 return 0;
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 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
970 && 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
971 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
972 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
973 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
974 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
975 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
976 return 0;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
977 }
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 return 1;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
981 }
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
982
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
983 /*
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
984 * 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
985 * 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
986 * 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
987 */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
988 static int
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
989 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
990 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
991 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
992 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
993 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
994 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
995 DWORD error;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
996 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
997 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
998 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
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 (!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
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 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
1004 return FAIL;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1005
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1006 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
1007 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
1008 goto failed;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1009
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1010 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
1011 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
1012 goto failed;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1013
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1014 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
1015 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
1016 goto failed;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1017
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1018 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
1019 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
1020 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
1021 goto failed;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1022
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1023 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
1024 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
1025 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
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 p,
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1028 NULL,
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1029 NULL,
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1030 &winpty_err);
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1031 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
1032 goto failed;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1033
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1034 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
1035 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
1036 goto failed;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1037
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1038 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
1039 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
1040 goto failed;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1041
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1042 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
1043 &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
1044 goto failed;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1045
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1046 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
1047 (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
1048 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
1049 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
1050 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
1051 (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
1052 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
1053 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
1054 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
1055 (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
1056 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
1057 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
1058 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
1059
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1060 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
1061 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
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 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
1065 goto failed;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1066
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1067 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
1068
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1069 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
1070
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1071 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
1072 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
1073
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_channel = channel;
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_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
1076 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
1077 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
1078 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
1079 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
1080
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1081 return OK;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1082
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1083 failed:
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1084 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
1085 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
1086 if (job != NULL)
11751
a1815c4f8b70 patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
1087 {
a1815c4f8b70 patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
1088 job->jv_channel = NULL;
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1089 job_cleanup(job);
11751
a1815c4f8b70 patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
1090 }
a1815c4f8b70 patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
1091 term->tl_job = NULL;
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1092 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
1093 CloseHandle(jo);
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1094 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
1095 winpty_free(term->tl_winpty);
11751
a1815c4f8b70 patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
1096 term->tl_winpty = NULL;
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1097 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
1098 winpty_config_free(term->tl_winpty_config);
11751
a1815c4f8b70 patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
1099 term->tl_winpty_config = NULL;
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1100 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
1101 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1102 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
1103 (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
1104
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1105 EMSG(msg);
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1106 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
1107 }
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1108 return FAIL;
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1109 }
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1110
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 * 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
1113 */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1114 static void
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1115 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
1116 {
11751
a1815c4f8b70 patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
1117 if (term->tl_winpty != NULL)
a1815c4f8b70 patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
1118 winpty_free(term->tl_winpty);
a1815c4f8b70 patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
1119 if (term->tl_winpty_config != NULL)
a1815c4f8b70 patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
1120 winpty_config_free(term->tl_winpty_config);
a1815c4f8b70 patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
1121 if (term->tl_vterm != NULL)
a1815c4f8b70 patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
1122 vterm_free(term->tl_vterm);
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1123 }
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 # else
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1126
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 * 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
1129 */
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 /*
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1132 * 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
1133 * 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
1134 * 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
1135 * 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
1136 */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1137 static int
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1138 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
1139 {
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1140 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
1141 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
1142
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1143 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
1144
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1145 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
1146 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
1147 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
1148 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
1149
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
1150 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
1151 && 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
1152 && 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
1153 }
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1154
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1155 /*
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1156 * 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
1157 */
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1158 static void
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1159 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
1160 {
11751
a1815c4f8b70 patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
1161 if (term->tl_vterm != NULL)
a1815c4f8b70 patch 8.0.0758: possible crash when using a terminal window
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
1162 vterm_free(term->tl_vterm);
11719
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1163 }
13ecb3e64399 patch 8.0.0742: terminal feature does not work on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11715
diff changeset
1164 # endif
11694
8f5840a59b31 patch 8.0.0730: terminal feature only supports Unix-like systems
Christian Brabandt <cb@256bit.org>
parents: 11690
diff changeset
1165
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1166 #endif /* FEAT_TERMINAL */