[+] (NT only) Missing numpad and math keys input under ConsoleStd noncan APIs
[*] Refactor NoncanonicalInput [*] Fix various keys resort in NUL getting added to ConsoleTTYs input field [*] Fix multichar right key input (finish TODO note) [*] Hex grammar: literals may end with 'h' now that i think about it. also added wiresharks seperator. let's continue to simply make sure we cover all forms of hex in a reasonably liberal fashion to account for user input from various human written and software form. (Nonuniform style of non-hex illegal chars are fine so long as it looks and reads like a legal array of hex characters. Comas must come directly after literals, possible [0x] prefixes are fine, whitespaces too, copy/pasted '[', ']', '{', '}', 'reasonable' new line rejection, etc)
This commit is contained in:
parent
39ef196c0a
commit
6dfa806e3a
@ -13,9 +13,9 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
{
|
{
|
||||||
ENoncanonicalInput type;
|
ENoncanonicalInput type;
|
||||||
AuString string;
|
AuString string;
|
||||||
int scrollDeltaY {};
|
int iScrollDeltaY {};
|
||||||
bool isControlSequence {};
|
bool bIsControlSequence {};
|
||||||
bool isAltSequence {};
|
bool bIsAltSequence {};
|
||||||
bool isShiftSequence {};
|
bool bIsShiftSequence {};
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -205,6 +205,10 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
NoncanonicalInput canInput {};
|
NoncanonicalInput canInput {};
|
||||||
canInput.type = ENoncanonicalInput::eInput;
|
canInput.type = ENoncanonicalInput::eInput;
|
||||||
canInput.string = line;
|
canInput.string = line;
|
||||||
|
if (auto uMax = ::strnlen(line.data(), line.size()))
|
||||||
|
{
|
||||||
|
canInput.string.resize(uMax);
|
||||||
|
}
|
||||||
SysAssert(AuTryInsert(gCanonicalBuffer, canInput));
|
SysAssert(AuTryInsert(gCanonicalBuffer, canInput));
|
||||||
|
|
||||||
canInput.type = ENoncanonicalInput::eEnter;
|
canInput.type = ENoncanonicalInput::eEnter;
|
||||||
@ -217,6 +221,10 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
NoncanonicalInput canInput {};
|
NoncanonicalInput canInput {};
|
||||||
canInput.type = ENoncanonicalInput::eInput;
|
canInput.type = ENoncanonicalInput::eInput;
|
||||||
canInput.string = remaining;
|
canInput.string = remaining;
|
||||||
|
if (auto uMax = ::strnlen(remaining.data(), remaining.size()))
|
||||||
|
{
|
||||||
|
canInput.string.resize(uMax);
|
||||||
|
}
|
||||||
SysAssert(AuTryInsert(gCanonicalBuffer, canInput));
|
SysAssert(AuTryInsert(gCanonicalBuffer, canInput));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,7 +290,7 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
bool dBreak = false;
|
bool dBreak = false;
|
||||||
NoncanonicalInput canInput;
|
NoncanonicalInput canInput;
|
||||||
canInput.type = ENoncanonicalInput::eEnumInvalid;
|
canInput.type = ENoncanonicalInput::eEnumInvalid;
|
||||||
canInput.scrollDeltaY = 0;
|
canInput.iScrollDeltaY = 0;
|
||||||
|
|
||||||
auto &record = records[i];
|
auto &record = records[i];
|
||||||
AuString key;
|
AuString key;
|
||||||
@ -374,13 +382,58 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
case VK_F12:
|
case VK_F12:
|
||||||
canInput.type = ENoncanonicalInput::eFunction12;
|
canInput.type = ENoncanonicalInput::eFunction12;
|
||||||
break;
|
break;
|
||||||
|
case VK_NUMPAD0:
|
||||||
|
case VK_NUMPAD1:
|
||||||
|
case VK_NUMPAD2:
|
||||||
|
case VK_NUMPAD3:
|
||||||
|
case VK_NUMPAD4:
|
||||||
|
case VK_NUMPAD5:
|
||||||
|
case VK_NUMPAD6:
|
||||||
|
case VK_NUMPAD7:
|
||||||
|
case VK_NUMPAD8:
|
||||||
|
case VK_NUMPAD9:
|
||||||
|
{
|
||||||
|
canInput.type = ENoncanonicalInput::eInput;
|
||||||
|
canInput.string = '0' + (record.Event.KeyEvent.wVirtualKeyCode - VK_NUMPAD0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case VK_MULTIPLY:
|
||||||
|
{
|
||||||
|
canInput.type = ENoncanonicalInput::eInput;
|
||||||
|
canInput.string = '*';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case VK_ADD:
|
||||||
|
{
|
||||||
|
canInput.type = ENoncanonicalInput::eInput;
|
||||||
|
canInput.string = '+';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case VK_SUBTRACT:
|
||||||
|
{
|
||||||
|
canInput.type = ENoncanonicalInput::eInput;
|
||||||
|
canInput.string = '-';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case VK_DIVIDE:
|
||||||
|
{
|
||||||
|
canInput.type = ENoncanonicalInput::eInput;
|
||||||
|
canInput.string = '/';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case VK_DECIMAL:
|
||||||
|
{
|
||||||
|
canInput.type = ENoncanonicalInput::eInput;
|
||||||
|
canInput.string = '.';
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
dBreak = true;
|
dBreak = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
canInput.isControlSequence = record.Event.KeyEvent.dwControlKeyState & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED);
|
canInput.bIsControlSequence = record.Event.KeyEvent.dwControlKeyState & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED);
|
||||||
canInput.isAltSequence = record.Event.KeyEvent.dwControlKeyState & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED);
|
canInput.bIsAltSequence = record.Event.KeyEvent.dwControlKeyState & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED);
|
||||||
canInput.isShiftSequence = record.Event.KeyEvent.dwControlKeyState & (SHIFT_PRESSED);
|
canInput.bIsShiftSequence = record.Event.KeyEvent.dwControlKeyState & (SHIFT_PRESSED);
|
||||||
|
|
||||||
// TODO: numpad
|
// TODO: numpad
|
||||||
if (!dBreak || ((record.Event.KeyEvent.wVirtualKeyCode <= VK_HELP &&
|
if (!dBreak || ((record.Event.KeyEvent.wVirtualKeyCode <= VK_HELP &&
|
||||||
@ -402,6 +455,8 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
|
|
||||||
for (z = 0; z < record.Event.KeyEvent.wRepeatCount; z++)
|
for (z = 0; z < record.Event.KeyEvent.wRepeatCount; z++)
|
||||||
{
|
{
|
||||||
|
key.resize(::strnlen(key.data(), key.size()));
|
||||||
|
|
||||||
canInput.string += key;
|
canInput.string += key;
|
||||||
|
|
||||||
if (key.size())
|
if (key.size())
|
||||||
@ -419,12 +474,12 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
if (record.Event.MouseEvent.dwEventFlags == MOUSE_WHEELED)
|
if (record.Event.MouseEvent.dwEventFlags == MOUSE_WHEELED)
|
||||||
{
|
{
|
||||||
canInput.type = ENoncanonicalInput::eScroll;
|
canInput.type = ENoncanonicalInput::eScroll;
|
||||||
canInput.scrollDeltaY = AuStaticCast<AuInt16>(AuBitsToHigher((AuUInt32)record.Event.MouseEvent.dwButtonState));
|
canInput.iScrollDeltaY = AuStaticCast<AuInt16>(AuBitsToHigher((AuUInt32)record.Event.MouseEvent.dwButtonState));
|
||||||
|
|
||||||
if (canInput.scrollDeltaY > 1)
|
if (canInput.iScrollDeltaY > 1)
|
||||||
canInput.scrollDeltaY = 1;
|
canInput.iScrollDeltaY = 1;
|
||||||
else if (canInput.scrollDeltaY < -1)
|
else if (canInput.iScrollDeltaY < -1)
|
||||||
canInput.scrollDeltaY = -1;
|
canInput.iScrollDeltaY = -1;
|
||||||
dBreak = false;
|
dBreak = false;
|
||||||
}
|
}
|
||||||
else if ((record.Event.MouseEvent.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED) != 0)
|
else if ((record.Event.MouseEvent.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED) != 0)
|
||||||
@ -525,6 +580,7 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
|
|
||||||
DWORD idc;
|
DWORD idc;
|
||||||
WriteConsoleInputW(gInputStream, niceWorkMicrosoft, 2, &idc);
|
WriteConsoleInputW(gInputStream, niceWorkMicrosoft, 2, &idc);
|
||||||
|
WriteConsoleInputW(gInputStream, niceWorkMicrosoft, 2, &idc);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1100,8 +1156,8 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
auto c = gLineEncodedBuffer[i];
|
auto c = gLineEncodedBuffer[i];
|
||||||
|
|
||||||
NoncanonicalInput canInput {};
|
NoncanonicalInput canInput {};
|
||||||
canInput.scrollDeltaY = 0;
|
canInput.iScrollDeltaY = 0;
|
||||||
canInput.isControlSequence = canInput.isShiftSequence = canInput.isAltSequence = false;
|
canInput.bIsControlSequence = canInput.bIsControlSequence = canInput.bIsControlSequence = false;
|
||||||
if (c == 127)
|
if (c == 127)
|
||||||
{
|
{
|
||||||
CanFlushLines();
|
CanFlushLines();
|
||||||
@ -1138,7 +1194,7 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
CanFlushLines();
|
CanFlushLines();
|
||||||
canInput.type = ENoncanonicalInput::eInput;
|
canInput.type = ENoncanonicalInput::eInput;
|
||||||
canInput.string = 'a' + c - 1;
|
canInput.string = 'a' + c - 1;
|
||||||
canInput.isControlSequence = true;
|
canInput.bIsControlSequence = true;
|
||||||
|
|
||||||
SysAssert(AuTryInsert(gCanonicalBuffer, canInput));
|
SysAssert(AuTryInsert(gCanonicalBuffer, canInput));
|
||||||
}
|
}
|
||||||
@ -1192,7 +1248,7 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
if (next == nestedChar) \
|
if (next == nestedChar) \
|
||||||
{ \
|
{ \
|
||||||
canInput.type = ENoncanonicalInput::op; \
|
canInput.type = ENoncanonicalInput::op; \
|
||||||
canInput.isControlSequence = true; \
|
canInput.bIsControlSequence = true; \
|
||||||
SysAssert(AuTryInsert(gCanonicalBuffer, canInput)); \
|
SysAssert(AuTryInsert(gCanonicalBuffer, canInput)); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
@ -1204,8 +1260,8 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
if (next == nestedChar) \
|
if (next == nestedChar) \
|
||||||
{ \
|
{ \
|
||||||
canInput.type = ENoncanonicalInput::op; \
|
canInput.type = ENoncanonicalInput::op; \
|
||||||
canInput.isShiftSequence = true; \
|
canInput.bIsShiftSequence = true; \
|
||||||
canInput.isControlSequence = true; \
|
canInput.bIsControlSequence = true; \
|
||||||
SysAssert(AuTryInsert(gCanonicalBuffer, canInput)); \
|
SysAssert(AuTryInsert(gCanonicalBuffer, canInput)); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
@ -1217,7 +1273,7 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
if (next == nestedChar) \
|
if (next == nestedChar) \
|
||||||
{ \
|
{ \
|
||||||
canInput.type = ENoncanonicalInput::op; \
|
canInput.type = ENoncanonicalInput::op; \
|
||||||
canInput.isShiftSequence = true; \
|
canInput.bIsShiftSequence = true; \
|
||||||
SysAssert(AuTryInsert(gCanonicalBuffer, canInput)); \
|
SysAssert(AuTryInsert(gCanonicalBuffer, canInput)); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
@ -1229,9 +1285,9 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
if (next == nestedChar) \
|
if (next == nestedChar) \
|
||||||
{ \
|
{ \
|
||||||
canInput.type = ENoncanonicalInput::op; \
|
canInput.type = ENoncanonicalInput::op; \
|
||||||
canInput.isShiftSequence = true; \
|
canInput.bIsShiftSequence = true; \
|
||||||
canInput.isControlSequence = true; \
|
canInput.bIsControlSequence = true; \
|
||||||
canInput.isAltSequence = true; \
|
canInput.bIsAltSequence = true; \
|
||||||
SysAssert(AuTryInsert(gCanonicalBuffer, canInput)); \
|
SysAssert(AuTryInsert(gCanonicalBuffer, canInput)); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
@ -1264,13 +1320,13 @@ namespace Aurora::Console::ConsoleStd
|
|||||||
if (esc == 'A')
|
if (esc == 'A')
|
||||||
{
|
{
|
||||||
canInput.type = ENoncanonicalInput::eScroll;
|
canInput.type = ENoncanonicalInput::eScroll;
|
||||||
canInput.scrollDeltaY = 4;
|
canInput.iScrollDeltaY = 4;
|
||||||
SysAssert(AuTryInsert(gCanonicalBuffer, canInput));
|
SysAssert(AuTryInsert(gCanonicalBuffer, canInput));
|
||||||
}
|
}
|
||||||
else if (esc == 'B')
|
else if (esc == 'B')
|
||||||
{
|
{
|
||||||
canInput.type = ENoncanonicalInput::eScroll;
|
canInput.type = ENoncanonicalInput::eScroll;
|
||||||
canInput.scrollDeltaY = -4;
|
canInput.iScrollDeltaY = -4;
|
||||||
SysAssert(AuTryInsert(gCanonicalBuffer, canInput));
|
SysAssert(AuTryInsert(gCanonicalBuffer, canInput));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,12 +204,12 @@ namespace Aurora::Console::ConsoleTTY
|
|||||||
}
|
}
|
||||||
case ConsoleStd::ENoncanonicalInput::eScroll:
|
case ConsoleStd::ENoncanonicalInput::eScroll:
|
||||||
{
|
{
|
||||||
Scroll(input.scrollDeltaY);
|
Scroll(input.iScrollDeltaY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
AuLogDbg("Key Stroke: {}, {}, {}", ConsoleStd::ENoncanonicalInputToString(input.type), input.scrollDeltaY, input.string);
|
AuLogDbg("Key Stroke: {}, {}, {}", ConsoleStd::ENoncanonicalInputToString(input.type), input.iScrollDeltaY, input.string);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -272,9 +272,10 @@ namespace Aurora::Console::ConsoleTTY
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: missing locale API
|
auto uAddend = AuLocale::Encoding::IterateUTF8({ &this->inputField[this->noncanonicalCursorPosInBytes], this->inputField.size() - this->noncanonicalCursorPosInBytes });
|
||||||
|
|
||||||
this->noncanonicalCursorPos++;
|
this->noncanonicalCursorPos++;
|
||||||
this->noncanonicalCursorPosInBytes++; // << ILLEGAL
|
this->noncanonicalCursorPosInBytes += uAddend;
|
||||||
NoncanonicalSetCursor();
|
NoncanonicalSetCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ namespace Aurora::Parse
|
|||||||
// Consume array
|
// Consume array
|
||||||
for (; i < in.size(); )
|
for (; i < in.size(); )
|
||||||
{
|
{
|
||||||
// Consume prefix
|
// Consume 0x prefix
|
||||||
if ((i + 1) < in.size())
|
if ((i + 1) < in.size())
|
||||||
{
|
{
|
||||||
if ((in[i] == '0') &&
|
if ((in[i] == '0') &&
|
||||||
@ -186,14 +186,22 @@ namespace Aurora::Parse
|
|||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
HEX_GRAMMAR_CONSUME_ONE(',');
|
if (i < in.size())
|
||||||
HEX_GRAMMAR_CONSUME_END_OF_LINE;
|
{
|
||||||
|
if ((in[i] == 'h' /*some hex dump code and people prefer FFh over 0xFF*/))
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HEX_GRAMMAR_CONSUME_EITHER(':' /*wireshark and other networking tools*/, ',' /*latin splitter array*/);
|
||||||
|
HEX_GRAMMAR_CONSUME_END_OF_LINE; // all whitespace [+newline[+all whitespace]]
|
||||||
|
|
||||||
// Consume end literal hint
|
// Consume end literal hint
|
||||||
if (i < in.size())
|
if (i < in.size())
|
||||||
{
|
{
|
||||||
if ((in[i] == '}') ||
|
if ((in[i] == '}' /*c-like*/) ||
|
||||||
(in[i] == ']'))
|
(in[i] == ']' /*more latin array tag*/))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user