lkundrak / rpms / vim

Forked from rpms/vim 4 years ago
Clone
c7dbd35
To: vim_dev@googlegroups.com
c7dbd35
Subject: Patch 7.4.137
c7dbd35
Fcc: outbox
c7dbd35
From: Bram Moolenaar <Bram@moolenaar.net>
c7dbd35
Mime-Version: 1.0
c7dbd35
Content-Type: text/plain; charset=UTF-8
c7dbd35
Content-Transfer-Encoding: 8bit
c7dbd35
------------
c7dbd35
c7dbd35
Patch 7.4.137
c7dbd35
Problem:    Cannot use IME with Windows 8 console.
c7dbd35
Solution:   Change the user of ReadConsoleInput() and PeekConsoleInput().
c7dbd35
	    (Nobuhiro Takasaki)
c7dbd35
Files:	    src/os_win32.c
c7dbd35
c7dbd35
c7dbd35
*** ../vim-7.4.136/src/os_win32.c	2014-01-10 13:05:12.000000000 +0100
c7dbd35
--- src/os_win32.c	2014-01-10 13:42:19.000000000 +0100
c7dbd35
***************
c7dbd35
*** 232,237 ****
c7dbd35
--- 232,306 ----
c7dbd35
  
c7dbd35
  static char_u *exe_path = NULL;
c7dbd35
  
c7dbd35
+ /*
c7dbd35
+  * Version of ReadConsoleInput() that works with IME.
c7dbd35
+  */
c7dbd35
+     static BOOL
c7dbd35
+ read_console_input(
c7dbd35
+     HANDLE hConsoleInput,
c7dbd35
+     PINPUT_RECORD lpBuffer,
c7dbd35
+     DWORD nLength,
c7dbd35
+     LPDWORD lpNumberOfEventsRead)
c7dbd35
+ {
c7dbd35
+     enum
c7dbd35
+     {
c7dbd35
+ 	IRSIZE = 10, /* rough value */
c7dbd35
+     };
c7dbd35
+     static INPUT_RECORD irCache[IRSIZE];
c7dbd35
+     static DWORD s_dwIndex = 0;
c7dbd35
+     static DWORD s_dwMax = 0;
c7dbd35
+ 
c7dbd35
+     if (hConsoleInput == NULL || lpBuffer == NULL)
c7dbd35
+ 	return ReadConsoleInput(hConsoleInput, lpBuffer, nLength,
c7dbd35
+ 							lpNumberOfEventsRead);
c7dbd35
+ 
c7dbd35
+     if (nLength == -1)
c7dbd35
+     {
c7dbd35
+ 	if (s_dwMax == 0)
c7dbd35
+ 	{
c7dbd35
+ 	    PeekConsoleInput(hConsoleInput, lpBuffer, 1, lpNumberOfEventsRead);
c7dbd35
+ 	    if (*lpNumberOfEventsRead == 0)
c7dbd35
+ 		return FALSE;
c7dbd35
+ 	    ReadConsoleInput(hConsoleInput, irCache, IRSIZE, &s_dwMax);
c7dbd35
+ 	    s_dwIndex = 0;
c7dbd35
+ 	}
c7dbd35
+ 	((PINPUT_RECORD)lpBuffer)[0] = irCache[s_dwIndex];
c7dbd35
+ 	*lpNumberOfEventsRead = 1;
c7dbd35
+ 	return TRUE;
c7dbd35
+     }
c7dbd35
+ 
c7dbd35
+     if (s_dwMax == 0)
c7dbd35
+     {
c7dbd35
+ 	ReadConsoleInput(hConsoleInput, irCache, IRSIZE, &s_dwMax);
c7dbd35
+ 	s_dwIndex = 0;
c7dbd35
+ 	if (s_dwMax == 0)
c7dbd35
+ 	{
c7dbd35
+ 	    *lpNumberOfEventsRead = 0;
c7dbd35
+ 	    return FALSE;
c7dbd35
+ 	}
c7dbd35
+     }
c7dbd35
+ 
c7dbd35
+     ((PINPUT_RECORD)lpBuffer)[0] = irCache[s_dwIndex];
c7dbd35
+     if (++s_dwIndex == s_dwMax)
c7dbd35
+ 	s_dwMax = 0;
c7dbd35
+     *lpNumberOfEventsRead = 1;
c7dbd35
+     return TRUE;
c7dbd35
+ }
c7dbd35
+ 
c7dbd35
+ /*
c7dbd35
+  * Version of PeekConsoleInput() that works with IME.
c7dbd35
+  */
c7dbd35
+     static BOOL
c7dbd35
+ peek_console_input(
c7dbd35
+     HANDLE hConsoleInput,
c7dbd35
+     PINPUT_RECORD lpBuffer,
c7dbd35
+     DWORD nLength,
c7dbd35
+     LPDWORD lpNumberOfEventsRead)
c7dbd35
+ {
c7dbd35
+     return read_console_input(hConsoleInput, lpBuffer, -1,
c7dbd35
+ 							lpNumberOfEventsRead);
c7dbd35
+ }
c7dbd35
+ 
c7dbd35
      static void
