On 29/09/2018 10:50, Mike Williams wrote:
> On 25/09/2018 13:46, Mike Williams wrote:
>> Hi,
>>
>> Long term user, occasional poster.
>>
>> I occasionally use vim in powershell or cmd consoles.  I have just
>> noticed that numbers on the keypad don't work.  All the surrounding keys
>> work just fine, but the numbers don't.  With -u NONE -UNONE and NumLock
>> on I get a lead byte of 0xce followed by 0xda (for 0) through 0xfe (for
>> 9) - each digit is offset by 4 from the previous one.
>>
>> With NumLock off there are no buffer updates for the number keys and
>> decimal point but various types of cursor/display updates occur (life's
>> too short to investigate 11 distinct actions with non-obvious effects).
>> The remaining keypad keys continue to insert expected characters.
>>
>> I rebuild 8.1.0000 and the same happens there.  I could have sworn it
>> used to work.  A quick google doesn't turn up anything obvious (some
>> discussion of console/keypad issues and WSL a year ago or so).  Should
>> the keypad work in console vim?
> 
> Small light bulb moment.  As you all know I am sure with NumLock off the
> keypad acts as the cursor movement set.  That just leaves my question of
> should the number pad with NumLock on result in digits being added to
> the buffer?
> 
> Debugging the code in decode_key_event() I can see the keys being
> detected and handled as not being used with a modifier which results in
> mch_inchar() inserting K_NUL and an 8-bit character in the type ahead
> buffer.  In fact based on the VirtKeyMap table any of the listed keys
> (some with modifiers) that produce an 8-bit character ends up inserting
> a character sequence and not being detected as a special key press.
> 
> Removing the numbers from VirtKeyMap table -
> 
> diff --git a/src/os_win32.c b/src/os_win32.c
> --- a/src/os_win32.c
> +++ b/src/os_win32.c
> @@ -908,7 +908,7 @@ static const struct
>        { VK_SUBTRACT, TRUE,'J',   'J',    'J',    'J',    }, /* keyp '-' */
>     /* { VK_DIVIDE,   TRUE,'N',   'N',    'N',    'N',    },    keyp '/' */
>        { VK_MULTIPLY, TRUE,'7',   '7',    '7',    '7',    }, /* keyp '*' */
> -
> +#if 0
>        { VK_NUMPAD0,TRUE,  '\332',        '\333', '\334',     '\335', },
>        { VK_NUMPAD1,TRUE,  '\336',        '\337', '\340',     '\341', },
>        { VK_NUMPAD2,TRUE,  '\342',        '\343', '\344',     '\345', },
> @@ -920,7 +920,7 @@ static const struct
>        { VK_NUMPAD8,TRUE,  '\372',        '\373', '\374',     '\375', },
>        /* Sorry, out of number space! <negri>*/
>        { VK_NUMPAD9,TRUE,  '\376',        '\377', '\377',     '\367', },
> -
> +#endif
>    };
> 
> 
> gets me the number keys working with NumLock on, but I have no idea on
> the effect with modifiers yet.  I doubt this is the complete solution,
> but I don't know how the key handling works in VIM.  Anyone willing to
> pick this up or tell me what needs doing?

I believe have a fix for all this.  It was a combination of poor code 
and the change for 8.0.1371 which exposed it - chars with top bit set 
are negative (at least with MSVC) which causes the wrong path in newer 
code to be taken.  Converting the 8bit chars to positive integer 
constants appears to fix the issue and more - see attached diff against 
8.1.0450.

This does raise the longer term issue of should console handling still 
be emulating MS-DOS ANSI.SYS behaviour?  Native console key handling 
would remove the whole issue of key mapping - as noted in original code, 
there aren't enough values for all keys and combinations!

HTH - TTFN

Mike
-- 
Hell hath no fury like a vested interest masquerading as a moral principle.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/os_win32.c b/src/os_win32.c
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -861,49 +861,49 @@ static const struct
     { VK_F8,   TRUE,   'B',    '[',    'e',        'o', },
     { VK_F9,   TRUE,   'C',    '\\',   'f',        'p', },
     { VK_F10,  TRUE,   'D',    ']',    'g',        'q', },
-    { VK_F11,  TRUE,   '\205', '\207', '\211',     '\213', },
-    { VK_F12,  TRUE,   '\206', '\210', '\212',     '\214', },
-
-    { VK_HOME, TRUE,   'G',    '\302', 'w',        '\303', },
-    { VK_UP,   TRUE,   'H',    '\304', '\305',     '\306', },
-    { VK_PRIOR,        TRUE,   'I',    '\307', '\204',     '\310', }, /*PgUp*/
-    { VK_LEFT, TRUE,   'K',    '\311', 's',        '\312', },
-    { VK_RIGHT,        TRUE,   'M',    '\313', 't',        '\314', },
-    { VK_END,  TRUE,   'O',    '\315', 'u',        '\316', },
-    { VK_DOWN, TRUE,   'P',    '\317', '\320',     '\321', },
-    { VK_NEXT, TRUE,   'Q',    '\322', 'v',        '\323', }, /*PgDn*/
-    { VK_INSERT,TRUE,  'R',    '\324', '\325',     '\326', },
-    { VK_DELETE,TRUE,  'S',    '\327', '\330',     '\331', },
+    { VK_F11,  TRUE,   0x85,   0x87,   0x89,       0x8B, },
+    { VK_F12,  TRUE,   0x86,   0x88,   0x8a,       0x8c, },
+
+    { VK_HOME, TRUE,   'G',    0xc2,   'w',        0xc3, },
+    { VK_UP,   TRUE,   'H',    0xc4,   0xc5,       0xc6, },
+    { VK_PRIOR,        TRUE,   'I',    0xc7,   0x84,       0xc8, }, /*PgUp*/
+    { VK_LEFT, TRUE,   'K',    0xc9,   's',        0xca, },
+    { VK_RIGHT,        TRUE,   'M',    0xcb,   't',        0xcc, },
+    { VK_END,  TRUE,   'O',    0xcd,   'u',        0xce, },
+    { VK_DOWN, TRUE,   'P',    0xcf,   0xd0,       0xd1, },
+    { VK_NEXT, TRUE,   'Q',    0xd2,   'v',        0xd3, }, /*PgDn*/
+    { VK_INSERT,TRUE,  'R',    0xd4,   0xd5,       0xd6, },
+    { VK_DELETE,TRUE,  'S',    0xd7,   0xd8,       0xd9, },
 
     { VK_SNAPSHOT,TRUE,        0,      0,      0,          'r', }, /*PrtScrn*/
 
 #if 0
     /* Most people don't have F13-F20, but what the hell... */
