[haiku-commits] r34894 - haiku/trunk/src/apps/terminal

  • From: stefano.ceccherini@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 4 Jan 2010 19:37:37 +0100 (CET)

Author: jackburton
Date: 2010-01-04 19:37:37 +0100 (Mon, 04 Jan 2010)
New Revision: 34894
Changeset: http://dev.haiku-os.org/changeset/34894/haiku

Removed:
   haiku/trunk/src/apps/terminal/CodeConv.cpp
   haiku/trunk/src/apps/terminal/CodeConv.h
   haiku/trunk/src/apps/terminal/UTF8WidthTbl.c
Modified:
   haiku/trunk/src/apps/terminal/Arguments.cpp
   haiku/trunk/src/apps/terminal/BasicTerminalBuffer.cpp
   haiku/trunk/src/apps/terminal/Encoding.cpp
   haiku/trunk/src/apps/terminal/Encoding.h
   haiku/trunk/src/apps/terminal/Jamfile
   haiku/trunk/src/apps/terminal/TermConst.h
   haiku/trunk/src/apps/terminal/TermParse.cpp
   haiku/trunk/src/apps/terminal/TermParse.h
   haiku/trunk/src/apps/terminal/TermView.cpp
Log:
Invoke the shell using /bin/bash instead of /bin/sh.
Use convert_to/from_utf8() directly instead of the homebrewn proxy methods.
Removed CodeConv from the repository.
Remove UTF8WidthTbl.c from the repository, since it's not used anymore.



Modified: haiku/trunk/src/apps/terminal/Arguments.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/Arguments.cpp 2010-01-04 18:34:52 UTC (rev 
34893)
+++ haiku/trunk/src/apps/terminal/Arguments.cpp 2010-01-04 18:37:37 UTC (rev 
34894)
@@ -19,7 +19,7 @@
          fShellArguments(NULL),
          fTitle(NULL)
 {
-       const char *argv[] = { "/bin/sh", "--login" };
+       const char *argv[] = { "/bin/bash", "--login" };
 
        _SetShellArguments(2, argv);
 }

Modified: haiku/trunk/src/apps/terminal/BasicTerminalBuffer.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/BasicTerminalBuffer.cpp       2010-01-04 
18:34:52 UTC (rev 34893)
+++ haiku/trunk/src/apps/terminal/BasicTerminalBuffer.cpp       2010-01-04 
18:37:37 UTC (rev 34894)
@@ -13,7 +13,6 @@
 
 #include <String.h>
 
-#include "CodeConv.h"
 #include "TermConst.h"
 #include "TerminalCharClassifier.h"
 #include "TerminalLine.h"