c7dbd35
  get_exe_name(void)
c7dbd35
  {
c7dbd35
***************
c7dbd35
*** 1117,1123 ****
c7dbd35
  			INPUT_RECORD ir;
c7dbd35
  			MOUSE_EVENT_RECORD* pmer2 = &ir.Event.MouseEvent;
c7dbd35
  
c7dbd35
! 			PeekConsoleInput(g_hConIn, &ir, 1, &cRecords);
c7dbd35
  
c7dbd35
  			if (cRecords == 0 || ir.EventType != MOUSE_EVENT
c7dbd35
  				|| !(pmer2->dwButtonState & LEFT_RIGHT))
c7dbd35
--- 1186,1192 ----
c7dbd35
  			INPUT_RECORD ir;
c7dbd35
  			MOUSE_EVENT_RECORD* pmer2 = &ir.Event.MouseEvent;
c7dbd35
  
c7dbd35
! 			peek_console_input(g_hConIn, &ir, 1, &cRecords);
c7dbd35
  
c7dbd35
  			if (cRecords == 0 || ir.EventType != MOUSE_EVENT
c7dbd35
  				|| !(pmer2->dwButtonState & LEFT_RIGHT))
c7dbd35
***************
c7dbd35
*** 1126,1132 ****
c7dbd35
  			{
c7dbd35
  			    if (pmer2->dwEventFlags != MOUSE_MOVED)
c7dbd35
  			    {
c7dbd35
! 				ReadConsoleInput(g_hConIn, &ir, 1, &cRecords);
c7dbd35
  
c7dbd35
  				return decode_mouse_event(pmer2);
c7dbd35
  			    }
c7dbd35
--- 1195,1201 ----
c7dbd35
  			{
c7dbd35
  			    if (pmer2->dwEventFlags != MOUSE_MOVED)
c7dbd35
  			    {
c7dbd35
! 				read_console_input(g_hConIn, &ir, 1, &cRecords);
c7dbd35
  
c7dbd35
  				return decode_mouse_event(pmer2);
c7dbd35
  			    }
c7dbd35
***************
c7dbd35
*** 1134,1143 ****
c7dbd35
  				     s_yOldMouse == pmer2->dwMousePosition.Y)
c7dbd35
  			    {
c7dbd35
  				/* throw away spurious mouse move */
c7dbd35
! 				ReadConsoleInput(g_hConIn, &ir, 1, &cRecords);
c7dbd35
  
c7dbd35
  				/* are there any more mouse events in queue? */
c7dbd35
! 				PeekConsoleInput(g_hConIn, &ir, 1, &cRecords);
c7dbd35
  
c7dbd35
  				if (cRecords==0 || ir.EventType != MOUSE_EVENT)
c7dbd35
  				    break;
c7dbd35
--- 1203,1212 ----
c7dbd35
  				     s_yOldMouse == pmer2->dwMousePosition.Y)
c7dbd35
  			    {
c7dbd35
  				/* throw away spurious mouse move */
c7dbd35
! 				read_console_input(g_hConIn, &ir, 1, &cRecords);
c7dbd35
  
c7dbd35
  				/* are there any more mouse events in queue? */
c7dbd35
! 				peek_console_input(g_hConIn, &ir, 1, &cRecords);
c7dbd35
  
c7dbd35
  				if (cRecords==0 || ir.EventType != MOUSE_EVENT)
c7dbd35
  				    break;
c7dbd35
***************
c7dbd35
*** 1374,1380 ****
c7dbd35
  	}
c7dbd35
  
c7dbd35
  	cRecords = 0;
c7dbd35
! 	PeekConsoleInput(g_hConIn, &ir, 1, &cRecords);
c7dbd35
  
c7dbd35
  #ifdef FEAT_MBYTE_IME
c7dbd35
  	if (State & CMDLINE && msg_row == Rows - 1)
c7dbd35
--- 1443,1449 ----
c7dbd35
  	}
c7dbd35
  
c7dbd35
  	cRecords = 0;
c7dbd35
! 	peek_console_input(g_hConIn, &ir, 1, &cRecords);
c7dbd35
  
c7dbd35
  #ifdef FEAT_MBYTE_IME
c7dbd35
  	if (State & CMDLINE && msg_row == Rows - 1)
c7dbd35
***************
c7dbd35
*** 1405,1411 ****
c7dbd35
  		if (ir.Event.KeyEvent.uChar.UnicodeChar == 0
c7dbd35
  			&& ir.Event.KeyEvent.wVirtualKeyCode == 13)
c7dbd35
  		{
c7dbd35
! 		    ReadConsoleInput(g_hConIn, &ir, 1, &cRecords);
c7dbd35
  		    continue;
c7dbd35
  		}
c7dbd35
  #endif
c7dbd35
--- 1474,1480 ----
c7dbd35
  		if (ir.Event.KeyEvent.uChar.UnicodeChar == 0
c7dbd35
  			&& ir.Event.KeyEvent.wVirtualKeyCode == 13)
c7dbd35
  		{
c7dbd35
! 		    read_console_input(g_hConIn, &ir, 1, &cRecords);
c7dbd35
  		    continue;
c7dbd35
  		}
c7dbd35
  #endif
c7dbd35
***************
c7dbd35
*** 1414,1420 ****
c7dbd35
  		    return TRUE;
c7dbd35
  	    }
