1 // Copyright (c) 2011-2015 Ryan Prichard
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to
5 // deal in the Software without restriction, including without limitation the
6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 // sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 #ifndef CONSOLEINPUT_H
22 #define CONSOLEINPUT_H
33 #include "SmallRect.h"
41 ConsoleInput(HANDLE conin, int mouseMode, DsrSender &dsrSender,
42 Win32Console &console);
43 void writeInput(const std::string &input);
44 void flushIncompleteEscapeCode();
45 void setMouseWindowRect(SmallRect val) { m_mouseWindowRect = val; }
46 void updateInputFlags(bool forceTrace=false);
47 bool shouldActivateTerminalMouse();
50 void doWrite(bool isEof);
51 void flushInputRecords(std::vector<INPUT_RECORD> &records);
52 int scanInput(std::vector<INPUT_RECORD> &records,
56 int scanMouseInput(std::vector<INPUT_RECORD> &records,
59 void appendUtf8Char(std::vector<INPUT_RECORD> &records,
60 const char *charBuffer,
62 bool terminalAltEscape);
63 void appendKeyPress(std::vector<INPUT_RECORD> &records,
65 uint32_t winCodePointDn,
66 uint32_t winCodePointUp,
72 static void appendCPInputRecords(std::vector<INPUT_RECORD> &records,
77 static void appendInputRecord(std::vector<INPUT_RECORD> &records,
84 DWORD inputConsoleMode();
87 Win32Console &m_console;
88 HANDLE m_conin = nullptr;
90 DsrSender &m_dsrSender;
91 bool m_dsrSent = false;
92 std::string m_byteQueue;
94 DWORD m_lastWriteTick = 0;
95 DWORD m_mouseButtonState = 0;
96 struct DoubleClickDetection {
100 bool released = false;
102 bool m_enableExtendedEnabled = false;
103 bool m_mouseInputEnabled = false;
104 bool m_quickEditEnabled = false;
105 bool m_escapeInputEnabled = false;
106 SmallRect m_mouseWindowRect;
109 #endif // CONSOLEINPUT_H