summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0035
blob: 329d2c5280284d93d5c95be8da529e9ba4eb39d1 (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
237
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0035
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.0035
Problem:    Not easy to switch between prompt buffer and other windows.
Solution:   Accept CTRL-W commands in Insert mode.  Start and stop Insert mode
            as one would expect.
Files:	    src/edit.c, src/ex_docmd.c, src/structs.h, src/window.c


*** ../vim-8.1.0034/src/edit.c	2018-06-03 14:42:17.840505115 +0200
--- src/edit.c	2018-06-06 09:06:43.329569894 +0200
***************
*** 811,816 ****
--- 811,824 ----
  	    do
  	    {
  		c = safe_vgetc();
+ 
+ 		if (stop_insert_mode)
+ 		{
+ 		    // Insert mode ended, possibly from a callback.
+ 		    count = 0;
+ 		    nomove = TRUE;
+ 		    goto doESCkey;
+ 		}
  	    } while (c == K_IGNORE || c == K_NOP);
  
  	/* Don't want K_CURSORHOLD for the second key, e.g., after CTRL-V. */
***************
*** 1165,1170 ****
--- 1173,1190 ----
  	    break;
  
  	case Ctrl_W:	/* delete word before the cursor */
+ #ifdef FEAT_JOB_CHANNEL
+ 	    if (bt_prompt(curbuf) && (mod_mask & MOD_MASK_SHIFT) == 0)
+ 	    {
+ 		// In a prompt window CTRL-W is used for window commands.
+ 		// Use Shift-CTRL-W to delete a word.
+ 		stuffcharReadbuff(Ctrl_W);
+ 		restart_edit = 'i';
+ 		nomove = TRUE;
+ 		count = 0;
+ 		goto doESCkey;
+ 	    }
+ #endif
  	    did_backspace = ins_bs(c, BACKSPACE_WORD, &inserted_space);
  	    auto_format(FALSE, TRUE);
  	    break;
***************
*** 1869,1874 ****
--- 1889,1907 ----
  	coladvance((colnr_T)MAXCOL);
  	changed_bytes(curbuf->b_ml.ml_line_count, 0);
      }
+ 
+     // Insert always starts after the prompt, allow editing text after it.
+     if (Insstart_orig.lnum != curwin->w_cursor.lnum
+ 				   || Insstart_orig.col != (int)STRLEN(prompt))
+     {
+ 	Insstart.lnum = curwin->w_cursor.lnum;
+ 	Insstart.col = STRLEN(prompt);
+ 	Insstart_orig = Insstart;
+ 	Insstart_textlen = Insstart.col;
+ 	Insstart_blank_vcol = MAXCOL;
+ 	arrow_used = FALSE;
+     }
+ 
      if (cmdchar_todo == 'A')
  	coladvance((colnr_T)MAXCOL);
      if (cmdchar_todo == 'I' || curwin->w_cursor.col <= (int)STRLEN(prompt))
