From: John Hodge (sonata) Date: Sun, 20 Jan 2013 10:45:15 +0000 (+0800) Subject: Usermode/GUITerminal - Text colouring and cursor X-Git-Tag: rel0.15~598^2~4 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=450d8178a7ef1708f69f1f3e0def83a78cbd1cee;p=tpg%2Facess2.git Usermode/GUITerminal - Text colouring and cursor --- diff --git a/Usermode/Applications/gui_shell_src/display.c b/Usermode/Applications/gui_shell_src/display.c index 4972ed13..06516345 100644 --- a/Usermode/Applications/gui_shell_src/display.c +++ b/Usermode/Applications/gui_shell_src/display.c @@ -42,6 +42,9 @@ void Display_Init(int Cols, int Lines, int ExtraScrollbackLines) gasDisplayLines = calloc( sizeof(char*), (Lines + ExtraScrollbackLines) ); gaiDisplayLineSizes = calloc( sizeof(int), (Lines + ExtraScrollbackLines) ); gabDisplayLinesDirty = calloc( sizeof(char), (Lines + ExtraScrollbackLines) ); + + AxWin3_RichText_SetLineCount(gMainWindow, Lines+ExtraScrollbackLines); + AxWin3_RichText_SetCursorType(gMainWindow, 1); // TODO: enum } void Display_int_PushString(int Length, const char *Text) @@ -59,6 +62,7 @@ void Display_int_PushString(int Length, const char *Text) memcpy(gasDisplayLines[giCurrentLine]+giCurrentLinePos, Text, Length); gabDisplayLinesDirty[giCurrentLine] = 1; gasDisplayLines[giCurrentLine][giCurrentLinePos+Length] = 0; + giCurrentLinePos += Length; } @@ -192,12 +196,16 @@ void Display_ClearLines(int Dir) // 0: All, 1: Forward, -1: Reverse void Display_SetForeground(uint32_t RGB) { - UNIMPLIMENTED(); + char buf[7+1]; + sprintf(buf, "\1%06x", RGB&0xFFFFFF); + Display_int_PushString(7, buf); } void Display_SetBackground(uint32_t RGB) { - UNIMPLIMENTED(); + char buf[7+1]; + sprintf(buf, "\2%06x", RGB&0xFFFFFF); + Display_int_PushString(7, buf); } void Display_Flush(void) @@ -214,7 +222,7 @@ void Display_Flush(void) } // force redraw? - AxWin3_FocusWindow(gMainWindow); + AxWin3_RichText_SetCursorPos(gMainWindow, giCurrentLine, giCurrentCol); } void Display_ShowAltBuffer(int AltBufEnabled) diff --git a/Usermode/Applications/gui_shell_src/main.c b/Usermode/Applications/gui_shell_src/main.c index 1c748b32..4b82d0e0 100644 --- a/Usermode/Applications/gui_shell_src/main.c +++ b/Usermode/Applications/gui_shell_src/main.c @@ -116,10 +116,10 @@ int Term_KeyHandler(tHWND Window, int bPress, uint32_t KeySym, uint32_t Translat switch(KeySym) { case KEYSYM_LEFTCTRL: - _bitset(ctrl_state, 0, bPress); + _bitset(ctrl_state, 0, bPress!=0); return 0; case KEYSYM_RIGHTCTRL: - _bitset(ctrl_state, 0, bPress); + _bitset(ctrl_state, 1, bPress!=0); return 0; } #undef _bitset @@ -131,30 +131,35 @@ int Term_KeyHandler(tHWND Window, int bPress, uint32_t KeySym, uint32_t Translat Translated = KeySym - KEYSYM_a + 1; } - if( Translated ) + // == 2 :: FIRE + if( bPress == 2 ) { - char buf[6]; - int len; - - // Encode and send - len = WriteUTF8(buf, Translated); - - _SysWrite(giChildStdin, buf, len); + if( Translated ) + { + char buf[6]; + int len; + + // Encode and send + len = WriteUTF8(buf, Translated); + + _SysDebug("Keystroke translated to '%.*s'", len, buf); + _SysWrite(giChildStdin, buf, len); + + return 0; + } - return 0; - } - - // No translation, look for escape sequences to send - const char *str = NULL; - switch(KeySym) - { - case KEYSYM_LEFTARROW: - str = "\x1b[D"; - break; - } - if( str ) - { - _SysWrite(giChildStdin, str, strlen(str)); + // No translation, look for escape sequences to send + const char *str = NULL; + switch(KeySym) + { + case KEYSYM_LEFTARROW: + str = "\x1b[D"; + break; + } + if( str ) + { + _SysWrite(giChildStdin, str, strlen(str)); + } } return 0; } diff --git a/Usermode/Applications/gui_shell_src/vt100.c b/Usermode/Applications/gui_shell_src/vt100.c index f73f4529..621cb10a 100644 --- a/Usermode/Applications/gui_shell_src/vt100.c +++ b/Usermode/Applications/gui_shell_src/vt100.c @@ -12,6 +12,13 @@ #include // isalpha #include // _SysDebug +const uint32_t caVT100Colours[] = { + // Black, Red, Green, Yellow, Blue, Purple, Cyan, Gray + // Same again, but bright + 0x000000, 0x770000, 0x007700, 0x777700, 0x000077, 0x770077, 0x007777, 0xAAAAAAA, + 0xCCCCCC, 0xFF0000, 0x00FF00, 0xFFFF00, 0x0000FF, 0xFF00FF, 0x00FFFF, 0xFFFFFFF +}; + int Term_HandleVT100_Long(int Len, const char *Buf); static inline int min(int a, int b) @@ -148,6 +155,33 @@ int Term_HandleVT100_Long(int Len, const char *Buffer) else _SysDebug("TODO: VT100 %i J", args[0]); break; + case 'm': + if( argc == 0 ) + { + // Reset + } + else + { + int i; + for( i = 0; i < argc; i ++ ) + { + if( args[i] < 8 ) + { + // Flags? + } + else if( 30 <= args[i] && args[i] <= 37 ) + { + // TODO: Bold/bright + Display_SetForeground( caVT100Colours[ args[i]-30 ] ); + } + else if( 40 <= args[i] && args[i] <= 47 ) + { + // TODO: Bold/bright + Display_SetBackground( caVT100Colours[ args[i]-30 ] ); + } + } + } + break; default: _SysDebug("Unknown VT100 escape char 0x%x", c); break;