diff --git a/src/Charsets.ts b/src/Charsets.ts new file mode 100644 index 00000000..4035d453 --- /dev/null +++ b/src/Charsets.ts @@ -0,0 +1,58 @@ +// TODO: Give this a proper type +export const CHARSETS: any = {}; + +// DEC Special Character and Line Drawing Set. +// http://vt100.net/docs/vt102-ug/table5-13.html +// A lot of curses apps use this if they see TERM=xterm. +// testing: echo -e '\e(0a\e(B' +// The xterm output sometimes seems to conflict with the +// reference above. xterm seems in line with the reference +// when running vttest however. +// The table below now uses xterm's output from vttest. +CHARSETS.SCLD = { // (0 + '`': '\u25c6', // '◆' + 'a': '\u2592', // '▒' + 'b': '\u0009', // '\t' + 'c': '\u000c', // '\f' + 'd': '\u000d', // '\r' + 'e': '\u000a', // '\n' + 'f': '\u00b0', // '°' + 'g': '\u00b1', // '±' + 'h': '\u2424', // '\u2424' (NL) + 'i': '\u000b', // '\v' + 'j': '\u2518', // '┘' + 'k': '\u2510', // '┐' + 'l': '\u250c', // '┌' + 'm': '\u2514', // '└' + 'n': '\u253c', // '┼' + 'o': '\u23ba', // '⎺' + 'p': '\u23bb', // '⎻' + 'q': '\u2500', // '─' + 'r': '\u23bc', // '⎼' + 's': '\u23bd', // '⎽' + 't': '\u251c', // '├' + 'u': '\u2524', // '┤' + 'v': '\u2534', // '┴' + 'w': '\u252c', // '┬' + 'x': '\u2502', // '│' + 'y': '\u2264', // '≤' + 'z': '\u2265', // '≥' + '{': '\u03c0', // 'π' + '|': '\u2260', // '≠' + '}': '\u00a3', // '£' + '~': '\u00b7' // '·' +}; + +CHARSETS.UK = null; // (A +CHARSETS.US = null; // (B (USASCII) +CHARSETS.Dutch = null; // (4 +CHARSETS.Finnish = null; // (C or (5 +CHARSETS.French = null; // (R +CHARSETS.FrenchCanadian = null; // (Q +CHARSETS.German = null; // (K +CHARSETS.Italian = null; // (Y +CHARSETS.NorwegianDanish = null; // (E or (6 +CHARSETS.Spanish = null; // (Z +CHARSETS.Swedish = null; // (H or (7 +CHARSETS.Swiss = null; // (= +CHARSETS.ISOLatin = null; // /A diff --git a/src/Parser.ts b/src/Parser.ts index b04327e1..ef10abc5 100644 --- a/src/Parser.ts +++ b/src/Parser.ts @@ -1,5 +1,6 @@ import { C0 } from './EscapeSequences'; import { IInputHandler } from './Interfaces'; +import { CHARSETS } from './Charsets'; const normalStateHandler: {[key: string]: (handler: IInputHandler) => void} = {}; normalStateHandler[C0.BEL] = (handler) => handler.bell(); @@ -217,7 +218,7 @@ export class Parser { case '%': // this.charset = null; this._terminal.setgLevel(0); - this._terminal.setgCharset(0, Terminal.charsets.US); + this._terminal.setgCharset(0, CHARSETS.US); this.state = ParserState.NORMAL; i++; break; @@ -346,53 +347,53 @@ export class Parser { case ParserState.CHARSET: switch (ch) { case '0': // DEC Special Character and Line Drawing Set. - cs = Terminal.charsets.SCLD; + cs = CHARSETS.SCLD; break; case 'A': // UK - cs = Terminal.charsets.UK; + cs = CHARSETS.UK; break; case 'B': // United States (USASCII). - cs = Terminal.charsets.US; + cs = CHARSETS.US; break; case '4': // Dutch - cs = Terminal.charsets.Dutch; + cs = CHARSETS.Dutch; break; case 'C': // Finnish case '5': - cs = Terminal.charsets.Finnish; + cs = CHARSETS.Finnish; break; case 'R': // French - cs = Terminal.charsets.French; + cs = CHARSETS.French; break; case 'Q': // FrenchCanadian - cs = Terminal.charsets.FrenchCanadian; + cs = CHARSETS.FrenchCanadian; break; case 'K': // German - cs = Terminal.charsets.German; + cs = CHARSETS.German; break; case 'Y': // Italian - cs = Terminal.charsets.Italian; + cs = CHARSETS.Italian; break; case 'E': // NorwegianDanish case '6': - cs = Terminal.charsets.NorwegianDanish; + cs = CHARSETS.NorwegianDanish; break; case 'Z': // Spanish - cs = Terminal.charsets.Spanish; + cs = CHARSETS.Spanish; break; case 'H': // Swedish case '7': - cs = Terminal.charsets.Swedish; + cs = CHARSETS.Swedish; break; case '=': // Swiss - cs = Terminal.charsets.Swiss; + cs = CHARSETS.Swiss; break; case '/': // ISOLatin (actually /A) - cs = Terminal.charsets.ISOLatin; + cs = CHARSETS.ISOLatin; i++; break; default: // Default - cs = Terminal.charsets.US; + cs = CHARSETS.US; break; } this._terminal.setgCharset(this._terminal.gcharset, cs); diff --git a/src/xterm.js b/src/xterm.js index 42661236..5f43c381 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -17,9 +17,10 @@ import { rightClickHandler, pasteHandler, copyHandler } from './handlers/Clipboa import { CircularList } from './utils/CircularList.js'; import { C0 } from './EscapeSequences'; import { InputHandler } from './InputHandler'; -import { Parser } from './Parser'; +import { Parser } from './Parser'; import * as Browser from './utils/Browser'; import * as Keyboard from './utils/Keyboard'; +import { CHARSETS } from './Charsets'; /** * Terminal Emulation References: @@ -3030,10 +3031,10 @@ Terminal.prototype.setMode = function(params) { this.applicationCursor = true; break; case 2: - this.setgCharset(0, Terminal.charsets.US); - this.setgCharset(1, Terminal.charsets.US); - this.setgCharset(2, Terminal.charsets.US); - this.setgCharset(3, Terminal.charsets.US); + this.setgCharset(0, CHARSETS.US); + this.setgCharset(1, CHARSETS.US); + this.setgCharset(2, CHARSETS.US); + this.setgCharset(3, CHARSETS.US); // set VT100 mode here break; case 3: // 132 col mode @@ -3806,68 +3807,6 @@ Terminal.prototype.deleteColumns = function() { this.maxRange(); }; -/** - * Character Sets - */ - -Terminal.charsets = {}; - -// DEC Special Character and Line Drawing Set. -// http://vt100.net/docs/vt102-ug/table5-13.html -// A lot of curses apps use this if they see TERM=xterm. -// testing: echo -e '\e(0a\e(B' -// The xterm output sometimes seems to conflict with the -// reference above. xterm seems in line with the reference -// when running vttest however. -// The table below now uses xterm's output from vttest. -Terminal.charsets.SCLD = { // (0 - '`': '\u25c6', // '◆' - 'a': '\u2592', // '▒' - 'b': '\u0009', // '\t' - 'c': '\u000c', // '\f' - 'd': '\u000d', // '\r' - 'e': '\u000a', // '\n' - 'f': '\u00b0', // '°' - 'g': '\u00b1', // '±' - 'h': '\u2424', // '\u2424' (NL) - 'i': '\u000b', // '\v' - 'j': '\u2518', // '┘' - 'k': '\u2510', // '┐' - 'l': '\u250c', // '┌' - 'm': '\u2514', // '└' - 'n': '\u253c', // '┼' - 'o': '\u23ba', // '⎺' - 'p': '\u23bb', // '⎻' - 'q': '\u2500', // '─' - 'r': '\u23bc', // '⎼' - 's': '\u23bd', // '⎽' - 't': '\u251c', // '├' - 'u': '\u2524', // '┤' - 'v': '\u2534', // '┴' - 'w': '\u252c', // '┬' - 'x': '\u2502', // '│' - 'y': '\u2264', // '≤' - 'z': '\u2265', // '≥' - '{': '\u03c0', // 'π' - '|': '\u2260', // '≠' - '}': '\u00a3', // '£' - '~': '\u00b7' // '·' -}; - -Terminal.charsets.UK = null; // (A -Terminal.charsets.US = null; // (B (USASCII) -Terminal.charsets.Dutch = null; // (4 -Terminal.charsets.Finnish = null; // (C or (5 -Terminal.charsets.French = null; // (R -Terminal.charsets.FrenchCanadian = null; // (Q -Terminal.charsets.German = null; // (K -Terminal.charsets.Italian = null; // (Y -Terminal.charsets.NorwegianDanish = null; // (E or (6 -Terminal.charsets.Spanish = null; // (Z -Terminal.charsets.Swedish = null; // (H or (7 -Terminal.charsets.Swiss = null; // (= -Terminal.charsets.ISOLatin = null; // /A - /** * Helpers */