@@ -550,8 +549,6 @@
 {
 //debug_printf("BasicTerminalBuffer::InsertChar('%.*s' (%d), %#lx)\n",
 //(int)c.ByteCount(), c.bytes, c.bytes[0], attributes);
-       // TODO: Check if this method can be removed completely
-       //int width = CodeConv::UTF8GetFontWidth(c.bytes);
        if ((int32)width == FULL_WIDTH)
                attributes |= A_WIDTH;
 
@@ -589,8 +586,6 @@
 void
 BasicTerminalBuffer::FillScreen(UTF8Char c, uint32 width, uint32 attributes)
 {
-       // TODO: Check if this method can be removed completely
-       //int width = CodeConv::UTF8GetFontWidth(c.bytes);
        if ((int32)width == FULL_WIDTH)
                attributes |= A_WIDTH;
 

Modified: haiku/trunk/src/apps/terminal/Encoding.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/Encoding.cpp  2010-01-04 18:34:52 UTC (rev 
34893)
+++ haiku/trunk/src/apps/terminal/Encoding.cpp  2010-01-04 18:37:37 UTC (rev 
34894)
@@ -4,6 +4,7 @@
  */
 
 #include "Encoding.h"
+#include "TermConst.h"
 
 #include <string.h>
 

Modified: haiku/trunk/src/apps/terminal/Encoding.h
===================================================================
--- haiku/trunk/src/apps/terminal/Encoding.h    2010-01-04 18:34:52 UTC (rev 
34893)
+++ haiku/trunk/src/apps/terminal/Encoding.h    2010-01-04 18:37:37 UTC (rev 
34894)
@@ -35,7 +35,6 @@
 #include <SupportDefs.h>
 #include <UTF8.h>
 
-#define M_UTF8 (-1)
 
 status_t       get_next_encoding(int i, int *id);
 

Modified: haiku/trunk/src/apps/terminal/Jamfile
===================================================================
--- haiku/trunk/src/apps/terminal/Jamfile       2010-01-04 18:34:52 UTC (rev 
34893)
+++ haiku/trunk/src/apps/terminal/Jamfile       2010-01-04 18:37:37 UTC (rev 
34894)
@@ -8,7 +8,6 @@
        AppearPrefView.cpp
        Arguments.cpp
        BasicTerminalBuffer.cpp
-       CodeConv.cpp
        Encoding.cpp
        FindWindow.cpp
        Globals.cpp
@@ -25,7 +24,6 @@
        TermScrollView.cpp
        TermView.cpp
        TermWindow.cpp
-       UTF8WidthTbl.c
        VTKeyTbl.c
        VTPrsTbl.c
        : be tracker textencoding $(TARGET_LIBSUPC++)

Modified: haiku/trunk/src/apps/terminal/TermConst.h
===================================================================
--- haiku/trunk/src/apps/terminal/TermConst.h   2010-01-04 18:34:52 UTC (rev 
34893)
+++ haiku/trunk/src/apps/terminal/TermConst.h   2010-01-04 18:37:37 UTC (rev 
34894)
@@ -152,6 +152,8 @@
   SCRDOWN
 };
 
+#define M_UTF8 -1
+
 #define TAB_WIDTH 8
 
 #define MIN_COLS 10

Modified: haiku/trunk/src/apps/terminal/TermParse.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/TermParse.cpp 2010-01-04 18:34:52 UTC (rev 
34893)
+++ haiku/trunk/src/apps/terminal/TermParse.cpp 2010-01-04 18:37:37 UTC (rev 
34894)
@@ -19,8 +19,8 @@
 #include <Autolock.h>
 #include <Beep.h>
 #include <Message.h>
+#include <UTF8.h>
 
-#include "CodeConv.h"
 #include "TermConst.h"
 #include "TerminalBuffer.h"
 #include "VTparse.h"
@@ -47,19 +47,17 @@
 
 
 //! Get char from pty reader buffer.
-inline status_t
-TermParse::_NextParseChar(uchar &c)
+inline uchar
+TermParse::_NextParseChar()
 {
        if (fParserBufferOffset >= fParserBufferSize) {
                // parser buffer empty
                status_t error = _ReadParserBuffer();
                if (error != B_OK)
-                       return error;
+                       throw error;
        }
 
-       c = fParserBuffer[fParserBufferOffset++];
-
-       return B_OK;
+       return fParserBuffer[fParserBufferOffset++];
 }
 
 
@@ -94,14 +92,14 @@
 
        fQuitting = false;
        fBuffer = buffer;
-
-       status_t status = InitPtyReader();
+       
+       status_t status = _InitPtyReader();
        if (status < B_OK) {
                fBuffer = NULL;
                return status;
        }
 
-       status = InitTermParse();
+       status = _InitTermParse();
        if (status < B_OK) {
                StopPtyReader();
                fBuffer = NULL;
@@ -120,8 +118,8 @@
 
        fQuitting = true;
 
-       StopPtyReader();
-       StopTermParse();
+       _StopPtyReader();
+       _StopTermParse();
 
        fBuffer = NULL;
 
@@ -131,7 +129,7 @@
 
 //! Initialize and spawn EscParse thread.
 status_t
-TermParse::InitTermParse()
+TermParse::_InitTermParse()
 {
        if (fParseThread >= 0)
                return B_ERROR; // we might want to return B_OK instead ?
@@ -139,6 +137,9 @@
        fParseThread = spawn_thread(_escparse_thread, "EscParse",
                B_DISPLAY_PRIORITY, this);
 
+       if (fParseThread < 0)
+               return fParseThread;
+               
        resume_thread(fParseThread);
 
        return B_OK;
@@ -147,7 +148,7 @@
 
 //! Initialize and spawn PtyReader thread.
 status_t
-TermParse::InitPtyReader()
+TermParse::_InitPtyReader()
 {
        if (fReaderThread >= 0)
                return B_ERROR; // same as above
@@ -180,7 +181,7 @@
 
 
 void
-TermParse::StopTermParse()
+TermParse::_StopTermParse()
 {
        if (fParseThread >= 0) {
                status_t dummy;
@@ -191,7 +192,7 @@
 
 
 void
-TermParse::StopPtyReader()
+TermParse::_StopPtyReader()
 {
        if (fReaderSem >= 0) {
                delete_sem(fReaderSem);
@@ -287,13 +288,15 @@
        };
        int i;
        fprintf(stderr, "groundtable: ");
-       for (i = 0; tables[i].p; i++)
+       for (i = 0; tables[i].p; i++) {
                if (tables[i].p == groundtable)
                        fprintf(stderr, "%s\t", tables[i].name);
+       }
        fprintf(stderr, "parsestate: ");
-       for (i = 0; tables[i].p; i++)
+       for (i = 0; tables[i].p; i++) {
                if (tables[i].p == parsestate)
                        fprintf(stderr, "%s\t", tables[i].name);
+       }
        fprintf(stderr, "char: 0x%02x (%d)\n", c, c);
 }
 
@@ -301,708 +304,726 @@
 int32
 TermParse::EscParse()
 {
-       int top, bot;
+       int top;
+       int bottom;
        int cs96 = 0;
        uchar curess = 0;
 
-       char cbuf[4], dstbuf[4];
+       char cbuf[4];
+       char dstbuf[4];
        char *ptr;
 
-       int now_coding = -1;
+       int currentEncoding = -1;
 
        int param[NPARAM];
        int nparam = 1;
 
-       int row, col;
+       int row;
+       int column;
 
-       /* default coding system is UTF8 */
+       /* default encoding system is UTF8 */
        int *groundtable = gUTF8GroundTable;
-       int *parsestate = groundtable;
+       int *parsestate = gUTF8GroundTable;
 
+       int32 srcLen;
+       int32 dstLen;
+       long dummyState = 0;
+                                       
        int width = 1;
        BAutolock locker(fBuffer);
 
        fAttr = fSavedAttr = BACKCOLOR;
 
        while (!fQuitting) {
-               uchar c;
-               if (_NextParseChar(c) < B_OK)
-                       break;
+               try {
+                       uchar c = _NextParseChar();
 
-               //DumpState(groundtable, parsestate, c);
+                       //DumpState(groundtable, parsestate, c);
 
-               if (now_coding != fBuffer->Encoding()) {
-                       /*
-                        * Change coding, change parse table.
-                        */
-                       switch (fBuffer->Encoding()) {
-                               case B_ISO1_CONVERSION:
-                               case B_ISO2_CONVERSION:
-                               case B_ISO3_CONVERSION:
-                               case B_ISO4_CONVERSION:
-                               case B_ISO5_CONVERSION:
-                               case B_ISO6_CONVERSION:
-                               case B_ISO7_CONVERSION:
-                               case B_ISO8_CONVERSION:
-                               case B_ISO9_CONVERSION:
-                               case B_ISO10_CONVERSION:
-                                       groundtable = gISO8859GroundTable;
-                                       break;
-                               case B_SJIS_CONVERSION:
-                                       groundtable = gSJISGroundTable;
-                                       break;
-                               case B_EUC_CONVERSION:
-                               case B_EUC_KR_CONVERSION:
-                               case B_JIS_CONVERSION:
-                               case B_GBK_CONVERSION:
-                               case B_BIG5_CONVERSION:
-                                       groundtable = gISO8859GroundTable;
-                                       break;
-                               case M_UTF8:
-                               default:
-                                       groundtable = gUTF8GroundTable;
-                                       break;
+                       if (currentEncoding != fBuffer->Encoding()) {
+                               /*
+                                * Change coding, change parse table.
+                                */
+                               switch (fBuffer->Encoding()) {
+                                       case B_ISO1_CONVERSION:
+                                       case B_ISO2_CONVERSION:
+                                       case B_ISO3_CONVERSION:
+                                       case B_ISO4_CONVERSION:
+                                       case B_ISO5_CONVERSION:
+                                       case B_ISO6_CONVERSION:
+                                       case B_ISO7_CONVERSION:
+                                       case B_ISO8_CONVERSION:
+                                       case B_ISO9_CONVERSION:
+                                       case B_ISO10_CONVERSION:
+                                               groundtable = 
gISO8859GroundTable;
+                                               break;
+                                       case B_SJIS_CONVERSION:
+                                               groundtable = gSJISGroundTable;
+                                               break;
+                                       case B_EUC_CONVERSION:
+                                       case B_EUC_KR_CONVERSION:
+                                       case B_JIS_CONVERSION:
+                                       case B_GBK_CONVERSION:
+                                       case B_BIG5_CONVERSION:
+                                               groundtable = 
gISO8859GroundTable;
+                                               break;
+                                       case M_UTF8:
+                                       default:
+                                               groundtable = gUTF8GroundTable;
+                                               break;
+                               }
+                               parsestate = groundtable;
+                               currentEncoding = fBuffer->Encoding();
                        }
-                       parsestate = groundtable;
-                       now_coding = fBuffer->Encoding();
-       }
 
-//debug_printf("TermParse: char: '%c' (%d), parse state: %d\n", c, c, 
parsestate[c]);
-               switch (parsestate[c]) {
-                       case CASE_PRINT:
-                               fBuffer->InsertChar((char)c, fAttr);
-                               break;
+       //debug_printf("TermParse: char: '%c' (%d), parse state: %d\n", c, c, 
parsestate[c]);
+                       switch (parsestate[c]) {
+                               case CASE_PRINT:
+                                       fBuffer->InsertChar((char)c, fAttr);
+                                       break;
 
-                       case CASE_PRINT_GR:
-                               /* case iso8859 gr character, or euc */
-                               ptr = cbuf;
-                               if (now_coding == B_EUC_CONVERSION
-                                       || now_coding == B_EUC_KR_CONVERSION
-                                       || now_coding == B_JIS_CONVERSION
-                                       || now_coding == B_GBK_CONVERSION
-                                       || now_coding == B_BIG5_CONVERSION) {
-                                       switch (parsestate[curess]) {
-                                               case CASE_SS2:          /* JIS 
X 0201 */
-                                                       width = 1;
-                                                       *ptr++ = curess;
-                                                       *ptr++ = c;
-                                                       *ptr = 0;
-                                                       curess = 0;
-                                                       break;
+                               case CASE_PRINT_GR:
+                                       /* case iso8859 gr character, or euc */
+                                       ptr = cbuf;
+                                       if (currentEncoding == B_EUC_CONVERSION
+                                               || currentEncoding == 
B_EUC_KR_CONVERSION
+                                               || currentEncoding == 
B_JIS_CONVERSION
+                                               || currentEncoding == 
B_GBK_CONVERSION
+                                               || currentEncoding == 
B_BIG5_CONVERSION) {
+                                               switch (parsestate[curess]) {
+                                                       case CASE_SS2:          
/* JIS X 0201 */
+                                                               width = 1;
+                                                               *ptr++ = curess;
+                                                               *ptr++ = c;
+                                                               *ptr = 0;
+                                                               curess = 0;
+                                                               break;
 
-                                               case CASE_SS3:          /* JIS 
X 0212 */
-                                                       width = 1;
-                                                       *ptr++ = curess;
-                                                       *ptr++ = c;
-                                                       _NextParseChar(c);
-                                                       *ptr++ = c;
-                                                       *ptr = 0;
-                                                       curess = 0;
-                                                       break;
+                                                       case CASE_SS3:          
/* JIS X 0212 */
+                                                               width = 1;
+                                                               *ptr++ = curess;
+                                                               *ptr++ = c;
+                                                               c = 
_NextParseChar();
+                                                               *ptr++ = c;
+                                                               *ptr = 0;
+                                                               curess = 0;
+                                                               break;
 
-                                               default:                /* JIS 
X 0208 */
-                                                       width = 2;
-                                                       *ptr++ = c;
-                                                       _NextParseChar(c);
-                                                       *ptr++ = c;
-                                                       *ptr = 0;
-                                                       break;
+                                                       default:                
/* JIS X 0208 */
+                                                               width = 2;
+                                                               *ptr++ = c;
+                                                               c = 
_NextParseChar();
+                                                               *ptr++ = c;
+                                                               *ptr = 0;
+                                                               break;
+                                               }
+                                       } else {
+                                               /* ISO-8859-1...10 and MacRoman 
*/
+                                               *ptr++ = c;
+                                               *ptr = 0;
                                        }
-                               } else {
-                                       /* ISO-8859-1...10 and MacRoman */
-                                       *ptr++ = c;
-                                       *ptr = 0;
-                               }
 
-                               if (now_coding != B_JIS_CONVERSION) {
-                                       CodeConv::ConvertToInternal(cbuf, -1, 
dstbuf, now_coding);
-                               } else {
-                                       CodeConv::ConvertToInternal(cbuf, -1, 
dstbuf,
-                                               B_EUC_CONVERSION);
-                               }
+                                       srcLen = strlen(cbuf);
+                                       if (currentEncoding != 
B_JIS_CONVERSION) {
+                                               
convert_to_utf8(currentEncoding, cbuf, &srcLen,
+                                                       dstbuf, &dstLen, 
&dummyState, '?');
+                                       } else {
+                                               
convert_to_utf8(B_EUC_CONVERSION, cbuf, &srcLen,
+                                                       dstbuf, &dstLen, 
&dummyState, '?');
+                                       }
 
-                               fBuffer->InsertChar(dstbuf, 4, width, fAttr);
-                               break;
+                                       fBuffer->InsertChar(dstbuf, dstLen, 
width, fAttr);
+                                       break;
 
-                       case CASE_PRINT_CS96:
-                               cbuf[0] = c | 0x80;
-                               _NextParseChar(c);
-                               cbuf[1] = c | 0x80;
-                               cbuf[2] = 0;
-                               CodeConv::ConvertToInternal(cbuf, 2, dstbuf, 
B_EUC_CONVERSION);
-                               fBuffer->InsertChar(dstbuf, 4, fAttr);
-                               break;
+                               case CASE_PRINT_CS96:
+                                       cbuf[0] = c | 0x80;
+                                       c = _NextParseChar();
+                                       cbuf[1] = c | 0x80;
+                                       cbuf[2] = 0;
+                                       srcLen = 2;
+                                       dstLen = 0;
+                                       convert_to_utf8(B_EUC_CONVERSION, cbuf, 
&srcLen,
+                                               dstbuf, &dstLen, &dummyState, 
'?');
+                                       fBuffer->InsertChar(dstbuf, dstLen, 
fAttr);
+                                       break;
 
-                       case CASE_LF:
-                               fBuffer->InsertLF();
-                               break;
+                               case CASE_LF:
+                                       fBuffer->InsertLF();
+                                       break;
 
-                       case CASE_CR:
-                               fBuffer->InsertCR();
-                               break;
-
-                       case CASE_SJIS_KANA:
-                               cbuf[0] = c;
-                               cbuf[1] = '\0';
-                               CodeConv::ConvertToInternal(cbuf, 1, dstbuf, 
now_coding);
-                               fBuffer->InsertChar(dstbuf, 4, fAttr);
-                               break;
-
-                       case CASE_SJIS_INSTRING:
-                               cbuf[0] = c;
-                               _NextParseChar(c);
-                               cbuf[1] = c;
-                               cbuf[2] = '\0';
-                               CodeConv::ConvertToInternal(cbuf, 2, dstbuf, 
now_coding);
-                               fBuffer->InsertChar(dstbuf, 4, fAttr);
-                               break;
-
-                       case CASE_UTF8_2BYTE:
-                               cbuf[0] = c;
-                               _NextParseChar(c);
-                               if (groundtable[c] != CASE_UTF8_INSTRING)
+                               case CASE_CR:
+                                       fBuffer->InsertCR();
                                        break;
-                               cbuf[1] = c;
-                               cbuf[2] = '\0';
 
-                               fBuffer->InsertChar(cbuf, 2, fAttr);
-                               break;
-
-                       case CASE_UTF8_3BYTE:
-                               cbuf[0] = c;
-                               _NextParseChar(c);
-                               if (groundtable[c] != CASE_UTF8_INSTRING)
+                               case CASE_SJIS_KANA:
+                                       cbuf[0] = c;
+                                       cbuf[1] = '\0';
+                                       srcLen = 1;
+                                       dstLen = 0;
+                                       convert_to_utf8(currentEncoding, cbuf, 
&srcLen,
+                                               dstbuf, &dstLen, &dummyState, 
'?');
+                                       fBuffer->InsertChar(dstbuf, dstLen, 
fAttr);
                                        break;
-                               cbuf[1] = c;
 
-                               _NextParseChar(c);
-                               if (groundtable[c] != CASE_UTF8_INSTRING)
+                               case CASE_SJIS_INSTRING:
+                                       cbuf[0] = c;
+                                       c = _NextParseChar();
+                                       cbuf[1] = c;
+                                       cbuf[2] = '\0';
+                                       srcLen = 2;
+                                       dstLen = 0;
+                                       convert_to_utf8(currentEncoding, cbuf, 
&srcLen,
+                                               dstbuf, &dstLen, &dummyState, 
'?');
+                                       fBuffer->InsertChar(dstbuf, dstLen, 
fAttr);
                                        break;
-                               cbuf[2] = c;
-                               cbuf[3] = '\0';
-                               fBuffer->InsertChar(cbuf, 3, fAttr);
-                               break;
 
-                       case CASE_MBCS:
-                               /* ESC $ */
-                               parsestate = gMbcsTable;
-                               break;
+                               case CASE_UTF8_2BYTE:
+                                       cbuf[0] = c;
+                                       c = _NextParseChar();
+                                       if (groundtable[c] != 
CASE_UTF8_INSTRING)
+                                               break;
+                                       cbuf[1] = c;
+                                       cbuf[2] = '\0';
 
-                       case CASE_GSETS:
-                               /* ESC $ ? */
-                               parsestate = gCS96GroundTable;
-                               cs96 = 1;
-                               break;
+                                       fBuffer->InsertChar(cbuf, 2, fAttr);
+                                       break;
 
-                       case CASE_SCS_STATE:
-                       {
-                               cs96 = 0;
-                               uchar dummy;
-                               _NextParseChar(dummy);
-                               parsestate = groundtable;
-                               break;
-                       }
-                       case CASE_GROUND_STATE:
-                               /* exit ignore mode */
-                               parsestate = groundtable;
-                               break;
+                               case CASE_UTF8_3BYTE:
+                                       cbuf[0] = c;
+                                       c = _NextParseChar();
+                                       if (groundtable[c] != 
CASE_UTF8_INSTRING)
+                                               break;
+                                       cbuf[1] = c;
 
-                       case CASE_BELL:
-                               beep();
-                               break;
+                                       c = _NextParseChar();
+                                       if (groundtable[c] != 
CASE_UTF8_INSTRING)
+                                               break;
+                                       cbuf[2] = c;
+                                       cbuf[3] = '\0';
+                                       fBuffer->InsertChar(cbuf, 3, fAttr);
+                                       break;
 
-                       case CASE_BS:
-                               fBuffer->MoveCursorLeft(1);
-                               break;
+                               case CASE_MBCS:
+                                       /* ESC $ */
+                                       parsestate = gMbcsTable;
+                                       break;
 
-                       case CASE_TAB:
-                               fBuffer->InsertTab();
-                               break;
+                               case CASE_GSETS:
+                                       /* ESC $ ? */
+                                       parsestate = gCS96GroundTable;
+                                       cs96 = 1;
+                                       break;
 
-                       case CASE_ESC:
-                               /* escape */
-                               parsestate = gEscTable;
-                               break;
+                               case CASE_SCS_STATE:
+                               {
+                                       cs96 = 0;
+                                       _NextParseChar();
+                                               // skip next char
+                                       parsestate = groundtable;
+                                       break;
+                               }
+                               case CASE_GROUND_STATE:
+                                       /* exit ignore mode */
+                                       parsestate = groundtable;
+                                       break;
 
-                       case CASE_IGNORE_STATE:
-                               /* Ies: ignore anything else */
-                               parsestate = gIgnoreTable;
-                               break;
+                               case CASE_BELL:
+                                       beep();
+                                       break;
 
-                       case CASE_IGNORE_ESC:
-                               /* Ign: escape */
-                               parsestate = gIesTable;
-                               break;
+                               case CASE_BS:
+                                       fBuffer->MoveCursorLeft(1);
+                                       break;
 
-                       case CASE_IGNORE:
-                               /* Ignore character */
-                               break;
+                               case CASE_TAB:
+                                       fBuffer->InsertTab();
+                                       break;
 
-                       case CASE_SI:
-                               break;
+                               case CASE_ESC:
+                                       /* escape */
+                                       parsestate = gEscTable;
+                                       break;
 
-                       case CASE_SO:
-                               break;
+                               case CASE_IGNORE_STATE:
+                                       /* Ies: ignore anything else */
+                                       parsestate = gIgnoreTable;
+                                       break;
 
-                       case CASE_SCR_STATE:    // ESC #
-                               /* enter scr state */
-                               parsestate = gScrTable;
-                               break;
+                               case CASE_IGNORE_ESC:
+                                       /* Ign: escape */
+                                       parsestate = gIesTable;
+                                       break;
 
-                       case CASE_ESC_IGNORE:
-                               /* unknown escape sequence */
-                               parsestate = gEscIgnoreTable;
-                               break;
+                               case CASE_IGNORE:
+                                       /* Ignore character */
+                                       break;
 
-                       case CASE_ESC_DIGIT:    // ESC [ number
-                               /* digit in csi or dec mode */
-                               if ((row = param[nparam - 1]) == DEFAULT)
-                                       row = 0;
-                               param[nparam - 1] = 10 * row + (c - '0');
-                               break;
+                               case CASE_SI:
+                                       break;
 
-                       case CASE_ESC_SEMI:             // ESC ;
-                               /* semicolon in csi or dec mode */
-                               if (nparam < NPARAM)
-                                       param[nparam++] = DEFAULT;
-                               break;
+                               case CASE_SO:
+                                       break;
 
-                       case CASE_DEC_STATE:
-                               /* enter dec mode */
-                               parsestate = gDecTable;
-                               break;
+                               case CASE_SCR_STATE:    // ESC #
+                                       /* enter scr state */
+                                       parsestate = gScrTable;
+                                       break;
 
-                       case CASE_ICH:          // ESC [@ insert charactor
-                               /* ICH */
-                               if ((row = param[0]) < 1)
-                                       row = 1;
-                               fBuffer->InsertSpace(row);
-                               parsestate = groundtable;
-                               break;
+                               case CASE_ESC_IGNORE:
+                                       /* unknown escape sequence */
+                                       parsestate = gEscIgnoreTable;
+                                       break;
 
-                       case CASE_CUU:          // ESC [A cursor up, up arrow 
key.
-                               /* CUU */
-                               if ((row = param[0]) < 1)
-                                       row = 1;
-                               fBuffer->MoveCursorUp(row);
-                               parsestate = groundtable;
-                               break;
+                               case CASE_ESC_DIGIT:    // ESC [ number
+                                       /* digit in csi or dec mode */
+                                       if ((row = param[nparam - 1]) == 
DEFAULT)
+                                               row = 0;
+                                       param[nparam - 1] = 10 * row + (c - 
'0');
+                                       break;
 
-                       case CASE_CUD:          // ESC [B cursor down, down 
arrow key.
-                               /* CUD */
-                               if ((row = param[0]) < 1)
-                                       row = 1;
-                               fBuffer->MoveCursorDown(row);
-                               parsestate = groundtable;
-                               break;
+                               case CASE_ESC_SEMI:             // ESC ;
+                                       /* semicolon in csi or dec mode */
+                                       if (nparam < NPARAM)
+                                               param[nparam++] = DEFAULT;
+                                       break;
 
-                       case CASE_CUF:          // ESC [C cursor forword
-                               /* CUF */
-                               if ((row = param[0]) < 1)
-                                       row = 1;
-                               fBuffer->MoveCursorRight(row);
-                               parsestate = groundtable;
-                               break;
+                               case CASE_DEC_STATE:
+                                       /* enter dec mode */
+                                       parsestate = gDecTable;
+                                       break;
 
-                       case CASE_CUB:          // ESC [D cursor backword
-                               /* CUB */
-                               if ((row = param[0]) < 1)
-                                       row = 1;
-                               fBuffer->MoveCursorLeft(row);
-                               parsestate = groundtable;
-                               break;
+                               case CASE_ICH:          // ESC [@ insert 
charactor
+                                       /* ICH */
+                                       if ((row = param[0]) < 1)
+                                               row = 1;
+                                       fBuffer->InsertSpace(row);
+                                       parsestate = groundtable;
+                                       break;
 
-                       case CASE_CUP:          // ESC [...H move cursor
-                               /* CUP | HVP */
-                               if ((row = param[0]) < 1)
-                                       row = 1;
-                               if (nparam < 2 || (col = param[1]) < 1)
-                                       col = 1;
+                               case CASE_CUU:          // ESC [A cursor up, up 
arrow key.
+                                       /* CUU */
+                                       if ((row = param[0]) < 1)
+                                               row = 1;
+                                       fBuffer->MoveCursorUp(row);
+                                       parsestate = groundtable;
+                                       break;
 
-                               fBuffer->SetCursor(col - 1, row - 1 );
-                               parsestate = groundtable;
-                               break;
+                               case CASE_CUD:          // ESC [B cursor down, 
down arrow key.
+                                       /* CUD */
+                                       if ((row = param[0]) < 1)
+                                               row = 1;
+                                       fBuffer->MoveCursorDown(row);
+                                       parsestate = groundtable;
+                                       break;
 
-                       case CASE_ED:           // ESC [ ...J clear screen
-                               /* ED */
-                               switch (param[0]) {
-                                       case DEFAULT:
-                                       case 0:
-                                               fBuffer->EraseBelow();
-                                               break;
+                               case CASE_CUF:          // ESC [C cursor forword
+                                       /* CUF */
+                                       if ((row = param[0]) < 1)
+                                               row = 1;
+                                       fBuffer->MoveCursorRight(row);
+                                       parsestate = groundtable;
+                                       break;
 
-                                       case 1:
-                                               fBuffer->EraseAbove();
-                                               break;
+                               case CASE_CUB:          // ESC [D cursor 
backword
+                                       /* CUB */
+                                       if ((row = param[0]) < 1)
+                                               row = 1;
+                                       fBuffer->MoveCursorLeft(row);
+                                       parsestate = groundtable;
+                                       break;
 
-                                       case 2:
-                                               fBuffer->EraseAll();
-                                               break;
-                               }
-                               parsestate = groundtable;
-                               break;
+                               case CASE_CUP:          // ESC [...H move cursor
+                                       /* CUP | HVP */
+                                       if ((row = param[0]) < 1)
+                                               row = 1;
+                                       if (nparam < 2 || (column = param[1]) < 
1)
+                                               column = 1;
 
-                       case CASE_EL:           // ESC [ ...K delete line
-                               /* EL */
-                               switch (param[0]) {
-                                       case DEFAULT:
-                                       case 0:
-                                               fBuffer->DeleteColumns();
-                                               break;
+                                       fBuffer->SetCursor(column - 1, row - 1 
);
+                                       parsestate = groundtable;
+                                       break;
 
-                                       case 1:
-                                               fBuffer->EraseCharsFrom(0, 
fBuffer->Cursor().x + 1);
-                                               break;
-
-                                       case 2:
-                                               fBuffer->DeleteColumnsFrom(0);
-                                               break;
-                               }
-                               parsestate = groundtable;
-                               break;
-
-                       case CASE_IL:
-                               /* IL */
-                               if ((row = param[0]) < 1)
-                                       row = 1;
-                               fBuffer->InsertLines(row);
-                               parsestate = groundtable;
-                               break;
-
-                       case CASE_DL:
-                               /* DL */
-                               if ((row = param[0]) < 1)
-                                       row = 1;
-                               fBuffer->DeleteLines(row);
-                               parsestate = groundtable;
-                               break;
-
-                       case CASE_DCH:
-                               /* DCH */
-                               if ((row = param[0]) < 1)
-                                       row = 1;
-                               fBuffer->DeleteChars(row);
-                               parsestate = groundtable;
-                               break;
-
-                       case CASE_SET:
-                               /* SET */
-                               if (param[0] == 4)
-                                       fBuffer->SetInsertMode(MODE_INSERT);
-                               parsestate = groundtable;
-                               break;
-
-                       case CASE_RST:
-                               /* RST */
-                               if (param[0] == 4)
-                                       fBuffer->SetInsertMode(MODE_OVER);
-                               parsestate = groundtable;
-                               break;
-
-                       case CASE_SGR:
-                               /* SGR */
-                               for (row = 0; row < nparam; ++row) {
-                                       switch (param[row]) {
+                               case CASE_ED:           // ESC [ ...J clear 
screen
+                                       /* ED */
+                                       switch (param[0]) {
                                                case DEFAULT:
-                                               case 0: /* Reset attribute */
-                                                       fAttr = 0;
+                                               case 0:
+                                                       fBuffer->EraseBelow();
                                                        break;
 
                                                case 1:
-                                               case 5: /* Bold         */
-                                                       fAttr |= BOLD;
+                                                       fBuffer->EraseAbove();
                                                        break;
 
-                                               case 4: /* Underline    */
-                                                       fAttr |= UNDERLINE;
+                                               case 2:
+                                                       fBuffer->EraseAll();
                                                        break;
+                                       }
+                                       parsestate = groundtable;
+                                       break;
 
-                                               case 7: /* Inverse      */
-                                                       fAttr |= INVERSE;
+                               case CASE_EL:           // ESC [ ...K delete 
line
+                                       /* EL */
+                                       switch (param[0]) {
+                                               case DEFAULT:
+                                               case 0:
+                                                       
fBuffer->DeleteColumns();
                                                        break;
 
-                                               case 22:        /* Not Bold     
*/
-                                                       fAttr &= ~BOLD;
+                                               case 1:
+                                                       
fBuffer->EraseCharsFrom(0, fBuffer->Cursor().x + 1);
                                                        break;
 
-                                               case 24:        /* Not 
Underline        */
-                                                       fAttr &= ~UNDERLINE;
+                                               case 2:
+                                                       
fBuffer->DeleteColumnsFrom(0);
                                                        break;
-
-                                               case 27:        /* Not Inverse  
*/
-                                                       fAttr &= ~INVERSE;
-                                                       break;
-
-                                               case 30:
-                                               case 31:
-                                               case 32:
-                                               case 33:
-                                               case 34:
-                                               case 35:
-                                               case 36:
-                                               case 37:
-                                                       fAttr &= ~FORECOLOR;
-                                                       fAttr |= 
FORECOLORED(param[row] - 30);
-                                                       fAttr |= FORESET;
-                                                       break;
-
-                                               case 39:
-                                                       fAttr &= ~FORESET;
-                                                       break;
-
-                                               case 40:
-                                               case 41:
-                                               case 42:
-                                               case 43:
-                                               case 44:
-                                               case 45:
-                                               case 46:
-                                               case 47:
-                                                       fAttr &= ~BACKCOLOR;
-                                                       fAttr |= 
BACKCOLORED(param[row] - 40);
-                                                       fAttr |= BACKSET;
-                                                       break;
-
-                                               case 49:
-                                                       fAttr &= ~BACKSET;

[... truncated: 614 lines follow ...]

Other related posts: