rPi Console: Fix console vt100 calls

* Use correct clear screen escape codes
* Use correct set cursor location escape codes
* Use correct set color escape codes
This commit is contained in:
Alexander von Gluck IV 2012-05-24 06:17:22 -05:00
parent 361ec26f10
commit 9b2efb1ad5
1 changed files with 16 additions and 13 deletions

View File

@ -98,38 +98,41 @@ VTConsole::VTConsole()
void void
VTConsole::ClearScreen() VTConsole::ClearScreen()
{ {
WriteAt(NULL, 0LL, "\033E", 2); WriteAt(NULL, 0LL, "\033[2J", 4);
} }
void void
VTConsole::SetCursor(int32 x, int32 y) VTConsole::SetCursor(int32 x, int32 y)
{ {
char buff[] = "\033Y "; char buffer[8];
x = MIN(79, MAX(0, x)); x = MIN(79, MAX(0, x));
y = MIN(24, MAX(0, y)); y = MIN(24, MAX(0, y));
buff[3] += (char)x; int len = snprintf(buffer, sizeof(buffer),
buff[2] += (char)y; "\033[%" B_PRId32 ";%" B_PRId32 "H", y, x);
WriteAt(NULL, 0LL, buff, 4); WriteAt(NULL, 0LL, buffer, len);
} }
void void
VTConsole::SetColor(int32 foreground, int32 background) VTConsole::SetColor(int32 foreground, int32 background)
{ {
return;
static const char cmap[] = { static const char cmap[] = {
15, 4, 2, 6, 1, 5, 3, 7, 0, 4, 2, 6, 1, 5, 3, 7 };
8, 12, 10, 14, 9, 13, 11, 0 }; char buffer[12];
char buff[] = "\033b \033c ";
if (foreground < 0 && foreground >= 16) if (foreground < 0 && foreground >= 8)
return; return;
if (background < 0 && background >= 16) if (background < 0 && background >= 8)
return; return;
buff[2] += cmap[foreground]; // We assume normal display attributes here
buff[5] += cmap[background]; int len = snprintf(buffer, sizeof(buffer),
WriteAt(NULL, 0LL, buff, 6); "\033[#0;3%" B_PRId32 ";4%" B_PRId32 "m",
cmap[foreground], cmap[background]);
WriteAt(NULL, 0LL, buffer, len);
} }