From e0e1a93ded529949d1af9b236f6f5b72198db6e8 Mon Sep 17 00:00:00 2001 From: flagarde Date: Mon, 22 Aug 2022 09:57:10 +0100 Subject: [PATCH 1/6] Fix #169, #168, #134(partially), #133 --- cpp-terminal/input.hpp | 142 ++++++++++++++++++++++++++++-- cpp-terminal/private/platform.cpp | 3 +- cpp-terminal/prompt.cpp | 10 +-- cpp-terminal/prompt.hpp | 2 +- examples/kilo.cpp | 1 - 5 files changed, 145 insertions(+), 13 deletions(-) diff --git a/cpp-terminal/input.hpp b/cpp-terminal/input.hpp index dca86fe7..7bbc5467 100644 --- a/cpp-terminal/input.hpp +++ b/cpp-terminal/input.hpp @@ -3,10 +3,144 @@ namespace Term { enum Key { - BACKSPACE = 1000, - ENTER, + NO_KEY = -1, + // Begin ASCII + NUL = 0, + SOH = 1, + STX = 2, + ETX = 3, + EOT = 4, + ENQ = 5, + ACK = 6, + BEL = 7, + BS = 8, + BACKSPACE = 8, + HT = 9, + TAB = 9, + LF = 10, + ENTER = 10, + VT = 11, + FF = 12, + CR = 13, + SO = 14, + SI = 15, + DLE = 16, + DC1 = 17, + DC2 = 18, + DC3 = 19, + DC4 = 20, + NAK = 21, + SYN = 22, + ETB = 23, + CAN = 24, + EM = 25, + SUB = 26, + ESC = 27, + FS = 28, + GS = 29, + RS = 30, + US = 31, + SPACE = 32, + EXCLAMATION_MARK = 33, + QUOTE = 34, + HASH = 35, + DOLLAR = 36, + PERCENT = 37, + AMPERSAND = 38, + APOSTROPHE = 39, + OPEN_PARENTHESIS = 40, + CLOSE_PARENTHESIS = 41, + ASTERISK = 42, + PLUS = 43, + COMMA = 44, + HYPHEN = 45, + MINUS = 45, + PERIOD = 46, + SLASH = 47, + ZERO = 48, + ONE = 49, + TWO = 50, + THREE = 51, + FOUR = 52, + FIVE = 53, + SIX = 54, + SEVEN = 55, + EIGHT = 56, + NINE = 57, + COLON = 58, + SEMICOLON = 59, + LESS_THAN = 60, + OPEN_CHEVRON = 60, + EQUAL = 61, + GREATER_THAN = 62, + CLOSE_CHEVRON = 62, + QUESTION_MARK = 63, + AROBASE = 64, + A = 65, + B = 66, + C = 67, + D = 68, + E = 69, + F = 70, + G = 71, + H = 72, + I = 73, + J = 74, + K = 75, + L = 76, + M = 77, + N = 78, + O = 79, + P = 80, + Q = 81, + R = 82, + S = 83, + T = 84, + U = 85, + V = 86, + W = 87, + X = 88, + Y = 89, + Z = 90, + OPEN_BRACKET = 91, + BACKSLASH = 92, + CLOSE_BRACKET = 93, + CARET = 94, + UNDERSCORE = 95, + GRAVE_ACCENT = 96, + a = 97, + b = 98, + c = 99, + d = 100, + e = 101, + f = 102, + g = 103, + h = 104, + i = 105, + j = 106, + k = 107, + l = 108, + m = 109, + n = 110, + o = 111, + p = 112, + q = 113, + r = 114, + s = 115, + t = 116, + u = 117, + v = 118, + w = 119, + x = 120, + y = 121, + z = 122, + OPEN_BRACE = 123, + VERTICAL_BAR = 124, + CLOSE_BRACE = 125, + TILDE = 126, + DEL = 127, + // End ASCII ALT_ENTER, - TAB, ARROW_LEFT, ARROW_RIGHT, ARROW_UP, @@ -16,13 +150,11 @@ enum Key { CTRL_RIGHT, CTRL_LEFT, NUMERIC_5, - DEL, HOME, INSERT, END, PAGE_UP, PAGE_DOWN, - ESC, F1, F2, F3, diff --git a/cpp-terminal/private/platform.cpp b/cpp-terminal/private/platform.cpp index a3076e1d..42b31bd8 100644 --- a/cpp-terminal/private/platform.cpp +++ b/cpp-terminal/private/platform.cpp @@ -180,7 +180,8 @@ Term::Private::BaseTerminal::BaseTerminal(bool enable_keyboard, } DWORD flags = dwOriginalInMode; flags |= ENABLE_VIRTUAL_TERMINAL_INPUT; - flags &= ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT); + flags &= + ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT); if (!SetConsoleMode(hin, flags)) { throw std::runtime_error("SetConsoleMode() failed"); } diff --git a/cpp-terminal/prompt.cpp b/cpp-terminal/prompt.cpp index f01bd48b..3c8af4d4 100644 --- a/cpp-terminal/prompt.cpp +++ b/cpp-terminal/prompt.cpp @@ -130,7 +130,7 @@ std::vector Term::split(const std::string& s) { return lines; } -char32_t Term::U(const std::string& s) { +char32_t Term::UU(const std::string& s) { std::u32string s2 = Private::utf8_to_utf32(s); if (s2.size() != 1) throw std::runtime_error("U(s): s not a codepoint."); @@ -140,13 +140,13 @@ char32_t Term::U(const std::string& s) { void Term::print_left_curly_bracket(Term::Window& scr, int x, int y1, int y2) { int h = y2 - y1 + 1; if (h == 1) { - scr.set_char(x, y1, U("]")); + scr.set_char(x, y1, UU("]")); } else { - scr.set_char(x, y1, U("┐")); + scr.set_char(x, y1, UU("┐")); for (int j = y1 + 1; j <= y2 - 1; j++) { - scr.set_char(x, j, U("│")); + scr.set_char(x, j, UU("│")); } - scr.set_char(x, y2, U("┘")); + scr.set_char(x, y2, UU("┘")); } } diff --git a/cpp-terminal/prompt.hpp b/cpp-terminal/prompt.hpp index a550a249..eda2723b 100644 --- a/cpp-terminal/prompt.hpp +++ b/cpp-terminal/prompt.hpp @@ -65,7 +65,7 @@ std::string concat(const std::vector&); std::vector split(const std::string&); -char32_t U(const std::string&); +char32_t UU(const std::string&); void print_left_curly_bracket(Term::Window&, int, int, int); diff --git a/examples/kilo.cpp b/examples/kilo.cpp index 5bb755cc..58c74f95 100644 --- a/examples/kilo.cpp +++ b/examples/kilo.cpp @@ -857,7 +857,6 @@ bool editorProcessKeypress() { break; case Key::BACKSPACE: - case Key::CTRL + 'h': case Key::DEL: if (c == Key::DEL) editorMoveCursor(Key::ARROW_RIGHT); From 98f95b8e0fe2bd95af4f6d9e01560e677c5293e8 Mon Sep 17 00:00:00 2001 From: flagarde Date: Thu, 25 Aug 2022 03:54:07 +0800 Subject: [PATCH 2/6] Fixes prompt and key --- cpp-terminal/input.cpp | 60 +++++++++++++++++++-------- cpp-terminal/input.hpp | 90 ++++++++++++++++++++++++----------------- cpp-terminal/prompt.cpp | 6 +-- examples/keys.cpp | 20 ++++----- 4 files changed, 109 insertions(+), 67 deletions(-) diff --git a/cpp-terminal/input.cpp b/cpp-terminal/input.cpp index f4bcff76..c2e4b431 100644 --- a/cpp-terminal/input.cpp +++ b/cpp-terminal/input.cpp @@ -1,24 +1,56 @@ #include #include #include +#include #include #include "private/platform.hpp" -int Term::read_key() { - int key{}; - while ((key = read_key0()) == 0) { +bool Term::is_ANSII(const Term::Key& key) { + if (key >= 0 && key <= 127) + return true; + else + return false; +} + +bool Term::is_extended_ANSII(const Term::Key& key) { + if (key >= 0 && key <= 255) + return true; + else + return false; +} + +bool Term::is_CTRL(const Term::Key& key) { + // Need to supress the TAB etc... + if (key > 0 && key <= 31 && key != Key::BACKSPACE && key != Key::TAB && + key != ESC && /* the two mapped to ENTER */ key != Key::LF && key != CR) + return true; + else + return false; +} + +bool Term::is_ALT(const Term::Key& key) { + if ((key & Key::ALT) == Key::ALT) + return true; + else + return false; +} + +std::int32_t Term::read_key() { + std::int32_t key{Key::NO_KEY}; + while ((key = read_key0()) == Key::NO_KEY) { std::this_thread::sleep_for(std::chrono::milliseconds(10)); } return key; } -int Term::read_key0() { - char c{}; +std::int32_t Term::read_key0() { + char c{'\0'}; if (!Private::read_raw(&c)) - return 0; - - if (c == '\x1b') { - char seq[4]; + return Key::NO_KEY; + if (is_CTRL(static_cast(c))) { + return c; + } else if (c == Key::ESC) { + char seq[4]{'\0', '\0', '\0', '\0'}; if (!Private::read_raw(&seq[0])) return Key::ESC; @@ -152,13 +184,9 @@ int Term::read_key0() { return -4; } else { switch (c) { - case '\x09': // TAB - return Key::TAB; - case '\x0a': // LF; falls-through - case '\x0d': // CR + case Key::LF: + case Key::CR: return Key::ENTER; - case '\x7f': // DEL - return Key::BACKSPACE; } if (c == '\xc3') { if (!Private::read_raw(&c)) { @@ -202,4 +230,4 @@ std::string Term::read_stdin_alone() { // temporarily enable raw mode Term::Terminal term(false, true, false, false); return Term::read_stdin(); -} \ No newline at end of file +} diff --git a/cpp-terminal/input.hpp b/cpp-terminal/input.hpp index 7bbc5467..3452360f 100644 --- a/cpp-terminal/input.hpp +++ b/cpp-terminal/input.hpp @@ -1,45 +1,44 @@ #pragma once +#include #include namespace Term { -enum Key { +enum Key : std::int32_t { NO_KEY = -1, - // Begin ASCII + // Begin ASCII (some ASCII names has been change to their CTRL + key part) NUL = 0, - SOH = 1, - STX = 2, - ETX = 3, - EOT = 4, - ENQ = 5, - ACK = 6, - BEL = 7, - BS = 8, + CTRL_A = 1, + CTRL_B = 2, + CTRL_C = 3, + CTRL_D = 4, + CTRL_E = 5, + CTRL_F = 6, + CTRL_G = 7, BACKSPACE = 8, - HT = 9, TAB = 9, - LF = 10, ENTER = 10, - VT = 11, - FF = 12, - CR = 13, - SO = 14, - SI = 15, - DLE = 16, - DC1 = 17, - DC2 = 18, - DC3 = 19, - DC4 = 20, - NAK = 21, - SYN = 22, - ETB = 23, - CAN = 24, - EM = 25, - SUB = 26, + LF = 10, + CTRL_K = 11, + CTRL_L = 12, + CR = 13, // MAPED to ENTER + CTRL_N = 14, + CTRL_O = 15, + CTRL_P = 16, + CTRL_Q = 17, + CTRL_R = 18, + CTRL_S = 19, + CTRL_T = 20, + CTRL_U = 21, + CTRL_V = 22, + CTRL_W = 23, + CTRL_X = 24, + CTRL_Y = 25, + CTRL_Z = 26, ESC = 27, - FS = 28, - GS = 29, - RS = 30, - US = 31, + CTRL_SLASH = 28, + CTRL_CLOSE_BRACKET = 29, + CTRL_CARET = 30, + CTRL_UNDERSCORE = 31, SPACE = 32, EXCLAMATION_MARK = 33, QUOTE = 34, @@ -140,7 +139,8 @@ enum Key { TILDE = 126, DEL = 127, // End ASCII - ALT_ENTER, + // Extended ANSII goes up to 255 + ALT_ENTER = 256, ARROW_LEFT, ARROW_RIGHT, ARROW_UP, @@ -167,20 +167,34 @@ enum Key { F10, F11, F12, - // special keys - CTRL = -96, - ALT = -128 + // Keys bellow need to be under 512 + // special keys (CTRL is special^2) + CTRL = -AROBASE, + // Now use << to for detecting special key + key press + ALT = (1 << 9) }; +// Detect if Key is convertible to ANSII +bool is_ANSII(const Key&); + +// Detect if Key is convertible to Extended ANSII +bool is_extended_ANSII(const Key&); + +// Detect if Key is CTRL+* +bool is_CTRL(const Key&); + +// Detecti if Key is ALT+* +bool is_ALT(const Key&); + // Waits for a key press, translates escape codes // if Term:Terminal is not enabling the keyboard it'll loop for infinity -int read_key(); +std::int32_t read_key(); // If there was a key press, returns the translated key from escape codes, // otherwise returns 0. If the escape code is not supported it returns a // negative number. // if Term::Terminal is not enabling the keyboard it'll always return 0 -int read_key0(); +std::int32_t read_key0(); // returns the stdin as a string // waits until the EOT signal is send diff --git a/cpp-terminal/prompt.cpp b/cpp-terminal/prompt.cpp index 3c8af4d4..d0577e39 100644 --- a/cpp-terminal/prompt.cpp +++ b/cpp-terminal/prompt.cpp @@ -205,14 +205,14 @@ std::string Term::prompt_multiline( hist.push_back(concat(m.lines)); // Push back empty input Term::Window scr(cols, 1); - int key; + Key key{NO_KEY}; render(scr, m, cols); std::cout << scr.render(1, row, term_attached) << std::flush; bool not_complete = true; while (not_complete) { - key = Term::read_key(); + key = static_cast(Term::read_key()); if ((key >= 'a' && key <= 'z') || (key >= 'A' && key <= 'Z') || - (!iscntrl(key) && key < 128)) { + (Term::is_extended_ANSII(key) && !iscntrl(key))) { std::string before = m.lines[m.cursor_row - 1].substr(0, m.cursor_col - 1); std::string newchar; diff --git a/examples/keys.cpp b/examples/keys.cpp index 960367a1..436a91b7 100644 --- a/examples/keys.cpp +++ b/examples/keys.cpp @@ -24,22 +24,22 @@ int main() { std::cout << "Press any key ('q' to quit):" << std::endl; bool on = true; while (on) { - int key = Term::read_key(); + Key key{Term::read_key()}; std::string s; - if (key >= 'a' && key <= 'z') { - s = (char)(key + 'A' - 'a'); // Convert to upper case + if (key >= Key::a && key <= Key::z) { + s = (char)(key + Key::A - Key::a); // Convert to upper case if (key == 'q') on = false; - } else if (key >= 'A' && key <= 'Z') { + } else if (key >= Key::A && key <= Key::Z) { s = (std::string) "Shift+" + (char)key; // Already in upper case; - } else if (key >= Key::CTRL + 'a' && key <= Key::CTRL + 'z') { - s = (std::string) "CTRL+" + (char)((-Key::CTRL + key) - 32); - } else if (key >= Key::ALT + 'a' && key <= Key::ALT + 'z') { + } else if (Term::is_CTRL(key)) { + s = (std::string) "CTRL+" + (char)((-Key::CTRL + key)); + } else if (Term::is_ALT(key)) { s = (std::string) "Alt+" + - (char)(key + 'A' - - (Key::ALT + 'a')); // Convert to upper case - } else if (key > 0 && !iscntrl(key) && key < 128) { + (char)(key + Key::A - + (Key::ALT + Key::a)); // Convert to upper case + } else if (Term::is_extended_ANSII(key) && !iscntrl(key)) { s = (char)key; } else { switch (key) { From ee8ad0c6403a60e9756a5dc9f31df442d2708f87 Mon Sep 17 00:00:00 2001 From: flagarde Date: Thu, 25 Aug 2022 04:27:27 +0800 Subject: [PATCH 3/6] Fix backspace key --- cpp-terminal/input.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp-terminal/input.cpp b/cpp-terminal/input.cpp index c2e4b431..f68f9c23 100644 --- a/cpp-terminal/input.cpp +++ b/cpp-terminal/input.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include "private/platform.hpp" @@ -184,6 +183,8 @@ std::int32_t Term::read_key0() { return -4; } else { switch (c) { + case Key::DEL: + return Key::BACKSPACE; case Key::LF: case Key::CR: return Key::ENTER; From e79020d7915cebb9461dc9560e41b9d751f20bba Mon Sep 17 00:00:00 2001 From: flagarde Date: Thu, 25 Aug 2022 04:33:13 +0800 Subject: [PATCH 4/6] Fix typo --- cpp-terminal/input.cpp | 4 ++-- cpp-terminal/input.hpp | 4 ++-- cpp-terminal/prompt.cpp | 2 +- examples/keys.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cpp-terminal/input.cpp b/cpp-terminal/input.cpp index f68f9c23..e6324c6d 100644 --- a/cpp-terminal/input.cpp +++ b/cpp-terminal/input.cpp @@ -4,14 +4,14 @@ #include #include "private/platform.hpp" -bool Term::is_ANSII(const Term::Key& key) { +bool Term::is_ASCII(const Term::Key& key) { if (key >= 0 && key <= 127) return true; else return false; } -bool Term::is_extended_ANSII(const Term::Key& key) { +bool Term::is_extended_ASCII(const Term::Key& key) { if (key >= 0 && key <= 255) return true; else diff --git a/cpp-terminal/input.hpp b/cpp-terminal/input.hpp index 3452360f..256a5eb4 100644 --- a/cpp-terminal/input.hpp +++ b/cpp-terminal/input.hpp @@ -175,10 +175,10 @@ enum Key : std::int32_t { }; // Detect if Key is convertible to ANSII -bool is_ANSII(const Key&); +bool is_ASCII(const Key&); // Detect if Key is convertible to Extended ANSII -bool is_extended_ANSII(const Key&); +bool is_extended_ASCII(const Key&); // Detect if Key is CTRL+* bool is_CTRL(const Key&); diff --git a/cpp-terminal/prompt.cpp b/cpp-terminal/prompt.cpp index d0577e39..631c5c5c 100644 --- a/cpp-terminal/prompt.cpp +++ b/cpp-terminal/prompt.cpp @@ -212,7 +212,7 @@ std::string Term::prompt_multiline( while (not_complete) { key = static_cast(Term::read_key()); if ((key >= 'a' && key <= 'z') || (key >= 'A' && key <= 'Z') || - (Term::is_extended_ANSII(key) && !iscntrl(key))) { + (Term::is_extended_ASCII(key) && !iscntrl(key))) { std::string before = m.lines[m.cursor_row - 1].substr(0, m.cursor_col - 1); std::string newchar; diff --git a/examples/keys.cpp b/examples/keys.cpp index 436a91b7..10a180fc 100644 --- a/examples/keys.cpp +++ b/examples/keys.cpp @@ -39,7 +39,7 @@ int main() { s = (std::string) "Alt+" + (char)(key + Key::A - (Key::ALT + Key::a)); // Convert to upper case - } else if (Term::is_extended_ANSII(key) && !iscntrl(key)) { + } else if (Term::is_extended_ASCII(key) && !iscntrl(key)) { s = (char)key; } else { switch (key) { From 9e7638545b8b72162977968233e0abdfbf9c5009 Mon Sep 17 00:00:00 2001 From: flagarde Date: Thu, 15 Sep 2022 23:49:25 +0100 Subject: [PATCH 5/6] Use disable_signal_keys on Windows --- cpp-terminal/base.cpp | 4 ++-- cpp-terminal/base.hpp | 2 +- cpp-terminal/private/platform.cpp | 13 +++++++++---- cpp-terminal/private/platform.hpp | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cpp-terminal/base.cpp b/cpp-terminal/base.cpp index aac25b1f..fb0eebd4 100644 --- a/cpp-terminal/base.cpp +++ b/cpp-terminal/base.cpp @@ -122,9 +122,9 @@ void Term::get_cursor_position(int& rows, int& cols) { Term::Terminal::Terminal(bool _clear_screen, bool enable_keyboard, - bool disable_ctrl_c, + bool disable_signal_keys, bool _hide_cursor) - : BaseTerminal(enable_keyboard, disable_ctrl_c), + : BaseTerminal(enable_keyboard, disable_signal_keys), clear_screen{_clear_screen}, hide_cursor{_hide_cursor} { if (clear_screen) { diff --git a/cpp-terminal/base.hpp b/cpp-terminal/base.hpp index da21ed43..2313cf47 100644 --- a/cpp-terminal/base.hpp +++ b/cpp-terminal/base.hpp @@ -114,7 +114,7 @@ class Terminal : public Private::BaseTerminal { public: Terminal(bool _clear_screen, bool enable_keyboard, - bool disable_ctrl_c, + bool disable_signal_keys, bool _hide_cursor); // providing no parameters will disable the keyboard and ctrl+c explicit Terminal(bool _clear_screen); diff --git a/cpp-terminal/private/platform.cpp b/cpp-terminal/private/platform.cpp index 42b31bd8..75c42cb1 100644 --- a/cpp-terminal/private/platform.cpp +++ b/cpp-terminal/private/platform.cpp @@ -144,7 +144,7 @@ Term::Private::BaseTerminal::~BaseTerminal() noexcept(false) { #ifdef _WIN32 Term::Private::BaseTerminal::BaseTerminal(bool enable_keyboard, - bool /*disable_ctrl_c*/) + bool disable_signal_keys) : keyboard_enabled{enable_keyboard} { // silently disable raw mode for non-tty if (keyboard_enabled) @@ -180,15 +180,20 @@ Term::Private::BaseTerminal::BaseTerminal(bool enable_keyboard, } DWORD flags = dwOriginalInMode; flags |= ENABLE_VIRTUAL_TERMINAL_INPUT; + if(disable_signal_keys) + { + flags &= + ~ENABLE_PROCESSED_INPUT; + } flags &= - ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT); + ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT); if (!SetConsoleMode(hin, flags)) { throw std::runtime_error("SetConsoleMode() failed"); } } #else Term::Private::BaseTerminal::BaseTerminal(bool enable_keyboard, - bool disable_ctrl_c) + bool disable_signal_keys) : orig_termios{std::make_unique()}, keyboard_enabled{enable_keyboard} { // silently disable raw mode for non-tty @@ -211,7 +216,7 @@ Term::Private::BaseTerminal::BaseTerminal(bool enable_keyboard, // raw.c_oflag &= ~(OPOST); raw.c_cflag |= (CS8); raw.c_lflag &= ~(ECHO | ICANON | IEXTEN); - if (disable_ctrl_c) { + if (disable_signal_keys) { raw.c_lflag &= ~(ISIG); } raw.c_cc[VMIN] = 0; diff --git a/cpp-terminal/private/platform.hpp b/cpp-terminal/private/platform.hpp index b92de6df..cd3ae3c0 100644 --- a/cpp-terminal/private/platform.hpp +++ b/cpp-terminal/private/platform.hpp @@ -59,7 +59,7 @@ class BaseTerminal { public: explicit BaseTerminal(bool enable_keyboard = false, - bool disable_ctrl_c = true); + bool disable_signal_keys = true); virtual ~BaseTerminal() noexcept(false); }; From abe9a2604b4d23e48693e1841efca4c39dd75389 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 15 Sep 2022 22:54:24 +0000 Subject: [PATCH 6/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- cpp-terminal/private/platform.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cpp-terminal/private/platform.cpp b/cpp-terminal/private/platform.cpp index 5aafa702..46e04781 100644 --- a/cpp-terminal/private/platform.cpp +++ b/cpp-terminal/private/platform.cpp @@ -216,13 +216,10 @@ Term::Private::BaseTerminal::BaseTerminal(bool enable_keyboard, if (has_ansi_escape_code()) { flags |= ENABLE_VIRTUAL_TERMINAL_INPUT; } - if(disable_signal_keys) - { - flags &= - ~ENABLE_PROCESSED_INPUT; + if (disable_signal_keys) { + flags &= ~ENABLE_PROCESSED_INPUT; } - flags &= - ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT); + flags &= ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT); if (!SetConsoleMode(hin, flags)) { throw std::runtime_error("SetConsoleMode() failed"); }