*** ../vim-8.1.0034/src/ex_docmd.c	2018-05-08 21:57:39.000000000 +0200
--- src/ex_docmd.c	2018-06-06 08:58:58.317930716 +0200
***************
*** 7341,7347 ****
  	{
  	    if (eap->addr_count == 0)
  		ex_win_close(eap->forceit, curwin, NULL);
! 	    else {
  		FOR_ALL_WINDOWS(win)
  		{
  		    winnr++;
--- 7341,7348 ----
  	{
  	    if (eap->addr_count == 0)
  		ex_win_close(eap->forceit, curwin, NULL);
! 	    else
! 	    {
  		FOR_ALL_WINDOWS(win)
  		{
  		    winnr++;
*** ../vim-8.1.0034/src/structs.h	2018-06-03 14:42:17.848505102 +0200
--- src/structs.h	2018-06-06 08:58:58.317930716 +0200
***************
*** 2360,2365 ****
--- 2360,2367 ----
      char_u	*b_prompt_text;	     // set by prompt_setprompt()
      char_u	*b_prompt_callback;  // set by prompt_setcallback()
      partial_T	*b_prompt_partial;   // set by prompt_setcallback()
+     int		b_prompt_insert;     // value for restart_edit when entering
+ 				     // a prompt buffer window.
  #endif
  #ifdef FEAT_MZSCHEME
      void	*b_mzscheme_ref; /* The MzScheme reference to this buffer */
*** ../vim-8.1.0034/src/window.c	2018-05-04 20:09:46.000000000 +0200
--- src/window.c	2018-06-06 08:58:58.321930713 +0200
***************
*** 2103,2108 ****
--- 2103,2131 ----
      }
  }
  
+ #ifdef FEAT_JOB_CHANNEL
+     static void
+ leaving_window(win_T *win)
+ {
+     // When leaving a prompt window stop Insert mode and perhaps restart
+     // it when entering that window again.
+     win->w_buffer->b_prompt_insert = restart_edit;
+     restart_edit = NUL;
+ 
+     // When leaving the window (or closing the window) was done from a
+     // callback we need to break out of the Insert mode loop.
+     if (State & INSERT)
+ 	stop_insert_mode = TRUE;
+ }
+ 
+     static void
+ entering_window(win_T *win)
+ {
+     // When entering the prompt window may restart Insert mode.
+     restart_edit = win->w_buffer->b_prompt_insert;
+ }
+ #endif
+ 
  /*
   * Close all windows for buffer "buf".
   */
***************
*** 2231,2236 ****
--- 2254,2262 ----
  	    if (h != tabline_height())
  		shell_new_rows();
  	}
+ #ifdef FEAT_JOB_CHANNEL
+ 	entering_window(curwin);
+ #endif
  	/* Since goto_tabpage_tp above did not trigger *Enter autocommands, do
  	 * that now. */
  	apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf);
***************
*** 2296,2301 ****
--- 2322,2330 ----
  
      if (win == curwin)
      {
+ #ifdef FEAT_JOB_CHANNEL
+ 	leaving_window(curwin);
+ #endif
  	/*
  	 * Guess which window is going to be the new current window.
  	 * This may change because of the autocommands (sigh).
***************
*** 3649,3654 ****
--- 3678,3686 ----
  	 * scrollbars.  Have to update them anyway. */
  	gui_may_update_scrollbars();
  #endif
+ #ifdef FEAT_JOB_CHANNEL
+ 	entering_window(curwin);
+ #endif
  
  	redraw_all_later(CLEAR);
  	apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf);
***************
*** 3822,3827 ****
--- 3854,3862 ----
  {
      tabpage_T	*tp = curtab;
  
+ #ifdef FEAT_JOB_CHANNEL
+     leaving_window(curwin);
+ #endif
      reset_VIsual_and_resel();	/* stop Visual mode */
      if (trigger_leave_autocmds)
      {
***************
*** 4318,4323 ****
--- 4353,4363 ----
      if (wp == curwin && !curwin_invalid)	/* nothing to do */
  	return;
  
+ #ifdef FEAT_JOB_CHANNEL
+     if (!curwin_invalid)
+ 	leaving_window(curwin);
+ #endif
+ 
      if (!curwin_invalid && trigger_leave_autocmds)
      {
  	/*
***************
*** 4389,4394 ****
--- 4429,4437 ----
  	shorten_fnames(TRUE);
      }
  
+ #ifdef FEAT_JOB_CHANNEL
+     entering_window(curwin);
+ #endif
      if (trigger_new_autocmds)
  	apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf);
      if (trigger_enter_autocmds)
*** ../vim-8.1.0034/src/version.c	2018-06-04 20:34:07.607373577 +0200
--- src/version.c	2018-06-06 09:01:35.521811501 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     35,
  /**/

-- 
How To Keep A Healthy Level Of Insanity:
12. Sing along at the opera.

 /// 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    ///