-    { VK_F13,  TRUE,   '\332', '\333', '\334',     '\335', },
-    { VK_F14,  TRUE,   '\336', '\337', '\340',     '\341', },
-    { VK_F15,  TRUE,   '\342', '\343', '\344',     '\345', },
-    { VK_F16,  TRUE,   '\346', '\347', '\350',     '\351', },
-    { VK_F17,  TRUE,   '\352', '\353', '\354',     '\355', },
-    { VK_F18,  TRUE,   '\356', '\357', '\360',     '\361', },
-    { VK_F19,  TRUE,   '\362', '\363', '\364',     '\365', },
-    { VK_F20,  TRUE,   '\366', '\367', '\370',     '\371', },
+    { VK_F13,  TRUE,   0xda,   0xdb,   0xdc,       0xdd, },
+    { VK_F14,  TRUE,   0xde,   0xdf,   0xe0,       0xe1, },
+    { VK_F15,  TRUE,   0xe2,   0xe3,   0xe4,       0xe5, },
+    { VK_F16,  TRUE,   0xe6,   0xe7,   0xe8,       0xe9, },
+    { VK_F17,  TRUE,   0xea,   0xeb,   0xec,       0xed, },
+    { VK_F18,  TRUE,   0xee,   0xef,   0xf0,       0xf1, },
+    { VK_F19,  TRUE,   0xf2,   0xf3,   0xf4,       0xf5, },
+    { VK_F20,  TRUE,   0xf6,   0xf7,   0xf8,       0xf9, },
 #endif
     { VK_ADD,  TRUE,   'N',    'N',    'N',    'N',    }, /* keyp '+' */
     { VK_SUBTRACT, TRUE,'J',   'J',    'J',    'J',    }, /* keyp '-' */
  /* { VK_DIVIDE,   TRUE,'N',   'N',    'N',    'N',    },    keyp '/' */
     { VK_MULTIPLY, TRUE,'7',   '7',    '7',    '7',    }, /* keyp '*' */
 
-    { VK_NUMPAD0,TRUE,  '\332',        '\333', '\334',     '\335', },
-    { VK_NUMPAD1,TRUE,  '\336',        '\337', '\340',     '\341', },
-    { VK_NUMPAD2,TRUE,  '\342',        '\343', '\344',     '\345', },
-    { VK_NUMPAD3,TRUE,  '\346',        '\347', '\350',     '\351', },
-    { VK_NUMPAD4,TRUE,  '\352',        '\353', '\354',     '\355', },
-    { VK_NUMPAD5,TRUE,  '\356',        '\357', '\360',     '\361', },
-    { VK_NUMPAD6,TRUE,  '\362',        '\363', '\364',     '\365', },
-    { VK_NUMPAD7,TRUE,  '\366',        '\367', '\370',     '\371', },
-    { VK_NUMPAD8,TRUE,  '\372',        '\373', '\374',     '\375', },
+    { VK_NUMPAD0,TRUE,  0xda,  0xdb,   0xdc,       0xdd, },
+    { VK_NUMPAD1,TRUE,  0xde,  0xdf,   0xe0,       0xe1, },
+    { VK_NUMPAD2,TRUE,  0xe2,  0xe3,   0xe4,       0xe5, },
+    { VK_NUMPAD3,TRUE,  0xe6,  0xe7,   0xe8,       0xe9, },
+    { VK_NUMPAD4,TRUE,  0xea,  0xeb,   0xec,       0xed, },
+    { VK_NUMPAD5,TRUE,  0xee,  0xef,   0xf0,       0xf1, },
+    { VK_NUMPAD6,TRUE,  0xf2,  0xf3,   0xf4,       0xf5, },
+    { VK_NUMPAD7,TRUE,  0xf6,  0xf7,   0xf8,       0xf9, },
+    { VK_NUMPAD8,TRUE,  0xfa,  0xfb,   0xfc,       0xfd, },
     /* Sorry, out of number space! <negri>*/
-    { VK_NUMPAD9,TRUE,  '\376',        '\377', '\377',     '\367', },
+    { VK_NUMPAD9,TRUE,  0xfe,  0xff,   0xff,       0xf7, },
 
 };
 

Raspunde prin e-mail lui