[+] ConsoleStd: Noncanonical input interprets right click as paste
This commit is contained in:
parent
1510beaf49
commit
e42efe930c
@ -171,6 +171,56 @@ namespace Aurora::Console::ConsoleStd
|
||||
::CloseClipboard();
|
||||
}
|
||||
|
||||
static void ProcessLines(AuList<AuString> &lines);
|
||||
|
||||
static void TryPasteFromClipboard()
|
||||
{
|
||||
AuString str;
|
||||
|
||||
if (!::OpenClipboard(nullptr))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto hClipboardData = ::GetClipboardData(CF_UNICODETEXT);
|
||||
if (hClipboardData == nullptr)
|
||||
{
|
||||
::CloseClipboard();
|
||||
return;
|
||||
}
|
||||
|
||||
auto pLpwStr = (LPWSTR)GlobalLock(hClipboardData);
|
||||
if (pLpwStr != nullptr)
|
||||
{
|
||||
str = AuLocale::ConvertFromWChar(pLpwStr);
|
||||
::GlobalUnlock(hClipboardData);
|
||||
}
|
||||
|
||||
{
|
||||
auto remaining = AuParse::SplitNewlines(str, [](const AuString &line)
|
||||
{
|
||||
NoncanonicalInput canInput {};
|
||||
canInput.type = ENoncanonicalInput::eInput;
|
||||
canInput.string = line;
|
||||
SysAssert(AuTryInsert(gCanonicalBuffer, canInput));
|
||||
|
||||
canInput.type = ENoncanonicalInput::eEnter;
|
||||
canInput.string.clear();
|
||||
SysAssert(AuTryInsert(gCanonicalBuffer, canInput));
|
||||
}, true);
|
||||
|
||||
if (remaining.size())
|
||||
{
|
||||
NoncanonicalInput canInput {};
|
||||
canInput.type = ENoncanonicalInput::eInput;
|
||||
canInput.string = remaining;
|
||||
SysAssert(AuTryInsert(gCanonicalBuffer, canInput));
|
||||
}
|
||||
}
|
||||
|
||||
::CloseClipboard();
|
||||
}
|
||||
|
||||
void ProcessCanonical(HANDLE h)
|
||||
{
|
||||
INPUT_RECORD records[4096];
|
||||
@ -326,6 +376,10 @@ namespace Aurora::Console::ConsoleStd
|
||||
{
|
||||
ConsoleTTY::LeaveScrollMode();
|
||||
}
|
||||
else if ((record.Event.MouseEvent.dwButtonState & RIGHTMOST_BUTTON_PRESSED) != 0 && record.Event.MouseEvent.dwEventFlags != 1)
|
||||
{
|
||||
TryPasteFromClipboard();
|
||||
}
|
||||
else
|
||||
{
|
||||
// NOOP
|
||||
|
Loading…
Reference in New Issue
Block a user