/* This file is part of Zutty. * Copyright (C) 2020 Tom Szilagyi * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * See the file LICENSE for the full license. */ #include "options.h"#include "pty.h"#include "vterm.h" #include <cstring> namespace{ using namespace zutty; using Key = VtKey; using InputSpec = Vterm::InputSpec; #define ESC "\x1b" #define CSI ESC "[" #define SS3 ESC "O" // magic byte to act as a placeholder for the Modifier Code: #define MC "\xff" const InputSpec is_modOtherKeys2 [] = { {Key::K2, CSI "27;" MC ";50~"}, {Key::K3, CSI "27;" MC ";51~"}, {Key::K4, CSI "27;" MC ";52~"}, {Key::K5, CSI "27;" MC ";53~"}, {Key::K6, CSI "27;" MC ";54~"}, {Key::K7, CSI "27;" MC ";55~"}, {Key::K8, CSI "27;" MC ";56~"}, {Key::Backtick, CSI "27;" MC ";96~"}, {Key::Tilde, CSI "27;" MC ";126~"}, {Key::Tab, CSI "27;" MC ";9~"}, {Key::Return, CSI "27;" MC ";13~"}, {Key::Space, CSI "27;" MC ";32~"}, {Key::Backspace, CSI "27;" MC ";127~"}, {Key::NONE, nullptr}, }; const InputSpec is_Alt [] = { // UTF-8 encoded: {Key::K0, "\xc2\xb0"}, {Key::K1, "\xc2\xb1"}, {Key::K2, "\xc2\xb2"}, {Key::K3, "\xc2\xb3"}, {Key::K4, "\xc2\xb4"}, {Key::K5, "\xc2\xb5"}, {Key::K6, "\xc2\xb6"}, {Key::K7, "\xc2\xb7"}, {Key::K8, "\xc2\xb8"}, {Key::K9, "\xc2\xb9"}, {Key::Backtick, "\xc3\xa0"}, {Key::Tilde, "\xc3\xbe"}, {Key::Backspace, "\xc3\xbf"}, {Key::NONE, nullptr}, }; const InputSpec is_Alt_altSendsEscape [] = { {Key::K0, ESC "0"}, {Key::K1, ESC "1"}, {Key::K2, ESC "2"}, {Key::K3, ESC "3"}, {Key::K4, ESC "4"}, {Key::K5, ESC "5"}, {Key::K6, ESC "6"}, {Key::K7, ESC "7"}, {Key::K8, ESC "8"}, {Key::K9, ESC "9"}, {Key::Backtick, ESC "`"}, {Key::Tilde, ESC "~"}, {Key::Backspace, ESC "\x7f"}, {Key::Space, ESC " "}, {Key::Tab, ESC "\t"}, {Key::Return, ESC "\n"}, {Key::NONE, nullptr}, }; const InputSpec is_Control_modOtherKeys [] = { {Key::K0, CSI "27;" MC ";48~"}, {Key::K1, CSI "27;" MC ";49~"}, {Key::K9, CSI "27;" MC ";57~"}, {Key::Tab, CSI "27;" MC ";9~"}, {Key::NONE, nullptr}, }; const InputSpec is_ControlAlt_altSendsEscape [] = { {Key::K2, ESC "\x00", 2}, {Key::K3, ESC "\x1b", 2}, {Key::K4, ESC "\x1c", 2}, {Key::K5, ESC "\x1d", 2}, {Key::K6, ESC "\x1e", 2}, {Key::K7, ESC "\x1f", 2}, {Key::K8, ESC "\x7f", 2}, {Key::Backtick, ESC "\x00", 2}, {Key::Tilde, ESC "\x1e", 2}, {Key::Space, ESC "\x00", 2}, {Key::NONE, nullptr}, }; const InputSpec is_Control [] = { {Key::K2, "\x00", 1}, {Key::K3, "\x1b", 1}, {Key::K4, "\x1c", 1}, {Key::K5, "\x1d", 1}, {Key::K6, "\x1e", 1}, {Key::K7, "\x1f", 1}, {Key::K8, "\x7f", 1}, {Key::Backtick, "\x00", 1}, {Key::Tilde, "\x1e", 1}, {Key::Space, "\x00", 1}, {Key::NONE, nullptr}, }; const InputSpec is_Shift [] = { {Key::Tab, CSI "Z"}, {Key::NONE, nullptr}, }; const InputSpec is_modOtherKeys [] = { {Key::Return, CSI "27;" MC ";13~"}, {Key::NONE, nullptr}, }; const InputSpec is_Ansi [] = { {Key::K0, "0"}, {Key::K1, "1"}, {Key::K2, "2"}, {Key::K3, "3"}, {Key::K4, "4"}, {Key::K5, "5"}, {Key::K6, "6"}, {Key::K7, "7"}, {Key::K8, "8"}, {Key::K9, "9"}, {Key::Backtick, "`"}, {Key::Tilde, "~"}, {Key::Space, " "}, {Key::Backspace, "\x7f"}, {Key::Tab, "\t"}, {Key::Return, "\r"}, {Key::Insert, CSI "2~"}, {Key::Delete, CSI "3~"}, {Key::PageUp, CSI "5~"}, {Key::PageDown, CSI "6~"}, {Key::NONE, nullptr}, }; const InputSpec is_Mod_Ansi [] = { {Key::Insert, CSI "2;" MC "~"}, {Key::Delete, CSI "3;" MC "~"}, {Key::PageUp, CSI "5;" MC "~"}, {Key::PageDown, CSI "6;" MC "~"}, {Key::NONE, nullptr}, }; const InputSpec is_Ansi_FunctionKeys [] = { {Key::F1, SS3 "P"}, {Key::KP_F1, SS3 "P"}, {Key::F2, SS3 "Q"}, {Key::KP_F2, SS3 "Q"}, {Key::F3, SS3 "R"}, {Key::KP_F3, SS3 "R"}, {Key::F4, SS3 "S"}, {Key::KP_F4, SS3 "S"}, {Key::F5, CSI "15~"}, {Key::F6, CSI "17~"}, {Key::F7, CSI "18~"}, {Key::F8, CSI "19~"}, {Key::F9, CSI "20~"}, {Key::F10, CSI "21~"}, {Key::F11, CSI "23~"}, {Key::F12, CSI "24~"}, {Key::F13, CSI "25~"}, {Key::F14, CSI "26~"}, {Key::F15, CSI "28~"}, {Key::F16, CSI "29~"}, {Key::F17, CSI "31~"}, {Key::F18, CSI "32~"}, {Key::F19, CSI "33~"}, {Key::F20, CSI "34~"}, {Key::NONE, nullptr}, }; const InputSpec is_Mod_Ansi_FunctionKeys [] = { {Key::F1, CSI "1;" MC "P"}, {Key::KP_F1, CSI "1;" MC "P"}, {Key::F2, CSI "1;" MC "Q"}, {Key::KP_F2, CSI "1;" MC "Q"}, {Key::F3, CSI "1;" MC "R"}, {Key::KP_F3, CSI "1;" MC "R"}, {Key::F4, CSI "1;" MC "S"}, {Key::KP_F4, CSI "1;" MC "S"}, {Key::F5, CSI "15;" MC "~"}, {Key::F6, CSI "17;" MC "~"}, {Key::F7, CSI "18;" MC "~"}, {Key::F8, CSI "19;" MC "~"}, {Key::F9, CSI "20;" MC "~"}, {Key::F10, CSI "21;" MC "~"}, {Key::F11, CSI "23;" MC "~"}, {Key::F12, CSI "24;" MC "~"}, {Key::F13, CSI "25;" MC "~"}, {Key::F14, CSI "26;" MC "~"}, {Key::F15, CSI "28;" MC "~"}, {Key::F16, CSI "29;" MC "~"}, {Key::F17, CSI "31;" MC "~"}, {Key::F18, CSI "32;" MC "~"}, {Key::F19, CSI "33;" MC "~"}, {Key::F20, CSI "34;" MC "~"}, {Key::NONE, nullptr}, }; const InputSpec is_Ansi_KeypadKeys [] = { {Key::KP_Space, " "}, {Key::KP_Tab, "\t"}, {Key::KP_Enter, "\r"}, {Key::KP_Star, "*"}, {Key::KP_Plus, "+"}, {Key::KP_Comma, ","}, {Key::KP_Minus, "-"}, {Key::KP_Slash, "/"}, {Key::KP_Delete, "."}, {Key::KP_Dot, "."}, {Key::KP_Insert, "0"}, {Key::KP_0, "0"}, {Key::KP_End, "1"}, {Key::KP_1, "1"}, {Key::KP_Down, "2"}, {Key::KP_2, "2"}, {Key::KP_PageDown, "3"}, {Key::KP_3, "3"}, {Key::KP_Left, "4"}, {Key::KP_4, "4"}, {Key::KP_Begin, "5"}, {Key::KP_5, "5"}, {Key::KP_Right, "6"}, {Key::KP_6, "6"}, {Key::KP_Home, "7"}, {Key::KP_7, "7"}, {Key::KP_Up, "8"}, {Key::KP_8, "8"}, {Key::KP_PageUp, "9"}, {Key::KP_9, "9"}, {Key::KP_Equal, "="}, {Key::NONE, nullptr}, }; const InputSpec is_Appl_KeypadKeys [] = { {Key::KP_Space, SS3 " "}, {Key::KP_Tab, SS3 "I"}, {Key::KP_Enter, SS3 "M"}, {Key::KP_Star, SS3 "j"}, {Key::KP_Plus, SS3 "k"}, {Key::KP_Comma, SS3 "l"}, {Key::KP_Minus, SS3 "m"}, {Key::KP_Delete, SS3 "n"}, {Key::KP_Slash, SS3 "o"}, {Key::KP_Insert, SS3 "p"}, {Key::KP_End, SS3 "q"}, {Key::KP_Down, SS3 "r"}, {Key::KP_PageDown, SS3 "s"}, {Key::KP_Left, SS3 "t"}, {Key::KP_Begin, SS3 "u"}, {Key::KP_Right, SS3 "v"}, {Key::KP_Home, SS3 "w"}, {Key::KP_Up, SS3 "x"}, {Key::KP_PageUp, SS3 "y"}, {Key::KP_Equal, SS3 "X"}, {Key::NONE, nullptr}, }; const InputSpec is_Mod_Appl_KeypadKeys [] = { {Key::KP_Space, SS3 MC " "}, {Key::KP_Tab, SS3 MC "I"}, {Key::KP_Enter, SS3 MC "M"}, {Key::KP_Star, SS3 MC "j"}, {Key::KP_Plus, SS3 MC "k"}, {Key::KP_Comma, SS3 MC "l"}, {Key::KP_Minus, SS3 MC "m"}, {Key::KP_Delete, SS3 MC "n"}, {Key::KP_Slash, SS3 MC "o"}, {Key::KP_Insert, SS3 MC "p"}, {Key::KP_End, SS3 MC "q"}, {Key::KP_Down, SS3 MC "r"}, {Key::KP_PageDown, SS3 MC "s"}, {Key::KP_Left, SS3 MC "t"}, {Key::KP_Begin, SS3 MC "u"}, {Key::KP_Right, SS3 MC "v"}, {Key::KP_Home, SS3 MC "w"}, {Key::KP_Up, SS3 MC "x"}, {Key::KP_PageUp, SS3 MC "y"}, {Key::KP_Equal, SS3 MC "X"}, {Key::NONE, nullptr}, }; const InputSpec is_VT52_KeypadKeys [] = { {Key::KP_Space, ESC "? "}, {Key::KP_Tab, ESC "?I"}, {Key::KP_Enter, ESC "?M"}, {Key::KP_Star, ESC "?j"}, {Key::KP_Plus, ESC "?k"}, {Key::KP_Comma, ESC "?l"}, {Key::KP_Minus, ESC "?m"}, {Key::KP_Delete, ESC "?n"}, {Key::KP_Slash, ESC "?o"}, {Key::KP_Insert, ESC "?p"}, {Key::KP_End, ESC "?q"}, {Key::KP_Down, ESC "?r"}, {Key::KP_PageDown, ESC "?s"}, {Key::KP_Left, ESC "?t"}, {Key::KP_Begin, ESC "?u"}, {Key::KP_Right, ESC "?v"}, {Key::KP_Home, ESC "?w"}, {Key::KP_Up, ESC "?x"}, {Key::KP_PageUp, ESC "?y"}, {Key::KP_Equal, ESC "?X"}, {Key::NONE, nullptr}, }; const InputSpec is_VT52_FunctionKeys [] = { {Key::F1, ESC "P"}, {Key::KP_F1, ESC "P"}, {Key::F2, ESC "Q"}, {Key::KP_F2, ESC "Q"}, {Key::F3, ESC "R"}, {Key::KP_F3, ESC "R"}, {Key::F4, ESC "S"}, {Key::KP_F4, ESC "S"}, {Key::NONE, nullptr}, }; const InputSpec is_Ansi_CursorKeys [] = { {Key::Up, CSI "A"}, {Key::Down, CSI "B"}, {Key::Right, CSI "C"}, {Key::Left, CSI "D"}, {Key::Home, CSI "H"}, {Key::End, CSI "F"}, {Key::NONE, nullptr}, }; const InputSpec is_Appl_CursorKeys [] = { {Key::Up, SS3 "A"}, {Key::Down, SS3 "B"}, {Key::Right, SS3 "C"}, {Key::Left, SS3 "D"}, {Key::Home, SS3 "H"}, {Key::End, SS3 "F"}, {Key::NONE, nullptr}, }; const InputSpec is_Mod_CursorKeys [] = { {Key::Up, CSI "1;" MC "A"}, {Key::Down, CSI "1;" MC "B"}, {Key::Right, CSI "1;" MC "C"}, {Key::Left, CSI "1;" MC "D"}, {Key::Home, CSI "1;" MC "H"}, {Key::End, CSI "1;" MC "F"}, {Key::NONE, nullptr}, }; const InputSpec is_VT52_CursorKeys [] = { {Key::Up, ESC "A"}, {Key::Down, ESC "B"}, {Key::Right, ESC "C"}, {Key::Left, ESC "D"}, {Key::Home, ESC "H"}, {Key::End, ESC "F"}, {Key::NONE, nullptr}, }; const InputSpec is_ReturnKey_ANL [] = { {Key::Return, "\r\n"}, {Key::KP_Enter, "\r\n"}, {Key::NONE, nullptr}, }; const InputSpec is_BackspaceKey_BkSp [] = { {Key::Backspace, "\b"}, {Key::NONE, nullptr}, }; const InputSpec is_Alt_BackspaceKey_BkSp [] = { {Key::Backspace, ESC "\b"}, {Key::NONE, nullptr}, }; #undef ESC #undef CSI #undef SS3 inline uint8_t getModifierCode (VtModifier modifiers) { switch (modifiers) { case VtModifier::none: return 0; case VtModifier::shift: return 2; case VtModifier::alt: return 3; case VtModifier::shift_alt: return 4; case VtModifier::control: return 5; case VtModifier::shift_control: return 6; case VtModifier::control_alt: return 7; case VtModifier::shift_control_alt: return 8; } return 0; } void makePalette256 (Color p[]) { // Standard colors opts.getColor ("color0", p[0]); opts.getColor ("color1", p[1]); opts.getColor ("color2", p[2]); opts.getColor ("color3", p[3]); opts.getColor ("color4", p[4]); opts.getColor ("color5", p[5]); opts.getColor ("color6", p[6]); opts.getColor ("color7", p[7]); opts.getColor ("color8", p[8]); opts.getColor ("color9", p[9]); opts.getColor ("color10", p[10]); opts.getColor ("color11", p[11]); opts.getColor ("color12", p[12]); opts.getColor ("color13", p[13]); opts.getColor ("color14", p[14]); opts.getColor ("color15", p[15]); // 216 colors for (uint8_t r = 0; r < 6; ++r) for (uint8_t g = 0; g < 6; ++g) for (uint8_t b = 0; b < 6; ++b) { uint8_t ri = r ? 55 + 40 * r : 0; uint8_t gi = g ? 55 + 40 * g : 0; uint8_t bi = b ? 55 + 40 * b : 0; p[16 + 36 * r + 6 * g + b] = {ri, gi, bi}; } // Grayscale colors for (uint8_t s = 0; s < 24; ++s) { uint8_t i = 8 + 10 * s; p[232 + s] = {i, i, i}; } } /* These tables perform translation of built-in "hard" character sets * to 16-bit Unicode points. All sets are defined as 96 characters, even * those originally designated by DEC as 94-character sets. * * These tables are referenced by Vterm::charCodes (see below). */ // Ref: https://en.wikipedia.org/wiki/DEC_Special_Graphics const uint16_t uc_DecSpec [] = { 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f, 0x25c6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 0x23ba, 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524, 0x2534, 0x252c, 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7, 0x0020, }; // Ref: https://en.wikipedia.org/wiki/Multinational_Character_Set const uint16_t uc_DecSuppl [] = { 0x0020, 0x00a1, 0x00a2, 0x00a3, 0x0024, 0x00a5, 0x0026, 0x00a7, 0x00a4, 0x00a9, 0x00aa, 0x00ab, 0x002c, 0x002d, 0x002e, 0x002f, 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x0034, 0x00b5, 0x00b6, 0x00b7, 0x0038, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x003e, 0x00bf, 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, 0x0050, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x0152, 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0178, 0x005e, 0x00df, 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, 0x0070, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x0153, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00ff, 0x007e, 0x007f, }; Lines 1–500 of 1623. Load more
/* This file is part of Zutty. * Copyright (C) 2020 Tom Szilagyi * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * See the file LICENSE for the full license. */ #include "options.h" #include "pty.h" #include "vterm.h" #include <cstring> namespace { using namespace zutty; using Key = VtKey; using InputSpec = Vterm::InputSpec; #define ESC "\x1b" #define CSI ESC "[" #define SS3 ESC "O" // magic byte to act as a placeholder for the Modifier Code: #define MC "\xff" const InputSpec is_modOtherKeys2 [] = { {Key::K2, CSI "27;" MC ";50~"}, {Key::K3, CSI "27;" MC ";51~"}, {Key::K4, CSI "27;" MC ";52~"}, {Key::K5, CSI "27;" MC ";53~"}, {Key::K6, CSI "27;" MC ";54~"}, {Key::K7, CSI "27;" MC ";55~"}, {Key::K8, CSI "27;" MC ";56~"}, {Key::Backtick, CSI "27;" MC ";96~"}, {Key::Tilde, CSI "27;" MC ";126~"}, {Key::Tab, CSI "27;" MC ";9~"}, {Key::Return, CSI "27;" MC ";13~"}, {Key::Space, CSI "27;" MC ";32~"}, {Key::Backspace, CSI "27;" MC ";127~"}, {Key::NONE, nullptr}, }; const InputSpec is_Alt [] = { // UTF-8 encoded: {Key::K0, "\xc2\xb0"}, {Key::K1, "\xc2\xb1"}, {Key::K2, "\xc2\xb2"}, {Key::K3, "\xc2\xb3"}, {Key::K4, "\xc2\xb4"}, {Key::K5, "\xc2\xb5"}, {Key::K6, "\xc2\xb6"}, {Key::K7, "\xc2\xb7"}, {Key::K8, "\xc2\xb8"}, {Key::K9, "\xc2\xb9"}, {Key::Backtick, "\xc3\xa0"}, {Key::Tilde, "\xc3\xbe"}, {Key::Backspace, "\xc3\xbf"}, {Key::NONE, nullptr}, }; const InputSpec is_Alt_altSendsEscape [] = { {Key::K0, ESC "0"}, {Key::K1, ESC "1"}, {Key::K2, ESC "2"}, {Key::K3, ESC "3"}, {Key::K4, ESC "4"}, {Key::K5, ESC "5"}, {Key::K6, ESC "6"}, {Key::K7, ESC "7"}, {Key::K8, ESC "8"}, {Key::K9, ESC "9"}, {Key::Backtick, ESC "`"}, {Key::Tilde, ESC "~"}, {Key::Backspace, ESC "\x7f"}, {Key::Space, ESC " "}, {Key::Tab, ESC "\t"}, {Key::Return, ESC "\n"}, {Key::NONE, nullptr}, }; const InputSpec is_Control_modOtherKeys [] = { {Key::K0, CSI "27;" MC ";48~"}, {Key::K1, CSI "27;" MC ";49~"}, {Key::K9, CSI "27;" MC ";57~"}, {Key::Tab, CSI "27;" MC ";9~"}, {Key::NONE, nullptr}, }; const InputSpec is_ControlAlt_altSendsEscape [] = { {Key::K2, ESC "\x00", 2}, {Key::K3, ESC "\x1b", 2}, {Key::K4, ESC "\x1c", 2}, {Key::K5, ESC "\x1d", 2}, {Key::K6, ESC "\x1e", 2}, {Key::K7, ESC "\x1f", 2}, {Key::K8, ESC "\x7f", 2}, {Key::Backtick, ESC "\x00", 2}, {Key::Tilde, ESC "\x1e", 2}, {Key::Space, ESC "\x00", 2}, {Key::NONE, nullptr}, }; const InputSpec is_Control [] = { {Key::K2, "\x00", 1}, {Key::K3, "\x1b", 1}, {Key::K4, "\x1c", 1}, {Key::K5, "\x1d", 1}, {Key::K6, "\x1e", 1}, {Key::K7, "\x1f", 1}, {Key::K8, "\x7f", 1}, {Key::Backtick, "\x00", 1}, {Key::Tilde, "\x1e", 1}, {Key::Space, "\x00", 1}, {Key::NONE, nullptr}, }; const InputSpec is_Shift [] = { {Key::Tab, CSI "Z"}, {Key::NONE, nullptr}, }; const InputSpec is_modOtherKeys [] = { {Key::Return, CSI "27;" MC ";13~"}, {Key::NONE, nullptr}, }; const InputSpec is_Ansi [] = { {Key::K0, "0"}, {Key::K1, "1"}, {Key::K2, "2"}, {Key::K3, "3"}, {Key::K4, "4"}, {Key::K5, "5"}, {Key::K6, "6"}, {Key::K7, "7"}, {Key::K8, "8"}, {Key::K9, "9"}, {Key::Backtick, "`"}, {Key::Tilde, "~"}, {Key::Space, " "}, {Key::Backspace, "\x7f"}, {Key::Tab, "\t"}, {Key::Return, "\r"}, {Key::Insert, CSI "2~"}, {Key::Delete, CSI "3~"}, {Key::PageUp, CSI "5~"}, {Key::PageDown, CSI "6~"}, {Key::NONE, nullptr}, }; const InputSpec is_Mod_Ansi [] = { {Key::Insert, CSI "2;" MC "~"}, {Key::Delete, CSI "3;" MC "~"}, {Key::PageUp, CSI "5;" MC "~"}, {Key::PageDown, CSI "6;" MC "~"}, {Key::NONE, nullptr}, }; const InputSpec is_Ansi_FunctionKeys [] = { {Key::F1, SS3 "P"}, {Key::KP_F1, SS3 "P"}, {Key::F2, SS3 "Q"}, {Key::KP_F2, SS3 "Q"}, {Key::F3, SS3 "R"}, {Key::KP_F3, SS3 "R"}, {Key::F4, SS3 "S"}, {Key::KP_F4, SS3 "S"}, {Key::F5, CSI "15~"}, {Key::F6, CSI "17~"}, {Key::F7, CSI "18~"}, {Key::F8, CSI "19~"}, {Key::F9, CSI "20~"}, {Key::F10, CSI "21~"}, {Key::F11, CSI "23~"}, {Key::F12, CSI "24~"}, {Key::F13, CSI "25~"}, {Key::F14, CSI "26~"}, {Key::F15, CSI "28~"}, {Key::F16, CSI "29~"}, {Key::F17, CSI "31~"}, {Key::F18, CSI "32~"}, {Key::F19, CSI "33~"}, {Key::F20, CSI "34~"}, {Key::NONE, nullptr}, }; const InputSpec is_Mod_Ansi_FunctionKeys [] = { {Key::F1, CSI "1;" MC "P"}, {Key::KP_F1, CSI "1;" MC "P"}, {Key::F2, CSI "1;" MC "Q"}, {Key::KP_F2, CSI "1;" MC "Q"}, {Key::F3, CSI "1;" MC "R"}, {Key::KP_F3, CSI "1;" MC "R"}, {Key::F4, CSI "1;" MC "S"}, {Key::KP_F4, CSI "1;" MC "S"}, {Key::F5, CSI "15;" MC "~"}, {Key::F6, CSI "17;" MC "~"}, {Key::F7, CSI "18;" MC "~"}, {Key::F8, CSI "19;" MC "~"}, {Key::F9, CSI "20;" MC "~"}, {Key::F10, CSI "21;" MC "~"}, {Key::F11, CSI "23;" MC "~"}, {Key::F12, CSI "24;" MC "~"}, {Key::F13, CSI "25;" MC "~"}, {Key::F14, CSI "26;" MC "~"}, {Key::F15, CSI "28;" MC "~"}, {Key::F16, CSI "29;" MC "~"}, {Key::F17, CSI "31;" MC "~"}, {Key::F18, CSI "32;" MC "~"}, {Key::F19, CSI "33;" MC "~"}, {Key::F20, CSI "34;" MC "~"}, {Key::NONE, nullptr}, }; const InputSpec is_Ansi_KeypadKeys [] = { {Key::KP_Space, " "}, {Key::KP_Tab, "\t"}, {Key::KP_Enter, "\r"}, {Key::KP_Star, "*"}, {Key::KP_Plus, "+"}, {Key::KP_Comma, ","}, {Key::KP_Minus, "-"}, {Key::KP_Slash, "/"}, {Key::KP_Delete, "."}, {Key::KP_Dot, "."}, {Key::KP_Insert, "0"}, {Key::KP_0, "0"}, {Key::KP_End, "1"}, {Key::KP_1, "1"}, {Key::KP_Down, "2"}, {Key::KP_2, "2"}, {Key::KP_PageDown, "3"}, {Key::KP_3, "3"}, {Key::KP_Left, "4"}, {Key::KP_4, "4"}, {Key::KP_Begin, "5"}, {Key::KP_5, "5"}, {Key::KP_Right, "6"}, {Key::KP_6, "6"}, {Key::KP_Home, "7"}, {Key::KP_7, "7"}, {Key::KP_Up, "8"}, {Key::KP_8, "8"}, {Key::KP_PageUp, "9"}, {Key::KP_9, "9"}, {Key::KP_Equal, "="}, {Key::NONE, nullptr}, }; const InputSpec is_Appl_KeypadKeys [] = { {Key::KP_Space, SS3 " "}, {Key::KP_Tab, SS3 "I"}, {Key::KP_Enter, SS3 "M"}, {Key::KP_Star, SS3 "j"}, {Key::KP_Plus, SS3 "k"}, {Key::KP_Comma, SS3 "l"}, {Key::KP_Minus, SS3 "m"}, {Key::KP_Delete, SS3 "n"}, {Key::KP_Slash, SS3 "o"}, {Key::KP_Insert, SS3 "p"}, {Key::KP_End, SS3 "q"}, {Key::KP_Down, SS3 "r"}, {Key::KP_PageDown, SS3 "s"}, {Key::KP_Left, SS3 "t"}, {Key::KP_Begin, SS3 "u"}, {Key::KP_Right, SS3 "v"}, {Key::KP_Home, SS3 "w"}, {Key::KP_Up, SS3 "x"}, {Key::KP_PageUp, SS3 "y"}, {Key::KP_Equal, SS3 "X"}, {Key::NONE, nullptr}, }; const InputSpec is_Mod_Appl_KeypadKeys [] = { {Key::KP_Space, SS3 MC " "}, {Key::KP_Tab, SS3 MC "I"}, {Key::KP_Enter, SS3 MC "M"}, {Key::KP_Star, SS3 MC "j"}, {Key::KP_Plus, SS3 MC "k"}, {Key::KP_Comma, SS3 MC "l"}, {Key::KP_Minus, SS3 MC "m"}, {Key::KP_Delete, SS3 MC "n"}, {Key::KP_Slash, SS3 MC "o"}, {Key::KP_Insert, SS3 MC "p"}, {Key::KP_End, SS3 MC "q"}, {Key::KP_Down, SS3 MC "r"}, {Key::KP_PageDown, SS3 MC "s"}, {Key::KP_Left, SS3 MC "t"}, {Key::KP_Begin, SS3 MC "u"}, {Key::KP_Right, SS3 MC "v"}, {Key::KP_Home, SS3 MC "w"}, {Key::KP_Up, SS3 MC "x"}, {Key::KP_PageUp, SS3 MC "y"}, {Key::KP_Equal, SS3 MC "X"}, {Key::NONE, nullptr}, }; const InputSpec is_VT52_KeypadKeys [] = { {Key::KP_Space, ESC "? "}, {Key::KP_Tab, ESC "?I"}, {Key::KP_Enter, ESC "?M"}, {Key::KP_Star, ESC "?j"}, {Key::KP_Plus, ESC "?k"}, {Key::KP_Comma, ESC "?l"}, {Key::KP_Minus, ESC "?m"}, {Key::KP_Delete, ESC "?n"}, {Key::KP_Slash, ESC "?o"}, {Key::KP_Insert, ESC "?p"}, {Key::KP_End, ESC "?q"}, {Key::KP_Down, ESC "?r"}, {Key::KP_PageDown, ESC "?s"}, {Key::KP_Left, ESC "?t"}, {Key::KP_Begin, ESC "?u"}, {Key::KP_Right, ESC "?v"}, {Key::KP_Home, ESC "?w"}, {Key::KP_Up, ESC "?x"}, {Key::KP_PageUp, ESC "?y"}, {Key::KP_Equal, ESC "?X"}, {Key::NONE, nullptr}, }; const InputSpec is_VT52_FunctionKeys [] = { {Key::F1, ESC "P"}, {Key::KP_F1, ESC "P"}, {Key::F2, ESC "Q"}, {Key::KP_F2, ESC "Q"}, {Key::F3, ESC "R"}, {Key::KP_F3, ESC "R"}, {Key::F4, ESC "S"}, {Key::KP_F4, ESC "S"}, {Key::NONE, nullptr}, }; const InputSpec is_Ansi_CursorKeys [] = { {Key::Up, CSI "A"}, {Key::Down, CSI "B"}, {Key::Right, CSI "C"}, {Key::Left, CSI "D"}, {Key::Home, CSI "H"}, {Key::End, CSI "F"}, {Key::NONE, nullptr}, }; const InputSpec is_Appl_CursorKeys [] = { {Key::Up, SS3 "A"}, {Key::Down, SS3 "B"}, {Key::Right, SS3 "C"}, {Key::Left, SS3 "D"}, {Key::Home, SS3 "H"}, {Key::End, SS3 "F"}, {Key::NONE, nullptr}, }; const InputSpec is_Mod_CursorKeys [] = { {Key::Up, CSI "1;" MC "A"}, {Key::Down, CSI "1;" MC "B"}, {Key::Right, CSI "1;" MC "C"}, {Key::Left, CSI "1;" MC "D"}, {Key::Home, CSI "1;" MC "H"}, {Key::End, CSI "1;" MC "F"}, {Key::NONE, nullptr}, }; const InputSpec is_VT52_CursorKeys [] = { {Key::Up, ESC "A"}, {Key::Down, ESC "B"}, {Key::Right, ESC "C"}, {Key::Left, ESC "D"}, {Key::Home, ESC "H"}, {Key::End, ESC "F"}, {Key::NONE, nullptr}, }; const InputSpec is_ReturnKey_ANL [] = { {Key::Return, "\r\n"}, {Key::KP_Enter, "\r\n"}, {Key::NONE, nullptr}, }; const InputSpec is_BackspaceKey_BkSp [] = { {Key::Backspace, "\b"}, {Key::NONE, nullptr}, }; const InputSpec is_Alt_BackspaceKey_BkSp [] = { {Key::Backspace, ESC "\b"}, {Key::NONE, nullptr}, }; #undef ESC #undef CSI #undef SS3 inline uint8_t getModifierCode (VtModifier modifiers) { switch (modifiers) { case VtModifier::none: return 0; case VtModifier::shift: return 2; case VtModifier::alt: return 3; case VtModifier::shift_alt: return 4; case VtModifier::control: return 5; case VtModifier::shift_control: return 6; case VtModifier::control_alt: return 7; case VtModifier::shift_control_alt: return 8; } return 0; } void makePalette256 (Color p[]) { // Standard colors opts.getColor ("color0", p[0]); opts.getColor ("color1", p[1]); opts.getColor ("color2", p[2]); opts.getColor ("color3", p[3]); opts.getColor ("color4", p[4]); opts.getColor ("color5", p[5]); opts.getColor ("color6", p[6]); opts.getColor ("color7", p[7]); opts.getColor ("color8", p[8]); opts.getColor ("color9", p[9]); opts.getColor ("color10", p[10]); opts.getColor ("color11", p[11]); opts.getColor ("color12", p[12]); opts.getColor ("color13", p[13]); opts.getColor ("color14", p[14]); opts.getColor ("color15", p[15]); // 216 colors for (uint8_t r = 0; r < 6; ++r) for (uint8_t g = 0; g < 6; ++g) for (uint8_t b = 0; b < 6; ++b) { uint8_t ri = r ? 55 + 40 * r : 0; uint8_t gi = g ? 55 + 40 * g : 0; uint8_t bi = b ? 55 + 40 * b : 0; p[16 + 36 * r + 6 * g + b] = {ri, gi, bi}; } // Grayscale colors for (uint8_t s = 0; s < 24; ++s) { uint8_t i = 8 + 10 * s; p[232 + s] = {i, i, i}; } } /* These tables perform translation of built-in "hard" character sets * to 16-bit Unicode points. All sets are defined as 96 characters, even * those originally designated by DEC as 94-character sets. * * These tables are referenced by Vterm::charCodes (see below). */ // Ref: https://en.wikipedia.org/wiki/DEC_Special_Graphics const uint16_t uc_DecSpec [] = { 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f, 0x25c6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 0x23ba, 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524, 0x2534, 0x252c, 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7, 0x0020, }; // Ref: https://en.wikipedia.org/wiki/Multinational_Character_Set const uint16_t uc_DecSuppl [] = { 0x0020, 0x00a1, 0x00a2, 0x00a3, 0x0024, 0x00a5, 0x0026, 0x00a7, 0x00a4, 0x00a9, 0x00aa, 0x00ab, 0x002c, 0x002d, 0x002e, 0x002f, 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x0034, 0x00b5, 0x00b6, 0x00b7, 0x0038, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x003e, 0x00bf, 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, 0x0050, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x0152, 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0178, 0x005e, 0x00df, 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, 0x0070, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x0153, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00ff, 0x007e, 0x007f, };