summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.137
blob: 4e685c1396e6d2158c10aa71b342b90d2eb8996c (plain) (blame)
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
238
239
To: vim_dev@googlegroups.com
Subject: Patch 7.4.137
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.137
Problem:    Cannot use IME with Windows 8 console.
Solution:   Change the user of ReadConsoleInput() and PeekConsoleInput().
	    (Nobuhiro Takasaki)
Files:	    src/os_win32.c


*** ../vim-7.4.136/src/os_win32.c	2014-01-10 13:05:12.000000000 +0100
--- src/os_win32.c	2014-01-10 13:42:19.000000000 +0100
***************
*** 232,237 ****
--- 232,306 ----
  
  static char_u *exe_path = NULL;
  
+ /*
+  * Version of ReadConsoleInput() that works with IME.
+  */
+     static BOOL
+ read_console_input(
+     HANDLE hConsoleInput,
+     PINPUT_RECORD lpBuffer,
+     DWORD nLength,
+     LPDWORD lpNumberOfEventsRead)
+ {
+     enum
+     {
+ 	IRSIZE = 10, /* rough value */
+     };
+     static INPUT_RECORD irCache[IRSIZE];
+     static DWORD s_dwIndex = 0;
+     static DWORD s_dwMax = 0;
+ 
+     if (hConsoleInput == NULL || lpBuffer == NULL)
+ 	return ReadConsoleInput(hConsoleInput, lpBuffer, nLength,
+ 							lpNumberOfEventsRead);
+ 
+     if (nLength == -1)
+     {
+ 	if (s_dwMax == 0)
+ 	{
+ 	    PeekConsoleInput(hConsoleInput, lpBuffer, 1, lpNumberOfEventsRead);
+ 	    if (*lpNumberOfEventsRead == 0)
+ 		return FALSE;
+ 	    ReadConsoleInput(hConsoleInput, irCache, IRSIZE, &s_dwMax);
+ 	    s_dwIndex = 0;
+ 	}
+ 	((PINPUT_RECORD)lpBuffer)[0] = irCache[s_dwIndex];
+ 	*lpNumberOfEventsRead = 1;
+ 	return TRUE;
+     }
+ 
+     if (s_dwMax == 0)
+     {
+ 	ReadConsoleInput(hConsoleInput, irCache, IRSIZE, &s_dwMax);
+ 	s_dwIndex = 0;
+ 	if (s_dwMax == 0)
+ 	{
+ 	    *lpNumberOfEventsRead = 0;
+ 	    return FALSE;
+ 	}
+     }
+ 
+     ((PINPUT_RECORD)lpBuffer)[0] = irCache[s_dwIndex];
+     if (++s_dwIndex == s_dwMax)
+ 	s_dwMax = 0;
+     *lpNumberOfEventsRead = 1;
+     return TRUE;
+ }
+ 
+ /*
+  * Version of PeekConsoleInput() that works with IME.
+  */
+     static BOOL
+ peek_console_input(
+     HANDLE hConsoleInput,
+     PINPUT_RECORD lpBuffer,
+     DWORD nLength,
+     LPDWORD lpNumberOfEventsRead)
+ {
+     return read_console_input(hConsoleInput, lpBuffer, -1,
+ 							lpNumberOfEventsRead);
+ }
+ 
      static void
  get_exe_name(void)
  {
***************
*** 1117,1123 ****
  			INPUT_RECORD ir;
  			MOUSE_EVENT_RECORD* pmer2 = &ir.Event.MouseEvent;
  
! 			PeekConsoleInput(g_hConIn, &ir, 1, &cRecords);
  
  			if (cRecords == 0 || ir.EventType != MOUSE_EVENT
  				|| !(pmer2->dwButtonState & LEFT_RIGHT))
--- 1186,1192 ----
  			INPUT_RECORD ir;
  			MOUSE_EVENT_RECORD* pmer2 = &ir.Event.MouseEvent;
  
! 			peek_console_input(g_hConIn, &ir, 1, &cRecords);
  
  			if (cRecords == 0 || ir.EventType != MOUSE_EVENT
  				|| !(pmer2->dwButtonState & LEFT_RIGHT))
***************
*** 1126,1132 ****
  			{
  			    if (pmer2->dwEventFlags != MOUSE_MOVED)
  			    {
! 				ReadConsoleInput(g_hConIn, &ir, 1, &cRecords);
  
  				return decode_mouse_event(pmer2);
  			    }
--- 1195,1201 ----
  			{
  			    if (pmer2->dwEventFlags != MOUSE_MOVED)
  			    {
! 				read_console_input(g_hConIn, &ir, 1, &cRecords);
  
  				return decode_mouse_event(pmer2);
  			    }
***************
*** 1134,1143 ****
  				     s_yOldMouse == pmer2->dwMousePosition.Y)
  			    {
  				/* throw away spurious mouse move */
! 				ReadConsoleInput(g_hConIn, &ir, 1, &cRecords);
  
  				/* are there any more mouse events in queue? */
! 				PeekConsoleInput(g_hConIn, &ir, 1, &cRecords);
  
  				if (cRecords==0 || ir.EventType != MOUSE_EVENT)
  				    break;
--- 1203,1212 ----
  				     s_yOldMouse == pmer2->dwMousePosition.Y)
  			    {
  				/* throw away spurious mouse move */
! 				read_console_input(g_hConIn, &ir, 1, &cRecords);
  
  				/* are there any more mouse events in queue? */
! 				peek_console_input(g_hConIn, &ir, 1, &cRecords);
  
  				if (cRecords==0 || ir.EventType != MOUSE_EVENT)
  				    break;
***************
*** 1374,1380 ****
  	}
  
  	cRecords = 0;
! 	PeekConsoleInput(g_hConIn, &ir, 1, &cRecords);
  
  #ifdef FEAT_MBYTE_IME
  	if (State & CMDLINE && msg_row == Rows - 1)
--- 1443,1449 ----
  	}
  
  	cRecords = 0;
! 	peek_console_input(g_hConIn, &ir, 1, &cRecords);
  
  #ifdef FEAT_MBYTE_IME
  	if (State & CMDLINE && msg_row == Rows - 1)
***************
*** 1405,1411 ****
  		if (ir.Event.KeyEvent.uChar.UnicodeChar == 0
  			&& ir.Event.KeyEvent.wVirtualKeyCode == 13)
  		{
! 		    ReadConsoleInput(g_hConIn, &ir, 1, &cRecords);
  		    continue;
  		}
  #endif
--- 1474,1480 ----
  		if (ir.Event.KeyEvent.uChar.UnicodeChar == 0
  			&& ir.Event.KeyEvent.wVirtualKeyCode == 13)
  		{
! 		    read_console_input(g_hConIn, &ir, 1, &cRecords);
  		    continue;
  		}
  #endif
***************
*** 1414,1420 ****
  		    return TRUE;
  	    }
  
! 	    ReadConsoleInput(g_hConIn, &ir, 1, &cRecords);
  
  	    if (ir.EventType == FOCUS_EVENT)
  		handle_focus_event(ir);
--- 1483,1489 ----
  		    return TRUE;
  	    }
  
! 	    read_console_input(g_hConIn, &ir, 1, &cRecords);
  
  	    if (ir.EventType == FOCUS_EVENT)
  		handle_focus_event(ir);
***************
*** 1484,1490 ****
  	    return 0;
  # endif
  #endif
! 	if (ReadConsoleInput(g_hConIn, &ir, 1, &cRecords) == 0)
  	{
  	    if (did_create_conin)
  		read_error_exit();
--- 1553,1559 ----
  	    return 0;
  # endif
  #endif
! 	if (read_console_input(g_hConIn, &ir, 1, &cRecords) == 0)
  	{
  	    if (did_create_conin)
  		read_error_exit();
*** ../vim-7.4.136/src/version.c	2014-01-10 13:05:12.000000000 +0100
--- src/version.c	2014-01-10 13:42:34.000000000 +0100
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     137,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
131. You challenge authority and society by portnuking people

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