summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0049
blob: 79dfbe23ae6cbe1f110ea73f644ce59c0933770e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0049
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0049
Problem:    Shell cannot tell running in a terminal window.
Solution:   Add the VIM_TERMINAL environment variable. (Christian Brabandt)
Files:	    runtime/doc/terminal.txt, src/os_unix.c, src/os_win32.c,
            src/testdir/test_terminal.vim


*** ../vim-8.1.0048/runtime/doc/terminal.txt	2018-05-17 14:49:10.000000000 +0200
--- runtime/doc/terminal.txt	2018-06-12 17:43:50.152692460 +0200
***************
*** 204,210 ****
  			++rows={height} Use {height} for the terminal window
  					height.  If the terminal uses the full
  					Vim height (no window above or below
! 					th terminal window) the command line
  					height will be reduced as needed.
  			++cols={width}  Use {width} for the terminal window
  					width. If the terminal uses the full
--- 204,210 ----
  			++rows={height} Use {height} for the terminal window
  					height.  If the terminal uses the full
  					Vim height (no window above or below
! 					the terminal window) the command line
  					height will be reduced as needed.
  			++cols={width}  Use {width} for the terminal window
  					width. If the terminal uses the full
***************
*** 243,249 ****
  You can use `CTRL-W :hide` to close the terminal window and make the buffer
  hidden, the job keeps running.  The `:buffer` command can be used to turn the
  current window into a terminal window.  If there are unsaved changes this
! fails, use !  to force, as usual.
  
  To have a background job run without a window, and open the window when it's
  done, use options like this: >
--- 243,249 ----
  You can use `CTRL-W :hide` to close the terminal window and make the buffer
  hidden, the job keeps running.  The `:buffer` command can be used to turn the
  current window into a terminal window.  If there are unsaved changes this
! fails, use ! to force, as usual.
  
  To have a background job run without a window, and open the window when it's
  done, use options like this: >
***************
*** 376,381 ****
--- 376,382 ----
      COLUMNS		number of columns in the terminal initially
      COLORS		number of colors, 't_Co' (256*256*256 in the GUI)
      VIM_SERVERNAME	v:servername
+     VIM_TERMINAL	v:version
  
  
  MS-Windows ~
*** ../vim-8.1.0048/src/os_unix.c	2018-05-12 17:42:33.000000000 +0200
--- src/os_unix.c	2018-06-12 17:58:42.928059243 +0200
***************
*** 4169,4174 ****
--- 4169,4175 ----
      static char	envbuf_Lines[20];
      static char	envbuf_Columns[20];
      static char	envbuf_Colors[20];
+     static char	envbuf_Version[20];
  #  ifdef FEAT_CLIENTSERVER
      static char	envbuf_Servername[60];
  #  endif
***************
*** 4189,4194 ****
--- 4190,4197 ----
      setenv("COLUMNS", (char *)envbuf, 1);
      sprintf((char *)envbuf, "%ld", colors);
      setenv("COLORS", (char *)envbuf, 1);
+     sprintf((char *)envbuf, "%ld",  get_vim_var_nr(VV_VERSION));
+     setenv("VIM_TERMINAL", (char *)envbuf, 1);
  #  ifdef FEAT_CLIENTSERVER
      setenv("VIM_SERVERNAME", serverName == NULL ? "" : (char *)serverName, 1);
  #  endif
***************
*** 4209,4214 ****
--- 4212,4220 ----
      putenv(envbuf_Columns);
      vim_snprintf(envbuf_Colors, sizeof(envbuf_Colors), "COLORS=%ld", colors);
      putenv(envbuf_Colors);
+     vim_snprintf(envbuf_Version, sizeof(envbuf_Version), "VIM_TERMINAL=%ld",
+ 						   get_vim_var_nr(VV_VERSION));
+     putenv(envbuf_Version);
  #  ifdef FEAT_CLIENTSERVER
      vim_snprintf(envbuf_Servername, sizeof(envbuf_Servername),
  	    "VIM_SERVERNAME=%s", serverName == NULL ? "" : (char *)serverName);
*** ../vim-8.1.0048/src/os_win32.c	2018-05-06 17:05:39.000000000 +0200
--- src/os_win32.c	2018-06-12 18:00:28.031513685 +0200
***************
*** 5275,5299 ****
  	}
      }
  
