2019-05-03 00:29:04 +02:00
|
|
|
/*++
|
|
|
|
Copyright (c) Microsoft Corporation
|
|
|
|
Licensed under the MIT license.
|
|
|
|
|
|
|
|
Module Name:
|
|
|
|
- terminalInput.hpp
|
|
|
|
|
|
|
|
Abstract:
|
|
|
|
- This serves as an adapter between virtual key input from a user and the virtual terminal sequences that are
|
|
|
|
typically emitted by an xterm-compatible console.
|
|
|
|
|
|
|
|
Author(s):
|
|
|
|
- Michael Niksa (MiNiksa) 30-Oct-2015
|
|
|
|
--*/
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include "../../types/inc/IInputEvent.hpp"
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Microsoft::Console::VirtualTerminal
|
|
|
|
{
|
|
|
|
class TerminalInput final
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TerminalInput(_In_ std::function<void(std::deque<std::unique_ptr<IInputEvent>>&)> pfn);
|
2019-05-30 20:15:37 +02:00
|
|
|
|
|
|
|
TerminalInput() = delete;
|
|
|
|
TerminalInput(const TerminalInput& old) = default;
|
|
|
|
TerminalInput(TerminalInput&& moved) = default;
|
|
|
|
|
|
|
|
TerminalInput& operator=(const TerminalInput& old) = default;
|
|
|
|
TerminalInput& operator=(TerminalInput&& moved) = default;
|
|
|
|
|
|
|
|
~TerminalInput() = default;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
bool HandleKey(const IInputEvent* const pInEvent) const;
|
2019-10-11 23:02:09 +02:00
|
|
|
bool HandleChar(const wchar_t ch);
|
2020-01-03 15:25:21 +01:00
|
|
|
void ChangeKeypadMode(const bool applicationMode) noexcept;
|
|
|
|
void ChangeCursorKeysMode(const bool applicationMode) noexcept;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::function<void(std::deque<std::unique_ptr<IInputEvent>>&)> _pfnWriteEvents;
|
2019-10-11 23:02:09 +02:00
|
|
|
|
|
|
|
// storage location for the leading surrogate of a utf-16 surrogate pair
|
|
|
|
std::optional<wchar_t> _leadingSurrogate;
|
|
|
|
|
2020-01-03 15:25:21 +01:00
|
|
|
bool _keypadApplicationMode = false;
|
|
|
|
bool _cursorApplicationMode = false;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
void _SendNullInputSequence(const DWORD dwControlKeyState) const;
|
2020-01-03 15:25:21 +01:00
|
|
|
void _SendInputSequence(const std::wstring_view sequence) const;
|
2019-05-03 00:29:04 +02:00
|
|
|
void _SendEscapedInputSequence(const wchar_t wch) const;
|
|
|
|
};
|
|
|
|
}
|