From 3eedbbbf0ef16a3e96f76d3f6f2e1750be52a5ac Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 16 Aug 2010 13:11:51 +0000 Subject: [PATCH] =?UTF-8?q?Handle=20more=20pseudo=C3=83-graphic=20characte?= =?UTF-8?q?rs=20and=20ways=20of=20using=20them.=20This=20gets=20aptitude?= =?UTF-8?q?=20(from=20debian=C3=83)=20displaying=20properly=20and=20should?= =?UTF-8?q?=20also=20fix=20midnight=20commander.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38139 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/terminal/TermParse.cpp | 62 ++++++++++++++++++++++++++++++--- src/apps/terminal/VTPrsTbl.c | 12 +++---- 2 files changed, 64 insertions(+), 10 deletions(-) diff --git a/src/apps/terminal/TermParse.cpp b/src/apps/terminal/TermParse.cpp index 5ba7211c92..a78cda3329 100644 --- a/src/apps/terminal/TermParse.cpp +++ b/src/apps/terminal/TermParse.cpp @@ -330,6 +330,10 @@ TermParse::EscParse() int *groundtable = gUTF8GroundTable; int *parsestate = gUTF8GroundTable; + /* Handle switch between G0 and G1 character sets */ + int *alternateParseTable = gUTF8GroundTable; + bool shifted_in = false; + int32 srcLen; int32 dstLen; long dummyState = 0; @@ -453,6 +457,9 @@ TermParse::EscParse() case CASE_PRINT_GRA: /* "Special characters and line drawing" enabled by \E(0 */ switch (c) { + case 'a': + fBuffer->InsertChar("\xE2\x96\x92",3,fAttr); + break; case 'j': fBuffer->InsertChar("\xE2\x94\x98",3,fAttr); break; @@ -465,9 +472,26 @@ TermParse::EscParse() case 'm': fBuffer->InsertChar("\xE2\x94\x94",3,fAttr); break; + case 'n': + fBuffer->InsertChar("\xE2\x94\xBC",3,fAttr); + break; case 'q': + fBuffer->InsertChar("\xE2\x94\x80",3,fAttr); + break; + case 't': + fBuffer->InsertChar("\xE2\x94\x9C",3,fAttr); + break; + case 'u': + fBuffer->InsertChar("\xE2\x94\xA4",3,fAttr); + break; + case 'v': + fBuffer->InsertChar("\xE2\x94\xB4",3,fAttr); + break; + case 'w': + fBuffer->InsertChar("\xE2\x94\xAC",3,fAttr); break; case 'x': + fBuffer->InsertChar("\xE2\x94\x82",3,fAttr); break; default: fBuffer->InsertChar((char)c, fAttr); @@ -542,11 +566,29 @@ TermParse::EscParse() break; case CASE_SCS_STATE: - if (_NextParseChar() == '0') - parsestate = gLineDrawTable; - else - parsestate = groundtable; + { + char page = _NextParseChar(); + + int* newTable = gUTF8GroundTable; + if (page == '0') + newTable = gLineDrawTable; + + if (c == '(') { + if (shifted_in) + alternateParseTable = newTable; + else + groundtable = newTable; + } else if (c == ')') { + if (!shifted_in) + alternateParseTable = newTable; + else + groundtable = newTable; + } + + parsestate = groundtable; + break; + } case CASE_GROUND_STATE: /* exit ignore mode */ @@ -585,9 +627,21 @@ TermParse::EscParse() break; case CASE_SI: + /* shift in (to G1 charset) */ + if (shifted_in == false) { + int* tmp = alternateParseTable; + alternateParseTable = parsestate; + parsestate = tmp; + } break; case CASE_SO: + /* shift out (to G0 charset) */ + if (shifted_in == true) { + int* tmp = alternateParseTable; + alternateParseTable = parsestate; + parsestate = tmp; + } break; case CASE_SCR_STATE: // ESC # diff --git a/src/apps/terminal/VTPrsTbl.c b/src/apps/terminal/VTPrsTbl.c index 724f3e507d..b94bcb4e68 100644 --- a/src/apps/terminal/VTPrsTbl.c +++ b/src/apps/terminal/VTPrsTbl.c @@ -4849,7 +4849,7 @@ CASE_PRINT, CASE_PRINT, /* ` a b c */ CASE_PRINT, -CASE_PRINT, +CASE_PRINT_GRA, CASE_PRINT, CASE_PRINT, /* d e f g */ @@ -4865,7 +4865,7 @@ CASE_PRINT_GRA, /* l m n o */ CASE_PRINT_GRA, CASE_PRINT_GRA, -CASE_PRINT, +CASE_PRINT_GRA, CASE_PRINT, /* p q r s */ CASE_PRINT, @@ -4873,10 +4873,10 @@ CASE_PRINT_GRA, CASE_PRINT, CASE_PRINT, /* t u v w */ -CASE_PRINT, -CASE_PRINT, -CASE_PRINT, -CASE_PRINT, +CASE_PRINT_GRA, +CASE_PRINT_GRA, +CASE_PRINT_GRA, +CASE_PRINT_GRA, /* x y z { */ CASE_PRINT_GRA, CASE_PRINT,