c7dbd35
  
c7dbd35
! 	    ReadConsoleInput(g_hConIn, &ir, 1, &cRecords);
c7dbd35
  
c7dbd35
  	    if (ir.EventType == FOCUS_EVENT)
c7dbd35
  		handle_focus_event(ir);
c7dbd35
--- 1483,1489 ----
c7dbd35
  		    return TRUE;
c7dbd35
  	    }
c7dbd35
  
c7dbd35
! 	    read_console_input(g_hConIn, &ir, 1, &cRecords);
c7dbd35
  
c7dbd35
  	    if (ir.EventType == FOCUS_EVENT)
c7dbd35
  		handle_focus_event(ir);
c7dbd35
***************
c7dbd35
*** 1484,1490 ****
c7dbd35
  	    return 0;
c7dbd35
  # endif
c7dbd35
  #endif
c7dbd35
! 	if (ReadConsoleInput(g_hConIn, &ir, 1, &cRecords) == 0)
c7dbd35
  	{
c7dbd35
  	    if (did_create_conin)
c7dbd35
  		read_error_exit();
c7dbd35
--- 1553,1559 ----
c7dbd35
  	    return 0;
c7dbd35
  # endif
c7dbd35
  #endif
c7dbd35
! 	if (read_console_input(g_hConIn, &ir, 1, &cRecords) == 0)
c7dbd35
  	{
c7dbd35
  	    if (did_create_conin)
c7dbd35
  		read_error_exit();
c7dbd35
*** ../vim-7.4.136/src/version.c	2014-01-10 13:05:12.000000000 +0100
c7dbd35
--- src/version.c	2014-01-10 13:42:34.000000000 +0100
c7dbd35
***************
c7dbd35
*** 740,741 ****
c7dbd35
--- 740,743 ----
c7dbd35
  {   /* Add new patch number below this line */
c7dbd35
+ /**/
c7dbd35
+     137,
c7dbd35
  /**/
c7dbd35
c7dbd35
-- 
c7dbd35
hundred-and-one symptoms of being an internet addict:
c7dbd35
131. You challenge authority and society by portnuking people
c7dbd35
c7dbd35
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
c7dbd35
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
c7dbd35
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
c7dbd35
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///