Set the ENHANCED_KEY key state for these keys:
* Arrow keys (up, down, left, right) * The block of 6 keys (insert, delete, home, end, pgup, pgdn) This change fixes arrow keys in the Ruby REPL (irb) Fixes https://github.com/rprichard/winpty/issues/99
This commit is contained in:
parent
db874f4a70
commit
84016539f3
@ -39,6 +39,7 @@
|
||||
#include "UnicodeEncoding.h"
|
||||
#include "Win32Console.h"
|
||||
|
||||
// MAPVK_VK_TO_VSC isn't defined by the old MinGW.
|
||||
#ifndef MAPVK_VK_TO_VSC
|
||||
#define MAPVK_VK_TO_VSC 0
|
||||
#endif
|
||||
@ -596,6 +597,7 @@ void ConsoleInput::appendKeyPress(std::vector<INPUT_RECORD> &records,
|
||||
const bool ctrl = (keyState & LEFT_CTRL_PRESSED) != 0;
|
||||
const bool alt = (keyState & LEFT_ALT_PRESSED) != 0;
|
||||
const bool shift = (keyState & SHIFT_PRESSED) != 0;
|
||||
const bool enhanced = (keyState & ENHANCED_KEY) != 0;
|
||||
bool hasDebugInput = false;
|
||||
|
||||
if (isTracingEnabled()) {
|
||||
@ -642,6 +644,9 @@ void ConsoleInput::appendKeyPress(std::vector<INPUT_RECORD> &records,
|
||||
stepKeyState |= SHIFT_PRESSED;
|
||||
appendInputRecord(records, TRUE, VK_SHIFT, 0, stepKeyState);
|
||||
}
|
||||
if (enhanced) {
|
||||
stepKeyState |= ENHANCED_KEY;
|
||||
}
|
||||
if (m_escapeInputEnabled) {
|
||||
reencodeEscapedKeyPress(records, virtualKey, codePoint, stepKeyState);
|
||||
} else {
|
||||
@ -658,6 +663,9 @@ void ConsoleInput::appendKeyPress(std::vector<INPUT_RECORD> &records,
|
||||
codePoint = 0;
|
||||
}
|
||||
appendCPInputRecords(records, FALSE, virtualKey, codePoint, stepKeyState);
|
||||
if (enhanced) {
|
||||
stepKeyState &= ~ENHANCED_KEY;
|
||||
}
|
||||
if (shift) {
|
||||
stepKeyState &= ~SHIFT_PRESSED;
|
||||
appendInputRecord(records, FALSE, VK_SHIFT, 0, stepKeyState);
|
||||
|
@ -206,6 +206,24 @@ const int kCsiShiftModifier = 1;
|
||||
const int kCsiAltModifier = 2;
|
||||
const int kCsiCtrlModifier = 4;
|
||||
|
||||
static inline bool useEnhancedForVirtualKey(uint16_t vk) {
|
||||
switch (vk) {
|
||||
case VK_UP:
|
||||
case VK_DOWN:
|
||||
case VK_LEFT:
|
||||
case VK_RIGHT:
|
||||
case VK_INSERT:
|
||||
case VK_DELETE:
|
||||
case VK_HOME:
|
||||
case VK_END:
|
||||
case VK_PRIOR:
|
||||
case VK_NEXT:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void addSimpleEntries(InputMap &inputMap) {
|
||||
struct SimpleEncoding {
|
||||
const char *encoding;
|
||||
@ -233,9 +251,13 @@ static void addSimpleEntries(InputMap &inputMap) {
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < DIM(simpleEncodings); ++i) {
|
||||
auto k = simpleEncodings[i].key;
|
||||
if (useEnhancedForVirtualKey(k.virtualKey)) {
|
||||
k.keyState |= ENHANCED_KEY;
|
||||
}
|
||||
inputMap.set(simpleEncodings[i].encoding,
|
||||
strlen(simpleEncodings[i].encoding),
|
||||
simpleEncodings[i].key);
|
||||
k);
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,6 +285,9 @@ static inline void setEncoding(const ExpandContext &ctx, char *end,
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (useEnhancedForVirtualKey(k.virtualKey)) {
|
||||
k.keyState |= ENHANCED_KEY;
|
||||
}
|
||||
ctx.inputMap.set(ctx.buffer, end - ctx.buffer, k);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user