- # ifdef FEAT_CLIENTSERVER
      if (is_terminal)
      {
  	char_u	*servername = get_vim_var_str(VV_SEND_SERVER);
! 	size_t	lval = STRLEN(servername);
! 	size_t	n;
  
! 	if (ga_grow(gap, (int)(14 + lval + 2)) == OK)
  	{
  	    for (n = 0; n < 15; n++)
  		*((WCHAR*)gap->ga_data + gap->ga_len++) =
  		    (WCHAR)"VIM_SERVERNAME="[n];
! 	    for (n = 0; n < lval; n++)
  		*((WCHAR*)gap->ga_data + gap->ga_len++) =
  		    (WCHAR)servername[n];
  	    *((WCHAR*)gap->ga_data + gap->ga_len++) = L'\0';
  	}
      }
- # endif
  }
  
      void
--- 5275,5317 ----
  	}
      }
  
      if (is_terminal)
      {
+ # ifdef FEAT_CLIENTSERVER
  	char_u	*servername = get_vim_var_str(VV_SEND_SERVER);
! 	size_t	servername_len = STRLEN(servername);
! # endif
! 	char_u	*version = get_vim_var_str(VV_VERSION);
! 	size_t	version_len = STRLEN(version);
! 	// size of "VIM_SERVERNAME=" and value,
! 	// plus "VIM_TERMINAL=" and value,
! 	// plus two terminating NULs
! 	size_t	n = 0
! # ifdef FEAT_CLIENTSERVER
! 		    + 15 + servername_len
! # endif
! 		    + 13 + version_len + 2;
  
! 	if (ga_grow(gap, (int)n) == OK)
  	{
+ # ifdef FEAT_CLIENTSERVER
  	    for (n = 0; n < 15; n++)
  		*((WCHAR*)gap->ga_data + gap->ga_len++) =
  		    (WCHAR)"VIM_SERVERNAME="[n];
! 	    for (n = 0; n < servername_len; n++)
  		*((WCHAR*)gap->ga_data + gap->ga_len++) =
  		    (WCHAR)servername[n];
  	    *((WCHAR*)gap->ga_data + gap->ga_len++) = L'\0';
+ # endif
+ 	    for (n = 0; n < 13; n++)
+ 		*((WCHAR*)gap->ga_data + gap->ga_len++) =
+ 		    (WCHAR)"VIM_TERMINAL="[n];
+ 	    for (n = 0; n < version_len; n++)
+ 		*((WCHAR*)gap->ga_data + gap->ga_len++) =
+ 		    (WCHAR)version[n];
+ 	    *((WCHAR*)gap->ga_data + gap->ga_len++) = L'\0';
  	}
      }
  }
  
      void
*** ../vim-8.1.0048/src/testdir/test_terminal.vim	2018-06-03 18:21:57.809890160 +0200
--- src/testdir/test_terminal.vim	2018-06-12 18:01:49.195092385 +0200
***************
*** 482,499 ****
    if !has('clientserver')
      return
    endif
    let buf = Run_shell_in_terminal({})
    " Wait for the shell to display a prompt
    call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
    if has('win32')
!     call term_sendkeys(buf, "echo %VIM_SERVERNAME%\r")
    else
!     call term_sendkeys(buf, "echo $VIM_SERVERNAME\r")
    endif
    call term_wait(buf)
    call Stop_shell_in_terminal(buf)
!   call WaitFor('getline(2) == v:servername')
!   call assert_equal(v:servername, getline(2))
  
    exe buf . 'bwipe'
    unlet buf
--- 482,506 ----
    if !has('clientserver')
      return
    endif
+   call s:test_environment("VIM_SERVERNAME", v:servername)
+ endfunc
+ 
+ func Test_terminal_version()
+   call s:test_environment("VIM_TERMINAL", string(v:version))
+ endfunc
+ 
+ func s:test_environment(name, value)
    let buf = Run_shell_in_terminal({})
    " Wait for the shell to display a prompt
    call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
    if has('win32')
!     call term_sendkeys(buf, "echo %" . a:name . "%\r")
    else
!     call term_sendkeys(buf, "echo $" . a:name . "\r")
    endif
    call term_wait(buf)
    call Stop_shell_in_terminal(buf)
!   call WaitForAssert({-> assert_equal(a:value, getline(2))})
  
    exe buf . 'bwipe'
    unlet buf
*** ../vim-8.1.0048/src/version.c	2018-06-12 17:25:32.054404315 +0200
--- src/version.c	2018-06-12 18:03:17.778632563 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     49,
  /**/

-- 
On the other hand, you have different fingers.
                                      -- Steven Wright

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///