Skip to content

Commit

Permalink
Provide translation for Alt+1 - Alt+31 (thanks cup!)
Browse files Browse the repository at this point in the history
  • Loading branch information
malxau committed Jul 11, 2019
1 parent b67fc52 commit a66f4bf
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions sh/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -1862,6 +1862,18 @@ YoriShProcessKeyDown(
return FALSE;
}

/**
MultiByteToWideChar seems to be able to convert the upper 128 characters
from the OEM CP into Unicode correctly, but that leaves the low 32 characters
which don't map to their Unicode equivalents. This is a simple translation
table for those characters.
*/
CONST TCHAR YoriShLowAsciiToUnicodeTable[] = {
0, 0x263a, 0x263b, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022,
0x25d8, 0x25cb, 0x25d9, 0x2642, 0x2640, 0x266a, 0x266b, 0x263c,
0x25ba, 0x25c4, 0x2195, 0x203c, 0x00b6, 0x00a7, 0x25ac, 0x21a8,
0x2191, 0x2193, 0x2192, 0x2190, 0x221f, 0x2194, 0x25b2, 0x25bc
};

/**
Perform processing related to when a key is released. This is only used for
Expand Down Expand Up @@ -1896,12 +1908,16 @@ YoriShProcessKeyUp(

HostKeyValue[0] = HostKeyValue[1] = 0;

MultiByteToWideChar(Buffer->NumericKeyAnsiMode?CP_ACP:CP_OEMCP,
0,
&SmallKeyValue,
1,
HostKeyValue,
1);
if (!Buffer->NumericKeyAnsiMode && SmallKeyValue < 32) {
HostKeyValue[0] = YoriShLowAsciiToUnicodeTable[SmallKeyValue];
} else {
MultiByteToWideChar(Buffer->NumericKeyAnsiMode?CP_ACP:CP_OEMCP,
0,
&SmallKeyValue,
1,
HostKeyValue,
1);
}

if (HostKeyValue != 0) {
YoriShPrepareForNextKey(Buffer);
Expand Down

0 comments on commit a66f4bf

Please sign in to comment.