diff --git a/demos/colors/dub.json b/demos/colors/dub.json index 834ac52..c612f4c 100644 --- a/demos/colors/dub.json +++ b/demos/colors/dub.json @@ -1,12 +1,12 @@ { - "copyright": "Copyright 2022 Garrett D'Amore", - "description": "Color Demo in Dcell", - "name": "colors", - "targetType": "executable", - "targetName": "colors", - "targetPath": "bin", - "mainSourceFile": "source/colors.d", - "dependencies": { - "dcell" : { "path": "../.." } - } + "copyright": "Copyright 2025 Garrett D'Amore", + "description": "Color Demo in Dcell", + "name": "colors", + "targetType": "executable", + "targetName": "colors", + "targetPath": "bin", + "mainSourceFile": "source/colors.d", + "dependencies": { + "dcell": { "path": "../.." } + } } diff --git a/dub.json b/dub.json index abcf24e..9d61346 100644 --- a/dub.json +++ b/dub.json @@ -1,19 +1,12 @@ { - "authors": [ - "Garrett D'Amore" - ], - "copyright": "Copyright 2022 Garrett D'Amore", - "dependencies": { - "east_asian_width": "~>1.0.0" - }, - "description": "Terminal Cells for D.", - "license": "BSL-1.0", - "name": "dcell", - "subPackages": [ - "./mkinfo/", - "./demos/colors/", - "./demos/hello/", - "./demos/mouse/" - ], - "targetType": "library" -} \ No newline at end of file + "authors": ["Garrett D'Amore"], + "copyright": "Copyright 2025 Garrett D'Amore", + "dependencies": { + "east_asian_width": "~>1.0.0" + }, + "description": "Terminal Cells for D.", + "license": "BSL-1.0", + "name": "dcell", + "subPackages": ["./demos/colors/", "./demos/hello/", "./demos/mouse/"], + "targetType": "library" +} diff --git a/mkinfo/dub.json b/mkinfo/dub.json deleted file mode 100644 index f3103ee..0000000 --- a/mkinfo/dub.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "copyright": "Copyright 2022 Garrett D'Amore", - "description": "Terminal database builder", - "name": "mkinfo", - "targetType": "executable", - "targetName": "mkinfo", - "targetPath": "bin", - "mainSourceFile": "source/mkinfo.d", - "dependencies": { - "dcell" : { "path": ".." } - } -} diff --git a/mkinfo/source/mkinfo.d b/mkinfo/source/mkinfo.d deleted file mode 100644 index 91ca5d7..0000000 --- a/mkinfo/source/mkinfo.d +++ /dev/null @@ -1,542 +0,0 @@ -// 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) - -/** - * This module implements a command to extra terminfo data from the system, - * and build a database of Termcap data for use by this library. - */ -module mkinfo; - -import std.algorithm : findSplit; -import std.stdio; -import std.process : execute; -import std.string; -import std.conv : to; -import std.outbuffer; -import std.traits; -import std.conv; - -import dcell.termcap; -import dcell.database; - -/** - * Caps represents a "parsed" terminfo entry, before it is converted into - * a Termcap structure. - */ -private struct Caps -{ - string name; - string desc; - string[] aliases; - bool[string] bools; - int[string] ints; - string[string] strs; - - int getInt(string s) - { - return (s in ints ? ints[s] : 0); - } - - bool getBool(string s) - { - return (s in bools) !is null; - } - - string getStr(string s) - { - return (s in strs ? strs[s] : ""); - } -} - -/** - * Unescape string data emitted by infocmp(1) into binary representations - * suitable for use by this library. This understands C style escape - * sequences such as \n, but also octal sequences. A lone \0 is understood - * to represent a special form of NULL. See terminfo(5) for more information. - */ -private string unescape(string s) -{ - enum escape - { - none, - ctrl, - esc - } - - string result; - - escape state = escape.none; - - while (s.length > 0) - { - auto c = s[0]; - s = s[1 .. $]; - final switch (state) - { - case escape.none: - switch (c) - { - case '\\': - state = escape.esc; - break; - case '^': - state = escape.ctrl; - break; - default: - result ~= c; - break; - } - break; - case escape.ctrl: - result ~= (c ^ (1 << 6)); // flip bit six - state = escape.none; - break; - case escape.esc: - switch (c) - { - case 'E', 'e': - result ~= '\x1b'; - break; - case '0', '1', '2', '3', '4', '5', '6', '7': - if (s.length >= 2 && s[0] >= '0' && s[0] <= '7' && s[1] >= '0' && s[1] <= '7') - { - result ~= ((c - '0') << 6) + ((s[0] - '0') << 3) + (s[1] - '0'); - s = s[2 .. $]; - } - else if (c == '0') - { - result ~= '\200'; - } - break; - case 'n': - result ~= '\n'; - break; - case 'r': - result ~= '\r'; - break; - case 't': - result ~= '\t'; - break; - case 'b': - result ~= '\b'; - break; - case 'f': - result ~= '\f'; - break; - case 's': - result ~= ' '; - break; - case 'l': - result ~= '\n'; - break; - default: - result ~= c; - break; - } - state = escape.none; - break; - } - } - return result; -} - -unittest -{ - assert(unescape("123") == "123"); - assert(unescape(`1\n2`) == "1\n2"); - assert(unescape("a^Gb") == "a\007b"); - assert(unescape("1\\_\\007") == "1_\007"); - assert(unescape(`\,\:\0`) == ",:\200"); - assert(unescape(`\e\E`) == "\x1b\x1b"); - assert(unescape(`\r\s\f\l\t\b`) == "\r \f\n\t\b"); -} - -/** - * Load capabilities (parsed from infocmp -1 -x). - * - * Params: info = output from infocmp -1 -x - * Returns: - * parsed capabilities on success, null otherwise - */ -Caps* parseCaps(string info) -{ - auto cap = new Caps; - auto first = true; - foreach (line; splitLines(info)) - { - // skip empty lines and comments - if (line.length == 0 || line[0] == '#') - { - continue; - } - if (first) - { - // first line is name|alias|alias...|description - auto parts = split(line, '|'); - cap.name = parts[0]; - if (parts.length > 1) - { - cap.desc = parts[$ - 1]; - cap.aliases = parts[1 .. $ - 1]; - } - first = false; - continue; - } - if (line[0] != '\t' || line[$ - 1] != ',') - { - // this is malformed, but ignore it - continue; - } - line = line[1 .. $ - 1]; - - // we can try to split the string across an equals sign. - // this is guaranteed to be safe even if there are escaped - // equals signs, because those can only appear *after* a bare - // one (for a string capability) - auto nvp = findSplit(line, "="); - if (nvp[1] == "=") - { - // this is a string capability - cap.strs[nvp[0]] = unescape(nvp[2]); - continue; - - } - nvp = findSplit(line, "#"); - if (nvp[1] == "#") - { - // numeric capability - cap.ints[nvp[0]] = to!int(nvp[2]); - continue; - } - // boolean capability - cap.bools[nvp[0]] = true; - } - if (cap.name == "") - { - return null; - } - return cap; -} - -unittest -{ - assert(parseCaps("\n") is null); - assert(parseCaps("#junk") is null); - auto c = parseCaps("myterm|something\n\tam,\n\tcup=123\\t345,\n\tcolor#4,\n\n"); - assert(c !is null); - assert(c.bools["am"] == true); - assert(c.ints["color"] == 4); - assert(c.strs["cup"] == "123\t345"); -} - -Caps* loadCaps(string name) -{ - auto info = execute(["infocmp", "-x", "-1", name]); - if (info.status != 0) - { - return null; - } - return (parseCaps(info.output)); -} - -private string escape(string s) -{ - string result = ""; - foreach (char c; s) - { - switch (c) - { - case '\t': - result ~= `\t`; - break; - case '\n': - result ~= `\n`; - break; - case '\r': - result ~= `\r`; - break; - case '\'', '"', '\\': - result ~= "\\"; - result ~= c; - break; - default: - if (c < ' ') - { - result ~= format("\\x%02x", c); - } - else - { - result ~= c; - } - break; - } - } - return result; -} - -unittest -{ - assert(escape(`a'b`) == `a\'b`); - assert(escape(`a\b`) == `a\\b`); - assert(escape(`a"b`) == `a\"b`); - assert(escape("a\nb") == `a\nb`); - assert(escape("a\tb") == `a\tb`); - assert(escape("a\rb") == `a\rb`); - assert(escape("a\x1bb") == `a\x1bb`); -} - -Termcap* getTermcap(string name) -{ - auto caps = loadCaps(name); - if (caps == null) - { - return null; - } - return convertCaps(caps); -} - -private Termcap* convertCaps(Caps* caps) -{ - auto tc = new Termcap; - tc.name = caps.name; - tc.aliases = cast(immutable(string)[]) caps.aliases; - tc.colors = caps.getInt("colors"); - tc.columns = caps.getInt("columns"); - tc.lines = caps.getInt("lines"); - tc.bell = caps.getStr("bel"); - tc.clear = caps.getStr("clear"); - tc.enterCA = caps.getStr("smcup"); - tc.exitCA = caps.getStr("rmcup"); - - tc.showCursor = caps.getStr("cnorm"); - tc.hideCursor = caps.getStr("civis"); - tc.attrOff = caps.getStr("sgr0"); - tc.underline = caps.getStr("smul"); - tc.bold = caps.getStr("bold"); - tc.blink = caps.getStr("blink"); - tc.dim = caps.getStr("dim"); - tc.italic = caps.getStr("sitm"); - tc.reverse = caps.getStr("rev"); - tc.enterKeypad = caps.getStr("smkx"); - tc.exitKeypad = caps.getStr("rmkx"); - tc.setFg = caps.getStr("setaf"); - tc.setBg = caps.getStr("setab"); - tc.resetColors = caps.getStr("op"); - tc.setCursor = caps.getStr("cup"); - tc.cursorBack1 = caps.getStr("cub1"); - tc.cursorUp1 = caps.getStr("cuu1"); - tc.insertChar = caps.getStr("ich1"); - tc.automargin = caps.getBool("am"); - tc.altChars = caps.getStr("acsc"); - tc.enterACS = caps.getStr("smacs"); - tc.exitACS = caps.getStr("rmacs"); - tc.enableACS = caps.getStr("enacs"); - tc.strikethrough = caps.getStr("smxx"); - tc.mouse = caps.getStr("kmous"); - - // 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. - // For this case we'll just assume it's XTerm compatible. Someday this - // may be incorrect, but right now it is correct, and nobody uses it - // anyway. - if (caps.getBool("Tc")) - { - // This presumes XTerm 24-bit true color. - tc.colors = 1 << 24; - } - else if (caps.getBool("RGB")) - { - // 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.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"; - } - - // We only support colors in ANSI 8 or 256 color mode. - if (tc.colors < 8 || tc.setFg == "") - { - tc.colors = 0; - } - if (tc.setCursor == "") - { - return null; // terminal is not addressable - } - - return tc; -} - -unittest -{ - assert(getTermcap("nosuch") is null); - auto tc = getTermcap("xterm-256color"); - assert(tc !is null); - tc = getTermcap("vt100"); - tc = getTermcap("rxvt"); -} - -// there might be better ways to do this - -OutBuffer mkTermSource(Termcap*[] tcs, string modname) -{ - auto ob = new OutBuffer; - - ob.writefln("// Generated automatically. DO NOT HAND-EDIT."); - ob.writefln(""); - ob.writefln("module %s;", modname); - ob.writefln(""); - ob.writefln("import dcell.database;"); - - void addInt(string n, int i) - { - if (i != 0) - { - ob.writefln(" %s: %d,", n, i); - } - } - - void addStr(string n, string s) - { - if (s != "") - { - ob.writefln(" %s: \"%s\",", n, escape(s)); - } - } - - void addBool(string n, bool b) - { - if (b) - { - ob.writefln(" %s: true,", n); - } - } - - void addArr(string n, string[] a) - { - if (a.length > 0) - { - ob.writef(" %s: [", n); - foreach (i, string s; a) - { - if (i > 0) - { - ob.writef(", "); - } - ob.writef(`"%s"`, escape(s)); - } - ob.writefln("],"); - } - } - - foreach (num, Termcap* tc; tcs) - { - ob.writefln(""); - ob.writefln("// %s", tc.name); - ob.writefln("static immutable Termcap term%d = {", num); - - auto names = FieldNameTuple!Termcap; - foreach (int i, ref x; tc.tupleof) - { - auto n = names[i]; - - static if (is(typeof(x) == int)) - { - addInt(n, x); - } - static if (is(typeof(x) == string)) - { - addStr(n, x); - } - static if (is(typeof(x) == bool)) - { - addBool(n, x); - } - static if (is(typeof(x) == string[])) - { - addArr(n, x); - } - } - - ob.writefln("};"); - } - ob.writefln(""); - ob.writefln("static this()"); - ob.writefln("{"); - foreach (num, _; tcs) - { - ob.writefln(" Database.put(&term%d);", num); - } - ob.writefln("}"); - return ob; -} - -unittest -{ - assert(getTermcap("nosuch") is null); - auto tc = getTermcap("xterm-256color"); - assert(tc !is null); - auto ob = mkTermSource([tc], "dcell.terminfo.xterm256color"); -} - -void main(string[] args) -{ - import core.stdc.stdlib; - import std.getopt; - import std.path; - import std.process; - - string[] terms; - string directory = "."; - - auto help = getopt(args, "directory", &directory); - if (help.helpWanted) - { - defaultGetoptFormatter(stderr.lockingTextWriter(), - "Emit terminal database", help.options); - exit(1); - } - args = args[1 .. $]; - if (args.length != 0) - { - terms = args; - } - else - { - terms ~= environment.get("TERM", "ansi"); - } - foreach (index, string name; terms) - { - Termcap*[] tcs; - auto tc = getTermcap(name); - if (tc is null) - { - throw new Exception("failed to get term for " ~ name); - } - tcs ~= tc; - - // look for common variants - foreach (unused, suffix; [ - "16color", "88color", "256color", "truecolor", "direct" - ]) - { - tc = getTermcap(name ~ "-" ~ suffix); - if (tc !is null) - { - tcs ~= tc; - } - } - - string pkg; - pkg = replace(name, "-", ""); - pkg = replace(pkg, ".", ""); - auto ob = mkTermSource(tcs, "dcell.terminfo." ~ pkg); - import std.file; - - auto autof = chainPath(directory, pkg ~ ".d"); - write(autof, ob.toString()); - } -} diff --git a/mkinfo/terms.txt b/mkinfo/terms.txt deleted file mode 100644 index c14f275..0000000 --- a/mkinfo/terms.txt +++ /dev/null @@ -1,43 +0,0 @@ -aixterm -alacritty -ansi -beterm -cygwin -dtterm -eterm -# eterm-256color -gnome -# gnome-256color -hpterm -konsole -#konsole-256color -kterm -linux -pcansi -rxvt -#rxvt-256color -#rxvt-88color -# rxvt-unicode -# rxvt-unicode-256color -screen -#screen-256color -# st -# st-256color -# termite -# tmux -vt52 -vt100 -vt102 -vt220 -vt320 -vt400 -vt420 -wy50 -wy60 -wy99-ansi -wy99a-ansi -xfce -xterm -#xterm-88color -#xterm-256color -# xterm-kitty diff --git a/source/dcell/database.d b/source/dcell/database.d index 5890d9e..895a6c6 100644 --- a/source/dcell/database.d +++ b/source/dcell/database.d @@ -140,45 +140,6 @@ synchronized class Database tc.resetColors = "\x1b[39;49m"; } - // if we have mouse support, we can try to assume that we - // can safely/reasonably add some other features, if they - // are not provided for explicitly in the database. - if (tc.mouse != "") - { - // changeable cursor shapes - if (tc.cursorReset == "") - { - tc.cursorReset = "\x1b[0 q"; - tc.cursorBlinkingBlock = "\x1b[1 q"; - tc.cursorBlock = "\x1b[2 q"; - tc.cursorBlinkingUnderline = "\x1b[3 q"; - tc.cursorUnderline = "\x1b[4 q"; - tc.cursorBlinkingBar = "\x1b[5 q"; - tc.cursorBar = "\x1b[6 q"; - } - // bracketed paste - if (tc.enablePaste == "") - { - tc.enablePaste = "\x1b[?2004h"; - tc.disablePaste = "\x1b[?2004l"; - tc.pasteStart = "\x1b[200~"; - tc.pasteEnd = "\x1b[201~"; - } - // OSC URL support - if (tc.enterURL == "") - { - tc.enterURL = "\x1b]8;;%p1%s\x1b\\"; - tc.exitURL = "\x1b]8;;\x1b\\"; - } - // OSC window size - if (tc.setWindowSize == "") - { - tc.setWindowSize = "\x1b[8;%p1%p2%d;%dt"; - } - } - - // likewise, if we have mouse support, let's try to add backeted - // paste support. return tc; } } @@ -188,9 +149,7 @@ synchronized class Database static immutable Termcap caps = { name: "mytest", aliases: ["mytest-1", "mytest-2"] }; - static immutable Termcap caps2 = { - name: "ctest", mouse: ":mouse", colors: 1 << 24 - }; + static immutable Termcap caps2 = {name: "ctest", colors: 1 << 24}; Database.put(&caps); Database.put(&caps2); @@ -224,5 +183,4 @@ synchronized class Database assert(tc.setFgBgRGB != ""); assert(tc.setFg != ""); assert(tc.resetColors != ""); - assert(tc.enablePaste != ""); // xterm like } diff --git a/source/dcell/parser.d b/source/dcell/parser.d index 5747d83..f8b3e67 100644 --- a/source/dcell/parser.d +++ b/source/dcell/parser.d @@ -814,11 +814,15 @@ private: return; } - if (p0 == 200) { + if (p0 == 200) + { pasting = true; pasteBuf = null; - } else if (p0 == 201) { - if (pasting) { + } + else if (p0 == 201) + { + if (pasting) + { evs ~= newPasteEvent(pasteBuf); pasting = false; pasteBuf = null; @@ -1194,93 +1198,6 @@ private: return false; } - bool parsePaste() - { - bool matches; - - if (pasteStart == "") - { - return false; - } - - auto now = MonoTime.currTime(); - if (!pasting) - { - if (parseSequence(pasteStart)) - { - pasting = true; - pasteBuf = ""; - pasteTime = now; - return true; - } - return false; - } - assert(pasting); - - // we end the sequence if we see it, but also if we timed out looking for it - if (parseSequence(pasteEnd) || - ((now - pasteTime) > seqTime * 4)) - { - pasting = false; - auto ev = newPasteEvent(pasteBuf); - pasteBuf = ""; - evs ~= ev; - return true; - } - if (parseRune()) - { - pasteTime = now; - } - // we pretend to have eaten the entire thing, even if there is stuff left - return true; - } - - bool parseRune() - { - if (buf.length == 0) - { - return false; - } - dchar dc; - Modifiers mod = Modifiers.none; - if ((buf[0] >= ' ' && buf[0] < 0x7F) || - (pasting && isWhite(buf[0]))) - { - dc = buf[0]; - buf = buf[1 .. $]; - // printable ascii, easy to deal with - if (escaped) - { - escaped = false; - mod = Modifiers.alt; - } - if (pasting) - pasteBuf ~= dc; - else - evs ~= newKeyEvent(Key.rune, dc, mod); - return true; - } - if ((buf[0] < 0x80) || (buf[0] == 0x7F)) // control character, not a rune - return false; - // unicode bits... - size_t index = 0; - auto temp = cast(string) buf; - try - { - dc = temp.decode(index); - } - catch (UTFException e) - { - return false; - } - if (pasting) - pasteBuf ~= dc; - else - evs ~= newKeyEvent(Key.rune, dc, mod); - buf = buf[index .. $]; - return true; - } - unittest { import core.thread; @@ -1291,9 +1208,6 @@ private: name: "test-term", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - mouse: "\x1b[M", }; Database.put(&term); auto tc = Database.get("test-term"); diff --git a/source/dcell/termcap.d b/source/dcell/termcap.d index a76643c..13b72bc 100644 --- a/source/dcell/termcap.d +++ b/source/dcell/termcap.d @@ -28,55 +28,21 @@ struct Termcap int columns; /// `cols`, the number of columns present int lines; /// `lines`, the number lines (rows) present int colors; // `colors`, the number of colors supported - string bell; /// `bell`, the sequence to ring a bell - string clear; /// `clear`, the sequence to clear the screen - string enterCA; /// `smcup`, sequence to enter cursor addressing mode - string exitCA; /// `rmcup`, sequence to exit cursor addressing mode - string showCursor; /// `cnorm`, should display the normal cursor - string hideCursor; /// `civis`, mark the cursor invisible - string attrOff; /// `sgr0`, turn off all text attributes and colors - string underline; /// `smul`, starts underlining - string bold; /// `bold`, starts bold (maybe intense or double-strike) - string blink; /// `blink`, starts blinking text - string reverse; /// `rev`, inverts the foreground and background colors - string dim; /// `dim`, reduces the intensity of text - string italic; /// `sitm`, starts italics mode (not widely supported) string enterKeypad; /// `smkx`, enables keypad mode string exitKeypad; /// `rmkx`, leaves keypad mode string setFg; /// `setaf`, sets foreground text color (indexed) string setBg; /// `setab`, sets background text color (indexed) string resetColors; /// `op`, sets foreground and background to default - 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 insertChar; /// `ich1`, insert a character, used for inserting at bottom right for automargin terminals - 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 - bool automargin; /// `am`, if true cursor wraps and advances to next row after last column // Non-standard additions to terminfo. YMMV. - string strikethrough; // smxx string setFgBg; /// sequence to set both foreground and background together, using indexed colors 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 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 - string pasteEnd; /// sequence sent by terminal to indicated end of a paste buffer - string cursorReset; /// sequence to reset the cursor shape to default - string cursorBlock; /// sequence to change the cursor to a solid block - string cursorUnderline; /// sequence to change the cursor to a steady underscore - string cursorBar; /// sequence to change the cursor to a steady vertical bar - string cursorBlinkingBlock; /// sequence to change the cursor to a blinking block - string cursorBlinkingUnderline; /// sequence to change the cursor to a blinking underscore - string cursorBlinkingBar; /// sequence to change the cursor to a blinking vertical bar - string enterURL; /// sequence to start making text a clickable link - string exitURL; /// sequence to stop making text clickable link - string setWindowSize; /// sequence to resize the window (rarely supported) /** Permits a constant value to be assigned to a mutable value. */ void opAssign(scope const(Termcap)* other) @trusted diff --git a/source/dcell/terminfo/aixterm.d b/source/dcell/terminfo/aixterm.d index 9b7bcd2..5d7c6dc 100644 --- a/source/dcell/terminfo/aixterm.d +++ b/source/dcell/terminfo/aixterm.d @@ -9,20 +9,10 @@ static immutable Termcap term0 = { name: "aixterm", lines: 25, colors: 8, - bell: "\x07", - clear: "\x1b[H\x1b[J", - attrOff: "\x1b[0;10m\x1b(B", - underline: "\x1b[4m", - bold: "\x1b[1m", - reverse: "\x1b[7m", setFg: "\x1b[3%p1%dm", setBg: "\x1b[4%p1%dm", resetColors: "\x1b[32m\x1b[40m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", altChars: "jjkkllmmnnqqttuuvvwwxx", - automargin: true, }; // aixterm-16color @@ -30,20 +20,10 @@ static immutable Termcap term1 = { name: "aixterm-16color", lines: 25, colors: 16, - bell: "\x07", - clear: "\x1b[H\x1b[J", - attrOff: "\x1b[0;10m\x1b(B", - underline: "\x1b[4m", - bold: "\x1b[1m", - reverse: "\x1b[7m", setFg: "\x1b[%?%p1%{8}%<%t%p1%{30}%+%e%p1%\'R\'%+%;%dm", setBg: "\x1b[%?%p1%{8}%<%t%p1%\'(\'%+%e%p1%{92}%+%;%dm", resetColors: "\x1b[32m\x1b[40m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", altChars: "jjkkllmmnnqqttuuvvwwxx", - automargin: true, }; static this() diff --git a/source/dcell/terminfo/alacritty.d b/source/dcell/terminfo/alacritty.d index 5e6a048..31b0d1d 100644 --- a/source/dcell/terminfo/alacritty.d +++ b/source/dcell/terminfo/alacritty.d @@ -9,62 +9,28 @@ static immutable Termcap term0 = { name: "alacritty", lines: 24, colors: 256, - bell: "\x07", - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b[?1049h\x1b[22;0;0t", - exitCA: "\x1b[?1049l\x1b[23;0;0t", - showCursor: "\x1b[?12l\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b(B\x1b[m", - underline: "\x1b[4m", - bold: "\x1b[1m", - reverse: "\x1b[7m", - dim: "\x1b[2m", - italic: "\x1b[3m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", setFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", setBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", - automargin: true, }; // alacritty-direct static immutable Termcap term1 = { name: "alacritty-direct", lines: 24, - bell: "\x07", - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b[?1049h\x1b[22;0;0t", - exitCA: "\x1b[?1049l\x1b[23;0;0t", - showCursor: "\x1b[?12l\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b(B\x1b[m", - underline: "\x1b[4m", - bold: "\x1b[1m", - reverse: "\x1b[7m", - dim: "\x1b[2m", - italic: "\x1b[3m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", setFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e38:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%d%;m", setBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e48:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%d%;m", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", - automargin: true, }; static this() diff --git a/source/dcell/terminfo/ansi.d b/source/dcell/terminfo/ansi.d index b855046..31f2577 100644 --- a/source/dcell/terminfo/ansi.d +++ b/source/dcell/terminfo/ansi.d @@ -9,23 +9,12 @@ static immutable Termcap term0 = { name: "ansi", lines: 24, colors: 8, - bell: "\x07", - clear: "\x1b[H\x1b[J", - attrOff: "\x1b[0;10m", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", setFg: "\x1b[3%p1%dm", setBg: "\x1b[4%p1%dm", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x1b[D", - cursorUp1: "\x1b[A", 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", - automargin: true, }; static this() diff --git a/source/dcell/terminfo/dtterm.d b/source/dcell/terminfo/dtterm.d index dd5a54e..7620f1a 100644 --- a/source/dcell/terminfo/dtterm.d +++ b/source/dcell/terminfo/dtterm.d @@ -9,27 +9,13 @@ static immutable Termcap term0 = { name: "dtterm", lines: 24, colors: 8, - bell: "\x07", - clear: "\x1b[H\x1b[J", - showCursor: "\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b[m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", - dim: "\x1b[2m", setFg: "\x1b[3%p1%dm", setBg: "\x1b[4%p1%dm", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b(B\x1b)0", - automargin: true, }; static this() diff --git a/source/dcell/terminfo/gnome.d b/source/dcell/terminfo/gnome.d index f2c13bb..c8e4dd4 100644 --- a/source/dcell/terminfo/gnome.d +++ b/source/dcell/terminfo/gnome.d @@ -9,30 +9,15 @@ static immutable Termcap term0 = { name: "gnome", lines: 24, colors: 8, - bell: "\x07", - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b7\x1b[?47h", - exitCA: "\x1b[2J\x1b[?47l\x1b8", - showCursor: "\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b[0m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", setFg: "\x1b[3%p1%dm", setBg: "\x1b[4%p1%dm", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b)0", - automargin: true, }; // gnome-256color @@ -40,30 +25,15 @@ static immutable Termcap term1 = { name: "gnome-256color", lines: 24, colors: 256, - bell: "\x07", - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b7\x1b[?47h", - exitCA: "\x1b[2J\x1b[?47l\x1b8", - showCursor: "\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b[0m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", setFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", setBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b)0", - automargin: true, }; static this() diff --git a/source/dcell/terminfo/konsole.d b/source/dcell/terminfo/konsole.d index 71daf4b..7039bce 100644 --- a/source/dcell/terminfo/konsole.d +++ b/source/dcell/terminfo/konsole.d @@ -9,30 +9,15 @@ static immutable Termcap term0 = { name: "konsole", lines: 24, colors: 8, - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b7\x1b[?47h", - exitCA: "\x1b[2J\x1b[?47l\x1b8", - showCursor: "\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b[0m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", setFg: "\x1b[3%p1%dm", setBg: "\x1b[4%p1%dm", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b)0", - automargin: true, }; // konsole-16color @@ -40,30 +25,14 @@ static immutable Termcap term1 = { name: "konsole-16color", lines: 24, colors: 16, - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b7\x1b[?47h", - exitCA: "\x1b[2J\x1b[?47l\x1b8", - showCursor: "\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b[0m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", setFg: "\x1b[%?%p1%{8}%<%t%p1%{30}%+%e%p1%\'R\'%+%;%dm", setBg: "\x1b[%?%p1%{8}%<%t%p1%\'(\'%+%e%p1%{92}%+%;%dm", - resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b)0", - automargin: true, }; // konsole-256color @@ -71,30 +40,15 @@ static immutable Termcap term2 = { name: "konsole-256color", lines: 24, colors: 256, - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b7\x1b[?47h", - exitCA: "\x1b[2J\x1b[?47l\x1b8", - showCursor: "\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b[0m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", setFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", setBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b)0", - automargin: true, }; static this() diff --git a/source/dcell/terminfo/linux.d b/source/dcell/terminfo/linux.d index 861cb5d..5467104 100644 --- a/source/dcell/terminfo/linux.d +++ b/source/dcell/terminfo/linux.d @@ -8,27 +8,12 @@ import dcell.database; static immutable Termcap term0 = { name: "linux", colors: 8, - bell: "\x07", - clear: "\x1b[H\x1b[J", - showCursor: "\x1b[?25h\x1b[?0c", - hideCursor: "\x1b[?25l\x1b[?1c", - attrOff: "\x1b[0;10m", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", - dim: "\x1b[2m", setFg: "\x1b[3%p1%dm", setBg: "\x1b[4%p1%dm", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - 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", exitACS: "\x1b[10m", - automargin: true, }; static this() diff --git a/source/dcell/terminfo/rxvt.d b/source/dcell/terminfo/rxvt.d index 5dd360c..520bcf4 100644 --- a/source/dcell/terminfo/rxvt.d +++ b/source/dcell/terminfo/rxvt.d @@ -9,32 +9,15 @@ static immutable Termcap term0 = { name: "rxvt", lines: 24, colors: 8, - bell: "\x07", - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b7\x1b[?47h", - exitCA: "\x1b[2J\x1b[?47l\x1b8", - showCursor: "\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b[m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b=", exitKeypad: "\x1b>", setFg: "\x1b[3%p1%dm", setBg: "\x1b[4%p1%dm", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - insertChar: "\x1b[@", - mouse: "\x1b[M", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b(B\x1b)0", - automargin: true, }; // rxvt-16color @@ -42,27 +25,11 @@ static immutable Termcap term1 = { name: "rxvt-16color", lines: 24, colors: 16, - bell: "\x07", - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b7\x1b[?47h", - exitCA: "\x1b[2J\x1b[?47l\x1b8", - showCursor: "\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b[m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b=", exitKeypad: "\x1b>", setFg: "\x1b[%?%p1%{8}%<%t%p1%{30}%+%e%p1%\'R\'%+%;%dm", setBg: "\x1b[%?%p1%{8}%<%t%p1%\'(\'%+%e%p1%{92}%+%;%dm", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - insertChar: "\x1b[@", - mouse: "\x1b[M", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", @@ -74,27 +41,11 @@ static immutable Termcap term2 = { name: "rxvt-88color", lines: 24, colors: 88, - bell: "\x07", - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b7\x1b[?47h", - exitCA: "\x1b[2J\x1b[?47l\x1b8", - showCursor: "\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b[m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b=", exitKeypad: "\x1b>", setFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", setBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - insertChar: "\x1b[@", - mouse: "\x1b[M", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", @@ -106,27 +57,11 @@ static immutable Termcap term3 = { name: "rxvt-256color", lines: 24, colors: 256, - bell: "\x07", - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b7\x1b[?47h", - exitCA: "\x1b[2J\x1b[?47l\x1b8", - showCursor: "\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b[m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b=", exitKeypad: "\x1b>", setFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", setBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - insertChar: "\x1b[@", - mouse: "\x1b[M", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", diff --git a/source/dcell/terminfo/screen.d b/source/dcell/terminfo/screen.d index 78f273b..7623cd4 100644 --- a/source/dcell/terminfo/screen.d +++ b/source/dcell/terminfo/screen.d @@ -9,31 +9,15 @@ static immutable Termcap term0 = { name: "screen", lines: 24, colors: 8, - bell: "\x07", - clear: "\x1b[H\x1b[J", - enterCA: "\x1b[?1049h", - exitCA: "\x1b[?1049l", - showCursor: "\x1b[34h\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b[m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", setFg: "\x1b[3%p1%dm", setBg: "\x1b[4%p1%dm", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1bM", - mouse: "\x1b[M", altChars: "++,,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b(B\x1b)0", - automargin: true, }; // screen-16color @@ -41,31 +25,15 @@ static immutable Termcap term1 = { name: "screen-16color", lines: 24, colors: 16, - bell: "\x07", - clear: "\x1b[H\x1b[J", - enterCA: "\x1b[?1049h", - exitCA: "\x1b[?1049l", - showCursor: "\x1b[34h\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b[m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", setFg: "\x1b[%?%p1%{8}%<%t%p1%{30}%+%e%p1%\'R\'%+%;%dm", setBg: "\x1b[%?%p1%{8}%<%t%p1%\'(\'%+%e%p1%{92}%+%;%dm", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1bM", - mouse: "\x1b[M", altChars: "++,,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b(B\x1b)0", - automargin: true, }; // screen-256color @@ -73,31 +41,15 @@ static immutable Termcap term2 = { name: "screen-256color", lines: 24, colors: 256, - bell: "\x07", - clear: "\x1b[H\x1b[J", - enterCA: "\x1b[?1049h", - exitCA: "\x1b[?1049l", - showCursor: "\x1b[34h\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b[m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", setFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", setBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1bM", - mouse: "\x1b[M", altChars: "++,,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b(B\x1b)0", - automargin: true, }; static this() diff --git a/source/dcell/terminfo/vt100.d b/source/dcell/terminfo/vt100.d index 0300790..51b766b 100644 --- a/source/dcell/terminfo/vt100.d +++ b/source/dcell/terminfo/vt100.d @@ -9,23 +9,12 @@ static immutable Termcap term0 = { name: "vt100", aliases: ["vt100-am"], lines: 24, - bell: "\x07", - clear: "\x1b[H\x1b[J", - attrOff: "\x1b[m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b(B\x1b)0", - automargin: true, }; static this() diff --git a/source/dcell/terminfo/vt102.d b/source/dcell/terminfo/vt102.d index e36e81b..334b83b 100644 --- a/source/dcell/terminfo/vt102.d +++ b/source/dcell/terminfo/vt102.d @@ -8,23 +8,12 @@ import dcell.database; static immutable Termcap term0 = { name: "vt102", lines: 24, - bell: "\x07", - clear: "\x1b[H\x1b[J", - attrOff: "\x1b[m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b(B\x1b)0", - automargin: true, }; static this() diff --git a/source/dcell/terminfo/vt220.d b/source/dcell/terminfo/vt220.d index bf7d366..b4a498e 100644 --- a/source/dcell/terminfo/vt220.d +++ b/source/dcell/terminfo/vt220.d @@ -9,21 +9,10 @@ static immutable Termcap term0 = { name: "vt220", aliases: ["vt200"], lines: 24, - bell: "\x07", - clear: "\x1b[H\x1b[J", - attrOff: "\x1b[m\x1b(B", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", enableACS: "\x1b)0", - automargin: true, }; static this() diff --git a/source/dcell/terminfo/vt320.d b/source/dcell/terminfo/vt320.d index a5d9d79..e60fe46 100644 --- a/source/dcell/terminfo/vt320.d +++ b/source/dcell/terminfo/vt320.d @@ -9,24 +9,11 @@ static immutable Termcap term0 = { name: "vt320", aliases: ["vt300"], lines: 24, - bell: "\x07", - clear: "\x1b[H\x1b[2J", - showCursor: "\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b[m\x1b(B", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", - automargin: true, }; static this() diff --git a/source/dcell/terminfo/vt420.d b/source/dcell/terminfo/vt420.d index 2073b5d..7499d33 100644 --- a/source/dcell/terminfo/vt420.d +++ b/source/dcell/terminfo/vt420.d @@ -8,22 +8,11 @@ import dcell.database; static immutable Termcap term0 = { name: "vt420", lines: 24, - bell: "\x07", - clear: "\x1b[H\x1b[2J", - attrOff: "\x1b[m", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b=", exitKeypad: "\x1b>", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", altChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", - automargin: true, }; static this() diff --git a/source/dcell/terminfo/xfce.d b/source/dcell/terminfo/xfce.d index 30a26bb..5d1b33f 100644 --- a/source/dcell/terminfo/xfce.d +++ b/source/dcell/terminfo/xfce.d @@ -9,30 +9,15 @@ static immutable Termcap term0 = { name: "xfce", lines: 24, colors: 8, - bell: "\x07", - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b7\x1b[?47h", - exitCA: "\x1b[2J\x1b[?47l\x1b8", - showCursor: "\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b[0m\x0f", - underline: "\x1b[4m", - bold: "\x1b[1m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", setFg: "\x1b[3%p1%dm", setBg: "\x1b[4%p1%dm", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x0e", exitACS: "\x0f", enableACS: "\x1b)0", - automargin: true, }; static this() diff --git a/source/dcell/terminfo/xterm.d b/source/dcell/terminfo/xterm.d index 8a4a0bc..236e283 100644 --- a/source/dcell/terminfo/xterm.d +++ b/source/dcell/terminfo/xterm.d @@ -9,30 +9,14 @@ static immutable Termcap term0 = { name: "xterm", lines: 24, colors: 8, - bell: "\x07", - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b[?1049h", - exitCA: "\x1b[?1049l", - showCursor: "\x1b[?12l\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b(B\x1b[m", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", setFg: "\x1b[3%p1%dm", setBg: "\x1b[4%p1%dm", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", - automargin: true, }; // xterm-16color @@ -40,30 +24,14 @@ static immutable Termcap term1 = { name: "xterm-16color", lines: 24, colors: 16, - bell: "\x07", - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b[?1049h", - exitCA: "\x1b[?1049l", - showCursor: "\x1b[?12l\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b(B\x1b[m", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", setFg: "\x1b[%?%p1%{8}%<%t%p1%{30}%+%e%p1%\'R\'%+%;%dm", setBg: "\x1b[%?%p1%{8}%<%t%p1%\'(\'%+%e%p1%{92}%+%;%dm", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", - automargin: true, }; // xterm-88color @@ -71,30 +39,14 @@ static immutable Termcap term2 = { name: "xterm-88color", lines: 24, colors: 88, - bell: "\x07", - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b[?1049h", - exitCA: "\x1b[?1049l", - showCursor: "\x1b[?12l\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b(B\x1b[m", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", setFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", setBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", - automargin: true, }; // xterm-256color @@ -102,30 +54,14 @@ static immutable Termcap term3 = { name: "xterm-256color", lines: 24, colors: 256, - bell: "\x07", - clear: "\x1b[H\x1b[2J", - enterCA: "\x1b[?1049h", - exitCA: "\x1b[?1049l", - showCursor: "\x1b[?12l\x1b[?25h", - hideCursor: "\x1b[?25l", - attrOff: "\x1b(B\x1b[m", - underline: "\x1b[4m", - bold: "\x1b[1m", - blink: "\x1b[5m", - reverse: "\x1b[7m", enterKeypad: "\x1b[?1h\x1b=", exitKeypad: "\x1b[?1l\x1b>", setFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", setBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", resetColors: "\x1b[39;49m", - setCursor: "\x1b[%i%p1%d;%p2%dH", - cursorBack1: "\x08", - cursorUp1: "\x1b[A", - mouse: "\x1b[M", altChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", enterACS: "\x1b(0", exitACS: "\x1b(B", - automargin: true, }; static this() diff --git a/source/dcell/termio.d b/source/dcell/termio.d index 8c7efdf..7c03c43 100644 --- a/source/dcell/termio.d +++ b/source/dcell/termio.d @@ -118,11 +118,10 @@ version (Posix) { if (file.isOpen()) { + ignoreResize(fd); flush(); restore(); - file.close(); } - ignoreResize(fd); } void save() @@ -150,7 +149,6 @@ version (Posix) tio.c_cc[VTIME] = 0; enforce(tcsetattr(fd, TCSANOW, &tio) >= 0); - fcntl(fd, F_SETFL, b ? 0 : O_NONBLOCK); block = b; } diff --git a/source/dcell/ttyscreen.d b/source/dcell/ttyscreen.d index 99afbb4..7819c82 100644 --- a/source/dcell/ttyscreen.d +++ b/source/dcell/ttyscreen.d @@ -1,7 +1,7 @@ /** * TtyScreen module implements POSIX style terminals (ala XTerm). * - * 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. @@ -14,12 +14,14 @@ package: import core.atomic; import core.time; -import std.string; +import std.algorithm : canFind; +import std.format; import std.concurrency; import std.exception; import std.outbuffer; import std.range; import std.stdio; +import std.string; import dcell.cell; import dcell.cursor; @@ -36,7 +38,74 @@ import dcell.turnstile; class TtyScreen : Screen { - this(TtyImpl tt, const(Termcap)* tc) + // Various escape escape sequences we can send. + // Note that we have a rather broad assumption that we only support terminals + // that understand these things, or in some cases, that will gracefully ignore + // them. (For example, terminals should ignore SGR settings they don't grok.) + struct Vt + { + enum string enableAutoMargin = "\x1b[?7h"; // dec private mode 7 (enable) + enum string disableAutoMargin = "\x1b[?7l"; + enum string setCursorPosition = "\x1b[%d;%dH"; + enum string sgr0 = "\x1b[m"; // attrOff + enum string bold = "\x1b[1m"; + enum string dim = "\x1b[2m"; + enum string italic = "\x1b[3m"; + enum string underline = "\x1b[4m"; + enum string blink = "\x1b[5m"; + enum string reverse = "\x1b[7m"; + enum string strikeThrough = "\x1b[9m"; + enum string showCursor = "\x1b[?25h"; + enum string hideCursor = "\x1b[?25l"; + enum string clear = "\x1b[H\x1b[J"; + enum string enablePaste = "\x1b[?2004h"; + enum string disablePaste = "\x1b[?2004l"; + enum string enableFocus = "\x1b[?1004h"; + enum string disableFocus = "\x1b[?1004l"; + enum string cursorReset = "\x1b[0 q"; // reset cursor shape to default + enum string cursorBlinkingBlock = "\x1b[1 q"; + enum string cursorBlock = "\x1b[2 q"; + enum string cursorBlinkingUnderline = "\x1b[3 q"; + enum string cursorUnderline = "\x1b[4 q"; + enum string cursorBlinkingBar = "\x1b[5 q"; + enum string cursorBar = "\x1b[6 q"; + enum string enterCA = "\x1b[?1049h"; // alternate screen + enum string exitCA = "\x1b[?1049l"; // alternate screen + enum string startSyncOut = "\x1b[?2026h"; + enum string endSyncOut = "\x1b[?2026l"; + + // these can be overridden (e.g. disabled for legacy) + string enterURL = "\x1b]8;;%s\x1b\\"; + string exitURL = "\x1b]8;;\x1b\\"; + string setWindowSize = "\x1b[8;%d;%dt"; + string saveTitle = "\x1b[22;2t"; + string restoreTitle = "\x1b[23;2t"; + string setTitle = "\x1b[>2t\x1b]2;%s\x1b\\"; + + // doubleUnder = "\x1b[4:2m" + // curlyUnder = "\x1b[4:3m" + // dottedUnder = "\x1b[4:4m" + // dashedUnder = "\x1b[4:5m" + // underColor = "\x1b[58:5:%dm" + // underRGB = "\x1b[58:2::%d:%d:%dm" + // underFg = "\x1b[59m" + // enableAltChars = "\x1b(B\x1b)0" // set G0 as US-ASCII, G1 as DEC line drawing + // startAltChars = "\x0e" // aka Shift-Out + // endAltChars = "\x0f" // aka Shift-In + // setFg8 = "\x1b[3%dm" // for colors less than 8 + // setFg256 = "\x1b[38;5;%dm" // for colors less than 256 + // setFgRgb = "\x1b[38;2;%d;%d;%dm" // for RGB + // setBg8 = "\x1b[4%dm" // color colors less than 8 + // setBg256 = "\x1b[48;5;%dm" // for colors less than 256 + // setBgRgb = "\x1b[48;2;%d;%d;%dm" // for RGB + // setFgBgRgb = "\x1b[38;2;%d;%d;%d;48;2;%d;%d;%dm" // for RGB, in one shot + // resetFgBg = "\x1b[39;49m" // ECMA defined + // enterKeypad = "\x1b[?1h\x1b=" // Note mode 1 might not be supported everywhere + // exitKeypad = "\x1b[?1l\x1b>" // Also mode 1 + // requestWindowSize = "\x1b[18t" // For modern terminals + } + + this(TtyImpl tt, const(Termcap)* tc, string term = "") { caps = tc; ti = tt; @@ -46,6 +115,24 @@ class TtyScreen : Screen stopping = new Turnstile(); defStyle.bg = Color.reset; defStyle.fg = Color.reset; + + legacy = false; + if (term.startsWith("vt") || term.canFind("ansi") || term == "linux" || term == "sun" || term == "sun-color") + { + // these terminals are "legacy" and not expected to support most OSC functions + legacy = true; + } + + // for legacy terminals, disable functions we don't support + if (legacy) + { + vt.enterURL = ""; + vt.exitURL = ""; + vt.setWindowSize = ""; + vt.setTitle = ""; + vt.restoreTitle = ""; + vt.saveTitle = ""; + } } ~this() @@ -60,7 +147,8 @@ class TtyScreen : Screen stopping.set(false); ti.save(); ti.raw(); - puts(caps.clear); + puts(vt.disableAutoMargin); + puts(vt.clear); resize(); draw(); spawn(&inputLoop, cast(shared TtyImpl) ti, tid, @@ -83,18 +171,21 @@ class TtyScreen : Screen { if (!started) return; + + puts(vt.enableAutoMargin); puts(caps.resetColors); - puts(caps.attrOff); - puts(caps.cursorReset); - puts(caps.showCursor); - puts(caps.cursorReset); - puts(caps.clear); - puts(caps.disablePaste); + puts(vt.sgr0); + puts(vt.cursorReset); + puts(vt.showCursor); + puts(vt.cursorReset); + puts(vt.clear); + puts(vt.disablePaste); enableMouse(MouseEnable.disable); - enableFocus(false); + puts(vt.disableFocus); flush(); stopping.set(true); ti.blocking(false); + ti.stop(); stopping.wait(false); ti.blocking(true); ti.restore(); @@ -167,7 +258,7 @@ class TtyScreen : Screen bool hasMouse() const pure { - return caps.mouse != ""; + return true; } int colors() const pure @@ -192,7 +283,7 @@ class TtyScreen : Screen void beep() { - puts(caps.bell); + puts("\x07"); flush(); } @@ -203,9 +294,9 @@ class TtyScreen : Screen void setSize(Coord size) { - if (caps.setWindowSize != "") + if (vt.setWindowSize != "") { - puts(caps.setWindowSize, size.x, size.y); + puts(vt.setWindowSize, size.y, size.x); flush(); cells.setAllDirty(true); resize(); @@ -218,16 +309,13 @@ class TtyScreen : Screen // to the de-facto standard from XTerm. This is necessary as // there is no standard terminfo sequence for reporting this // information. - if (caps.mouse != "") - { - mouseEn = en; // save this so we can restore after a suspend - sendMouseEnable(en); - } + mouseEn = en; // save this so we can restore after a suspend + sendMouseEnable(en); } void enableFocus(bool enabled) { - puts("\x1b[?1004%s", enabled ? "h" : "l"); + puts(enabled ? Vt.enableFocus : Vt.disableFocus); flush(); } @@ -271,10 +359,10 @@ private: OutBuffer ob; Turnstile stopping; bool started; + bool legacy; // legacy terminals don't have support for OSC, APC, DSC, etc. EventQueue eq; + Vt vt; - // puts emits a parameterized string that may contain embedded delay padding. - // it should not be used for user-supplied strings. void puts(string s) { Termcap.puts(ob, s, &flush); @@ -355,19 +443,19 @@ private: { auto attr = style.attr; if (attr & Attr.bold) - puts(caps.bold); + puts(Vt.bold); if (attr & Attr.underline) - puts(caps.underline); + puts(Vt.underline); if (attr & Attr.reverse) - puts(caps.reverse); + puts(Vt.reverse); if (attr & Attr.blink) - puts(caps.blink); + puts(Vt.blink); if (attr & Attr.dim) - puts(caps.dim); + puts(Vt.dim); if (attr & Attr.italic) - puts(caps.italic); + puts(Vt.italic); if (attr & Attr.strikethrough) - puts(caps.strikethrough); + puts(Vt.strikeThrough); } void clearScreen() @@ -375,12 +463,12 @@ private: if (clear_) { clear_ = false; - puts(caps.attrOff); - puts(caps.exitURL); + puts(vt.sgr0); + puts(vt.exitURL); sendColors(defStyle); sendAttrs(defStyle); style_ = defStyle; - puts(caps.clear); + puts(Vt.clear); flush(); } } @@ -389,7 +477,7 @@ private: { if (pos != pos_) { - puts(caps.setCursor, pos.y, pos.x); + puts(format!(Vt.setCursorPosition)(pos.y, pos.x)); pos_ = pos; } } @@ -399,49 +487,37 @@ private: { if (!cells.isLegal(cursorPos) || (cursorShape == Cursor.hidden)) { - if (caps.hideCursor != "") - { - puts(caps.hideCursor); - } - else - { - // go to last cell (lower right) - // this is the best we can do to move the cursor - // out of the way. - auto size = cells.size(); - goTo(Coord(size.x - 1, size.y - 1)); - } + puts(vt.hideCursor); return; } goTo(cursorPos); - puts(caps.showCursor); + puts(cursorShape != Cursor.hidden ? vt.showCursor : vt.hideCursor); final switch (cursorShape) { case Cursor.current: break; case Cursor.hidden: - puts(caps.hideCursor); break; case Cursor.reset: - puts(caps.cursorReset); + puts(vt.cursorReset); break; case Cursor.bar: - puts(caps.cursorBar); + puts(vt.cursorBar); break; case Cursor.block: - puts(caps.cursorBlock); + puts(vt.cursorBlock); break; case Cursor.underline: - puts(caps.cursorUnderline); + puts(vt.cursorUnderline); break; case Cursor.blinkingBar: - puts(caps.cursorBlinkingBar); + puts(vt.cursorBlinkingBar); break; case Cursor.blinkingBlock: - puts(caps.cursorBlinkingBlock); + puts(vt.cursorBlinkingBlock); break; case Cursor.blinkingUnderline: - puts(caps.cursorBlinkingUnderline); + puts(vt.cursorBlinkingUnderline); break; } @@ -458,19 +534,8 @@ private: { return c.width; } - // auto-margin handling -- if we are going to automatically - // wrap at the bottom right corner, then we want to insert - // 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 != "")) - { - auto pp = pos; - pp.x--; - goTo(pp); - insert = true; - } - else if (pos != pos_) + if (pos != pos_) { goTo(pos); } @@ -483,7 +548,7 @@ private: c.style.attr ^= Attr.reverse; } } - if (caps.enterURL == "") + if (vt.enterURL == "") { // avoid pointless changes due to URL where not supported c.style.url = ""; @@ -491,7 +556,7 @@ private: if (c.style.fg != style_.fg || c.style.bg != style_.bg || c.style.attr != style_.attr) { - puts(caps.attrOff); + puts(Vt.sgr0); sendColors(c.style); sendAttrs(c.style); } @@ -499,11 +564,11 @@ private: { if (c.style.url != "") { - puts(caps.enterURL, c.style.url); + puts(format(vt.enterURL, c.style.url)); } else { - puts(caps.exitURL); + puts(vt.exitURL); } } // TODO: replacement encoding (ACSC, application supplied fallbacks) @@ -533,7 +598,7 @@ private: void draw() { - puts(caps.hideCursor); // hide the cursor while we draw + puts(vt.hideCursor); // hide the cursor while we draw clearScreen(); // no op if not needed auto size = cells.size(); Coord pos = Coord(0, 0); @@ -564,27 +629,24 @@ private: // to the de-facto standard from XTerm. This is necessary as // there is no standard terminfo sequence for reporting this // information. - if (caps.mouse != "") - { - // start by disabling everything - puts("\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l"); - // then turn on specific enables - if (en & MouseEnable.buttons) - puts("\x1b[?1000h"); - if (en & MouseEnable.drag) - puts("\x1b[?1002h"); - if (en & MouseEnable.motion) - puts("\x1b[?1003h"); - // and if any are set, we need to send this - if (en & MouseEnable.all) - puts("\x1b[?1006h"); - flush(); - } + // start by disabling everything + puts("\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l"); + // then turn on specific enables + if (en & MouseEnable.buttons) + puts("\x1b[?1000h"); + if (en & MouseEnable.drag) + puts("\x1b[?1002h"); + if (en & MouseEnable.motion) + puts("\x1b[?1003h"); + // and if any are set, we need to send this + if (en & MouseEnable.all) + puts("\x1b[?1006h"); + flush(); } void sendPasteEnable(bool b) { - puts(b ? caps.enablePaste : caps.disablePaste); + puts(b ? Vt.enablePaste : Vt.disablePaste); flush(); } @@ -624,6 +686,13 @@ private: eq.send(ev); } } + + if (stopping.get()) + { + stopping.set(false); + return; + } + if (!p.empty() || !finished) { f.blocking(false); @@ -633,12 +702,6 @@ private: // No data, so we can sleep until some arrives. f.blocking(true); } - - if (stopping.get()) - { - stopping.set(false); - return; - } } } } @@ -658,5 +721,5 @@ Screen newTtyScreen(string term = "") { throw new Exception("terminal not found"); } - return new TtyScreen(newDevTty(), caps); + return new TtyScreen(newDevTty(), caps, term); }