Merge branch 'master' of git://cadel.mutabah.net/acess2
[tpg/acess2.git] / KernelLand / Kernel / drv / vterm_vt100.c
index 6d123e5..1f34479 100644 (file)
@@ -158,7 +158,23 @@ void VT_int_ParseEscape_StandardLarge(tVTerm *Term, char CmdChar, int argc, int
                        Term->ViewPos += Term->TextWidth*tmp;
                }
                break;
-       
+       // Set Mode (?)
+       case 'h':
+               if( argc >= 1 )
+               {
+                       switch(args[0])
+                       {
+                       case 2: // Keyboard action mode
+                       case 4: // Insert mode
+                       case 12:        // Send/receive
+                       case 20:        // Automatic newline
+                               break;
+                       default:        // ?
+                               break;
+                       }
+               }
+               break;
+               
        // Set Font flags
        case 'm':
                for( ; argc--; )
@@ -229,8 +245,24 @@ int VT_int_ParseEscape(tVTerm *Term, const char *Buffer, size_t Bytes)
         int    argc = 0, j = 0;
         int    args[6] = {0,0,0,0};
         int    bQuestionMark = 0;
+       const int       ofs = Term->EscapeCodeLen;
+       const int       sparespace = sizeof(Term->EscapeCodeCache)-Term->EscapeCodeLen;
+       const int       copysize = MIN(Bytes, sparespace);
+
+       memcpy( Term->EscapeCodeCache + Term->EscapeCodeLen, Buffer, copysize );
+       Term->EscapeCodeLen += copysize;
+       
+       Bytes = Term->EscapeCodeLen;
+       Buffer = Term->EscapeCodeCache;
+
+       if( Bytes == j )        return j-ofs;
+       c = Buffer[j++];
+       if(c != '\x1b') {
+               Term->EscapeCodeLen = 0;
+               return 0;
+       }
 
-       if( Bytes == j )        return j;
+       if( Bytes == j )        return j-ofs;
        c = Buffer[j++];
 
        switch(c)
@@ -238,24 +270,24 @@ int VT_int_ParseEscape(tVTerm *Term, const char *Buffer, size_t Bytes)
        //Large Code
        case '[':
                // Get Arguments
-               if(Bytes == j)  return j;
+               if(Bytes == j)  return j-ofs;
                c = Buffer[j++];
                if(c == '?') {
                        bQuestionMark = 1;
-                       if(Bytes == j)  return j;
+                       if(Bytes == j)  return j-ofs;
                        c = Buffer[j++];
                }
                if( '0' <= c && c <= '9' )
                {
                        do {
                                if(c == ';') {
-                                       if(Bytes == j)  return j;
+                                       if(Bytes == j)  return j-ofs;
                                        c = Buffer[j++];
                                }
                                while('0' <= c && c <= '9') {
                                        args[argc] *= 10;
                                        args[argc] += c-'0';
-                                       if(Bytes == j)  return j;
+                                       if(Bytes == j)  return j-ofs;
                                        c = Buffer[j++];
                                }
                                argc ++;
@@ -265,8 +297,10 @@ int VT_int_ParseEscape(tVTerm *Term, const char *Buffer, size_t Bytes)
                // Get Command
                if( !('a' <= c && c <= 'z') && !('A' <= c && c <= 'Z') )
                {
-                       // Error
-                       return j;
+                       // Error - eat ESC only?
+                       // > j : Entire code skipped
+                       Term->EscapeCodeLen = 0;
+                       return j-ofs;
                }
                
                if( bQuestionMark )
@@ -325,5 +359,6 @@ int VT_int_ParseEscape(tVTerm *Term, const char *Buffer, size_t Bytes)
        }
        
        //Log_Debug("VTerm", "j = %i, Buffer = '%s'", j, Buffer);
-       return j;
+       Term->EscapeCodeLen = 0;
+       return j-ofs;
 }

UCC git Repository :: git.ucc.asn.au