X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fdrv%2Fvterm_vt100.c;h=c054e75e79e351fa65efc1d49725d55c65cf119c;hb=ea487239a8b3632d13c6e4ec92d21f0fcd460bdd;hp=6e7910158523b0113cc7b4f9cfe51c1afd6b6f13;hpb=281dc40f1891f368873b0380c58c443669fd958c;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/drv/vterm_vt100.c b/KernelLand/Kernel/drv/vterm_vt100.c index 6e791015..c054e75e 100644 --- a/KernelLand/Kernel/drv/vterm_vt100.c +++ b/KernelLand/Kernel/drv/vterm_vt100.c @@ -139,7 +139,6 @@ void VT_int_ParseEscape_StandardLarge(tVTerm *Term, char CmdChar, int argc, int Term->WritePos = args[0] + args[1]*Term->TextWidth; //Log_Debug("VTerm", "args = {%i, %i}", args[0], args[1]); break; - // Scroll up `n` lines case 'S': tmp = -1; @@ -158,7 +157,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--; ) @@ -196,7 +211,7 @@ void VT_int_ParseEscape_StandardLarge(tVTerm *Term, char CmdChar, int argc, int } // Background Colour - bright else if(100 <= args[argc] && args[argc] <= 107 ) { - colour_idx = args[argc]-10 + 8; + colour_idx = args[argc]-100 + 8; Term->CurColour &= 0xFFFF8000; Term->CurColour |= (Uint32)caVT100Colours[ colour_idx ]; } @@ -212,7 +227,19 @@ void VT_int_ParseEscape_StandardLarge(tVTerm *Term, char CmdChar, int argc, int Term->ScrollTop = args[0]; Term->ScrollHeight = args[1] - args[0]; break; - + + // Save cursor position + case 's': + if( argc != 0 ) break; + Term->SavedWritePos = (Term->Flags & VT_FLAG_ALTBUF) ? Term->AltWritePos : Term->WritePos; + break; + + // Restore saved cursor position + case 'u': + if( argc != 0 ) break; + *((Term->Flags & VT_FLAG_ALTBUF) ? &Term->AltWritePos : &Term->WritePos) = Term->SavedWritePos; + break; + default: Log_Warning("VTerm", "Unknown control sequence '\\x1B[%c'", CmdChar); break; @@ -229,8 +256,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); - if( Bytes == j ) return j; + 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-ofs; c = Buffer[j++]; switch(c) @@ -238,24 +281,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 +308,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 ) @@ -311,6 +356,12 @@ int VT_int_ParseEscape(tVTerm *Term, const char *Buffer, size_t Bytes) case '\0': // Ignore \0 break; + // Reset all attributes + case 'c': + Term->CurColour = DEFAULT_COLOUR; + Term->Flags = 0; + Term->ScrollHeight = 0; + break; default: //Log_Notice("VTerm", "TODO: Handle short escape codes"); { @@ -325,5 +376,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; }