diff --git a/demos/colors/source/colors.d b/demos/colors/source/colors.d index ba8a5d8..c52c9b0 100644 --- a/demos/colors/source/colors.d +++ b/demos/colors/source/colors.d @@ -1,7 +1,7 @@ /** * Color demo for dcell. * - * Copyright: Copyright 2022 Garrett D'Amore + * Copyright: Copyright 2025 Garrett D'Amore * Authors: Garrett D'Amore * License: * Distributed under the Boost Software License, Version 1.0. @@ -19,154 +19,158 @@ import dcell; class ColorBoxes { - import std.random; + import std.random; - int r; - int g; - int b; - int ri; - int gi; - int bi; - Random rng; - enum inc = 8; - int cnt; + int r; + int g; + int b; + int ri; + int gi; + int bi; + Random rng; + enum inc = 8; + int cnt; - bool flip() - { - return (rng.uniform!ubyte() & 0x1) != 0; - } + bool flip() + { + return (rng.uniform!ubyte() & 0x1) != 0; + } - this() - { - rng = rndGen(); - r = rng.uniform!ubyte(); - g = rng.uniform!ubyte(); - b = rng.uniform!ubyte(); - ri = inc; - gi = inc / 4; // humans are very sensitive to green - bi = inc; - } + this() + { + rng = rndGen(); + r = rng.uniform!ubyte(); + g = rng.uniform!ubyte(); + b = rng.uniform!ubyte(); + ri = inc; + gi = inc / 4; // humans are very sensitive to green + bi = inc; + } - void makeBox(Screen s) - { - Coord wsz = s.size(); - dchar dc = ' '; - Style style; - cnt++; + void makeBox(Screen s) + { + Coord wsz = s.size(); + dchar dc = ' '; + Style style; + cnt++; - if (s.colors() == 0) - { - dchar[] glyphs = ['@', '#', '&', '*', '=', '%', 'Z', 'A']; - dc = choice(glyphs, rng); - if (flip()) - style.attr |= Attr.reverse; - else - style.attr &= ~Attr.reverse; - } - else - { - r += ri; - g += gi; - b += bi; - if (r >= 256 || r < 0) - { - ri = -ri; - r += ri; - } - if (g >= 256 || g < 0) - { - gi = -gi; - g += gi; - } - if (b >= 256 || b < 0) - { - bi = -bi; - b += bi; - } - if (cnt % (256 / inc) == 0) - { - if (flip()) - { - ri = -ri; - } + if (s.colors() == 0) + { + dchar[] glyphs = ['@', '#', '&', '*', '=', '%', 'Z', 'A']; + dc = choice(glyphs, rng); + if (flip()) + style.attr |= Attr.reverse; + else + style.attr &= ~Attr.reverse; + } + else + { + r += ri; + g += gi; + b += bi; + if (r >= 256 || r < 0) + { + ri = -ri; + r += ri; + } + if (g >= 256 || g < 0) + { + gi = -gi; + g += gi; + } + if (b >= 256 || b < 0) + { + bi = -bi; + b += bi; + } + if (cnt % (256 / inc) == 0) + { + if (flip()) + { + ri = -ri; + } - if (flip()) - { - gi = -gi; - } + if (flip()) + { + gi = -gi; + } - if (flip()) - { - bi = -bi; - } - } - style.bg = fromHex( - int(r) << 15 | int(g) << 8 | int(b)); - } + if (flip()) + { + bi = -bi; + } + } + style.bg = fromHex( + int(r) << 16 | int(g) << 8 | int(b)); + } - // half the width and half the height - Coord c1 = Coord(wsz.x / 4, wsz.y / 4); - Coord c2 = Coord(c1.x + wsz.x / 2, c1.y + wsz.y / 2); - Coord pos = c1; - Cell cell = Cell(dc, style); - for (pos.y = c1.y; pos.y <= c2.y; pos.y++) - { - for (pos.x = c1.x; pos.x <= c2.x; pos.x++) - { - s[pos] = cell; - } - } - s.show(); - } + // half the width and half the height + Coord c1 = Coord(wsz.x / 4, wsz.y / 4); + Coord c2 = Coord(c1.x + wsz.x / 2, c1.y + wsz.y / 2); + Coord pos = c1; + Cell cell = Cell(dc, style); + for (pos.y = c1.y; pos.y <= c2.y; pos.y++) + { + for (pos.x = c1.x; pos.x <= c2.x; pos.x++) + { + s[pos] = cell; + } + } + s.show(); + } } void main() { - import std.stdio; - import core.time; - import core.stdc.stdlib; + import std.stdio; + import core.time; + import core.stdc.stdlib; - auto s = newScreen(); - assert(s !is null); - ColorBoxes cb = new ColorBoxes(); + auto s = newScreen(); + assert(s !is null); + ColorBoxes cb = new ColorBoxes(); - auto now = MonoTime.currTime(); + auto now = MonoTime.currTime(); - s.start(); - bool done = false; - while (!done) - { - cb.makeBox(s); - auto ev = s.receiveEvent(msecs(50)); - switch (ev.type) - { - case EventType.key: - switch (ev.key.key) - { - case Key.esc, Key.enter: - done = true; - break; - case Key.ctrlL: - s.resize(); - s.sync(); - break; - default: + s.start(); + bool done = false; + while (!done) + { + cb.makeBox(s); + auto ev = s.receiveEvent(msecs(50)); + switch (ev.type) + { + case EventType.key: + switch (ev.key.key) + { + case Key.esc, Key.enter: + done = true; + break; + case Key.rune: + // Ctrl-L (without other modifiers) used to force a redraw. + if (ev.key.ch == 'l' && ev.key.mod == Modifiers.ctrl) + { + s.resize(); + s.sync(); + } + break; + default: - } - break; - case EventType.resize: - s.resize(); - break; - case EventType.closed: - done = true; - break; - case EventType.error: - assert(0, "errror received"); - default: - } - } - auto end = MonoTime.currTime(); - s.stop(); - writefln("Drew %d boxes in %s.", cb.cnt, end - now); - writefln("Average per box %s.", (end - now) / cb.cnt); + } + break; + case EventType.resize: + s.resize(); + break; + case EventType.closed: + done = true; + break; + case EventType.error: + assert(0, "error received"); + default: + } + } + auto end = MonoTime.currTime(); + s.stop(); + writefln("Drew %d boxes in %s.", cb.cnt, end - now); + writefln("Average per box %s.", (end - now) / cb.cnt); } diff --git a/demos/mouse/source/mouse.d b/demos/mouse/source/mouse.d index a93cd0c..1b1ef79 100644 --- a/demos/mouse/source/mouse.d +++ b/demos/mouse/source/mouse.d @@ -1,7 +1,7 @@ /** * Mouse demo for dcell. This demonstrates various forms of input handling. * - * Copyright: Copyright 2022 Garrett D'Amore + * Copyright: Copyright 2025 Garrett D'Amore * Authors: Garrett D'Amore * License: * Distributed under the Boost Software License, Version 1.0. @@ -19,269 +19,280 @@ import dcell; void emitStr(Screen s, Coord pos, Style style, dstring str) { - while (str != "") - { - s[pos] = Cell(str[0], style); - str = str[1 .. $]; - pos.x++; - } + while (str != "") + { + s[pos] = Cell(str[0], style); + str = str[1 .. $]; + pos.x++; + } } void order(ref int i1, ref int i2) { - if (i2 < i1) - { - int v = i1; - i1 = i2; - i2 = v; - } + if (i2 < i1) + { + int v = i1; + i1 = i2; + i2 = v; + } } void order(ref Coord c1, ref Coord c2) { - order(c1.x, c2.x); - order(c1.y, c2.y); + order(c1.x, c2.x); + order(c1.y, c2.y); } void drawBox(Screen s, Coord c1, Coord c2, Style style, dchar fill = ' ') { - order(c1, c2); - Coord pos; - for (pos.x = c1.x; pos.x <= c2.x; pos.x++) - { - s[Coord(pos.x, c1.y)] = Cell(Glyph.horizLine, style); - s[Coord(pos.x, c2.y)] = Cell(Glyph.horizLine, style); - } - for (pos.y = c1.y + 1; pos.y < c2.y; pos.y++) - { - s[Coord(c1.x, pos.y)] = Cell(Glyph.vertLine, style); - s[Coord(c2.x, pos.y)] = Cell(Glyph.vertLine, style); - } - if (c1.y != c2.y && c1.x != c2.x) - { - s[Coord(c1.x, c1.y)] = Cell(Glyph.upperLeftCorner, style); - s[Coord(c2.x, c1.y)] = Cell(Glyph.upperRightCorner, style); - s[Coord(c1.x, c2.y)] = Cell(Glyph.lowerLeftCorner, style); - s[Coord(c2.x, c2.y)] = Cell(Glyph.lowerRightCorner, style); - } - for (pos.y = c1.y + 1; pos.y < c2.y; pos.y++) - { - for (pos.x = c1.x + 1; pos.x < c2.x; pos.x++) - { - s[pos] = Cell(fill, style); - } - } + order(c1, c2); + Coord pos; + for (pos.x = c1.x; pos.x <= c2.x; pos.x++) + { + s[Coord(pos.x, c1.y)] = Cell(Glyph.horizLine, style); + s[Coord(pos.x, c2.y)] = Cell(Glyph.horizLine, style); + } + for (pos.y = c1.y + 1; pos.y < c2.y; pos.y++) + { + s[Coord(c1.x, pos.y)] = Cell(Glyph.vertLine, style); + s[Coord(c2.x, pos.y)] = Cell(Glyph.vertLine, style); + } + if (c1.y != c2.y && c1.x != c2.x) + { + s[Coord(c1.x, c1.y)] = Cell(Glyph.upperLeftCorner, style); + s[Coord(c2.x, c1.y)] = Cell(Glyph.upperRightCorner, style); + s[Coord(c1.x, c2.y)] = Cell(Glyph.lowerLeftCorner, style); + s[Coord(c2.x, c2.y)] = Cell(Glyph.lowerRightCorner, style); + } + for (pos.y = c1.y + 1; pos.y < c2.y; pos.y++) + { + for (pos.x = c1.x + 1; pos.x < c2.x; pos.x++) + { + s[pos] = Cell(fill, style); + } + } } void drawSelect(Screen s, Coord c1, Coord c2, bool sel) { - order(c1, c2); - Coord pos; - for (pos.y = c1.y; pos.y < c2.y; pos.y++) - { - for (pos.x = c1.x; pos.x < c2.x; pos.x++) - { - if (sel) - s[pos].style.attr |= Attr.reverse; - else - s[pos].style.attr &= ~Attr.reverse; - } - } + order(c1, c2); + Coord pos; + for (pos.y = c1.y; pos.y < c2.y; pos.y++) + { + for (pos.x = c1.x; pos.x < c2.x; pos.x++) + { + if (sel) + s[pos].style.attr |= Attr.reverse; + else + s[pos].style.attr &= ~Attr.reverse; + } + } } void main() { - import std.stdio; + import std.stdio; - auto s = newScreen(); - assert(s !is null); + auto s = newScreen(); + assert(s !is null); - dstring posFmt = "Mouse: %d, %d"; - dstring btnFmt = "Buttons: %s"; - dstring keyFmt = "Keys: %s"; - dstring pasteFmt = "Paste: [%d] %s"; - dstring bStr = ""; - dstring kStr = ""; - dstring pStr = ""; + dstring posFmt = "Mouse: %d, %d"; + dstring btnFmt = "Buttons: %s"; + dstring keyFmt = "Keys: %s"; + dstring pasteFmt = "Paste: [%d] %s"; + dstring focusFmt = "Focus: %s"; + dstring bStr = ""; + dstring kStr = ""; + dstring pStr = ""; - s.start(thisTid()); - s.showCursor(Cursor.hidden); - s.enableMouse(MouseEnable.all); - s.enablePaste(true); - Style white; - white.fg = Color.midnightBlue; - white.bg = Color.lightCoral; - Coord mousePos = Coord(-1, -1); - Coord oldTop = Coord(-1, -1); - Coord oldBot = Coord(-1, -1); - int esc = 0; - dchar lb; + s.start(thisTid()); + s.showCursor(Cursor.hidden); + s.enableMouse(MouseEnable.all); + s.enablePaste(true); + s.enableFocus(true); + Style white; + white.fg = Color.midnightBlue; + white.bg = Color.lightCoral; + Coord mousePos = Coord(-1, -1); + Coord oldTop = Coord(-1, -1); + Coord oldBot = Coord(-1, -1); + int esc = 0; + dchar lb; + bool focused = true; - for (;;) - { - auto ps = pStr; - if (ps.length > 25) - ps = "..." ~ ps[$ - 23 .. $]; - drawBox(s, Coord(1, 1), Coord(42, 7), white); - Coord pos = Coord(3, 2); - emitStr(s, pos, white, "Press ESC twice to exit, C to clear."); - pos.y++; - emitStr(s, pos, white, format(posFmt, mousePos.x, mousePos.y)); - pos.y++; - emitStr(s, pos, white, format(btnFmt, bStr)); - pos.y++; - emitStr(s, pos, white, format(keyFmt, kStr)); - pos.y++; - emitStr(s, pos, white, format(pasteFmt, pStr.length, ps)); - s.show(); - bStr = ""; - Event ev; - receive( - (Event ee) { ev = ee; } - ); - Style st; - st.bg = Color.red; - Style up; - up.bg = Color.blue; - up.fg = Color.black; - // clear previous selection - if (oldTop.x >= 0 && oldTop.y >= 0 && oldBot.x >= 0) - { - drawSelect(s, oldTop, oldBot, false); - } - pos = s.size(); - pos.x--; - pos.y--; + for (;;) + { + auto ps = pStr; + if (ps.length > 25) + ps = "..." ~ ps[$ - 23 .. $]; + drawBox(s, Coord(1, 1), Coord(42, 8), white); + Coord pos = Coord(3, 2); + emitStr(s, pos, white, "Press ESC twice to exit, C to clear."); + pos.y++; + emitStr(s, pos, white, format(posFmt, mousePos.x, mousePos.y)); + pos.y++; + emitStr(s, pos, white, format(btnFmt, bStr)); + pos.y++; + emitStr(s, pos, white, format(keyFmt, kStr)); + pos.y++; + emitStr(s, pos, white, format(focusFmt, focused)); + pos.y++; + emitStr(s, pos, white, format(pasteFmt, pStr.length, ps)); + s.show(); + bStr = ""; + Event ev; + receive( + (Event ee) { ev = ee; } + ); + Style st; + st.bg = Color.red; + Style up; + up.bg = Color.blue; + up.fg = Color.black; + // clear previous selection + if (oldTop.x >= 0 && oldTop.y >= 0 && oldBot.x >= 0) + { + drawSelect(s, oldTop, oldBot, false); + } + pos = s.size(); + pos.x--; + pos.y--; - switch (ev.type) - { - case EventType.resize: - s.resize(); - s.sync(); - break; - case EventType.paste: - pStr = ev.paste.content; - break; - case EventType.key: - pStr = ""; - s[pos] = Cell('K', st); - switch (ev.key.key) - { - case Key.esc: - esc++; - if (esc > 1) - { - s.stop(); - exit(0); - } - break; - case Key.ctrlL: - s.sync(); - esc = 0; - break; - case Key.rune: - if (ev.key.ch == 'C' || ev.key.ch == 'c') - { - s.clear(); - } - esc = 0; - s[pos] = Cell('R', st); - break; - default: - break; - } - kStr = ev.key.toString(); - break; - case EventType.mouse: - if (ev.mouse.mod & Modifiers.shift) - bStr ~= " S"; - if (ev.mouse.mod & Modifiers.ctrl) - bStr ~= " C"; - if (ev.mouse.mod & Modifiers.alt) - bStr ~= " A"; - if (ev.mouse.mod & Modifiers.meta) - bStr ~= " M"; - if (ev.mouse.btn & Buttons.wheelUp) - bStr ~= " WU"; - if (ev.mouse.btn & Buttons.wheelDown) - bStr ~= " WD"; - if (ev.mouse.btn & Buttons.wheelLeft) - bStr ~= " WL"; - if (ev.mouse.btn & Buttons.wheelRight) - bStr ~= " WR"; - // we only want buttons, not wheel events - auto button = ev.mouse.btn; - button &= 0xff; + switch (ev.type) + { + case EventType.resize: + s.resize(); + s.sync(); + break; + case EventType.paste: + pStr = ev.paste.content; + break; + case EventType.key: + pStr = ""; + s[pos] = Cell('K', st); + switch (ev.key.key) + { + case Key.esc: + esc++; + if (esc > 1) + { + s.stop(); + exit(0); + } + break; + case Key.rune: + if (ev.key.ch == 'C' || ev.key.ch == 'c') + { + s.clear(); + } + // Ctrl-L (without other modifiers) is used to redraw (UNIX convention) + else if (ev.key.ch == 'l' && ev.key.mod == Modifiers.ctrl) + { + s.sync(); + } + esc = 0; + s[pos] = Cell('R', st); + break; + default: + break; + } + kStr = ev.key.toString(); + break; + case EventType.mouse: + if (ev.mouse.mod & Modifiers.shift) + bStr ~= " S"; + if (ev.mouse.mod & Modifiers.ctrl) + bStr ~= " C"; + if (ev.mouse.mod & Modifiers.alt) + bStr ~= " A"; + if (ev.mouse.mod & Modifiers.meta) + bStr ~= " M"; + if (ev.mouse.mod & Modifiers.hyper) + bStr ~= " H"; + if (ev.mouse.btn & Buttons.wheelUp) + bStr ~= " WU"; + if (ev.mouse.btn & Buttons.wheelDown) + bStr ~= " WD"; + if (ev.mouse.btn & Buttons.wheelLeft) + bStr ~= " WL"; + if (ev.mouse.btn & Buttons.wheelRight) + bStr ~= " WR"; + // we only want buttons, not wheel events + auto button = ev.mouse.btn; + button &= 0xff; - if ((button != Buttons.none) && (oldTop.x < 0)) - { - oldTop = ev.mouse.pos; - } + if ((button != Buttons.none) && (oldTop.x < 0)) + { + oldTop = ev.mouse.pos; + } - // NB: this does is the unmasked value! - // It also does not support chording mouse buttons - switch (ev.mouse.btn) - { - case Buttons.none: - if (oldTop.x >= 0) - { - Style ns = up; - ns.bg = (cast(Color)(lb - '0')); - drawBox(s, oldTop, ev.mouse.pos, ns, lb); - oldTop = Coord(-1, -1); - oldBot = Coord(-1, -1); - } - break; - case Buttons.button1: - lb = '1'; - bStr ~= " B1"; - break; - case Buttons.button2: - lb = '2'; - bStr ~= " B2"; - break; - case Buttons.button3: - lb = '3'; - bStr ~= " B3"; - break; - case Buttons.button4: - lb = '4'; - bStr ~= " B4"; - break; - case Buttons.button5: - lb = '5'; - bStr ~= " B5"; - break; - case Buttons.button6: - lb = '6'; - bStr ~= " B6"; - break; - case Buttons.button7: - lb = '7'; - bStr ~= " B7"; - break; - case Buttons.button8: - lb = '8'; - bStr ~= " B8"; - break; - default: - lb = '?'; - break; - } - // mousePos = ev.mouse.pos; - if (button != Buttons.none) - oldBot = ev.mouse.pos; + // NB: this does is the unmasked value! + // It also does not support chording mouse buttons + switch (ev.mouse.btn) + { + case Buttons.none: + if (oldTop.x >= 0) + { + Style ns = up; + ns.bg = (cast(Color)(lb - '0')); + drawBox(s, oldTop, ev.mouse.pos, ns, lb); + oldTop = Coord(-1, -1); + oldBot = Coord(-1, -1); + } + break; + case Buttons.button1: + lb = '1'; + bStr ~= " B1"; + break; + case Buttons.button2: + lb = '2'; + bStr ~= " B2"; + break; + case Buttons.button3: + lb = '3'; + bStr ~= " B3"; + break; + case Buttons.button4: + lb = '4'; + bStr ~= " B4"; + break; + case Buttons.button5: + lb = '5'; + bStr ~= " B5"; + break; + case Buttons.button6: + lb = '6'; + bStr ~= " B6"; + break; + case Buttons.button7: + lb = '7'; + bStr ~= " B7"; + break; + case Buttons.button8: + lb = '8'; + bStr ~= " B8"; + break; + default: + lb = '?'; + break; + } + // mousePos = ev.mouse.pos; + if (button != Buttons.none) + oldBot = ev.mouse.pos; - mousePos = ev.mouse.pos; - s[pos] = Cell('M', st); - break; - default: - s[pos] = Cell('X', st); - break; - } - if (oldTop.x >= 0 && oldBot.x >= 0) - { - drawSelect(s, oldTop, oldBot, true); - } - } + mousePos = ev.mouse.pos; + s[pos] = Cell('M', st); + break; + case EventType.focus: + focused = ev.focus.focused; + break; + default: + s[pos] = Cell('X', st); + break; + } + if (oldTop.x >= 0 && oldBot.x >= 0) + { + drawSelect(s, oldTop, oldBot, true); + } + } } diff --git a/mkinfo/source/mkinfo.d b/mkinfo/source/mkinfo.d index 574e3f8..91ca5d7 100644 --- a/mkinfo/source/mkinfo.d +++ b/mkinfo/source/mkinfo.d @@ -1,4 +1,4 @@ -// Copyright 2022 Garrett D'Amore +// Copyright 2025 Garrett D'Amore // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE or https://www.boost.org/LICENSE_1_0.txt) @@ -301,7 +301,7 @@ private Termcap* convertCaps(Caps* caps) { auto tc = new Termcap; tc.name = caps.name; - tc.aliases = cast(immutable(string)[])caps.aliases; + tc.aliases = cast(immutable(string)[]) caps.aliases; tc.colors = caps.getInt("colors"); tc.columns = caps.getInt("columns"); tc.lines = caps.getInt("lines"); @@ -329,35 +329,6 @@ private Termcap* convertCaps(Caps* caps) tc.cursorUp1 = caps.getStr("cuu1"); tc.insertChar = caps.getStr("ich1"); tc.automargin = caps.getBool("am"); - tc.keyF1 = caps.getStr("kf1"); - tc.keyF2 = caps.getStr("kf2"); - tc.keyF3 = caps.getStr("kf3"); - tc.keyF4 = caps.getStr("kf4"); - tc.keyF5 = caps.getStr("kf5"); - tc.keyF6 = caps.getStr("kf6"); - tc.keyF7 = caps.getStr("kf7"); - tc.keyF8 = caps.getStr("kf8"); - tc.keyF9 = caps.getStr("kf9"); - tc.keyF10 = caps.getStr("kf10"); - tc.keyF11 = caps.getStr("kf11"); - tc.keyF12 = caps.getStr("kf12"); - tc.keyInsert = caps.getStr("kich1"); - tc.keyDelete = caps.getStr("kdch1"); - tc.keyBackspace = caps.getStr("kbs"); - tc.keyHome = caps.getStr("khome"); - tc.keyEnd = caps.getStr("kend"); - tc.keyUp = caps.getStr("kcuu1"); - tc.keyDown = caps.getStr("kcud1"); - tc.keyRight = caps.getStr("kcuf1"); - tc.keyLeft = caps.getStr("kcub1"); - tc.keyPgDn = caps.getStr("knp"); - tc.keyPgUp = caps.getStr("kpp"); - tc.keyBacktab = caps.getStr("kcbt"); - tc.keyExit = caps.getStr("kext"); - tc.keyCancel = caps.getStr("kcan"); - tc.keyPrint = caps.getStr("kprt"); - tc.keyHelp = caps.getStr("khlp"); - tc.keyClear = caps.getStr("kclr"); tc.altChars = caps.getStr("acsc"); tc.enterACS = caps.getStr("smacs"); tc.exitACS = caps.getStr("rmacs"); @@ -365,86 +336,6 @@ private Termcap* convertCaps(Caps* caps) tc.strikethrough = caps.getStr("smxx"); tc.mouse = caps.getStr("kmous"); - // Lookup high level function keys. - tc.keyShfInsert = caps.getStr("kIC"); - tc.keyShfDelete = caps.getStr("kDC"); - tc.keyShfRight = caps.getStr("kRIT"); - tc.keyShfLeft = caps.getStr("kLFT"); - tc.keyShfHome = caps.getStr("kHOM"); - tc.keyShfEnd = caps.getStr("kEND"); - tc.keyF13 = caps.getStr("kf13"); - tc.keyF14 = caps.getStr("kf14"); - tc.keyF15 = caps.getStr("kf15"); - tc.keyF16 = caps.getStr("kf16"); - tc.keyF17 = caps.getStr("kf17"); - tc.keyF18 = caps.getStr("kf18"); - tc.keyF19 = caps.getStr("kf19"); - tc.keyF20 = caps.getStr("kf20"); - tc.keyF21 = caps.getStr("kf21"); - tc.keyF22 = caps.getStr("kf22"); - tc.keyF23 = caps.getStr("kf23"); - tc.keyF24 = caps.getStr("kf24"); - tc.keyF25 = caps.getStr("kf25"); - tc.keyF26 = caps.getStr("kf26"); - tc.keyF27 = caps.getStr("kf27"); - tc.keyF28 = caps.getStr("kf28"); - tc.keyF29 = caps.getStr("kf29"); - tc.keyF30 = caps.getStr("kf30"); - tc.keyF31 = caps.getStr("kf31"); - tc.keyF32 = caps.getStr("kf32"); - tc.keyF33 = caps.getStr("kf33"); - tc.keyF34 = caps.getStr("kf34"); - tc.keyF35 = caps.getStr("kf35"); - tc.keyF36 = caps.getStr("kf36"); - tc.keyF37 = caps.getStr("kf37"); - tc.keyF38 = caps.getStr("kf38"); - tc.keyF39 = caps.getStr("kf39"); - tc.keyF40 = caps.getStr("kf40"); - tc.keyF41 = caps.getStr("kf41"); - tc.keyF42 = caps.getStr("kf42"); - tc.keyF43 = caps.getStr("kf43"); - tc.keyF44 = caps.getStr("kf44"); - tc.keyF45 = caps.getStr("kf45"); - tc.keyF46 = caps.getStr("kf46"); - tc.keyF47 = caps.getStr("kf47"); - tc.keyF48 = caps.getStr("kf48"); - tc.keyF49 = caps.getStr("kf49"); - tc.keyF50 = caps.getStr("kf50"); - tc.keyF51 = caps.getStr("kf51"); - tc.keyF52 = caps.getStr("kf52"); - tc.keyF53 = caps.getStr("kf53"); - tc.keyF54 = caps.getStr("kf54"); - tc.keyF55 = caps.getStr("kf55"); - tc.keyF56 = caps.getStr("kf56"); - tc.keyF57 = caps.getStr("kf57"); - tc.keyF58 = caps.getStr("kf58"); - tc.keyF59 = caps.getStr("kf59"); - tc.keyF60 = caps.getStr("kf60"); - tc.keyF61 = caps.getStr("kf61"); - tc.keyF62 = caps.getStr("kf62"); - tc.keyF63 = caps.getStr("kf63"); - tc.keyF64 = caps.getStr("kf64"); - - // And the same thing for rxvt. - // It seems that urxvt at least send ESC as ALT prefix for these, - // although some places seem to indicate a separate ALT key sequence. - // Users are encouraged to update to an emulator that more closely - // matches xterm for better functionality. - if (tc.keyShfRight == "\x1b[c" && tc.keyShfLeft == "\x1b[d") - { - tc.keyShfUp = "\x1b[a"; - tc.keyShfDown = "\x1b[b"; - tc.keyCtrlUp = "\x1b[Oa"; - tc.keyCtrlDown = "\x1b[Ob"; - tc.keyCtrlRight = "\x1b[Oc"; - tc.keyCtrlLeft = "\x1b[Od"; - } - if (tc.keyShfHome == "\x1b[7$" && tc.keyShfEnd == "\x1b[8$") - { - tc.keyCtrlHome = "\x1b[7^"; - tc.keyCtrlEnd = "\x1b[8^"; - } - // Technically the RGB flag that is provided for xterm-direct is not // quite right. The problem is that the -direct flag that was introduced // with ncurses 6.1 requires a parsing for the parameters that we lack. @@ -461,7 +352,7 @@ private Termcap* convertCaps(Caps* caps) // This is for xterm-direct, which uses a different scheme entirely. // (ncurses went a very different direction from everyone else, and // so it's unlikely anything is using this definition.) - tc.colors = 1 < 24; + tc.colors = 1 << 24; tc.setBg = "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m"; tc.setFg = "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m"; } @@ -475,16 +366,6 @@ private Termcap* convertCaps(Caps* caps) { return null; // terminal is not addressable } - // For padding, we lookup the pad char. If that isn't present, - // and npc is *not* set, then we assume a null byte. - tc.padChar = caps.getStr("pad"); - if (tc.padChar == "") - { - if (!caps.getBool("npc")) - { - tc.padChar = "\u0000"; - } - } return tc; } @@ -551,7 +432,7 @@ OutBuffer mkTermSource(Termcap*[] tcs, string modname) } } - foreach (num, Termcap *tc; tcs) + foreach (num, Termcap* tc; tcs) { ob.writefln(""); ob.writefln("// %s", tc.name); diff --git a/source/dcell/database.d b/source/dcell/database.d index f853c98..5890d9e 100644 --- a/source/dcell/database.d +++ b/source/dcell/database.d @@ -177,26 +177,6 @@ synchronized class Database } } - // Amend some sequences for URXVT. - // It seems that urxvt at least send ESC as ALT prefix for these, - // although some places seem to indicate a separate ALT key sequence. - // Users are encouraged to update to an emulator that more closely - // matches xterm for better functionality. - if (tc.keyShfRight == "\x1b[c" && tc.keyShfLeft == "\x1b[d") - { - tc.keyShfUp = "\x1b[a"; - tc.keyShfDown = "\x1b[b"; - tc.keyCtrlUp = "\x1b[Oa"; - tc.keyCtrlDown = "\x1b[Ob"; - tc.keyCtrlRight = "\x1b[Oc"; - tc.keyCtrlLeft = "\x1b[Od"; - } - if (tc.keyShfHome == "\x1b[7$" && tc.keyShfEnd == "\x1b[8$") - { - tc.keyCtrlHome = "\x1b[7^"; - tc.keyCtrlEnd = "\x1b[8^"; - } - // likewise, if we have mouse support, let's try to add backeted // paste support. return tc; diff --git a/source/dcell/event.d b/source/dcell/event.d index c4fe7ba..15a966d 100644 --- a/source/dcell/event.d +++ b/source/dcell/event.d @@ -1,7 +1,7 @@ /** * Events module for dcell. * - * Copyright: Copyright 2022 Garrett D'Amore + * Copyright: Copyright 2025 Garrett D'Amore * Authors: Garrett D'Amore * License: * Distributed under the Boost Software License, Version 1.0. @@ -24,6 +24,7 @@ enum EventType mouse, /// a mouse event paste, /// a paste event resize, /// window was resized + focus, /// focus changed } /** @@ -42,6 +43,7 @@ struct Event KeyEvent key; ResizeEvent resize; PasteEvent paste; + FocusEvent focus; } } @@ -61,3 +63,9 @@ struct PasteEvent { dstring content; } + +/// Focus event. +struct FocusEvent +{ + bool focused; +} diff --git a/source/dcell/key.d b/source/dcell/key.d index 3f6a0cc..9454de7 100644 --- a/source/dcell/key.d +++ b/source/dcell/key.d @@ -1,7 +1,7 @@ /** * Key module for dcell containing definitiosn for various key strokes. * - * Copyright: Copyright 2022 Garrett D'Amore + * Copyright: Copyright 2025 Garrett D'Amore * Authors: Garrett D'Amore * License: * Distributed under the Boost Software License, Version 1.0. @@ -21,42 +21,9 @@ enum Key { none = 0, - // control keys are assigned their ASCII values - // these definitions should not be used by apps, but instead - // by using key rune, the character, and a modifier. - // TODO: consider just removing these. - ctrlSpace = 0, - ctrlA, - ctrlB, - ctrlC, - ctrlD, - ctrlE, - ctrlF, - ctrlG, - ctrlH, - ctrlI, - ctrlJ, - ctrlK, - ctrlL, - ctrlM, - ctrlN, - ctrlO, - ctrlP, - ctrlQ, - ctrlR, - ctrlS, - ctrlT, - ctrlU, - ctrlV, - ctrlW, - ctrlX, - ctrlY, - ctrlZ, - ctrlLeftSq, // Escape - ctrlBackslash, - ctrlRightSq, - ctrlCarat, - ctrlUnderscore, + // NB: the low keys are empty because they are used for control + // encodings. But we translate them to rune with a payload char. + // and ctrl modifier. rune = 256, // start of defined keys, numbered high to avoid conflicts up, @@ -147,10 +114,10 @@ enum Key f64, // convenience aliases - backspace = ctrlH, - tab = ctrlI, - esc = ctrlLeftSq, - enter = ctrlM, + backspace = 0x08, + tab = 0x09, + esc = 0x1B, + enter = 0x0A, del = 0x7F, // Note del2 has a different value } @@ -247,37 +214,9 @@ shared static this() keyNames[Key.f62] = "F62"; keyNames[Key.f63] = "F63"; keyNames[Key.f64] = "F64"; - keyNames[Key.ctrlA] = "Ctrl-A"; - keyNames[Key.ctrlB] = "Ctrl-B"; - keyNames[Key.ctrlC] = "Ctrl-C"; - keyNames[Key.ctrlD] = "Ctrl-D"; - keyNames[Key.ctrlE] = "Ctrl-E"; - keyNames[Key.ctrlF] = "Ctrl-F"; - keyNames[Key.ctrlG] = "Ctrl-G"; - keyNames[Key.ctrlJ] = "Ctrl-J"; - keyNames[Key.ctrlK] = "Ctrl-K"; - keyNames[Key.ctrlL] = "Ctrl-L"; - keyNames[Key.ctrlN] = "Ctrl-N"; - keyNames[Key.ctrlO] = "Ctrl-O"; - keyNames[Key.ctrlP] = "Ctrl-P"; - keyNames[Key.ctrlQ] = "Ctrl-Q"; - keyNames[Key.ctrlR] = "Ctrl-R"; - keyNames[Key.ctrlS] = "Ctrl-S"; - keyNames[Key.ctrlT] = "Ctrl-T"; - keyNames[Key.ctrlU] = "Ctrl-U"; - keyNames[Key.ctrlV] = "Ctrl-V"; - keyNames[Key.ctrlW] = "Ctrl-W"; - keyNames[Key.ctrlX] = "Ctrl-X"; - keyNames[Key.ctrlY] = "Ctrl-Y"; - keyNames[Key.ctrlZ] = "Ctrl-Z"; - keyNames[Key.ctrlSpace] = "Ctrl-Space"; - keyNames[Key.ctrlUnderscore] = "Ctrl-_"; - keyNames[Key.ctrlRightSq] = "Ctrl-]"; - keyNames[Key.ctrlBackslash] = "Ctrl-\\"; - keyNames[Key.ctrlCarat] = "Ctrl-^"; } -/** +/** * Modifiers are special keys that when combined with other keys * change their meaning. */ @@ -288,6 +227,7 @@ enum Modifiers ctrl = 1 << 1, alt = 1 << 2, meta = 1 << 3, + hyper = 1 << 4, } /** @@ -302,6 +242,14 @@ struct KeyEvent dstring toString() const pure { dstring s = ""; + if (mod & Modifiers.ctrl) + { + s ~= "Ctrl-"; + } + if (mod & Modifiers.shift) + { + s ~= "Shift-"; + } if (mod & Modifiers.meta) { s ~= "Meta-"; @@ -310,6 +258,10 @@ struct KeyEvent { s ~= "Alt-"; } + if (mod & Modifiers.hyper) + { + s ~= "Hyper-"; + } dstring kn = ""; if (key in keyNames) { @@ -317,17 +269,23 @@ struct KeyEvent } else if (key == Key.rune) { - kn = [ch]; + if (mod == Modifiers.none) + { + kn = [ch]; + } + else if (ch == ' ') + { + kn = "Space"; + } + else + { + kn = [ch.toUpper]; + } } else { - kn = format("Key[%02X]"d, key); } - if ((mod & Modifiers.ctrl) && !startsWith(kn, "Ctrl-")) - { - s ~= "Ctrl-"; - } return s ~ kn; } diff --git a/source/dcell/parser.d b/source/dcell/parser.d index 18d264e..5747d83 100644 --- a/source/dcell/parser.d +++ b/source/dcell/parser.d @@ -12,9 +12,12 @@ module dcell.parser; import core.time; +import std.algorithm : max; import std.ascii; +import std.conv : to; +import std.process : environment; import std.string; -import std.utf; +import std.utf : decode, UTFException; import dcell.event; import dcell.key; @@ -29,391 +32,1076 @@ struct KeyCode Modifiers mod; } -struct ParseKeys +struct CsiKey { + char M; // Mode + int P; // Parameter (first) +} + +// Fixed set of keys that are returned as CSI sequences (apart from Csi-U and Csi-_) +// All terminals we support use some of these, and they do not overlap/collide. +immutable KeyCode[CsiKey] csiAllKeys = [ + CsiKey('A'): KeyCode(Key.up), + CsiKey('B'): KeyCode(Key.down), + CsiKey('C'): KeyCode(Key.right), + CsiKey('D'): KeyCode(Key.left), + CsiKey('F'): KeyCode(Key.end), + CsiKey('H'): KeyCode(Key.home), + CsiKey('L'): KeyCode(Key.insert), + CsiKey('P'): KeyCode(Key.f1), + CsiKey('Q'): KeyCode(Key.f2), + CsiKey('S'): KeyCode(Key.f4), + CsiKey('Z'): KeyCode(Key.backtab), + CsiKey('a'): KeyCode(Key.up, Modifiers.shift), + CsiKey('b'): KeyCode(Key.down, Modifiers.shift), + CsiKey('c'): KeyCode(Key.right, Modifiers.shift), + CsiKey('d'): KeyCode(Key.left, Modifiers.shift), + CsiKey('q', 1): KeyCode(Key.f1), // all these 'q' are for aixterm + CsiKey('q', 2): KeyCode(Key.f2), + CsiKey('q', 3): KeyCode(Key.f3), + CsiKey('q', 4): KeyCode(Key.f4), + CsiKey('q', 5): KeyCode(Key.f5), + CsiKey('q', 6): KeyCode(Key.f6), + CsiKey('q', 7): KeyCode(Key.f7), + CsiKey('q', 8): KeyCode(Key.f8), + CsiKey('q', 9): KeyCode(Key.f9), + CsiKey('q', 10): KeyCode(Key.f10), + CsiKey('q', 11): KeyCode(Key.f11), + CsiKey('q', 12): KeyCode(Key.f12), + CsiKey('q', 13): KeyCode(Key.f13), + CsiKey('q', 14): KeyCode(Key.f14), + CsiKey('q', 15): KeyCode(Key.f15), + CsiKey('q', 16): KeyCode(Key.f16), + CsiKey('q', 17): KeyCode(Key.f17), + CsiKey('q', 18): KeyCode(Key.f18), + CsiKey('q', 19): KeyCode(Key.f19), + CsiKey('q', 20): KeyCode(Key.f20), + CsiKey('q', 21): KeyCode(Key.f21), + CsiKey('q', 22): KeyCode(Key.f22), + CsiKey('q', 23): KeyCode(Key.f23), + CsiKey('q', 24): KeyCode(Key.f24), + CsiKey('q', 25): KeyCode(Key.f25), + CsiKey('q', 26): KeyCode(Key.f26), + CsiKey('q', 27): KeyCode(Key.f27), + CsiKey('q', 28): KeyCode(Key.f28), + CsiKey('q', 29): KeyCode(Key.f29), + CsiKey('q', 30): KeyCode(Key.f30), + CsiKey('q', 31): KeyCode(Key.f31), + CsiKey('q', 32): KeyCode(Key.f32), + CsiKey('q', 33): KeyCode(Key.f33), + CsiKey('q', 34): KeyCode(Key.f34), + CsiKey('q', 35): KeyCode(Key.f35), + CsiKey('q', 36): KeyCode(Key.f36), + CsiKey('q', 144): KeyCode(Key.clear), + CsiKey('q', 146): KeyCode(Key.end), + CsiKey('q', 150): KeyCode(Key.pgUp), + CsiKey('q', 154): KeyCode(Key.pgDn), + CsiKey('z', 214): KeyCode(Key.home), + CsiKey('z', 216): KeyCode(Key.pgUp), + CsiKey('z', 220): KeyCode(Key.end), + CsiKey('z', 222): KeyCode(Key.pgDn), + CsiKey('z', 224): KeyCode(Key.f1), + CsiKey('z', 225): KeyCode(Key.f2), + CsiKey('z', 226): KeyCode(Key.f3), + CsiKey('z', 227): KeyCode(Key.f4), + CsiKey('z', 228): KeyCode(Key.f5), + CsiKey('z', 229): KeyCode(Key.f6), + CsiKey('z', 230): KeyCode(Key.f7), + CsiKey('z', 231): KeyCode(Key.f8), + CsiKey('z', 232): KeyCode(Key.f9), + CsiKey('z', 233): KeyCode(Key.f10), + CsiKey('z', 234): KeyCode(Key.f11), + CsiKey('z', 235): KeyCode(Key.f12), + CsiKey('z', 247): KeyCode(Key.insert), + CsiKey('^', 1): KeyCode(Key.home, Modifiers.ctrl), + CsiKey('^', 2): KeyCode(Key.insert, Modifiers.ctrl), + CsiKey('^', 3): KeyCode(Key.del, Modifiers.ctrl), + CsiKey('^', 4): KeyCode(Key.end, Modifiers.ctrl), + CsiKey('^', 5): KeyCode(Key.pgUp, Modifiers.ctrl), + CsiKey('^', 6): KeyCode(Key.pgDn, Modifiers.ctrl), + CsiKey('^', 7): KeyCode(Key.home, Modifiers.ctrl), + CsiKey('^', 8): KeyCode(Key.end, Modifiers.ctrl), + CsiKey('^', 11): KeyCode(Key.f23), + CsiKey('^', 12): KeyCode(Key.f24), + CsiKey('^', 13): KeyCode(Key.f25), + CsiKey('^', 14): KeyCode(Key.f26), + CsiKey('^', 15): KeyCode(Key.f27), + CsiKey('^', 17): KeyCode(Key.f28), // 16 is a gap + CsiKey('^', 18): KeyCode(Key.f29), + CsiKey('^', 19): KeyCode(Key.f30), + CsiKey('^', 20): KeyCode(Key.f31), + CsiKey('^', 21): KeyCode(Key.f32), + CsiKey('^', 23): KeyCode(Key.f33), // 22 is a gap + CsiKey('^', 24): KeyCode(Key.f34), + CsiKey('^', 25): KeyCode(Key.f35), + CsiKey('^', 26): KeyCode(Key.f36), + CsiKey('^', 28): KeyCode(Key.f37), // 27 is a gap + CsiKey('^', 29): KeyCode(Key.f38), + CsiKey('^', 31): KeyCode(Key.f39), // 30 is a gap + CsiKey('^', 32): KeyCode(Key.f40), + CsiKey('^', 33): KeyCode(Key.f41), + CsiKey('^', 34): KeyCode(Key.f42), + CsiKey('@', 23): KeyCode(Key.f43), + CsiKey('@', 24): KeyCode(Key.f44), + CsiKey('@', 1): KeyCode(Key.home, Modifiers.shift | Modifiers.ctrl), + CsiKey('@', 2): KeyCode(Key.insert, Modifiers.shift | Modifiers.ctrl), + CsiKey('@', 3): KeyCode(Key.del, Modifiers.shift | Modifiers.ctrl), + CsiKey('@', 4): KeyCode(Key.end, Modifiers.shift | Modifiers.ctrl), + CsiKey('@', 5): KeyCode(Key.pgUp, Modifiers.shift | Modifiers.ctrl), + CsiKey('@', 6): KeyCode(Key.pgDn, Modifiers.shift | Modifiers.ctrl), + CsiKey('@', 7): KeyCode(Key.home, Modifiers.shift | Modifiers.ctrl), + CsiKey('@', 8): KeyCode(Key.end, Modifiers.shift | Modifiers.ctrl), + CsiKey('$', 1): KeyCode(Key.home, Modifiers.shift), + CsiKey('$', 2): KeyCode(Key.insert, Modifiers.shift), + CsiKey('$', 3): KeyCode(Key.del, Modifiers.shift), + CsiKey('$', 4): KeyCode(Key.end, Modifiers.shift), + CsiKey('$', 5): KeyCode(Key.pgUp, Modifiers.shift), + CsiKey('$', 6): KeyCode(Key.pgDn, Modifiers.shift), + CsiKey('$', 7): KeyCode(Key.home, Modifiers.shift), + CsiKey('$', 8): KeyCode(Key.end, Modifiers.shift), + CsiKey('$', 23): KeyCode(Key.f21), + CsiKey('$', 24): KeyCode(Key.f22), + CsiKey('~', 1): KeyCode(Key.home), + CsiKey('~', 2): KeyCode(Key.insert), + CsiKey('~', 3): KeyCode(Key.del), + CsiKey('~', 4): KeyCode(Key.end), + CsiKey('~', 5): KeyCode(Key.pgUp), + CsiKey('~', 6): KeyCode(Key.pgDn), + CsiKey('~', 7): KeyCode(Key.home), + CsiKey('~', 8): KeyCode(Key.end), + CsiKey('~', 11): KeyCode(Key.f1), + CsiKey('~', 12): KeyCode(Key.f2), + CsiKey('~', 13): KeyCode(Key.f3), + CsiKey('~', 14): KeyCode(Key.f4), + CsiKey('~', 15): KeyCode(Key.f5), + CsiKey('~', 16): KeyCode(Key.f6), + CsiKey('~', 18): KeyCode(Key.f7), + CsiKey('~', 19): KeyCode(Key.f8), + CsiKey('~', 20): KeyCode(Key.f9), + CsiKey('~', 21): KeyCode(Key.f10), + CsiKey('~', 23): KeyCode(Key.f11), + CsiKey('~', 24): KeyCode(Key.f12), + CsiKey('~', 25): KeyCode(Key.f13), + CsiKey('~', 26): KeyCode(Key.f14), + CsiKey('~', 28): KeyCode(Key.f15), + CsiKey('~', 29): KeyCode(Key.f16), + CsiKey('~', 31): KeyCode(Key.f17), + CsiKey('~', 32): KeyCode(Key.f18), + CsiKey('~', 33): KeyCode(Key.f19), + CsiKey('~', 34): KeyCode(Key.f20), + // CsiKey('~', 200): KeyCode(keyPasteStart), + // CsiKey('~', 201): KeyCode(keyPasteEnd), +]; + +// keys by their SS3 - used in application mode usually (legacy VT-style) +immutable KeyCode[char] ss3Keys = [ + 'A': KeyCode(Key.up), + 'B': KeyCode(Key.down), + 'C': KeyCode(Key.right), + 'D': KeyCode(Key.left), + 'F': KeyCode(Key.end), + 'H': KeyCode(Key.home), + 'P': KeyCode(Key.f1), + 'Q': KeyCode(Key.f2), + 'R': KeyCode(Key.f3), + 'S': KeyCode(Key.f4), + 't': KeyCode(Key.f5), + 'u': KeyCode(Key.f6), + 'v': KeyCode(Key.f7), + 'l': KeyCode(Key.f8), + 'w': KeyCode(Key.f9), + 'x': KeyCode(Key.f10), +]; + +// linux terminal uses these non ECMA keys prefixed by CSI-[ +immutable KeyCode[char] linuxFKeys = [ + 'A': KeyCode(Key.f1), + 'B': KeyCode(Key.f2), + 'C': KeyCode(Key.f3), + 'D': KeyCode(Key.f4), + 'E': KeyCode(Key.f5), +]; + +immutable KeyCode[int] csiUKeys = [ + 27: KeyCode(Key.esc), + 9: KeyCode(Key.tab), + 13: KeyCode(Key.enter), + 127: KeyCode(Key.backspace), + // 57_358: KeyCode(KeyCapsLock), + // 57_359: KeyCode(KeyScrollLock), + // 57_360: KeyCode(KeyNumLock), + 57_361: KeyCode(Key.print), + 57_362: KeyCode(Key.pause), + // 57_363: KeyCode(Key.menu), + 57_376: KeyCode(Key.f13), + 57_377: KeyCode(Key.f14), + 57_378: KeyCode(Key.f15), + 57_379: KeyCode(Key.f16), + 57_380: KeyCode(Key.f17), + 57_381: KeyCode(Key.f18), + 57_382: KeyCode(Key.f19), + 57_383: KeyCode(Key.f20), + 57_384: KeyCode(Key.f21), + 57_385: KeyCode(Key.f22), + 57_386: KeyCode(Key.f23), + 57_387: KeyCode(Key.f24), + 57_388: KeyCode(Key.f25), + 57_389: KeyCode(Key.f26), + 57_390: KeyCode(Key.f27), + 57_391: KeyCode(Key.f28), + 57_392: KeyCode(Key.f29), + 57_393: KeyCode(Key.f30), + 57_394: KeyCode(Key.f31), + 57_395: KeyCode(Key.f32), + 57_396: KeyCode(Key.f33), + 57_397: KeyCode(Key.f34), + 57_398: KeyCode(Key.f35), + // TODO: KP keys + // TODO: Media keys +]; + +// windows virtual key codes per microsoft +immutable KeyCode[int] winKeys = [ + 0x03: KeyCode(Key.cancel), // vkCancel + 0x08: KeyCode(Key.backspace), // vkBackspace + 0x09: KeyCode(Key.tab), // vkTab + 0x0d: KeyCode(Key.enter), // vkReturn + 0x12: KeyCode(Key.clear), // vClear + 0x13: KeyCode(Key.pause), // vkPause + 0x1b: KeyCode(Key.esc), // vkEscape + 0x21: KeyCode(Key.pgUp), // vkPrior + 0x22: KeyCode(Key.pgDn), // vkNext + 0x23: KeyCode(Key.end), // vkEnd + 0x24: KeyCode(Key.home), // vkHome + 0x25: KeyCode(Key.left), // vkLeft + 0x26: KeyCode(Key.up), // vkUp + 0x27: KeyCode(Key.right), // vkRight + 0x28: KeyCode(Key.down), // vkDown + 0x2a: KeyCode(Key.print), // vkPrint + 0x2c: KeyCode(Key.print), // vkPrtScr + 0x2d: KeyCode(Key.insert), // vkInsert + 0x2e: KeyCode(Key.del), // vkDelete + 0x2f: KeyCode(Key.help), // vkHelp + 0x70: KeyCode(Key.f1), // vkF1 + 0x71: KeyCode(Key.f2), // vkF2 + 0x72: KeyCode(Key.f3), // vkF3 + 0x73: KeyCode(Key.f4), // vkF4 + 0x74: KeyCode(Key.f5), // vkF5 + 0x75: KeyCode(Key.f6), // vkF6 + 0x76: KeyCode(Key.f7), // vkF7 + 0x77: KeyCode(Key.f8), // vkF8 + 0x78: KeyCode(Key.f9), // vkF9 + 0x79: KeyCode(Key.f10), // vkF10 + 0x7a: KeyCode(Key.f11), // vkF11 + 0x7b: KeyCode(Key.f12), // vkF12 + 0x7c: KeyCode(Key.f13), // vkF13 + 0x7d: KeyCode(Key.f14), // vkF14 + 0x7e: KeyCode(Key.f15), // vkF15 + 0x7f: KeyCode(Key.f16), // vkF16 + 0x80: KeyCode(Key.f17), // vkF17 + 0x81: KeyCode(Key.f18), // vkF18 + 0x82: KeyCode(Key.f19), // vkF19 + 0x83: KeyCode(Key.f20), // vkF20 + 0x84: KeyCode(Key.f21), // vkF21 + 0x85: KeyCode(Key.f22), // vkF22 + 0x86: KeyCode(Key.f23), // vkF23 + 0x87: KeyCode(Key.f24), // vkF24 +]; + +class Parser +{ + + Event[] events() pure + { + auto res = evs; + evs = null; + return cast(Event[]) res; + } + + bool parse(string b) + { + buf ~= b; + scan(); + return parseState == ParseState.ini; + } + + bool empty() const pure + { + return buf.length == 0; + } + +private: + enum ParseState + { + ini, // initial state + esc, // escaped + utf, // inside a UTF-8 + csi, // control sequence introducer + osc, // operating system command + dcs, // device control string + sos, // start of string (unused) + pm, // privacy message (unused) + apc, // application program command + str, // string terminator + ss2, // single shift 2 + ss3, // single shift 3 + lnx, // linux F-key (not ECMA-48 compliant - bogus CSI) + } - immutable bool[Key] exist; - immutable KeyCode[string] keys; + ParseState parseState; + ParseState strState; + Parser nested; // nested parser, required for Windows key processing with 3rd party terminals + string csiParams; + string csiInterm; + string scratch; + + bool escaped; + ubyte[] buf; + ubyte[] accum; + Event[] evs; + int utfLen; // how many UTF bytes are expected + ubyte escChar; // character immediately following escape (zero if none) + const KeyCode[string] keyCodes; + bool partial; // record partially parsed sequences + MonoTime keyStart; // when the timer started + Duration seqTime = msecs(50); // time to fully decode a partial sequence + bool buttonDown; // true if buttons were down + bool pasting; + MonoTime pasteTime; + dstring pasteBuf; string pasteStart; string pasteEnd; - this(const Termcap* caps) + void postKey(Key k, dchar dch, Modifiers mod) { + if (pasting) + { + if (dch != 0) + { + pasteBuf ~= dch; + } + } + else + { + evs ~= newKeyEvent(k, dch, mod); + } + } - bool[Key] ex; - KeyCode[string] kc; - - void addKey(Key key, string val, Modifiers mod = Modifiers.none, Key replace = cast(Key) 0) + void scan() + { + while (!buf.empty) { - if (val == "") - return; - if ((val !in kc) || kc[val].key == replace) + ubyte ch = buf[0]; + buf = buf[1 .. $]; + escChar = 0; + + final switch (parseState) { - ex[key] = true; - kc[val] = KeyCode(key, mod); + case ParseState.utf: + accum ~= ch; + if (accum.length >= utfLen) + { + parseState = ParseState.ini; + size_t index = 0; + dchar dch = decode(cast(string) accum, index); + accum = null; + postKey(Key.rune, dch, Modifiers.none); + } + break; + case ParseState.ini: + if (ch >= 0x80) + { + accum = null; + parseState = ParseState.utf; + accum ~= ch; + if ((ch & 0xE0) == 0xC0) + { + utfLen = 2; + } + else if ((ch & 0xF0) == 0xE0) + { + utfLen = 3; + } + else if ((ch & 0xF0) == 0xF0) + { + utfLen = 4; + } + else + { + // garbled - got a non-leading byte (e.g. 0x80 through 0xBF) + parseState = ParseState.ini; + accum = null; + } + continue; + } + switch (ch) + { + case '\x1b': + parseState = ParseState.esc; + keyStart = MonoTime.currTime(); + continue; + case '\t': + postKey(Key.tab, ch, Modifiers.none); + break; + case '\b', '\x7F': + postKey(Key.backspace, ch, Modifiers.none); + break; + case '\n', '\r': + // will be converted by postKey + postKey(Key.enter, ch, Modifiers.none); + break; + default: + // simple runes + if (ch >= ' ') + { + postKey(Key.rune, ch, Modifiers.none); + } + // Control keys below here - legacy handling + else if (ch == 0) + { + postKey(Key.rune, ' ', Modifiers.ctrl); + } + else if (ch < '\x1b') + { + postKey(Key.rune, ch + 0x60, Modifiers.ctrl); + } + else + { + // control keys + postKey(Key.rune, ch + 0x40, Modifiers.ctrl); + } + break; + } + break; + case ParseState.esc: + switch (ch) + { + case '[': + parseState = ParseState.csi; + csiInterm = null; + csiParams = null; + escChar = ch; // save the escChar, it might be just esc as alt + break; + case ']': + parseState = ParseState.osc; + scratch = null; + escChar = ch; // save the escChar, it might be just esc as alt + break; + case 'N': + parseState = ParseState.ss2; // no known uses + scratch = null; + escChar = ch; // save the escChar, it might be just esc as alt + break; + case 'O': + parseState = ParseState.ss3; + scratch = null; + escChar = ch; // save the escChar, it might be just esc as alt + break; + case 'X': + parseState = ParseState.sos; + scratch = null; + escChar = ch; // save the escChar, it might be just esc as alt + break; + case '^': + parseState = ParseState.pm; + scratch = null; + escChar = ch; // save the escChar, it might be just esc as alt + break; + case '_': + parseState = ParseState.apc; + scratch = null; + escChar = ch; // save the escChar, it might be just esc as alt + break; + case '\\': // string terminator reached, (orphaned?) + parseState = ParseState.ini; + break; + case '\t': // Linux console only, does not conform to ECMA + parseState = ParseState.ini; + postKey(Key.backtab, 0, Modifiers.none); + break; + case '\x1b': + // leading ESC to capture alt + escaped = true; + break; + default: + // treat as alt-key ... legacy emulators only (no CSI-u or other) + parseState = parseState.ini; + escaped = false; + if (ch >= ' ') + { + postKey(Key.rune, ch, Modifiers.meta); + } + else if (ch < '\x1b') + { + postKey(Key.rune, ch + 0x60, Modifiers.meta | Modifiers.ctrl); + } + else + { + postKey(Key.rune, ch + 0x40, Modifiers.meta | Modifiers.ctrl); + } + } + break; + case ParseState.ss2: + // no known uses + parseState = ParseState.ini; + break; + case ParseState.ss3: + parseState = ParseState.ini; + if (ch in ss3Keys) + { + auto k = ss3Keys[ch]; + postKey(k.key, 0, k.mod); + } + break; + + case ParseState.apc, ParseState.pm, ParseState.sos, ParseState.dcs: // these we just eat + switch (ch) + { + case '\x1b': + strState = parseState; + parseState = ParseState.str; + break; + case '\x07': // bell - some send this instead of ST + parseState = ParseState.ini; + break; + default: + break; + } + break; + case ParseState.osc: // not sure if used + switch (ch) + { + case '\x1b': + strState = parseState; + parseState = ParseState.str; + break; + case '\x07': + handleOsc(); + break; + default: + scratch ~= (ch & 0x7F); + break; + } + break; + case ParseState.str: + if (ch == '\\' || ch == '\x07') + { + parseState = ParseState.ini; + if (strState == ParseState.osc) + { + handleOsc(); + } + else + { + parseState = ParseState.ini; + } + } + else + { + scratch ~= '\x1b'; + scratch ~= ch; + parseState = strState; + } + break; + case ParseState.lnx: + if (ch in linuxFKeys) + { + auto k = linuxFKeys[ch]; + postKey(k.key, 0, Modifiers.none); + } + parseState = ParseState.ini; + break; + + case ParseState.csi: + // usual case for incoming keys + // NB: rxvt uses terminating '$' which is not a legal CSI terminator, + // for certain shifted key sequences. We special case this, and it's ok + // because no other terminal seems to use this for CSI intermediates from + // the terminal to the host (queries in the other direction can use it.) + if (ch >= 0x30 && ch <= 0x3F) + { // parameter bytes + csiParams ~= ch; + } + else if (ch == '$' && !csiParams.empty) + { + // rxvt $ terminator (not technically legal) + handleCsi(ch, csiParams, csiInterm); + } + else if ((ch >= 0x20) && (ch <= 0x2F)) + { + // intermediate bytes, rarely used + csiInterm ~= ch; + } + else if (ch >= 0x40 && ch <= 0x7F) + { + // final byte + handleCsi(ch, csiParams, csiInterm); + } + else + { + // bad parse, just swallow it all + parseState = ParseState.ini; + } + break; } } - void addXTermKey(Key key, string val) + auto now = MonoTime.currTime(); + if ((now - keyStart) > seqTime) { - if (val.length > 2 && val[0] == '\x1b' && val[1] == '[' && val[$ - 1] == '~') + if (parseState == ParseState.esc) + { + postKey(Key.esc, '\x1b', Modifiers.none); + parseState = ParseState.ini; + } + else if (escChar != 0) { - // These suffixes are calculated assuming Xterm style modifier suffixes. - // Please see https://invisible-island.net/xterm/ctlseqs/ctlseqs.pdf for - // more information (specifically "PC-Style Function Keys"). - val = val[0 .. $ - 1]; // drop trailing ~ - addKey(key, val ~ ";2~", Modifiers.shift, cast(Key)(key + 12)); - addKey(key, val ~ ";3~", Modifiers.alt, cast(Key)(key + 48)); - addKey(key, val ~ ";4~", Modifiers.alt | Modifiers.shift, cast(Key)(key + 60)); - addKey(key, val ~ ";5~", Modifiers.ctrl, cast(Key)(key + 24)); - addKey(key, val ~ ";6~", Modifiers.ctrl | Modifiers.shift, cast(Key)(key + 36)); - addKey(key, val ~ ";7~", Modifiers.alt | Modifiers.ctrl); - addKey(key, val ~ ";8~", Modifiers.shift | Modifiers.alt | Modifiers.ctrl); - addKey(key, val ~ ";9~", Modifiers.meta); - addKey(key, val ~ ";10~", Modifiers.meta | Modifiers.shift); - addKey(key, val ~ ";11~", Modifiers.meta | Modifiers.alt); - addKey(key, val ~ ";12~", Modifiers.meta | Modifiers.shift | Modifiers.alt); - addKey(key, val ~ ";13~", Modifiers.meta | Modifiers.ctrl); - addKey(key, val ~ ";14~", Modifiers.meta | Modifiers.ctrl | Modifiers.shift); - addKey(key, val ~ ";15~", Modifiers.meta | Modifiers.ctrl | Modifiers.alt); - addKey(key, val ~ ";16~", - Modifiers.meta | Modifiers.ctrl | Modifiers.shift | Modifiers.alt); + postKey(Key.rune, escChar, Modifiers.alt); + escChar = 0; + parseState = ParseState.ini; } - else if (val.length == 3 && val[0] == '\x1b' && val[1] == 'O') + } + } + + void handleOsc() + { + // TODO: OSC 52 is for clipboard + // if content, ok := strings.CutPrefix(str, "52;c;"); ok { + // decoded := make([]byte, base64.StdEncoding.DecodedLen(len(content))) + // if count, err := base64.StdEncoding.Decode(decoded, []byte(content)); err == nil { + // ip.post(NewEventClipboard(decoded[:count])) + // return + // } + // } + + // string is located in scratch. + parseState = ParseState.ini; + } + + void handleCsi(ubyte mode, string params, string interm) + { + parseState = ParseState.ini; + + if (!interm.empty) + { + // we don't know what to do with these for now + return; + } + + auto hasLT = false; + int plen, p0, p1, p2, p3, p4, p5; + + // extract numeric parameters + if (!params.empty && params[0] == '<') + { + hasLT = true; + params = params[1 .. $]; + } + if ((!params.empty) && params[0] >= '0' && params[0] <= '9') + { + int[6] pints; + string[] parts = split(params, ";"); + plen = cast(int) parts.length; + foreach (i, ps; parts) { - val = val[2 .. $]; - addKey(key, "\x1b[1;2" ~ val, Modifiers.shift, cast(Key)(key + 12)); - addKey(key, "\x1b[1;3" ~ val, Modifiers.alt, cast(Key)(key + 48)); - addKey(key, "\x1b[1;5" ~ val, Modifiers.ctrl, cast(Key)(key + 24)); - addKey(key, "\x1b[1;6" ~ val, Modifiers.ctrl | Modifiers.shift, cast(Key)(key + 36)); - addKey(key, "\x1b[1;4" ~ val, Modifiers.alt | Modifiers.shift, cast(Key)(key + 60)); - addKey(key, "\x1b[1;7" ~ val, Modifiers.alt | Modifiers.ctrl); - addKey(key, "\x1b[1;8" ~ val, Modifiers.shift | Modifiers.alt | Modifiers.ctrl); - addKey(key, "\x1b[1;9" ~ val, Modifiers.meta,); - addKey(key, "\x1b[1;10" ~ val, Modifiers.meta | Modifiers.shift); - addKey(key, "\x1b[1;11" ~ val, Modifiers.meta | Modifiers.alt); - addKey(key, "\x1b[1;12" ~ val, Modifiers.meta | Modifiers.alt | Modifiers.shift); - addKey(key, "\x1b[1;13" ~ val, Modifiers.meta | Modifiers.ctrl); - addKey(key, "\x1b[1;14" ~ val, Modifiers.meta | Modifiers.ctrl | Modifiers.shift); - addKey(key, "\x1b[1;15" ~ val, Modifiers.meta | Modifiers.ctrl | Modifiers.alt); - addKey(key, "\x1b[1;16" ~ val, - Modifiers.meta | Modifiers.ctrl | Modifiers.alt | Modifiers.shift); + if (i < 6 && !ps.empty) + { + try + { + pints[i] = ps.to!int; + } + catch (Exception) + { + } + } } + + // None of the use cases use care about have more than three parameters. + p0 = pints[0]; + p1 = pints[1]; + p2 = pints[2]; + p3 = pints[3]; + p4 = pints[4]; + p5 = pints[5]; } - void addXTermKeys(const Termcap* caps) + // leading less than is only used for mouse reports. + if (hasLT) { - if (caps.keyShfRight != "\x1b[1;2C") // does this look "xtermish"? - return; - addXTermKey(Key.right, caps.keyRight); - addXTermKey(Key.left, caps.keyLeft); - addXTermKey(Key.up, caps.keyUp); - addXTermKey(Key.down, caps.keyDown); - addXTermKey(Key.insert, caps.keyInsert); - addXTermKey(Key.del, caps.keyDelete); - addXTermKey(Key.pgUp, caps.keyPgUp); - addXTermKey(Key.pgDn, caps.keyPgDn); - addXTermKey(Key.home, caps.keyHome); - addXTermKey(Key.end, caps.keyEnd); - addXTermKey(Key.f1, caps.keyF1); - addXTermKey(Key.f2, caps.keyF2); - addXTermKey(Key.f3, caps.keyF3); - addXTermKey(Key.f4, caps.keyF4); - addXTermKey(Key.f5, caps.keyF5); - addXTermKey(Key.f6, caps.keyF6); - addXTermKey(Key.f7, caps.keyF7); - addXTermKey(Key.f8, caps.keyF8); - addXTermKey(Key.f9, caps.keyF9); - addXTermKey(Key.f10, caps.keyF10); - addXTermKey(Key.f11, caps.keyF11); - addXTermKey(Key.f12, caps.keyF12); - } - - void addCtrlKeys() - { - // we look briefly at all the keyCodes we - // have, to find their starting character. - // the vast majority of these will be escape. - bool[char] initials; - foreach (esc, _; kc) + if (mode == 'm' || mode == 'M') { - if (esc != "") - initials[esc[0]] = true; + handleMouse(mode, p0, p1, p2); } - // Add key mappings for control keys. - for (char i = 0; i < ' '; i++) + return; + } + + switch (mode) + { + case 'I': // focus in + evs ~= newFocusEvent(true); + return; + case 'O': // focus out + evs ~= newFocusEvent(false); + return; + case '[': // linux console F-key - CSI-[ modifies next key + parseState = ParseState.lnx; + return; + case 'u': // CSI-u kitty keyboard protocol + if (plen > 0) { + Modifiers mod = Modifiers.none; + Key key = Key.rune; + dchar chr = 0; + if (p0 in csiUKeys) + { + auto k = csiUKeys[p0]; + key = k.key; + } + else + { + chr = cast(dchar) p0; + } - // If this is starting character (typically esc) of other sequences, - // then do not set up the fast path mapping for it. - // We need to let the read do the whole timeout thing. - if (i in initials) - continue; + evs ~= newKeyEvent(key, chr, plen > 1 ? calcModifier(p1) : Modifiers.none); + } + return; - Key k = cast(Key) i; - ex[k] = true; - switch (k) + case '_': + if (plen > 0) + { + handleWinKey(p0, p1, p2, p3, p4, p5); + } + return; + + case 't': + // if (P.length == 3 && P[0] == 8) + // { + // // window size report + // auto h = p1; + // auto w = p2; + // if (h != rows || w != cols) + // { + // setSize(w, h); + // } + // } + return; + + case '~': + + // look for modified keys (note that unmodified keys are handled below) + auto ck = CsiKey(mode, p0); + auto mod = plen > 1 ? calcModifier(p1) : Modifiers.none; + + if (ck in csiAllKeys) + { + auto kc = csiAllKeys[ck]; + evs ~= newKeyEvent(kc.key, 0, mod); + return; + } + + // this might be XTerm modifyOtherKeys protocol + // CSI 27; modifiers; chr; ~ + if (p0 == 27 && p2 > 0 && p2 <= 0xff) + { + if (p2 < ' ' || p2 == 0x7F) { - case Key.backspace, Key.tab, Key.esc, Key.enter: - // these are directly typeable - kc["" ~ i] = KeyCode(k, Modifiers.none); - break; - default: - // these are generally represented as a control sequence - kc["" ~ i] = KeyCode(k, Modifiers.ctrl); - break; + evs ~= newKeyEvent(cast(Key) p2, 0, mod); + } + else + { + evs ~= newKeyEvent(Key.rune, p2, mod); } + return; } - } + if (p0 == 200) { + pasting = true; + pasteBuf = null; + } else if (p0 == 201) { + if (pasting) { + evs ~= newPasteEvent(pasteBuf); + pasting = false; + pasteBuf = null; + } + } - addKey(Key.backspace, caps.keyBackspace); - addKey(Key.f1, caps.keyF1); - addKey(Key.f2, caps.keyF2); - addKey(Key.f3, caps.keyF3); - addKey(Key.f4, caps.keyF4); - addKey(Key.f5, caps.keyF5); - addKey(Key.f6, caps.keyF6); - addKey(Key.f7, caps.keyF7); - addKey(Key.f8, caps.keyF8); - addKey(Key.f9, caps.keyF9); - addKey(Key.f10, caps.keyF10); - addKey(Key.f11, caps.keyF11); - addKey(Key.f12, caps.keyF12); - addKey(Key.f13, caps.keyF13); - addKey(Key.f14, caps.keyF14); - addKey(Key.f15, caps.keyF15); - addKey(Key.f16, caps.keyF16); - addKey(Key.f17, caps.keyF17); - addKey(Key.f18, caps.keyF18); - addKey(Key.f19, caps.keyF19); - addKey(Key.f20, caps.keyF20); - addKey(Key.f21, caps.keyF21); - addKey(Key.f22, caps.keyF22); - addKey(Key.f23, caps.keyF23); - addKey(Key.f24, caps.keyF24); - addKey(Key.f25, caps.keyF25); - addKey(Key.f26, caps.keyF26); - addKey(Key.f27, caps.keyF27); - addKey(Key.f28, caps.keyF28); - addKey(Key.f29, caps.keyF29); - addKey(Key.f30, caps.keyF30); - addKey(Key.f31, caps.keyF31); - addKey(Key.f32, caps.keyF32); - addKey(Key.f33, caps.keyF33); - addKey(Key.f34, caps.keyF34); - addKey(Key.f35, caps.keyF35); - addKey(Key.f36, caps.keyF36); - addKey(Key.f37, caps.keyF37); - addKey(Key.f38, caps.keyF38); - addKey(Key.f39, caps.keyF39); - addKey(Key.f40, caps.keyF40); - addKey(Key.f41, caps.keyF41); - addKey(Key.f42, caps.keyF42); - addKey(Key.f43, caps.keyF43); - addKey(Key.f44, caps.keyF44); - addKey(Key.f45, caps.keyF45); - addKey(Key.f46, caps.keyF46); - addKey(Key.f47, caps.keyF47); - addKey(Key.f48, caps.keyF48); - addKey(Key.f49, caps.keyF49); - addKey(Key.f50, caps.keyF50); - addKey(Key.f51, caps.keyF51); - addKey(Key.f52, caps.keyF52); - addKey(Key.f53, caps.keyF53); - addKey(Key.f54, caps.keyF54); - addKey(Key.f55, caps.keyF55); - addKey(Key.f56, caps.keyF56); - addKey(Key.f57, caps.keyF57); - addKey(Key.f58, caps.keyF58); - addKey(Key.f59, caps.keyF59); - addKey(Key.f60, caps.keyF60); - addKey(Key.f61, caps.keyF61); - addKey(Key.f62, caps.keyF62); - addKey(Key.f63, caps.keyF63); - addKey(Key.f64, caps.keyF64); - addKey(Key.insert, caps.keyInsert); - addKey(Key.del, caps.keyDelete); - addKey(Key.home, caps.keyHome); - addKey(Key.end, caps.keyEnd); - addKey(Key.up, caps.keyUp); - addKey(Key.down, caps.keyDown); - addKey(Key.left, caps.keyLeft); - addKey(Key.right, caps.keyRight); - addKey(Key.pgUp, caps.keyPgUp); - addKey(Key.pgDn, caps.keyPgDn); - addKey(Key.help, caps.keyHelp); - addKey(Key.print, caps.keyPrint); - addKey(Key.cancel, caps.keyCancel); - addKey(Key.exit, caps.keyExit); - addKey(Key.backtab, caps.keyBacktab); - - addKey(Key.right, caps.keyShfRight, Modifiers.shift); - addKey(Key.left, caps.keyShfLeft, Modifiers.shift); - addKey(Key.up, caps.keyShfUp, Modifiers.shift); - addKey(Key.down, caps.keyShfDown, Modifiers.shift); - addKey(Key.home, caps.keyShfHome, Modifiers.shift); - addKey(Key.end, caps.keyShfEnd, Modifiers.shift); - addKey(Key.pgUp, caps.keyShfPgUp, Modifiers.shift); - addKey(Key.pgDn, caps.keyShfPgDn, Modifiers.shift); - - addKey(Key.right, caps.keyCtrlRight, Modifiers.ctrl); - addKey(Key.left, caps.keyCtrlLeft, Modifiers.ctrl); - addKey(Key.up, caps.keyCtrlUp, Modifiers.ctrl); - addKey(Key.down, caps.keyCtrlDown, Modifiers.ctrl); - addKey(Key.home, caps.keyCtrlHome, Modifiers.ctrl); - addKey(Key.end, caps.keyCtrlEnd, Modifiers.ctrl); - - // Sadly, xterm handling of keycodes is somewhat erratic. In - // particular, different codes are sent depending on application - // mode is in use or not, and the entries for many of these are - // simply absent from terminfo on many systems. So we insert - // a number of escape sequences if they are not already used, in - // order to have the widest correct usage. Note that prepareKey - // will not inject codes if the escape sequence is already known. - // We also only do this for terminals that have the application - // mode present. - - if (caps.enterKeypad != "") - { - addKey(Key.up, "\x1b[A"); - addKey(Key.down, "\x1b[B"); - addKey(Key.right, "\x1b[C"); - addKey(Key.left, "\x1b[D"); - addKey(Key.end, "\x1b[F"); - addKey(Key.home, "\x1b[H"); - addKey(Key.del2, "\x1b[3~"); - addKey(Key.home, "\x1b[1~"); - addKey(Key.end, "\x1b[4~"); - addKey(Key.pgUp, "\x1b[5~"); - addKey(Key.pgDn, "\x1b[6~"); - - // Application mode - addKey(Key.up, "\x1bOA"); - addKey(Key.down, "\x1bOB"); - addKey(Key.right, "\x1bOC"); - addKey(Key.left, "\x1bOD"); - addKey(Key.home, "\x1bOH"); - } - - addXTermKeys(caps); - - pasteStart = caps.pasteStart; - pasteEnd = caps.pasteEnd; - - addCtrlKeys(); // do this one last - - // if DELETE didn't make it at 0x7F, add it - seems to be missing - // from some of the sequences. - addKey(Key.del2, "\x7F"); - - exist = cast(immutable(bool[Key])) ex; - keys = cast(immutable(KeyCode[string])) kc; + break; + case 'P': + // aixterm uses this for KeyDelete, but it is F1 for others + if (environment.get("TERM") == "aixterm") + { + evs ~= newKeyEvent(Key.del, 0, Modifiers.none); + return; + } + // other cases we use the lookup (P is an SS3 key) + goto default; + + default: + + if ((mode in ss3Keys) && p0 == 1 && plen > 1) + { + auto kc = ss3Keys[mode]; + evs ~= newKeyEvent(kc.key, 0, calcModifier(p1)); + } + else + { + auto ck = CsiKey(mode, p0); + if (ck in csiAllKeys) + { + auto kc = csiAllKeys[ck]; + evs ~= newKeyEvent(kc.key, 0, kc.mod); + } + } + return; + } } - bool hasKey(Key k) const pure + void handleMouse(ubyte mode, int p0, int p1, int p2) { - if (k == Key.rune) + // XTerm mouse events only report at most one button at a time, + // which may include a wheel button. Wheel motion events are + // reported as single impulses, while other button events are reported + // as separate press & release events. + // + auto btn = p0; + auto x = p1 - 1; + auto y = p2 - 1; + bool motion = (btn & 0x20) != 0; + bool scroll = (btn & 0x42) == 0x40; + btn &= ~0x20; + if (mode == 'm') { - return true; + // mouse release, clear all buttons + btn |= 0x03; + btn &= ~0x40; + buttonDown = false; + } + else if (motion) + { + // Some broken terminals appear to send + // mouse button one motion events, instead of + // encoding 35 (no buttons) into these events. + // We resolve these by looking for a non-motion + // event first. + if (!buttonDown) + { + btn |= 0x03; + btn &= ~0x40; + } + } + else if (!scroll) + { + buttonDown = true; } - return (k in exist ? true : false); - } -} -class Parser -{ + auto button = Buttons.none; + auto mod = Modifiers.none; - this(const ParseKeys pk) - { - keyCodes = pk.keys; - pasteStart = pk.pasteStart; - pasteEnd = pk.pasteEnd; - } + // Mouse wheel has bit 6 set, no release events. It should be noted + // that wheel events are sometimes misdelivered as mouse button events + // during a click-drag, so we debounce these, considering them to be + // button press events unless we see an intervening release event. + final switch (btn & 0x43) + { + case 0: + button = Buttons.button1; + break; + case 1: + button = Buttons.button3; // Note we prefer to treat right as button 2 + break; + case 2: + button = Buttons.button2; // And the middle button as button 3 + break; + case 3: + button = Buttons.none; + break; + case 0x40: + button = Buttons.wheelUp; + break; + case 0x41: + button = Buttons.wheelDown; + break; + case 0x42: + button = Buttons.wheelLeft; + break; + case 0x43: + button = Buttons.wheelRight; + break; + } - Event[] events() pure - { - auto res = evs; - evs = null; - return cast(Event[]) res; + if ((btn & 0x4) != 0) + { + mod |= Modifiers.shift; + } + if ((btn & 0x8) != 0) + { + mod |= Modifiers.alt; + } + if ((btn & 0x10) != 0) + { + mod |= Modifiers.ctrl; + } + + evs ~= newMouseEvent(x, y, button, mod); } - bool parse(string b) + void handleWinKey(int p0, int p1, int p2, int p3, int p4, int p5) { - auto now = MonoTime.currTime(); - if (b.length != 0) + // win32-input-mode + // ^[ [ Vk ; Sc ; Uc ; Kd ; Cs ; Rc _ + // Vk: the value of wVirtualKeyCode - any number. If omitted, defaults to '0'. + // Sc: the value of wVirtualScanCode - any number. If omitted, defaults to '0'. + // Uc: the decimal value of UnicodeChar - for example, NUL is "0", LF is + // "10", the character 'A' is "65". If omitted, defaults to '0'. + // Kd: the value of bKeyDown - either a '0' or '1'. If omitted, defaults to '0'. + // Cs: the value of dwControlKeyState - any number. If omitted, defaults to '0'. + // Rc: the value of wRepeatCount - any number. If omitted, defaults to '1'. + // + // Note that some 3rd party terminal emulators (not Terminal) suffer from a bug + // where other events, such as mouse events, are doubly encoded, using Vk 0 + // for each character. (So a CSI-M sequence is encoded as a series of CSI-_ + // sequences.) We consider this a bug in those terminal emulators -- Windows 11 + // Terminal does not suffer this brain damage. (We've observed this with both Alacritty + // and WezTerm.) + // + if (p3 == 0) { - // if we are adding to it, restart the timer - keyStart = now; + // key up event ignore ignore + return; } - buf ~= b; - - while (buf.length != 0) + if (p0 == 0 && p2 == 27 && nested is null) { - partial = false; + nested = new Parser(); + } - // we have to parse the paste bit first - if (parsePaste() || parseRune() || parseFnKey() || parseSgrMouse()) + if (nested !is null && p2 > 0 && p2 < 0x80) + { + // only ASCII in win32-input-mode + nested.buf ~= cast(ubyte) p2; + nested.scan(); + foreach (ev; nested.evs) { - keyStart = now; - continue; + evs ~= ev; } - auto expire = ((now - keyStart) > seqTime); + nested.evs = null; + return; + } - if (!partial || expire) + auto key = Key.rune; + auto chr = p2; + auto mod = Modifiers.none; + auto rpt = max(1, p5); + + if (p0 in winKeys) + { + auto kc = winKeys[p0]; + key = kc.key; + chr = 0; + } + else if (chr == 0 && p0 >= 0x30 && p0 <= 0x39) + { + chr = p0; + } + else if (chr < ' ' && p0 >= 0x41 && p0 <= 0x5a) + { + key = cast(Key) p0; + chr = 0; + } + else if (key == 0x11 || key == 0x13 || key == 0x14) + { + // lone modifiers + return; + } + + // Modifiers + if ((p4 & 0x010) != 0) + { + mod |= Modifiers.shift; + } + if ((p4 & 0x000c) != 0) + { + mod |= Modifiers.ctrl; + } + if ((p4 & 0x0003) != 0) + { + mod |= Modifiers.alt; + } + if (key == Key.rune && chr > ' ' && mod == Modifiers.shift) + { + // filter out lone shift for printable chars + mod = Modifiers.none; + } + if (((mod & (Modifiers.ctrl | Modifiers.alt)) == (Modifiers.ctrl | Modifiers.alt)) && ( + chr != 0)) + { + // Filter out ctrl+alt (it means AltGr) + mod = Modifiers.none; + } + + for (; rpt > 0; rpt--) + { + if (key != key.rune || chr != 0) { - if (buf[0] == '\x1b') - { - if (buf.length == 1) - { - evs ~= newKeyEvent(Key.esc); - escaped = false; - } - else - { - escaped = true; - } - buf = buf[1 .. $]; - keyStart = now; - continue; - } - // no matches or timeout waiting for data, yank off the first byte - evs ~= newKeyEvent(Key.rune, buf[0], escaped ? Modifiers.alt : Modifiers.none); - escaped = false; - keyStart = now; - continue; + evs ~= newKeyEvent(key, chr, mod); } - // we must have partial data, so wait and come back in a bit - return false; } - - return true; } - bool empty() const pure + // calculate the modifiers from the CSI modifier parameter. + Modifiers calcModifier(int n) { - return buf.length == 0; - } + n--; + Modifiers m; + if ((n & 1) != 0) + { + m |= Modifiers.shift; + } + if ((n & 2) != 0) + { + m |= Modifiers.alt; + } + if ((n & 4) != 0) + { + m |= Modifiers.ctrl; + } + if ((n & 8) != 0) + { + m |= Modifiers.meta; // kitty calls this Super + } + if ((n & 16) != 0) + { + m |= Modifiers.hyper; + } + if ((n & 32) != 0) + { + m |= Modifiers.meta; // for now not separating from Super + } + // Not doing (kitty only): + // caps_lock 0b1000000 (64) + // num_lock 0b10000000 (128) -private: + return m; + } - bool escaped; - ubyte[] buf; - Event[] evs; - const KeyCode[string] keyCodes; - bool partial; // record partially parsed sequences - MonoTime keyStart; // when the timer started - Duration seqTime = msecs(50); // time to fully decode a partial sequence - bool buttonDown; // true if buttons were down - bool pasting; - MonoTime pasteTime; - dstring pasteBuf; - string pasteStart; - string pasteEnd; + Event newFocusEvent(bool focused) + { + Event ev = + { + type: EventType.focus, when: MonoTime.currTime(), focus: { + focused: focused + } + }; + return ev; + } Event newKeyEvent(Key k, dchar dch = 0, Modifiers mod = Modifiers.none) { + if (escaped) + { + mod |= Modifiers.alt; + escaped = false; + } Event ev = { type: EventType.key, when: MonoTime.currTime(), key: { key: k, ch: dch, mod: mod @@ -422,6 +1110,18 @@ private: return ev; } + Event newMouseEvent(int x, int y, Buttons btn, Modifiers mod) + { + Event ev = { + type: EventType.mouse, when: MonoTime.currTime, mouse: { + pos: Coord(x, y), + btn: btn, + mod: mod, + } + }; + return ev; + } + // NB: it is possible for x and y to be outside the current coordinates // (happens for click drag for example). Consumer of the event should clip // the coordinates as needed. @@ -478,7 +1178,6 @@ private: } }; return ev; - } bool parseSequence(string seq) @@ -582,156 +1281,6 @@ private: return true; } - bool parseFnKey() - { - Modifiers mod = Modifiers.none; - if (buf.length == 0) - { - return false; - } - foreach (seq, kc; keyCodes) - { - // ideally we'd use a trie to isolate - // duplicates for this. for now, we just handle esc. - if (seq.length == 1 && seq[0] == '\x1b') - { - continue; - } - if (parseSequence(seq)) - { - mod = kc.mod; - if (escaped) - { - escaped = false; - mod = Modifiers.alt; - } - evs ~= newKeyEvent(kc.key, seq.length == 1 ? seq[0] : 0, mod); - return true; - } - } - return false; - } - - // look for an SGR mouse record, using a state machine - bool parseSgrMouse() - { - int x, y, btn, mov, state, val; - bool dig, neg; - - for (int i = 0; i < buf.length; i++) - { - switch (buf[i]) - { - case '\x1b': - if (state != 0) - return false; - state = 1; - break; - case '\x9b': // 8-bit mode CSI - if (state != 0) - return false; - state = 2; - break; - case '[': - if (state != 1) - return false; - state = 2; - break; - case '<': - if (state != 2) - return false; - val = 0; - dig = false; - neg = false; - state = 3; - break; - case '-': - if (state < 3 || state > 5 || dig || neg) - return false; - neg = true; // no state change - break; - case '0': .. case '9': - if (state < 3 || state > 5) - return false; - val *= 10; - val += cast(int)(buf[i] - '0'); - dig = true; // no state change - break; - case ';': - if (state != 3 && state != 4) - return false; - if (neg) - val = -val; - switch (state) - { - case 3: - btn = val; - val = 0; - neg = false; - dig = false; - state = 4; - break; - case 4: - x = val - 1; - val = 0; - neg = false; - dig = false; - state = 5; - break; - default: - return false; - } - break; - case 'm', 'M': - if (state != 5) - return false; - if (neg) - { - val = -val; - } - y = val - 1; - mov = (btn & 0x20) != 0; - btn &= ~0x20; - if (buf[i] == 'm') - { - // release - btn |= 0x3; - btn &= ~0x40; - buttonDown = false; - } - else if (mov) - { - // Some broken terminals appear to send - // mouse button one motion events, instead of - // encoding 35 (no buttons) into these events. - // We resolve these by looking for a non-motion - // event first. - if (!buttonDown) - { - btn |= 0x3; - btn &= ~0x40; - } - } - else - { - buttonDown = true; - } - buf = buf[i + 1 .. $]; - import std.stdio; - - evs ~= newMouseEvent(x, y, btn); - return true; - default: - // definitely not ours - return false; - } - } - // might be ours, inconclusive - if (state > 0) - partial = true; - return false; - } - unittest { import core.thread; @@ -744,28 +1293,12 @@ private: exitKeypad: "\x1b[?1l\x1b>", cursorBack1: "\x08", cursorUp1: "\x1b[A", - keyBackspace: "\x08", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1bOH", - keyEnd: "\x1bOF", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", - keyShfRight: "\x1b[1;2C", mouse: "\x1b[M", }; Database.put(&term); auto tc = Database.get("test-term"); assert(tc !is null); - Parser p = new Parser(ParseKeys(tc)); + Parser p = new Parser(); assert(p.empty()); assert(p.parse("")); // no data, is fine assert(p.parse("\x1bOC")); @@ -781,7 +1314,7 @@ private: assert(p.parse(['\x1b', 'O']) == false); ev = p.events(); assert(ev.length == 0); - Thread.sleep(msecs(100)); + Thread.sleep(msecs(200)); assert(p.parse([]) == true); ev = p.events(); assert(ev.length == 1); @@ -802,7 +1335,6 @@ private: assert(ev[0].key.mod == Modifiers.none); // try injecting paste events - assert(tc.enablePaste != ""); assert(p.parse(['\x1b', '[', '2', '0', '0', '~'])); assert(p.parse(['A'])); assert(p.parse(['\x1b', '[', '2', '0', '1', '~'])); diff --git a/source/dcell/screen.d b/source/dcell/screen.d index 67a2caa..c1239ba 100644 --- a/source/dcell/screen.d +++ b/source/dcell/screen.d @@ -1,7 +1,7 @@ /** * Screen module for dcell provides the common interface for different implementations of KVM type devices. * - * Copyright: Copyright 2022 Garrett D'Amore + * Copyright: Copyright 2025 Garrett D'Amore * Authors: Garrett D'Amore * License: * Distributed under the Boost Software License, Version 1.0. @@ -50,7 +50,6 @@ interface Screen */ void opIndexAssign(Cell, size_t x, size_t y); - /** Convenience for indexing. */ final void opIndexAssign(Cell c, Coord pos) { @@ -58,10 +57,14 @@ interface Screen } /** Support $ operation in indices. */ - size_t opDollar(size_t dim)() { - static if (dim == 0) { + size_t opDollar(size_t dim)() + { + static if (dim == 0) + { return size().x; - } else { + } + else + { return size().y; } } @@ -81,17 +84,6 @@ interface Screen */ void showCursor(Coord pos, Cursor cur = Cursor.current); - /** - * It would be nice to know if a given key is supported by - * a terminal. Note that this is best-effort, and some terminals - * may present the ability to support a key, without actually having - * such a physical key and some combinations may be suppressed by - * the emulator or the environment the emulator runs in. - * - * Returns: true if the key appears to be supported on the terminal. - */ - bool hasKey(Key); - /** * Obtain the terminal window size. * The x, y represent the number of columns and rows. @@ -128,6 +120,15 @@ interface Screen */ void enablePaste(bool b); + /** + * Enable focus reporting. This will cause focus events to be sent + * when the window focus changes. + * + * Params: + * b = true to enable focus reporting, false to disable + */ + void enableFocus(bool b); + /** * Do we have a mouse? This may be overly optimistic for some * terminals, but it is a good first guess. diff --git a/source/dcell/termcap.d b/source/dcell/termcap.d index 2cf95a7..a76643c 100644 --- a/source/dcell/termcap.d +++ b/source/dcell/termcap.d @@ -49,100 +49,12 @@ struct Termcap string setCursor; /// `cup`, sets cursor location to row and column string cursorBack1; /// `cub1`, move cursor backwards one string cursorUp1; /// `cuu1`, mover cursor up one line - string padChar; /// `pad`, padding character, if non-empty enables padding delays string insertChar; /// `ich1`, insert a character, used for inserting at bottom right for automargin terminals - string keyBackspace; /// `kbs`, backspace key - string keyF1; // kf1 - string keyF2; // kf2 - string keyF3; // kf3 - string keyF4; // kf4 - string keyF5; // kf5 - string keyF6; // kf6 - string keyF7; // kf7 - string keyF8; // kf8 - string keyF9; // kf9 - string keyF10; // kf10 - string keyF11; // kf11 - string keyF12; // kf12 - string keyF13; // kf13 - string keyF14; // kf14 - string keyF15; // kf15 - string keyF16; // kf16 - string keyF17; // kf17 - string keyF18; // kf18 - string keyF19; // kf19 - string keyF20; // kf20 - string keyF21; // kf21 - string keyF22; // kf22 - string keyF23; // kf23 - string keyF24; // kf24 - string keyF25; // kf25 - string keyF26; // kf26 - string keyF27; // kf27 - string keyF28; // kf28 - string keyF29; // kf29 - string keyF30; // kf30 - string keyF31; // kf31 - string keyF32; // kf32 - string keyF33; // kf33 - string keyF34; // kf34 - string keyF35; // kf35 - string keyF36; // kf36 - string keyF37; // kf37 - string keyF38; // kf38 - string keyF39; // kf39 - string keyF40; // kf40 - string keyF41; // kf41 - string keyF42; // kf42 - string keyF43; // kf43 - string keyF44; // kf44 - string keyF45; // kf45 - string keyF46; // kf46 - string keyF47; // kf47 - string keyF48; // kf48 - string keyF49; // kf49 - string keyF50; // kf50 - string keyF51; // kf51 - string keyF52; // kf52 - string keyF53; // kf53 - string keyF54; // kf54 - string keyF55; // kf55 - string keyF56; // kf56 - string keyF57; // kf57 - string keyF58; // kf58 - string keyF59; // kf59 - string keyF60; // kf60 - string keyF61; // kf61 - string keyF62; // kf62 - string keyF63; // kf63 - string keyF64; // kf64 - string keyInsert; // kich1 - string keyDelete; // kdch1 - string keyHome; // khome - string keyEnd; // kend - string keyHelp; // khlp - string keyPgUp; // kpp - string keyPgDn; // knp - string keyUp; // kcuu1 - string keyDown; // kcud1 - string keyLeft; // kcub1 - string keyRight; // kcuf1 - string keyBacktab; // kcbt - string keyExit; // kext - string keyClear; // kclr - string keyPrint; // kprt - string keyCancel; // kcan string mouse; /// `kmouse`, indicates support for mouse mode - XTerm style sequences are assumed string altChars; /// `acsc`, alternate characters, used for non-ASCII characters with certain legacy terminals string enterACS; /// `smacs`, sequence to switch to alternate character set string exitACS; /// `rmacs`, sequence to return to normal character set string enableACS; /// `enacs`, sequence to enable alternate character set support - string keyShfRight; // kRIT - string keyShfLeft; // kLFT - string keyShfHome; // kHOM - string keyShfEnd; // kEND - string keyShfInsert; // kIC - string keyShfDelete; // kDC bool automargin; /// `am`, if true cursor wraps and advances to next row after last column // Non-standard additions to terminfo. YMMV. @@ -151,46 +63,6 @@ struct Termcap string setFgBgRGB; /// sequence to set both foreground and background together, using RGB colors string setFgRGB; /// sequence to set foreground color to RGB value string setBgRGB; /// sequence to set background color RGB value - string keyShfUp; - string keyShfDown; - string keyShfPgUp; - string keyShfPgDn; - string keyCtrlUp; - string keyCtrlDown; - string keyCtrlRight; - string keyCtrlLeft; - string keyMetaUp; - string keyMetaDown; - string keyMetaRight; - string keyMetaLeft; - string keyAltUp; - string keyAltDown; - string keyAltRight; - string keyAltLeft; - string keyCtrlHome; - string keyCtrlEnd; - string keyMetaHome; - string keyMetaEnd; - string keyAltHome; - string keyAltEnd; - string keyAltShfUp; - string keyAltShfDown; - string keyAltShfLeft; - string keyAltShfRight; - string keyMetaShfUp; - string keyMetaShfDown; - string keyMetaShfLeft; - string keyMetaShfRight; - string keyCtrlShfUp; - string keyCtrlShfDown; - string keyCtrlShfLeft; - string keyCtrlShfRight; - string keyCtrlShfHome; - string keyCtrlShfEnd; - string keyAltShfHome; - string keyAltShfEnd; - string keyMetaShfHome; - string keyMetaShfEnd; string enablePaste; /// sequence to enable delimited paste mode string disablePaste; /// sequence to disable delimited paste mode string pasteStart; /// sequence sent by terminal to indicate start of a paste buffer diff --git a/source/dcell/terminfo/aixterm.d b/source/dcell/terminfo/aixterm.d index 0047786..9b7bcd2 100644 --- a/source/dcell/terminfo/aixterm.d +++ b/source/dcell/terminfo/aixterm.d @@ -21,56 +21,6 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", - keyBackspace: "\x08", - keyF1: "\x1b[001q", - keyF2: "\x1b[002q", - keyF3: "\x1b[003q", - keyF4: "\x1b[004q", - keyF5: "\x1b[005q", - keyF6: "\x1b[006q", - keyF7: "\x1b[007q", - keyF8: "\x1b[008q", - keyF9: "\x1b[009q", - keyF10: "\x1b[010q", - keyF11: "\x1b[011q", - keyF12: "\x1b[012q", - keyF13: "\x1b[013q", - keyF14: "\x1b[014q", - keyF15: "\x1b[015q", - keyF16: "\x1b[016q", - keyF17: "\x1b[017q", - keyF18: "\x1b[018q", - keyF19: "\x1b[019q", - keyF20: "\x1b[020q", - keyF21: "\x1b[021q", - keyF22: "\x1b[022q", - keyF23: "\x1b[023q", - keyF24: "\x1b[024q", - keyF25: "\x1b[025q", - keyF26: "\x1b[026q", - keyF27: "\x1b[027q", - keyF28: "\x1b[028q", - keyF29: "\x1b[029q", - keyF30: "\x1b[030q", - keyF31: "\x1b[031q", - keyF32: "\x1b[032q", - keyF33: "\x1b[033q", - keyF34: "\x1b[034q", - keyF35: "\x1b[035q", - keyF36: "\x1b[036q", - keyInsert: "\x1b[139q", - keyDelete: "\x1b[P", - keyHome: "\x1b[H", - keyEnd: "\x1b[146q", - keyPgUp: "\x1b[150q", - keyPgDn: "\x1b[154q", - keyUp: "\x1b[A", - keyDown: "\x1b[B", - keyLeft: "\x1b[D", - keyRight: "\x1b[C", - keyBacktab: "\x1b[Z", - keyClear: "\x1b[144q", altChars: "jjkkllmmnnqqttuuvvwwxx", automargin: true, }; @@ -92,56 +42,6 @@ static immutable Termcap term1 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", - keyBackspace: "\x08", - keyF1: "\x1b[001q", - keyF2: "\x1b[002q", - keyF3: "\x1b[003q", - keyF4: "\x1b[004q", - keyF5: "\x1b[005q", - keyF6: "\x1b[006q", - keyF7: "\x1b[007q", - keyF8: "\x1b[008q", - keyF9: "\x1b[009q", - keyF10: "\x1b[010q", - keyF11: "\x1b[011q", - keyF12: "\x1b[012q", - keyF13: "\x1b[013q", - keyF14: "\x1b[014q", - keyF15: "\x1b[015q", - keyF16: "\x1b[016q", - keyF17: "\x1b[017q", - keyF18: "\x1b[018q", - keyF19: "\x1b[019q", - keyF20: "\x1b[020q", - keyF21: "\x1b[021q", - keyF22: "\x1b[022q", - keyF23: "\x1b[023q", - keyF24: "\x1b[024q", - keyF25: "\x1b[025q", - keyF26: "\x1b[026q", - keyF27: "\x1b[027q", - keyF28: "\x1b[028q", - keyF29: "\x1b[029q", - keyF30: "\x1b[030q", - keyF31: "\x1b[031q", - keyF32: "\x1b[032q", - keyF33: "\x1b[033q", - keyF34: "\x1b[034q", - keyF35: "\x1b[035q", - keyF36: "\x1b[036q", - keyInsert: "\x1b[139q", - keyDelete: "\x1b[P", - keyHome: "\x1b[H", - keyEnd: "\x1b[146q", - keyPgUp: "\x1b[150q", - keyPgDn: "\x1b[154q", - keyUp: "\x1b[A", - keyDown: "\x1b[B", - keyLeft: "\x1b[D", - keyRight: "\x1b[C", - keyBacktab: "\x1b[Z", - keyClear: "\x1b[144q", altChars: "jjkkllmmnnqqttuuvvwwxx", automargin: true, }; diff --git a/source/dcell/terminfo/alacritty.d b/source/dcell/terminfo/alacritty.d index 75e06b4..5e6a048 100644 --- a/source/dcell/terminfo/alacritty.d +++ b/source/dcell/terminfo/alacritty.d @@ -29,91 +29,10 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - keyBackspace: "", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1b[1;2P", - keyF14: "\x1b[1;2Q", - keyF15: "\x1b[1;2R", - keyF16: "\x1b[1;2S", - keyF17: "\x1b[15;2~", - keyF18: "\x1b[17;2~", - keyF19: "\x1b[18;2~", - keyF20: "\x1b[19;2~", - keyF21: "\x1b[20;2~", - keyF22: "\x1b[21;2~", - keyF23: "\x1b[23;2~", - keyF24: "\x1b[24;2~", - keyF25: "\x1b[1;5P", - keyF26: "\x1b[1;5Q", - keyF27: "\x1b[1;5R", - keyF28: "\x1b[1;5S", - keyF29: "\x1b[15;5~", - keyF30: "\x1b[17;5~", - keyF31: "\x1b[18;5~", - keyF32: "\x1b[19;5~", - keyF33: "\x1b[20;5~", - keyF34: "\x1b[21;5~", - keyF35: "\x1b[23;5~", - keyF36: "\x1b[24;5~", - keyF37: "\x1b[1;6P", - keyF38: "\x1b[1;6Q", - keyF39: "\x1b[1;6R", - keyF40: "\x1b[1;6S", - keyF41: "\x1b[15;6~", - keyF42: "\x1b[17;6~", - keyF43: "\x1b[18;6~", - keyF44: "\x1b[19;6~", - keyF45: "\x1b[20;6~", - keyF46: "\x1b[21;6~", - keyF47: "\x1b[23;6~", - keyF48: "\x1b[24;6~", - keyF49: "\x1b[1;3P", - keyF50: "\x1b[1;3Q", - keyF51: "\x1b[1;3R", - keyF52: "\x1b[1;3S", - keyF53: "\x1b[15;3~", - keyF54: "\x1b[17;3~", - keyF55: "\x1b[18;3~", - keyF56: "\x1b[19;3~", - keyF57: "\x1b[20;3~", - keyF58: "\x1b[21;3~", - keyF59: "\x1b[23;3~", - keyF60: "\x1b[24;3~", - keyF61: "\x1b[1;4P", - keyF62: "\x1b[1;4Q", - keyF63: "\x1b[1;4R", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1bOH", - keyEnd: "\x1bOF", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", - keyShfRight: "\x1b[1;2C", - keyShfLeft: "\x1b[1;2D", - keyShfHome: "\x1b[1;2H", - keyShfEnd: "\x1b[1;2F", - keyShfInsert: "\x1b[2;2~", - keyShfDelete: "\x1b[3;2~", automargin: true, }; @@ -141,91 +60,10 @@ static immutable Termcap term1 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - keyBackspace: "", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1b[1;2P", - keyF14: "\x1b[1;2Q", - keyF15: "\x1b[1;2R", - keyF16: "\x1b[1;2S", - keyF17: "\x1b[15;2~", - keyF18: "\x1b[17;2~", - keyF19: "\x1b[18;2~", - keyF20: "\x1b[19;2~", - keyF21: "\x1b[20;2~", - keyF22: "\x1b[21;2~", - keyF23: "\x1b[23;2~", - keyF24: "\x1b[24;2~", - keyF25: "\x1b[1;5P", - keyF26: "\x1b[1;5Q", - keyF27: "\x1b[1;5R", - keyF28: "\x1b[1;5S", - keyF29: "\x1b[15;5~", - keyF30: "\x1b[17;5~", - keyF31: "\x1b[18;5~", - keyF32: "\x1b[19;5~", - keyF33: "\x1b[20;5~", - keyF34: "\x1b[21;5~", - keyF35: "\x1b[23;5~", - keyF36: "\x1b[24;5~", - keyF37: "\x1b[1;6P", - keyF38: "\x1b[1;6Q", - keyF39: "\x1b[1;6R", - keyF40: "\x1b[1;6S", - keyF41: "\x1b[15;6~", - keyF42: "\x1b[17;6~", - keyF43: "\x1b[18;6~", - keyF44: "\x1b[19;6~", - keyF45: "\x1b[20;6~", - keyF46: "\x1b[21;6~", - keyF47: "\x1b[23;6~", - keyF48: "\x1b[24;6~", - keyF49: "\x1b[1;3P", - keyF50: "\x1b[1;3Q", - keyF51: "\x1b[1;3R", - keyF52: "\x1b[1;3S", - keyF53: "\x1b[15;3~", - keyF54: "\x1b[17;3~", - keyF55: "\x1b[18;3~", - keyF56: "\x1b[19;3~", - keyF57: "\x1b[20;3~", - keyF58: "\x1b[21;3~", - keyF59: "\x1b[23;3~", - keyF60: "\x1b[24;3~", - keyF61: "\x1b[1;4P", - keyF62: "\x1b[1;4Q", - keyF63: "\x1b[1;4R", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1bOH", - keyEnd: "\x1bOF", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", - keyShfRight: "\x1b[1;2C", - keyShfLeft: "\x1b[1;2D", - keyShfHome: "\x1b[1;2H", - keyShfEnd: "\x1b[1;2F", - keyShfInsert: "\x1b[2;2~", - keyShfDelete: "\x1b[3;2~", automargin: true, }; diff --git a/source/dcell/terminfo/ansi.d b/source/dcell/terminfo/ansi.d index 1f38f0c..b855046 100644 --- a/source/dcell/terminfo/ansi.d +++ b/source/dcell/terminfo/ansi.d @@ -22,15 +22,6 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x1b[D", cursorUp1: "\x1b[A", - padChar: "\x00", - keyBackspace: "\x08", - keyInsert: "\x1b[L", - keyHome: "\x1b[H", - keyUp: "\x1b[A", - keyDown: "\x1b[B", - keyLeft: "\x1b[D", - keyRight: "\x1b[C", - keyBacktab: "\x1b[Z", altChars: "+\x10,\x11-\x18.\x190Û`\x04a±føgñh°jÙk¿lÚmÀnÅo~pÄqÄrÄs_tÃu´vÁwÂx³yózò{ã|Ø}œ~þ", enterACS: "\x1b[11m", exitACS: "\x1b[10m", diff --git a/source/dcell/terminfo/dtterm.d b/source/dcell/terminfo/dtterm.d index 61320ca..dd5a54e 100644 --- a/source/dcell/terminfo/dtterm.d +++ b/source/dcell/terminfo/dtterm.d @@ -25,37 +25,6 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", - keyBackspace: "\x08", - keyF1: "\x1b[11~", - keyF2: "\x1b[12~", - keyF3: "\x1b[13~", - keyF4: "\x1b[14~", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1b[25~", - keyF14: "\x1b[26~", - keyF15: "\x1b[28~", - keyF16: "\x1b[29~", - keyF17: "\x1b[31~", - keyF18: "\x1b[32~", - keyF19: "\x1b[33~", - keyF20: "\x1b[34~", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHelp: "\x1b[28~", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1b[A", - keyDown: "\x1b[B", - keyLeft: "\x1b[D", - keyRight: "\x1b[C", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", diff --git a/source/dcell/terminfo/gnome.d b/source/dcell/terminfo/gnome.d index 32ee253..f2c13bb 100644 --- a/source/dcell/terminfo/gnome.d +++ b/source/dcell/terminfo/gnome.d @@ -27,93 +27,11 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", - keyBackspace: "", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1bO1;2P", - keyF14: "\x1bO1;2Q", - keyF15: "\x1bO1;2R", - keyF16: "\x1bO1;2S", - keyF17: "\x1b[15;2~", - keyF18: "\x1b[17;2~", - keyF19: "\x1b[18;2~", - keyF20: "\x1b[19;2~", - keyF21: "\x1b[20;2~", - keyF22: "\x1b[21;2~", - keyF23: "\x1b[23;2~", - keyF24: "\x1b[24;2~", - keyF25: "\x1bO1;5P", - keyF26: "\x1bO1;5Q", - keyF27: "\x1bO1;5R", - keyF28: "\x1bO1;5S", - keyF29: "\x1b[15;5~", - keyF30: "\x1b[17;5~", - keyF31: "\x1b[18;5~", - keyF32: "\x1b[19;5~", - keyF33: "\x1b[20;5~", - keyF34: "\x1b[21;5~", - keyF35: "\x1b[23;5~", - keyF36: "\x1b[24;5~", - keyF37: "\x1bO1;6P", - keyF38: "\x1bO1;6Q", - keyF39: "\x1bO1;6R", - keyF40: "\x1bO1;6S", - keyF41: "\x1b[15;6~", - keyF42: "\x1b[17;6~", - keyF43: "\x1b[18;6~", - keyF44: "\x1b[19;6~", - keyF45: "\x1b[20;6~", - keyF46: "\x1b[21;6~", - keyF47: "\x1b[23;6~", - keyF48: "\x1b[24;6~", - keyF49: "\x1bO1;3P", - keyF50: "\x1bO1;3Q", - keyF51: "\x1bO1;3R", - keyF52: "\x1bO1;3S", - keyF53: "\x1b[15;3~", - keyF54: "\x1b[17;3~", - keyF55: "\x1b[18;3~", - keyF56: "\x1b[19;3~", - keyF57: "\x1b[20;3~", - keyF58: "\x1b[21;3~", - keyF59: "\x1b[23;3~", - keyF60: "\x1b[24;3~", - keyF61: "\x1bO1;4P", - keyF62: "\x1bO1;4Q", - keyF63: "\x1bO1;4R", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1bOH", - keyEnd: "\x1bOF", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b)0", - keyShfRight: "\x1b[1;2C", - keyShfLeft: "\x1b[1;2D", - keyShfHome: "\x1b[1;2H", - keyShfEnd: "\x1b[1;2F", - keyShfInsert: "\x1b[2;2~", - keyShfDelete: "\x1b[3;2~", automargin: true, }; @@ -140,93 +58,11 @@ static immutable Termcap term1 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", - keyBackspace: "", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1bO1;2P", - keyF14: "\x1bO1;2Q", - keyF15: "\x1bO1;2R", - keyF16: "\x1bO1;2S", - keyF17: "\x1b[15;2~", - keyF18: "\x1b[17;2~", - keyF19: "\x1b[18;2~", - keyF20: "\x1b[19;2~", - keyF21: "\x1b[20;2~", - keyF22: "\x1b[21;2~", - keyF23: "\x1b[23;2~", - keyF24: "\x1b[24;2~", - keyF25: "\x1bO1;5P", - keyF26: "\x1bO1;5Q", - keyF27: "\x1bO1;5R", - keyF28: "\x1bO1;5S", - keyF29: "\x1b[15;5~", - keyF30: "\x1b[17;5~", - keyF31: "\x1b[18;5~", - keyF32: "\x1b[19;5~", - keyF33: "\x1b[20;5~", - keyF34: "\x1b[21;5~", - keyF35: "\x1b[23;5~", - keyF36: "\x1b[24;5~", - keyF37: "\x1bO1;6P", - keyF38: "\x1bO1;6Q", - keyF39: "\x1bO1;6R", - keyF40: "\x1bO1;6S", - keyF41: "\x1b[15;6~", - keyF42: "\x1b[17;6~", - keyF43: "\x1b[18;6~", - keyF44: "\x1b[19;6~", - keyF45: "\x1b[20;6~", - keyF46: "\x1b[21;6~", - keyF47: "\x1b[23;6~", - keyF48: "\x1b[24;6~", - keyF49: "\x1bO1;3P", - keyF50: "\x1bO1;3Q", - keyF51: "\x1bO1;3R", - keyF52: "\x1bO1;3S", - keyF53: "\x1b[15;3~", - keyF54: "\x1b[17;3~", - keyF55: "\x1b[18;3~", - keyF56: "\x1b[19;3~", - keyF57: "\x1b[20;3~", - keyF58: "\x1b[21;3~", - keyF59: "\x1b[23;3~", - keyF60: "\x1b[24;3~", - keyF61: "\x1bO1;4P", - keyF62: "\x1bO1;4Q", - keyF63: "\x1bO1;4R", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1bOH", - keyEnd: "\x1bOF", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b)0", - keyShfRight: "\x1b[1;2C", - keyShfLeft: "\x1b[1;2D", - keyShfHome: "\x1b[1;2H", - keyShfEnd: "\x1b[1;2F", - keyShfInsert: "\x1b[2;2~", - keyShfDelete: "\x1b[3;2~", automargin: true, }; diff --git a/source/dcell/terminfo/konsole.d b/source/dcell/terminfo/konsole.d index 77fd95b..71daf4b 100644 --- a/source/dcell/terminfo/konsole.d +++ b/source/dcell/terminfo/konsole.d @@ -27,81 +27,6 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - keyBackspace: "", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1bO2P", - keyF14: "\x1bO2Q", - keyF15: "\x1bO2R", - keyF16: "\x1bO2S", - keyF17: "\x1b[15;2~", - keyF18: "\x1b[17;2~", - keyF19: "\x1b[18;2~", - keyF20: "\x1b[19;2~", - keyF21: "\x1b[20;2~", - keyF22: "\x1b[21;2~", - keyF23: "\x1b[23;2~", - keyF24: "\x1b[24;2~", - keyF25: "\x1bO5P", - keyF26: "\x1bO5Q", - keyF27: "\x1bO5R", - keyF28: "\x1bO5S", - keyF29: "\x1b[15;5~", - keyF30: "\x1b[17;5~", - keyF31: "\x1b[18;5~", - keyF32: "\x1b[19;5~", - keyF33: "\x1b[20;5~", - keyF34: "\x1b[21;5~", - keyF35: "\x1b[23;5~", - keyF36: "\x1b[24;5~", - keyF37: "\x1bO6P", - keyF38: "\x1bO6Q", - keyF39: "\x1bO6R", - keyF40: "\x1bO6S", - keyF41: "\x1b[15;6~", - keyF42: "\x1b[17;6~", - keyF43: "\x1b[18;6~", - keyF44: "\x1b[19;6~", - keyF45: "\x1b[20;6~", - keyF46: "\x1b[21;6~", - keyF47: "\x1b[23;6~", - keyF48: "\x1b[24;6~", - keyF49: "\x1bO3P", - keyF50: "\x1bO3Q", - keyF51: "\x1bO3R", - keyF52: "\x1bO3S", - keyF53: "\x1b[15;3~", - keyF54: "\x1b[17;3~", - keyF55: "\x1b[18;3~", - keyF56: "\x1b[19;3~", - keyF57: "\x1b[20;3~", - keyF58: "\x1b[21;3~", - keyF59: "\x1b[23;3~", - keyF60: "\x1b[24;3~", - keyF61: "\x1bO4P", - keyF62: "\x1bO4Q", - keyF63: "\x1bO4R", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1bOH", - keyEnd: "\x1bOF", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", @@ -133,81 +58,6 @@ static immutable Termcap term1 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - keyBackspace: "", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1bO2P", - keyF14: "\x1bO2Q", - keyF15: "\x1bO2R", - keyF16: "\x1bO2S", - keyF17: "\x1b[15;2~", - keyF18: "\x1b[17;2~", - keyF19: "\x1b[18;2~", - keyF20: "\x1b[19;2~", - keyF21: "\x1b[20;2~", - keyF22: "\x1b[21;2~", - keyF23: "\x1b[23;2~", - keyF24: "\x1b[24;2~", - keyF25: "\x1bO5P", - keyF26: "\x1bO5Q", - keyF27: "\x1bO5R", - keyF28: "\x1bO5S", - keyF29: "\x1b[15;5~", - keyF30: "\x1b[17;5~", - keyF31: "\x1b[18;5~", - keyF32: "\x1b[19;5~", - keyF33: "\x1b[20;5~", - keyF34: "\x1b[21;5~", - keyF35: "\x1b[23;5~", - keyF36: "\x1b[24;5~", - keyF37: "\x1bO6P", - keyF38: "\x1bO6Q", - keyF39: "\x1bO6R", - keyF40: "\x1bO6S", - keyF41: "\x1b[15;6~", - keyF42: "\x1b[17;6~", - keyF43: "\x1b[18;6~", - keyF44: "\x1b[19;6~", - keyF45: "\x1b[20;6~", - keyF46: "\x1b[21;6~", - keyF47: "\x1b[23;6~", - keyF48: "\x1b[24;6~", - keyF49: "\x1bO3P", - keyF50: "\x1bO3Q", - keyF51: "\x1bO3R", - keyF52: "\x1bO3S", - keyF53: "\x1b[15;3~", - keyF54: "\x1b[17;3~", - keyF55: "\x1b[18;3~", - keyF56: "\x1b[19;3~", - keyF57: "\x1b[20;3~", - keyF58: "\x1b[21;3~", - keyF59: "\x1b[23;3~", - keyF60: "\x1b[24;3~", - keyF61: "\x1bO4P", - keyF62: "\x1bO4Q", - keyF63: "\x1bO4R", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1bOH", - keyEnd: "\x1bOF", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", @@ -239,81 +89,6 @@ static immutable Termcap term2 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - keyBackspace: "", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1bO2P", - keyF14: "\x1bO2Q", - keyF15: "\x1bO2R", - keyF16: "\x1bO2S", - keyF17: "\x1b[15;2~", - keyF18: "\x1b[17;2~", - keyF19: "\x1b[18;2~", - keyF20: "\x1b[19;2~", - keyF21: "\x1b[20;2~", - keyF22: "\x1b[21;2~", - keyF23: "\x1b[23;2~", - keyF24: "\x1b[24;2~", - keyF25: "\x1bO5P", - keyF26: "\x1bO5Q", - keyF27: "\x1bO5R", - keyF28: "\x1bO5S", - keyF29: "\x1b[15;5~", - keyF30: "\x1b[17;5~", - keyF31: "\x1b[18;5~", - keyF32: "\x1b[19;5~", - keyF33: "\x1b[20;5~", - keyF34: "\x1b[21;5~", - keyF35: "\x1b[23;5~", - keyF36: "\x1b[24;5~", - keyF37: "\x1bO6P", - keyF38: "\x1bO6Q", - keyF39: "\x1bO6R", - keyF40: "\x1bO6S", - keyF41: "\x1b[15;6~", - keyF42: "\x1b[17;6~", - keyF43: "\x1b[18;6~", - keyF44: "\x1b[19;6~", - keyF45: "\x1b[20;6~", - keyF46: "\x1b[21;6~", - keyF47: "\x1b[23;6~", - keyF48: "\x1b[24;6~", - keyF49: "\x1bO3P", - keyF50: "\x1bO3Q", - keyF51: "\x1bO3R", - keyF52: "\x1bO3S", - keyF53: "\x1b[15;3~", - keyF54: "\x1b[17;3~", - keyF55: "\x1b[18;3~", - keyF56: "\x1b[19;3~", - keyF57: "\x1b[20;3~", - keyF58: "\x1b[21;3~", - keyF59: "\x1b[23;3~", - keyF60: "\x1b[24;3~", - keyF61: "\x1bO4P", - keyF62: "\x1bO4Q", - keyF63: "\x1bO4R", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1bOH", - keyEnd: "\x1bOF", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", diff --git a/source/dcell/terminfo/linux.d b/source/dcell/terminfo/linux.d index d4983cb..861cb5d 100644 --- a/source/dcell/terminfo/linux.d +++ b/source/dcell/terminfo/linux.d @@ -24,40 +24,6 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", - insertChar: "\x1b[@", - keyBackspace: "", - keyF1: "\x1b[[A", - keyF2: "\x1b[[B", - keyF3: "\x1b[[C", - keyF4: "\x1b[[D", - keyF5: "\x1b[[E", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1b[25~", - keyF14: "\x1b[26~", - keyF15: "\x1b[28~", - keyF16: "\x1b[29~", - keyF17: "\x1b[31~", - keyF18: "\x1b[32~", - keyF19: "\x1b[33~", - keyF20: "\x1b[34~", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1b[1~", - keyEnd: "\x1b[4~", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1b[A", - keyDown: "\x1b[B", - keyLeft: "\x1b[D", - keyRight: "\x1b[C", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "+\x10,\x11-\x18.\x190Û`\x04a±føgñh°iÎjÙk¿lÚmÀnÅo~pÄqÄrÄs_tÃu´vÁwÂx³yózò{ã|Ø}œ~þ", enterACS: "\x1b[11m", diff --git a/source/dcell/terminfo/rxvt.d b/source/dcell/terminfo/rxvt.d index eaf0d58..5dd360c 100644 --- a/source/dcell/terminfo/rxvt.d +++ b/source/dcell/terminfo/rxvt.d @@ -28,84 +28,13 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", insertChar: "\x1b[@", - keyBackspace: "\x08", - keyF1: "\x1b[11~", - keyF2: "\x1b[12~", - keyF3: "\x1b[13~", - keyF4: "\x1b[14~", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1b[25~", - keyF14: "\x1b[26~", - keyF15: "\x1b[28~", - keyF16: "\x1b[29~", - keyF17: "\x1b[31~", - keyF18: "\x1b[32~", - keyF19: "\x1b[33~", - keyF20: "\x1b[34~", - keyF21: "\x1b[23$", - keyF22: "\x1b[24$", - keyF23: "\x1b[11^", - keyF24: "\x1b[12^", - keyF25: "\x1b[13^", - keyF26: "\x1b[14^", - keyF27: "\x1b[15^", - keyF28: "\x1b[17^", - keyF29: "\x1b[18^", - keyF30: "\x1b[19^", - keyF31: "\x1b[20^", - keyF32: "\x1b[21^", - keyF33: "\x1b[23^", - keyF34: "\x1b[24^", - keyF35: "\x1b[25^", - keyF36: "\x1b[26^", - keyF37: "\x1b[28^", - keyF38: "\x1b[29^", - keyF39: "\x1b[31^", - keyF40: "\x1b[32^", - keyF41: "\x1b[33^", - keyF42: "\x1b[34^", - keyF43: "\x1b[23@", - keyF44: "\x1b[24@", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1b[7~", - keyEnd: "\x1b[8~", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1b[A", - keyDown: "\x1b[B", - keyLeft: "\x1b[D", - keyRight: "\x1b[C", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b(B\x1b)0", - keyShfRight: "\x1b[c", - keyShfLeft: "\x1b[d", - keyShfHome: "\x1b[7$", - keyShfEnd: "\x1b[8$", - keyShfInsert: "\x1b[2$", - keyShfDelete: "\x1b[3$", automargin: true, - keyShfUp: "\x1b[a", - keyShfDown: "\x1b[b", - keyCtrlUp: "\x1b[Oa", - keyCtrlDown: "\x1b[Ob", - keyCtrlRight: "\x1b[Oc", - keyCtrlLeft: "\x1b[Od", - keyCtrlHome: "\x1b[7^", - keyCtrlEnd: "\x1b[8^", }; // rxvt-16color @@ -132,84 +61,12 @@ static immutable Termcap term1 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", insertChar: "\x1b[@", - keyBackspace: "\x08", - keyF1: "\x1b[11~", - keyF2: "\x1b[12~", - keyF3: "\x1b[13~", - keyF4: "\x1b[14~", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1b[25~", - keyF14: "\x1b[26~", - keyF15: "\x1b[28~", - keyF16: "\x1b[29~", - keyF17: "\x1b[31~", - keyF18: "\x1b[32~", - keyF19: "\x1b[33~", - keyF20: "\x1b[34~", - keyF21: "\x1b[23$", - keyF22: "\x1b[24$", - keyF23: "\x1b[11^", - keyF24: "\x1b[12^", - keyF25: "\x1b[13^", - keyF26: "\x1b[14^", - keyF27: "\x1b[15^", - keyF28: "\x1b[17^", - keyF29: "\x1b[18^", - keyF30: "\x1b[19^", - keyF31: "\x1b[20^", - keyF32: "\x1b[21^", - keyF33: "\x1b[23^", - keyF34: "\x1b[24^", - keyF35: "\x1b[25^", - keyF36: "\x1b[26^", - keyF37: "\x1b[28^", - keyF38: "\x1b[29^", - keyF39: "\x1b[31^", - keyF40: "\x1b[32^", - keyF41: "\x1b[33^", - keyF42: "\x1b[34^", - keyF43: "\x1b[23@", - keyF44: "\x1b[24@", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1b[7~", - keyEnd: "\x1b[8~", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1b[A", - keyDown: "\x1b[B", - keyLeft: "\x1b[D", - keyRight: "\x1b[C", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b(B\x1b)0", - keyShfRight: "\x1b[c", - keyShfLeft: "\x1b[d", - keyShfHome: "\x1b[7$", - keyShfEnd: "\x1b[8$", - keyShfInsert: "\x1b[2$", - keyShfDelete: "\x1b[3$", - automargin: true, - keyShfUp: "\x1b[a", - keyShfDown: "\x1b[b", - keyCtrlUp: "\x1b[Oa", - keyCtrlDown: "\x1b[Ob", - keyCtrlRight: "\x1b[Oc", - keyCtrlLeft: "\x1b[Od", - keyCtrlHome: "\x1b[7^", - keyCtrlEnd: "\x1b[8^", }; // rxvt-88color @@ -236,84 +93,12 @@ static immutable Termcap term2 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", insertChar: "\x1b[@", - keyBackspace: "\x08", - keyF1: "\x1b[11~", - keyF2: "\x1b[12~", - keyF3: "\x1b[13~", - keyF4: "\x1b[14~", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1b[25~", - keyF14: "\x1b[26~", - keyF15: "\x1b[28~", - keyF16: "\x1b[29~", - keyF17: "\x1b[31~", - keyF18: "\x1b[32~", - keyF19: "\x1b[33~", - keyF20: "\x1b[34~", - keyF21: "\x1b[23$", - keyF22: "\x1b[24$", - keyF23: "\x1b[11^", - keyF24: "\x1b[12^", - keyF25: "\x1b[13^", - keyF26: "\x1b[14^", - keyF27: "\x1b[15^", - keyF28: "\x1b[17^", - keyF29: "\x1b[18^", - keyF30: "\x1b[19^", - keyF31: "\x1b[20^", - keyF32: "\x1b[21^", - keyF33: "\x1b[23^", - keyF34: "\x1b[24^", - keyF35: "\x1b[25^", - keyF36: "\x1b[26^", - keyF37: "\x1b[28^", - keyF38: "\x1b[29^", - keyF39: "\x1b[31^", - keyF40: "\x1b[32^", - keyF41: "\x1b[33^", - keyF42: "\x1b[34^", - keyF43: "\x1b[23@", - keyF44: "\x1b[24@", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1b[7~", - keyEnd: "\x1b[8~", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1b[A", - keyDown: "\x1b[B", - keyLeft: "\x1b[D", - keyRight: "\x1b[C", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b(B\x1b)0", - keyShfRight: "\x1b[c", - keyShfLeft: "\x1b[d", - keyShfHome: "\x1b[7$", - keyShfEnd: "\x1b[8$", - keyShfInsert: "\x1b[2$", - keyShfDelete: "\x1b[3$", - automargin: true, - keyShfUp: "\x1b[a", - keyShfDown: "\x1b[b", - keyCtrlUp: "\x1b[Oa", - keyCtrlDown: "\x1b[Ob", - keyCtrlRight: "\x1b[Oc", - keyCtrlLeft: "\x1b[Od", - keyCtrlHome: "\x1b[7^", - keyCtrlEnd: "\x1b[8^", }; // rxvt-256color @@ -340,84 +125,12 @@ static immutable Termcap term3 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", insertChar: "\x1b[@", - keyBackspace: "\x08", - keyF1: "\x1b[11~", - keyF2: "\x1b[12~", - keyF3: "\x1b[13~", - keyF4: "\x1b[14~", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1b[25~", - keyF14: "\x1b[26~", - keyF15: "\x1b[28~", - keyF16: "\x1b[29~", - keyF17: "\x1b[31~", - keyF18: "\x1b[32~", - keyF19: "\x1b[33~", - keyF20: "\x1b[34~", - keyF21: "\x1b[23$", - keyF22: "\x1b[24$", - keyF23: "\x1b[11^", - keyF24: "\x1b[12^", - keyF25: "\x1b[13^", - keyF26: "\x1b[14^", - keyF27: "\x1b[15^", - keyF28: "\x1b[17^", - keyF29: "\x1b[18^", - keyF30: "\x1b[19^", - keyF31: "\x1b[20^", - keyF32: "\x1b[21^", - keyF33: "\x1b[23^", - keyF34: "\x1b[24^", - keyF35: "\x1b[25^", - keyF36: "\x1b[26^", - keyF37: "\x1b[28^", - keyF38: "\x1b[29^", - keyF39: "\x1b[31^", - keyF40: "\x1b[32^", - keyF41: "\x1b[33^", - keyF42: "\x1b[34^", - keyF43: "\x1b[23@", - keyF44: "\x1b[24@", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1b[7~", - keyEnd: "\x1b[8~", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1b[A", - keyDown: "\x1b[B", - keyLeft: "\x1b[D", - keyRight: "\x1b[C", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b(B\x1b)0", - keyShfRight: "\x1b[c", - keyShfLeft: "\x1b[d", - keyShfHome: "\x1b[7$", - keyShfEnd: "\x1b[8$", - keyShfInsert: "\x1b[2$", - keyShfDelete: "\x1b[3$", - automargin: true, - keyShfUp: "\x1b[a", - keyShfDown: "\x1b[b", - keyCtrlUp: "\x1b[Oa", - keyCtrlDown: "\x1b[Ob", - keyCtrlRight: "\x1b[Oc", - keyCtrlLeft: "\x1b[Od", - keyCtrlHome: "\x1b[7^", - keyCtrlEnd: "\x1b[8^", }; static this() diff --git a/source/dcell/terminfo/screen.d b/source/dcell/terminfo/screen.d index 80cae3f..78f273b 100644 --- a/source/dcell/terminfo/screen.d +++ b/source/dcell/terminfo/screen.d @@ -28,31 +28,6 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1bM", - padChar: "\x00", - keyBackspace: "\x08", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1b[1~", - keyEnd: "\x1b[4~", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "++,,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", @@ -85,31 +60,6 @@ static immutable Termcap term1 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1bM", - padChar: "\x00", - keyBackspace: "\x08", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1b[1~", - keyEnd: "\x1b[4~", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "++,,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", @@ -142,31 +92,6 @@ static immutable Termcap term2 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1bM", - padChar: "\x00", - keyBackspace: "\x08", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1b[1~", - keyEnd: "\x1b[4~", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "++,,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", diff --git a/source/dcell/terminfo/vt100.d b/source/dcell/terminfo/vt100.d index 30b09a2..0300790 100644 --- a/source/dcell/terminfo/vt100.d +++ b/source/dcell/terminfo/vt100.d @@ -21,22 +21,6 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", - keyBackspace: "\x08", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1bOt", - keyF6: "\x1bOu", - keyF7: "\x1bOv", - keyF8: "\x1bOl", - keyF9: "\x1bOw", - keyF10: "\x1bOx", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", diff --git a/source/dcell/terminfo/vt102.d b/source/dcell/terminfo/vt102.d index b13c0cb..e36e81b 100644 --- a/source/dcell/terminfo/vt102.d +++ b/source/dcell/terminfo/vt102.d @@ -20,22 +20,6 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", - keyBackspace: "\x08", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1bOt", - keyF6: "\x1bOu", - keyF7: "\x1bOv", - keyF8: "\x1bOl", - keyF9: "\x1bOw", - keyF10: "\x1bOx", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", diff --git a/source/dcell/terminfo/vt220.d b/source/dcell/terminfo/vt220.d index 45d5d05..bf7d366 100644 --- a/source/dcell/terminfo/vt220.d +++ b/source/dcell/terminfo/vt220.d @@ -19,33 +19,6 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", - keyBackspace: "\x08", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1b[25~", - keyF14: "\x1b[26~", - keyF17: "\x1b[31~", - keyF18: "\x1b[32~", - keyF19: "\x1b[33~", - keyF20: "\x1b[34~", - keyInsert: "\x1b[2~", - keyHelp: "\x1b[28~", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1b[A", - keyDown: "\x1b[B", - keyLeft: "\x1b[D", - keyRight: "\x1b[C", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", diff --git a/source/dcell/terminfo/vt320.d b/source/dcell/terminfo/vt320.d index 2ebf50d..a5d9d79 100644 --- a/source/dcell/terminfo/vt320.d +++ b/source/dcell/terminfo/vt320.d @@ -23,36 +23,6 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", - keyBackspace: "", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1b[25~", - keyF14: "\x1b[26~", - keyF15: "\x1b[28~", - keyF16: "\x1b[29~", - keyF17: "\x1b[31~", - keyF18: "\x1b[32~", - keyF19: "\x1b[33~", - keyF20: "\x1b[34~", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1b[1~", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", diff --git a/source/dcell/terminfo/vt420.d b/source/dcell/terminfo/vt420.d index 0560eff..2073b5d 100644 --- a/source/dcell/terminfo/vt420.d +++ b/source/dcell/terminfo/vt420.d @@ -20,26 +20,6 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", - keyBackspace: "\x08", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[17~", - keyF6: "\x1b[18~", - keyF7: "\x1b[19~", - keyF8: "\x1b[20~", - keyF9: "\x1b[21~", - keyF10: "\x1b[29~", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1b[A", - keyDown: "\x1b[B", - keyLeft: "\x1b[D", - keyRight: "\x1b[C", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", diff --git a/source/dcell/terminfo/xfce.d b/source/dcell/terminfo/xfce.d index 78b5b76..30a26bb 100644 --- a/source/dcell/terminfo/xfce.d +++ b/source/dcell/terminfo/xfce.d @@ -27,93 +27,11 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - padChar: "\x00", - keyBackspace: "", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1bO1;2P", - keyF14: "\x1bO1;2Q", - keyF15: "\x1bO1;2R", - keyF16: "\x1bO1;2S", - keyF17: "\x1b[15;2~", - keyF18: "\x1b[17;2~", - keyF19: "\x1b[18;2~", - keyF20: "\x1b[19;2~", - keyF21: "\x1b[20;2~", - keyF22: "\x1b[21;2~", - keyF23: "\x1b[23;2~", - keyF24: "\x1b[24;2~", - keyF25: "\x1bO1;5P", - keyF26: "\x1bO1;5Q", - keyF27: "\x1bO1;5R", - keyF28: "\x1bO1;5S", - keyF29: "\x1b[15;5~", - keyF30: "\x1b[17;5~", - keyF31: "\x1b[18;5~", - keyF32: "\x1b[19;5~", - keyF33: "\x1b[20;5~", - keyF34: "\x1b[21;5~", - keyF35: "\x1b[23;5~", - keyF36: "\x1b[24;5~", - keyF37: "\x1bO1;6P", - keyF38: "\x1bO1;6Q", - keyF39: "\x1bO1;6R", - keyF40: "\x1bO1;6S", - keyF41: "\x1b[15;6~", - keyF42: "\x1b[17;6~", - keyF43: "\x1b[18;6~", - keyF44: "\x1b[19;6~", - keyF45: "\x1b[20;6~", - keyF46: "\x1b[21;6~", - keyF47: "\x1b[23;6~", - keyF48: "\x1b[24;6~", - keyF49: "\x1bO1;3P", - keyF50: "\x1bO1;3Q", - keyF51: "\x1bO1;3R", - keyF52: "\x1bO1;3S", - keyF53: "\x1b[15;3~", - keyF54: "\x1b[17;3~", - keyF55: "\x1b[18;3~", - keyF56: "\x1b[19;3~", - keyF57: "\x1b[20;3~", - keyF58: "\x1b[21;3~", - keyF59: "\x1b[23;3~", - keyF60: "\x1b[24;3~", - keyF61: "\x1bO1;4P", - keyF62: "\x1bO1;4Q", - keyF63: "\x1bO1;4R", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1bOH", - keyEnd: "\x1bOF", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b)0", - keyShfRight: "\x1b[1;2C", - keyShfLeft: "\x1b[1;2D", - keyShfHome: "\x1b[1;2H", - keyShfEnd: "\x1b[1;2F", - keyShfInsert: "\x1b[2;2~", - keyShfDelete: "\x1b[3;2~", automargin: true, }; diff --git a/source/dcell/terminfo/xterm.d b/source/dcell/terminfo/xterm.d index a18f453..8a4a0bc 100644 --- a/source/dcell/terminfo/xterm.d +++ b/source/dcell/terminfo/xterm.d @@ -28,91 +28,10 @@ static immutable Termcap term0 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - keyBackspace: "\x08", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1b[1;2P", - keyF14: "\x1b[1;2Q", - keyF15: "\x1b[1;2R", - keyF16: "\x1b[1;2S", - keyF17: "\x1b[15;2~", - keyF18: "\x1b[17;2~", - keyF19: "\x1b[18;2~", - keyF20: "\x1b[19;2~", - keyF21: "\x1b[20;2~", - keyF22: "\x1b[21;2~", - keyF23: "\x1b[23;2~", - keyF24: "\x1b[24;2~", - keyF25: "\x1b[1;5P", - keyF26: "\x1b[1;5Q", - keyF27: "\x1b[1;5R", - keyF28: "\x1b[1;5S", - keyF29: "\x1b[15;5~", - keyF30: "\x1b[17;5~", - keyF31: "\x1b[18;5~", - keyF32: "\x1b[19;5~", - keyF33: "\x1b[20;5~", - keyF34: "\x1b[21;5~", - keyF35: "\x1b[23;5~", - keyF36: "\x1b[24;5~", - keyF37: "\x1b[1;6P", - keyF38: "\x1b[1;6Q", - keyF39: "\x1b[1;6R", - keyF40: "\x1b[1;6S", - keyF41: "\x1b[15;6~", - keyF42: "\x1b[17;6~", - keyF43: "\x1b[18;6~", - keyF44: "\x1b[19;6~", - keyF45: "\x1b[20;6~", - keyF46: "\x1b[21;6~", - keyF47: "\x1b[23;6~", - keyF48: "\x1b[24;6~", - keyF49: "\x1b[1;3P", - keyF50: "\x1b[1;3Q", - keyF51: "\x1b[1;3R", - keyF52: "\x1b[1;3S", - keyF53: "\x1b[15;3~", - keyF54: "\x1b[17;3~", - keyF55: "\x1b[18;3~", - keyF56: "\x1b[19;3~", - keyF57: "\x1b[20;3~", - keyF58: "\x1b[21;3~", - keyF59: "\x1b[23;3~", - keyF60: "\x1b[24;3~", - keyF61: "\x1b[1;4P", - keyF62: "\x1b[1;4Q", - keyF63: "\x1b[1;4R", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1bOH", - keyEnd: "\x1bOF", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", - keyShfRight: "\x1b[1;2C", - keyShfLeft: "\x1b[1;2D", - keyShfHome: "\x1b[1;2H", - keyShfEnd: "\x1b[1;2F", - keyShfInsert: "\x1b[2;2~", - keyShfDelete: "\x1b[3;2~", automargin: true, }; @@ -140,91 +59,10 @@ static immutable Termcap term1 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - keyBackspace: "\x08", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1b[1;2P", - keyF14: "\x1b[1;2Q", - keyF15: "\x1b[1;2R", - keyF16: "\x1b[1;2S", - keyF17: "\x1b[15;2~", - keyF18: "\x1b[17;2~", - keyF19: "\x1b[18;2~", - keyF20: "\x1b[19;2~", - keyF21: "\x1b[20;2~", - keyF22: "\x1b[21;2~", - keyF23: "\x1b[23;2~", - keyF24: "\x1b[24;2~", - keyF25: "\x1b[1;5P", - keyF26: "\x1b[1;5Q", - keyF27: "\x1b[1;5R", - keyF28: "\x1b[1;5S", - keyF29: "\x1b[15;5~", - keyF30: "\x1b[17;5~", - keyF31: "\x1b[18;5~", - keyF32: "\x1b[19;5~", - keyF33: "\x1b[20;5~", - keyF34: "\x1b[21;5~", - keyF35: "\x1b[23;5~", - keyF36: "\x1b[24;5~", - keyF37: "\x1b[1;6P", - keyF38: "\x1b[1;6Q", - keyF39: "\x1b[1;6R", - keyF40: "\x1b[1;6S", - keyF41: "\x1b[15;6~", - keyF42: "\x1b[17;6~", - keyF43: "\x1b[18;6~", - keyF44: "\x1b[19;6~", - keyF45: "\x1b[20;6~", - keyF46: "\x1b[21;6~", - keyF47: "\x1b[23;6~", - keyF48: "\x1b[24;6~", - keyF49: "\x1b[1;3P", - keyF50: "\x1b[1;3Q", - keyF51: "\x1b[1;3R", - keyF52: "\x1b[1;3S", - keyF53: "\x1b[15;3~", - keyF54: "\x1b[17;3~", - keyF55: "\x1b[18;3~", - keyF56: "\x1b[19;3~", - keyF57: "\x1b[20;3~", - keyF58: "\x1b[21;3~", - keyF59: "\x1b[23;3~", - keyF60: "\x1b[24;3~", - keyF61: "\x1b[1;4P", - keyF62: "\x1b[1;4Q", - keyF63: "\x1b[1;4R", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1bOH", - keyEnd: "\x1bOF", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", - keyShfRight: "\x1b[1;2C", - keyShfLeft: "\x1b[1;2D", - keyShfHome: "\x1b[1;2H", - keyShfEnd: "\x1b[1;2F", - keyShfInsert: "\x1b[2;2~", - keyShfDelete: "\x1b[3;2~", automargin: true, }; @@ -252,91 +90,10 @@ static immutable Termcap term2 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - keyBackspace: "\x08", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1b[1;2P", - keyF14: "\x1b[1;2Q", - keyF15: "\x1b[1;2R", - keyF16: "\x1b[1;2S", - keyF17: "\x1b[15;2~", - keyF18: "\x1b[17;2~", - keyF19: "\x1b[18;2~", - keyF20: "\x1b[19;2~", - keyF21: "\x1b[20;2~", - keyF22: "\x1b[21;2~", - keyF23: "\x1b[23;2~", - keyF24: "\x1b[24;2~", - keyF25: "\x1b[1;5P", - keyF26: "\x1b[1;5Q", - keyF27: "\x1b[1;5R", - keyF28: "\x1b[1;5S", - keyF29: "\x1b[15;5~", - keyF30: "\x1b[17;5~", - keyF31: "\x1b[18;5~", - keyF32: "\x1b[19;5~", - keyF33: "\x1b[20;5~", - keyF34: "\x1b[21;5~", - keyF35: "\x1b[23;5~", - keyF36: "\x1b[24;5~", - keyF37: "\x1b[1;6P", - keyF38: "\x1b[1;6Q", - keyF39: "\x1b[1;6R", - keyF40: "\x1b[1;6S", - keyF41: "\x1b[15;6~", - keyF42: "\x1b[17;6~", - keyF43: "\x1b[18;6~", - keyF44: "\x1b[19;6~", - keyF45: "\x1b[20;6~", - keyF46: "\x1b[21;6~", - keyF47: "\x1b[23;6~", - keyF48: "\x1b[24;6~", - keyF49: "\x1b[1;3P", - keyF50: "\x1b[1;3Q", - keyF51: "\x1b[1;3R", - keyF52: "\x1b[1;3S", - keyF53: "\x1b[15;3~", - keyF54: "\x1b[17;3~", - keyF55: "\x1b[18;3~", - keyF56: "\x1b[19;3~", - keyF57: "\x1b[20;3~", - keyF58: "\x1b[21;3~", - keyF59: "\x1b[23;3~", - keyF60: "\x1b[24;3~", - keyF61: "\x1b[1;4P", - keyF62: "\x1b[1;4Q", - keyF63: "\x1b[1;4R", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1bOH", - keyEnd: "\x1bOF", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", - keyShfRight: "\x1b[1;2C", - keyShfLeft: "\x1b[1;2D", - keyShfHome: "\x1b[1;2H", - keyShfEnd: "\x1b[1;2F", - keyShfInsert: "\x1b[2;2~", - keyShfDelete: "\x1b[3;2~", automargin: true, }; @@ -364,91 +121,10 @@ static immutable Termcap term3 = { setCursor: "\x1b[%i%p1%d;%p2%dH", cursorBack1: "\x08", cursorUp1: "\x1b[A", - keyBackspace: "\x08", - keyF1: "\x1bOP", - keyF2: "\x1bOQ", - keyF3: "\x1bOR", - keyF4: "\x1bOS", - keyF5: "\x1b[15~", - keyF6: "\x1b[17~", - keyF7: "\x1b[18~", - keyF8: "\x1b[19~", - keyF9: "\x1b[20~", - keyF10: "\x1b[21~", - keyF11: "\x1b[23~", - keyF12: "\x1b[24~", - keyF13: "\x1b[1;2P", - keyF14: "\x1b[1;2Q", - keyF15: "\x1b[1;2R", - keyF16: "\x1b[1;2S", - keyF17: "\x1b[15;2~", - keyF18: "\x1b[17;2~", - keyF19: "\x1b[18;2~", - keyF20: "\x1b[19;2~", - keyF21: "\x1b[20;2~", - keyF22: "\x1b[21;2~", - keyF23: "\x1b[23;2~", - keyF24: "\x1b[24;2~", - keyF25: "\x1b[1;5P", - keyF26: "\x1b[1;5Q", - keyF27: "\x1b[1;5R", - keyF28: "\x1b[1;5S", - keyF29: "\x1b[15;5~", - keyF30: "\x1b[17;5~", - keyF31: "\x1b[18;5~", - keyF32: "\x1b[19;5~", - keyF33: "\x1b[20;5~", - keyF34: "\x1b[21;5~", - keyF35: "\x1b[23;5~", - keyF36: "\x1b[24;5~", - keyF37: "\x1b[1;6P", - keyF38: "\x1b[1;6Q", - keyF39: "\x1b[1;6R", - keyF40: "\x1b[1;6S", - keyF41: "\x1b[15;6~", - keyF42: "\x1b[17;6~", - keyF43: "\x1b[18;6~", - keyF44: "\x1b[19;6~", - keyF45: "\x1b[20;6~", - keyF46: "\x1b[21;6~", - keyF47: "\x1b[23;6~", - keyF48: "\x1b[24;6~", - keyF49: "\x1b[1;3P", - keyF50: "\x1b[1;3Q", - keyF51: "\x1b[1;3R", - keyF52: "\x1b[1;3S", - keyF53: "\x1b[15;3~", - keyF54: "\x1b[17;3~", - keyF55: "\x1b[18;3~", - keyF56: "\x1b[19;3~", - keyF57: "\x1b[20;3~", - keyF58: "\x1b[21;3~", - keyF59: "\x1b[23;3~", - keyF60: "\x1b[24;3~", - keyF61: "\x1b[1;4P", - keyF62: "\x1b[1;4Q", - keyF63: "\x1b[1;4R", - keyInsert: "\x1b[2~", - keyDelete: "\x1b[3~", - keyHome: "\x1bOH", - keyEnd: "\x1bOF", - keyPgUp: "\x1b[5~", - keyPgDn: "\x1b[6~", - keyUp: "\x1bOA", - keyDown: "\x1bOB", - keyLeft: "\x1bOD", - keyRight: "\x1bOC", - keyBacktab: "\x1b[Z", mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", - keyShfRight: "\x1b[1;2C", - keyShfLeft: "\x1b[1;2D", - keyShfHome: "\x1b[1;2H", - keyShfEnd: "\x1b[1;2F", - keyShfInsert: "\x1b[2;2~", - keyShfDelete: "\x1b[3;2~", automargin: true, }; diff --git a/source/dcell/ttyscreen.d b/source/dcell/ttyscreen.d index 96831ac..99afbb4 100644 --- a/source/dcell/ttyscreen.d +++ b/source/dcell/ttyscreen.d @@ -42,7 +42,6 @@ class TtyScreen : Screen ti = tt; ti.start(); cells = new CellBuffer(ti.windowSize()); - keys = ParseKeys(tc); ob = new OutBuffer(); stopping = new Turnstile(); defStyle.bg = Color.reset; @@ -64,8 +63,8 @@ class TtyScreen : Screen puts(caps.clear); resize(); draw(); - spawn(&inputLoop, cast(shared TtyImpl) ti, keys, tid, - cast(shared EventQueue) eq, cast(shared Turnstile) stopping); + spawn(&inputLoop, cast(shared TtyImpl) ti, tid, + cast(shared EventQueue) eq, cast(shared Turnstile) stopping); started = true; } @@ -92,6 +91,7 @@ class TtyScreen : Screen puts(caps.clear); puts(caps.disablePaste); enableMouse(MouseEnable.disable); + enableFocus(false); flush(); stopping.set(true); ti.blocking(false); @@ -212,11 +212,6 @@ class TtyScreen : Screen } } - bool hasKey(Key k) const pure - { - return (keys.hasKey(k)); - } - void enableMouse(MouseEnable en) { // we rely on the fact that all known implementations adhere @@ -230,6 +225,12 @@ class TtyScreen : Screen } } + void enableFocus(bool enabled) + { + puts("\x1b[?1004%s", enabled ? "h" : "l"); + flush(); + } + Event receiveEvent(Duration dur) { if (eq is null) @@ -266,7 +267,6 @@ private: Cursor cursorShape; MouseEnable mouseEn; // saved state for suspend/resume bool pasteEn; // saved state for suspend/resume - ParseKeys keys; TtyImpl ti; OutBuffer ob; Turnstile stopping; @@ -463,7 +463,7 @@ private: // that character in place, to avoid the scroll of doom. auto size = cells.size(); if ((pos.y == size.y - 1) && (pos.x == size.x - 1) && caps.automargin - && (caps.insertChar != "")) + && (caps.insertChar != "")) { auto pp = pos; pp.x--; @@ -588,12 +588,11 @@ private: flush(); } - static void inputLoop(shared TtyImpl tin, ParseKeys keys, Tid tid, - shared EventQueue eq, shared Turnstile stopping) + static void inputLoop(shared TtyImpl tin, Tid tid, + shared EventQueue eq, shared Turnstile stopping) { TtyImpl f = cast(TtyImpl) tin; - Parser p = new Parser(keys); - bool poll = false; + Parser p = new Parser(); f.blocking(true); @@ -607,7 +606,7 @@ private: catch (Exception e) { } - p.parse(s); + bool finished = p.parse(s); auto evs = p.events(); if (f.resized()) { @@ -622,21 +621,17 @@ private: send(ownerTid(), ev); else { - import std.stdio; - eq.send(ev); } } - if (!p.empty()) + if (!p.empty() || !finished) { f.blocking(false); - poll = true; } else { // No data, so we can sleep until some arrives. f.blocking(true); - poll = false; } if (stopping.get())