summary refs log tree commit diff
path: root/term.c
diff options
context:
space:
mode:
Diffstat (limited to 'term.c')
-rw-r--r--term.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/term.c b/term.c
index 342bc66..aa44454 100644
--- a/term.c
+++ b/term.c
@@ -320,7 +320,28 @@ ACTION(sgr) {
 	}
 }
 
+enum {
+	USASCII,
+	DECSpecial,
+};
+
+ACTION(usascii) { t->charset = USASCII; }
+ACTION(decSpecial) { t->charset = DECSpecial; }
+
+static const wchar_t AltCharset[128] = {
+	['`'] = L'◆', ['a'] = L'▒', ['f'] = L'°', ['g'] = L'±', ['i'] = L'␋',
+	['j'] = L'┘', ['k'] = L'┐', ['l'] = L'┌', ['m'] = L'└', ['n'] = L'┼',
+	['o'] = L'⎺', ['p'] = L'⎻', ['q'] = L'─', ['r'] = L'⎼', ['s'] = L'⎽',
+	['t'] = L'├', ['u'] = L'┤', ['v'] = L'┴', ['w'] = L'┬', ['x'] = L'│',
+	['y'] = L'≤', ['z'] = L'≥', ['{'] = L'π', ['|'] = L'≠', ['}'] = L'£',
+	['~'] = L'·',
+};
+
 ACTION(add) {
+	if (t->charset == DECSpecial && ch < 128 && AltCharset[ch]) {
+		ch = AltCharset[ch];
+	}
+
 	int width = wcwidth(ch);
 	if (width < 0) {
 		unhandled("\\u%02X", ch);
@@ -364,6 +385,11 @@ ACTION(escDefault) {
 	unhandled("ESC %lc", ch);
 }
 
+ACTION(g0Default) {
+	unhandled("G0 %lc", ch);
+	t->charset = USASCII;
+}
+
 ACTION(csiInter) {
 	switch (t->state) {
 		break; case CSI: unhandled("CSI %lc ...", ch);
@@ -414,7 +440,9 @@ void termUpdate(struct Term *term, wchar_t ch) {
 			D(escDefault, Data);
 		}
 		S(G0) {
-			D(nop, Data);
+			A('0', decSpecial, Data);
+			A('B', usascii, Data);
+			D(g0Default, Data);
 		}
 
 		S(CSI) {