Fix formatting issues
This commit is contained in:
parent
2ea1f071e6
commit
b0445819cf
@ -90,7 +90,7 @@ static void consoleCls(int mode) {
|
|||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
colTemp = currentConsole->cursorX ;
|
colTemp = currentConsole->cursorX ;
|
||||||
rowTemp = currentConsole->cursorY ;
|
rowTemp = currentConsole->cursorY ;
|
||||||
@ -102,7 +102,7 @@ static void consoleCls(int mode) {
|
|||||||
currentConsole->cursorY = rowTemp;
|
currentConsole->cursorY = rowTemp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
colTemp = currentConsole->cursorX ;
|
colTemp = currentConsole->cursorX ;
|
||||||
rowTemp = currentConsole->cursorY ;
|
rowTemp = currentConsole->cursorY ;
|
||||||
@ -117,7 +117,7 @@ static void consoleCls(int mode) {
|
|||||||
currentConsole->cursorY = rowTemp;
|
currentConsole->cursorY = rowTemp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
currentConsole->cursorY = 0;
|
currentConsole->cursorY = 0;
|
||||||
currentConsole->cursorX = 0;
|
currentConsole->cursorX = 0;
|
||||||
@ -141,7 +141,7 @@ static void consoleClearLine(int mode) {
|
|||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
colTemp = currentConsole->cursorX ;
|
colTemp = currentConsole->cursorX ;
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ static void consoleClearLine(int mode) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
colTemp = currentConsole->cursorX ;
|
colTemp = currentConsole->cursorX ;
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ static void consoleClearLine(int mode) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
colTemp = currentConsole->cursorX ;
|
colTemp = currentConsole->cursorX ;
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ static struct
|
|||||||
ESC_BUILDING_FORMAT_FG_NONRGB,
|
ESC_BUILDING_FORMAT_FG_NONRGB,
|
||||||
ESC_BUILDING_FORMAT_BG_NONRGB,
|
ESC_BUILDING_FORMAT_BG_NONRGB,
|
||||||
ESC_BUILDING_FORMAT_FG_RGB,
|
ESC_BUILDING_FORMAT_FG_RGB,
|
||||||
ESC_BUILDING_FORMAT_BG_RGB
|
ESC_BUILDING_FORMAT_BG_RGB,
|
||||||
} state;
|
} state;
|
||||||
} escapeSeq;
|
} escapeSeq;
|
||||||
|
|
||||||
@ -257,182 +257,182 @@ static void consoleHandleColorEsc(int code)
|
|||||||
{
|
{
|
||||||
switch (escapeSeq.state)
|
switch (escapeSeq.state)
|
||||||
{
|
{
|
||||||
case ESC_BUILDING_FORMAT_UNKNOWN:
|
case ESC_BUILDING_FORMAT_UNKNOWN:
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
case 0: // reset
|
case 0: // reset
|
||||||
escapeSeq.color.flags = 0;
|
escapeSeq.color.flags = 0;
|
||||||
escapeSeq.color.bg = 0;
|
escapeSeq.color.bg = 0;
|
||||||
escapeSeq.color.fg = 7;
|
escapeSeq.color.fg = 7;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: // bold
|
case 1: // bold
|
||||||
escapeSeq.color.flags &= ~CONSOLE_COLOR_FAINT;
|
escapeSeq.color.flags &= ~CONSOLE_COLOR_FAINT;
|
||||||
escapeSeq.color.flags |= CONSOLE_COLOR_BOLD;
|
escapeSeq.color.flags |= CONSOLE_COLOR_BOLD;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: // faint
|
case 2: // faint
|
||||||
escapeSeq.color.flags &= ~CONSOLE_COLOR_BOLD;
|
escapeSeq.color.flags &= ~CONSOLE_COLOR_BOLD;
|
||||||
escapeSeq.color.flags |= CONSOLE_COLOR_FAINT;
|
escapeSeq.color.flags |= CONSOLE_COLOR_FAINT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: // italic
|
case 3: // italic
|
||||||
escapeSeq.color.flags |= CONSOLE_ITALIC;
|
escapeSeq.color.flags |= CONSOLE_ITALIC;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4: // underline
|
case 4: // underline
|
||||||
escapeSeq.color.flags |= CONSOLE_UNDERLINE;
|
escapeSeq.color.flags |= CONSOLE_UNDERLINE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5: // blink slow
|
case 5: // blink slow
|
||||||
escapeSeq.color.flags &= ~CONSOLE_BLINK_FAST;
|
escapeSeq.color.flags &= ~CONSOLE_BLINK_FAST;
|
||||||
escapeSeq.color.flags |= CONSOLE_BLINK_SLOW;
|
escapeSeq.color.flags |= CONSOLE_BLINK_SLOW;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6: // blink fast
|
case 6: // blink fast
|
||||||
escapeSeq.color.flags &= ~CONSOLE_BLINK_SLOW;
|
escapeSeq.color.flags &= ~CONSOLE_BLINK_SLOW;
|
||||||
escapeSeq.color.flags |= CONSOLE_BLINK_FAST;
|
escapeSeq.color.flags |= CONSOLE_BLINK_FAST;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7: // reverse video
|
case 7: // reverse video
|
||||||
escapeSeq.color.flags |= CONSOLE_COLOR_REVERSE;
|
escapeSeq.color.flags |= CONSOLE_COLOR_REVERSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 8: // conceal
|
case 8: // conceal
|
||||||
escapeSeq.color.flags |= CONSOLE_CONCEAL;
|
escapeSeq.color.flags |= CONSOLE_CONCEAL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 9: // crossed-out
|
case 9: // crossed-out
|
||||||
escapeSeq.color.flags |= CONSOLE_CROSSED_OUT;
|
escapeSeq.color.flags |= CONSOLE_CROSSED_OUT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 21: // bold off
|
case 21: // bold off
|
||||||
escapeSeq.color.flags &= ~CONSOLE_COLOR_BOLD;
|
escapeSeq.color.flags &= ~CONSOLE_COLOR_BOLD;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 22: // normal color
|
case 22: // normal color
|
||||||
escapeSeq.color.flags &= ~CONSOLE_COLOR_BOLD;
|
escapeSeq.color.flags &= ~CONSOLE_COLOR_BOLD;
|
||||||
escapeSeq.color.flags &= ~CONSOLE_COLOR_FAINT;
|
escapeSeq.color.flags &= ~CONSOLE_COLOR_FAINT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 23: // italic off
|
case 23: // italic off
|
||||||
escapeSeq.color.flags &= ~CONSOLE_ITALIC;
|
escapeSeq.color.flags &= ~CONSOLE_ITALIC;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 24: // underline off
|
case 24: // underline off
|
||||||
escapeSeq.color.flags &= ~CONSOLE_UNDERLINE;
|
escapeSeq.color.flags &= ~CONSOLE_UNDERLINE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 25: // blink off
|
case 25: // blink off
|
||||||
escapeSeq.color.flags &= ~CONSOLE_BLINK_SLOW;
|
escapeSeq.color.flags &= ~CONSOLE_BLINK_SLOW;
|
||||||
escapeSeq.color.flags &= ~CONSOLE_BLINK_FAST;
|
escapeSeq.color.flags &= ~CONSOLE_BLINK_FAST;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 27: // reverse off
|
case 27: // reverse off
|
||||||
escapeSeq.color.flags &= ~CONSOLE_COLOR_REVERSE;
|
escapeSeq.color.flags &= ~CONSOLE_COLOR_REVERSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 29: // crossed-out off
|
case 29: // crossed-out off
|
||||||
escapeSeq.color.flags &= ~CONSOLE_CROSSED_OUT;
|
escapeSeq.color.flags &= ~CONSOLE_CROSSED_OUT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 30 ... 37: // writing color
|
case 30 ... 37: // writing color
|
||||||
escapeSeq.color.flags &= ~CONSOLE_FG_CUSTOM;
|
escapeSeq.color.flags &= ~CONSOLE_FG_CUSTOM;
|
||||||
escapeSeq.color.fg = code - 30;
|
escapeSeq.color.fg = code - 30;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 38: // custom foreground color
|
case 38: // custom foreground color
|
||||||
escapeSeq.state = ESC_BUILDING_FORMAT_FG;
|
escapeSeq.state = ESC_BUILDING_FORMAT_FG;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 39: // reset foreground color
|
case 39: // reset foreground color
|
||||||
escapeSeq.color.flags &= ~CONSOLE_FG_CUSTOM;
|
escapeSeq.color.flags &= ~CONSOLE_FG_CUSTOM;
|
||||||
escapeSeq.color.fg = 7;
|
escapeSeq.color.fg = 7;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 40 ... 47: // screen color
|
case 40 ... 47: // screen color
|
||||||
escapeSeq.color.flags &= ~CONSOLE_BG_CUSTOM;
|
escapeSeq.color.flags &= ~CONSOLE_BG_CUSTOM;
|
||||||
escapeSeq.color.bg = code - 40;
|
escapeSeq.color.bg = code - 40;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 48: // custom background color
|
case 48: // custom background color
|
||||||
escapeSeq.state = ESC_BUILDING_FORMAT_BG;
|
escapeSeq.state = ESC_BUILDING_FORMAT_BG;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 49: // reset background color
|
case 49: // reset background color
|
||||||
escapeSeq.color.flags &= ~CONSOLE_BG_CUSTOM;
|
escapeSeq.color.flags &= ~CONSOLE_BG_CUSTOM;
|
||||||
escapeSeq.color.fg = 0;
|
escapeSeq.color.fg = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ESC_BUILDING_FORMAT_FG:
|
||||||
|
if (escapeSeq.color.args[0] == 5)
|
||||||
|
escapeSeq.state = ESC_BUILDING_FORMAT_FG_NONRGB;
|
||||||
|
else if (escapeSeq.color.args[0] == 2)
|
||||||
|
escapeSeq.state = ESC_BUILDING_FORMAT_FG_RGB;
|
||||||
|
else
|
||||||
|
escapeSeq.state = ESC_BUILDING_FORMAT_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
}
|
case ESC_BUILDING_FORMAT_BG:
|
||||||
break;
|
if (escapeSeq.color.args[0] == 5)
|
||||||
case ESC_BUILDING_FORMAT_FG:
|
escapeSeq.state = ESC_BUILDING_FORMAT_BG_NONRGB;
|
||||||
if (escapeSeq.color.args[0] == 5)
|
else if (escapeSeq.color.args[0] == 2)
|
||||||
escapeSeq.state = ESC_BUILDING_FORMAT_FG_NONRGB;
|
escapeSeq.state = ESC_BUILDING_FORMAT_BG_RGB;
|
||||||
else if (escapeSeq.color.args[0] == 2)
|
else
|
||||||
escapeSeq.state = ESC_BUILDING_FORMAT_FG_RGB;
|
escapeSeq.state = ESC_BUILDING_FORMAT_UNKNOWN;
|
||||||
else
|
break;
|
||||||
|
case ESC_BUILDING_FORMAT_FG_NONRGB:
|
||||||
|
if (code <= 15) {
|
||||||
|
escapeSeq.color.fg = code;
|
||||||
|
escapeSeq.color.flags &= ~CONSOLE_FG_CUSTOM;
|
||||||
|
} else if (code <= 231) {
|
||||||
|
code -= 16;
|
||||||
|
unsigned int r = code / 36;
|
||||||
|
unsigned int g = (code - r * 36) / 6;
|
||||||
|
unsigned int b = code - r * 36 - g * 6;
|
||||||
|
|
||||||
|
escapeSeq.color.fg = RGB8_to_565 (colorCube[r], colorCube[g], colorCube[b]);
|
||||||
|
escapeSeq.color.flags |= CONSOLE_FG_CUSTOM;
|
||||||
|
} else if (code <= 255) {
|
||||||
|
code -= 232;
|
||||||
|
|
||||||
|
escapeSeq.color.fg = RGB8_to_565 (grayScale[code], grayScale[code], grayScale[code]);
|
||||||
|
escapeSeq.color.flags |= CONSOLE_FG_CUSTOM;
|
||||||
|
}
|
||||||
escapeSeq.state = ESC_BUILDING_FORMAT_UNKNOWN;
|
escapeSeq.state = ESC_BUILDING_FORMAT_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
case ESC_BUILDING_FORMAT_BG:
|
case ESC_BUILDING_FORMAT_BG_NONRGB:
|
||||||
if (escapeSeq.color.args[0] == 5)
|
if (code <= 15) {
|
||||||
escapeSeq.state = ESC_BUILDING_FORMAT_BG_NONRGB;
|
escapeSeq.color.bg = code;
|
||||||
else if (escapeSeq.color.args[0] == 2)
|
escapeSeq.color.flags &= ~CONSOLE_BG_CUSTOM;
|
||||||
escapeSeq.state = ESC_BUILDING_FORMAT_BG_RGB;
|
} else if (code <= 231) {
|
||||||
else
|
code -= 16;
|
||||||
|
unsigned int r = code / 36;
|
||||||
|
unsigned int g = (code - r * 36) / 6;
|
||||||
|
unsigned int b = code - r * 36 - g * 6;
|
||||||
|
|
||||||
|
escapeSeq.color.bg = RGB8_to_565 (colorCube[r], colorCube[g], colorCube[b]);
|
||||||
|
escapeSeq.color.flags |= CONSOLE_BG_CUSTOM;
|
||||||
|
} else if (code <= 255) {
|
||||||
|
code -= 232;
|
||||||
|
|
||||||
|
escapeSeq.color.bg = RGB8_to_565 (grayScale[code], grayScale[code], grayScale[code]);
|
||||||
|
escapeSeq.color.flags |= CONSOLE_BG_CUSTOM;
|
||||||
|
}
|
||||||
escapeSeq.state = ESC_BUILDING_FORMAT_UNKNOWN;
|
escapeSeq.state = ESC_BUILDING_FORMAT_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
case ESC_BUILDING_FORMAT_FG_NONRGB:
|
case ESC_BUILDING_FORMAT_FG_RGB:
|
||||||
if (code <= 15) {
|
escapeSeq.color.fg = RGB8_to_565((unsigned int)escapeSeq.color.args[0], (unsigned int)escapeSeq.color.args[1], (unsigned int)escapeSeq.color.args[2]);
|
||||||
escapeSeq.color.fg = code;
|
|
||||||
escapeSeq.color.flags &= ~CONSOLE_FG_CUSTOM;
|
|
||||||
} else if (code <= 231) {
|
|
||||||
code -= 16;
|
|
||||||
unsigned int r = code / 36;
|
|
||||||
unsigned int g = (code - r * 36) / 6;
|
|
||||||
unsigned int b = code - r * 36 - g * 6;
|
|
||||||
|
|
||||||
escapeSeq.color.fg = RGB8_to_565 (colorCube[r], colorCube[g], colorCube[b]);
|
|
||||||
escapeSeq.color.flags |= CONSOLE_FG_CUSTOM;
|
escapeSeq.color.flags |= CONSOLE_FG_CUSTOM;
|
||||||
} else if (code <= 255) {
|
escapeSeq.state = ESC_BUILDING_FORMAT_UNKNOWN;
|
||||||
code -= 232;
|
break;
|
||||||
|
case ESC_BUILDING_FORMAT_BG_RGB:
|
||||||
escapeSeq.color.fg = RGB8_to_565 (grayScale[code], grayScale[code], grayScale[code]);
|
escapeSeq.color.bg = RGB8_to_565((unsigned int)escapeSeq.color.args[0], (unsigned int)escapeSeq.color.args[1], (unsigned int)escapeSeq.color.args[2]);
|
||||||
escapeSeq.color.flags |= CONSOLE_FG_CUSTOM;
|
|
||||||
}
|
|
||||||
escapeSeq.state = ESC_BUILDING_FORMAT_UNKNOWN;
|
|
||||||
break;
|
|
||||||
case ESC_BUILDING_FORMAT_BG_NONRGB:
|
|
||||||
if (code <= 15) {
|
|
||||||
escapeSeq.color.bg = code;
|
|
||||||
escapeSeq.color.flags &= ~CONSOLE_BG_CUSTOM;
|
|
||||||
} else if (code <= 231) {
|
|
||||||
code -= 16;
|
|
||||||
unsigned int r = code / 36;
|
|
||||||
unsigned int g = (code - r * 36) / 6;
|
|
||||||
unsigned int b = code - r * 36 - g * 6;
|
|
||||||
|
|
||||||
escapeSeq.color.bg = RGB8_to_565 (colorCube[r], colorCube[g], colorCube[b]);
|
|
||||||
escapeSeq.color.flags |= CONSOLE_BG_CUSTOM;
|
escapeSeq.color.flags |= CONSOLE_BG_CUSTOM;
|
||||||
} else if (code <= 255) {
|
escapeSeq.state = ESC_BUILDING_FORMAT_UNKNOWN;
|
||||||
code -= 232;
|
break;
|
||||||
|
default:
|
||||||
escapeSeq.color.bg = RGB8_to_565 (grayScale[code], grayScale[code], grayScale[code]);
|
break;
|
||||||
escapeSeq.color.flags |= CONSOLE_BG_CUSTOM;
|
|
||||||
}
|
|
||||||
escapeSeq.state = ESC_BUILDING_FORMAT_UNKNOWN;
|
|
||||||
break;
|
|
||||||
case ESC_BUILDING_FORMAT_FG_RGB:
|
|
||||||
escapeSeq.color.fg = RGB8_to_565((unsigned int)escapeSeq.color.args[0], (unsigned int)escapeSeq.color.args[1], (unsigned int)escapeSeq.color.args[2]);
|
|
||||||
escapeSeq.color.flags |= CONSOLE_FG_CUSTOM;
|
|
||||||
escapeSeq.state = ESC_BUILDING_FORMAT_UNKNOWN;
|
|
||||||
break;
|
|
||||||
case ESC_BUILDING_FORMAT_BG_RGB:
|
|
||||||
escapeSeq.color.bg = RGB8_to_565((unsigned int)escapeSeq.color.args[0], (unsigned int)escapeSeq.color.args[1], (unsigned int)escapeSeq.color.args[2]);
|
|
||||||
escapeSeq.color.flags |= CONSOLE_BG_CUSTOM;
|
|
||||||
escapeSeq.state = ESC_BUILDING_FORMAT_UNKNOWN;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
escapeSeq.argIdx = 0;
|
escapeSeq.argIdx = 0;
|
||||||
}
|
}
|
||||||
@ -461,14 +461,9 @@ static void consoleColorStateShift(void)
|
|||||||
case ESC_BUILDING_FORMAT_FG_RGB:
|
case ESC_BUILDING_FORMAT_FG_RGB:
|
||||||
case ESC_BUILDING_FORMAT_BG_RGB:
|
case ESC_BUILDING_FORMAT_BG_RGB:
|
||||||
if (escapeSeq.argIdx < 3)
|
if (escapeSeq.argIdx < 3)
|
||||||
{
|
|
||||||
escapeSeq.argIdx++;
|
escapeSeq.argIdx++;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
consoleHandleColorEsc(0); // Nothing passed here because three RGB items
|
||||||
// Nothing passed here because three RGB items
|
|
||||||
consoleHandleColorEsc(0);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -502,167 +497,163 @@ ssize_t con_write(struct _reent *r,void *fd,const char *ptr, size_t len) {
|
|||||||
|
|
||||||
switch (escapeSeq.state)
|
switch (escapeSeq.state)
|
||||||
{
|
{
|
||||||
case ESC_NONE:
|
case ESC_NONE:
|
||||||
if (chr == 0x1b)
|
if (chr == 0x1b)
|
||||||
{
|
escapeSeq.state = ESC_START;
|
||||||
escapeSeq.state = ESC_START;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
consolePrintChar(chr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ESC_START:
|
|
||||||
if (chr == '[')
|
|
||||||
{
|
|
||||||
escapeSeq.state = ESC_BUILDING_UNKNOWN;
|
|
||||||
memset(escapeSeq.rawBuf, 0, sizeof(escapeSeq.rawBuf));
|
|
||||||
memset(escapeSeq.hasArg, 0, sizeof(escapeSeq.hasArg));
|
|
||||||
escapeSeq.color.bg = currentConsole->bg;
|
|
||||||
escapeSeq.color.fg = currentConsole->fg;
|
|
||||||
escapeSeq.color.flags = currentConsole->flags;
|
|
||||||
escapeSeq.argIdx = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
consolePrintChar(0x1b);
|
|
||||||
consolePrintChar(chr);
|
|
||||||
escapeSeq.state = ESC_NONE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ESC_BUILDING_UNKNOWN:
|
|
||||||
switch (chr)
|
|
||||||
{
|
|
||||||
case '0':
|
|
||||||
case '1':
|
|
||||||
case '2':
|
|
||||||
case '3':
|
|
||||||
case '4':
|
|
||||||
case '5':
|
|
||||||
case '6':
|
|
||||||
case '7':
|
|
||||||
case '8':
|
|
||||||
case '9':
|
|
||||||
escapeSeq.hasArg[escapeSeq.argIdx] = true;
|
|
||||||
escapeSeq.rawBuf[escapeSeq.argIdx] = escapeSeq.rawBuf[escapeSeq.argIdx] * 10 + (chr - '0');
|
|
||||||
break;
|
|
||||||
case ';':
|
|
||||||
if (escapeSeq.argIdx < 2)
|
|
||||||
escapeSeq.argIdx++;
|
|
||||||
else
|
else
|
||||||
consoleColorStateShift();
|
consolePrintChar(chr);
|
||||||
break;
|
break;
|
||||||
|
case ESC_START:
|
||||||
//---------------------------------------
|
if (chr == '[')
|
||||||
// Cursor directional movement
|
{
|
||||||
//---------------------------------------
|
escapeSeq.state = ESC_BUILDING_UNKNOWN;
|
||||||
case 'A':
|
memset(escapeSeq.rawBuf, 0, sizeof(escapeSeq.rawBuf));
|
||||||
if (!escapeSeq.hasArg[0])
|
memset(escapeSeq.hasArg, 0, sizeof(escapeSeq.hasArg));
|
||||||
escapeSeq.directional.movement = 1;
|
escapeSeq.color.bg = currentConsole->bg;
|
||||||
currentConsole->cursorY = (currentConsole->cursorY - escapeSeq.directional.movement) < 0 ? 0 : currentConsole->cursorY - escapeSeq.directional.movement;
|
escapeSeq.color.fg = currentConsole->fg;
|
||||||
escapeSeq.state = ESC_NONE;
|
escapeSeq.color.flags = currentConsole->flags;
|
||||||
break;
|
escapeSeq.argIdx = 0;
|
||||||
case 'B':
|
}
|
||||||
if (!escapeSeq.hasArg[0])
|
else
|
||||||
escapeSeq.directional.movement = 1;
|
{
|
||||||
currentConsole->cursorY = (currentConsole->cursorY + escapeSeq.directional.movement) > currentConsole->windowHeight - 1 ? currentConsole->windowHeight - 1 : currentConsole->cursorY + escapeSeq.directional.movement;
|
consolePrintChar(0x1b);
|
||||||
escapeSeq.state = ESC_NONE;
|
consolePrintChar(chr);
|
||||||
break;
|
escapeSeq.state = ESC_NONE;
|
||||||
case 'C':
|
}
|
||||||
if (!escapeSeq.hasArg[0])
|
|
||||||
escapeSeq.directional.movement = 1;
|
|
||||||
currentConsole->cursorX = (currentConsole->cursorX + escapeSeq.directional.movement) > currentConsole->windowWidth - 1 ? currentConsole->windowWidth - 1 : currentConsole->cursorX + escapeSeq.directional.movement;
|
|
||||||
escapeSeq.state = ESC_NONE;
|
|
||||||
break;
|
|
||||||
case 'D':
|
|
||||||
if (!escapeSeq.hasArg[0])
|
|
||||||
escapeSeq.directional.movement = 1;
|
|
||||||
currentConsole->cursorX = (currentConsole->cursorX - escapeSeq.directional.movement) < 0 ? 0 : currentConsole->cursorX - escapeSeq.directional.movement;
|
|
||||||
escapeSeq.state = ESC_NONE;
|
|
||||||
break;
|
|
||||||
//---------------------------------------
|
|
||||||
// Cursor position movement
|
|
||||||
//---------------------------------------
|
|
||||||
case 'H':
|
|
||||||
case 'f':
|
|
||||||
consolePosition(escapeSeq.hasArg[1] ? escapeSeq.absolute.x : 1, escapeSeq.hasArg[0] ? escapeSeq.absolute.y : 1);
|
|
||||||
escapeSeq.state = ESC_NONE;
|
|
||||||
break;
|
|
||||||
//---------------------------------------
|
|
||||||
// Screen clear
|
|
||||||
//---------------------------------------
|
|
||||||
case 'J':
|
|
||||||
consoleCls(escapeSeq.hasArg[0] ? escapeSeq.clear.type : 0);
|
|
||||||
escapeSeq.state = ESC_NONE;
|
|
||||||
break;
|
|
||||||
//---------------------------------------
|
|
||||||
// Line clear
|
|
||||||
//---------------------------------------
|
|
||||||
case 'K':
|
|
||||||
consoleClearLine(escapeSeq.hasArg[0] ? escapeSeq.clear.type : 0);
|
|
||||||
escapeSeq.state = ESC_NONE;
|
|
||||||
break;
|
|
||||||
//---------------------------------------
|
|
||||||
// Save cursor position
|
|
||||||
//---------------------------------------
|
|
||||||
case 's':
|
|
||||||
currentConsole->prevCursorX = currentConsole->cursorX ;
|
|
||||||
currentConsole->prevCursorY = currentConsole->cursorY ;
|
|
||||||
escapeSeq.state = ESC_NONE;
|
|
||||||
break;
|
|
||||||
//---------------------------------------
|
|
||||||
// Load cursor position
|
|
||||||
//---------------------------------------
|
|
||||||
case 'u':
|
|
||||||
currentConsole->cursorX = currentConsole->prevCursorX ;
|
|
||||||
currentConsole->cursorY = currentConsole->prevCursorY ;
|
|
||||||
escapeSeq.state = ESC_NONE;
|
|
||||||
break;
|
|
||||||
//---------------------------------------
|
|
||||||
// Color scan codes
|
|
||||||
//---------------------------------------
|
|
||||||
case 'm':
|
|
||||||
consoleColorStateShift();
|
|
||||||
consoleColorApply();
|
|
||||||
escapeSeq.state = ESC_NONE;
|
|
||||||
break;
|
break;
|
||||||
|
case ESC_BUILDING_UNKNOWN:
|
||||||
|
switch (chr)
|
||||||
|
{
|
||||||
|
case '0':
|
||||||
|
case '1':
|
||||||
|
case '2':
|
||||||
|
case '3':
|
||||||
|
case '4':
|
||||||
|
case '5':
|
||||||
|
case '6':
|
||||||
|
case '7':
|
||||||
|
case '8':
|
||||||
|
case '9':
|
||||||
|
escapeSeq.hasArg[escapeSeq.argIdx] = true;
|
||||||
|
escapeSeq.rawBuf[escapeSeq.argIdx] = escapeSeq.rawBuf[escapeSeq.argIdx] * 10 + (chr - '0');
|
||||||
|
break;
|
||||||
|
case ';':
|
||||||
|
if (escapeSeq.argIdx < 2)
|
||||||
|
escapeSeq.argIdx++;
|
||||||
|
else
|
||||||
|
consoleColorStateShift();
|
||||||
|
break;
|
||||||
|
|
||||||
|
//---------------------------------------
|
||||||
|
// Cursor directional movement
|
||||||
|
//---------------------------------------
|
||||||
|
case 'A':
|
||||||
|
if (!escapeSeq.hasArg[0])
|
||||||
|
escapeSeq.directional.movement = 1;
|
||||||
|
currentConsole->cursorY = (currentConsole->cursorY - escapeSeq.directional.movement) < 0 ? 0 : currentConsole->cursorY - escapeSeq.directional.movement;
|
||||||
|
escapeSeq.state = ESC_NONE;
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
if (!escapeSeq.hasArg[0])
|
||||||
|
escapeSeq.directional.movement = 1;
|
||||||
|
currentConsole->cursorY = (currentConsole->cursorY + escapeSeq.directional.movement) > currentConsole->windowHeight - 1 ? currentConsole->windowHeight - 1 : currentConsole->cursorY + escapeSeq.directional.movement;
|
||||||
|
escapeSeq.state = ESC_NONE;
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
if (!escapeSeq.hasArg[0])
|
||||||
|
escapeSeq.directional.movement = 1;
|
||||||
|
currentConsole->cursorX = (currentConsole->cursorX + escapeSeq.directional.movement) > currentConsole->windowWidth - 1 ? currentConsole->windowWidth - 1 : currentConsole->cursorX + escapeSeq.directional.movement;
|
||||||
|
escapeSeq.state = ESC_NONE;
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
if (!escapeSeq.hasArg[0])
|
||||||
|
escapeSeq.directional.movement = 1;
|
||||||
|
currentConsole->cursorX = (currentConsole->cursorX - escapeSeq.directional.movement) < 0 ? 0 : currentConsole->cursorX - escapeSeq.directional.movement;
|
||||||
|
escapeSeq.state = ESC_NONE;
|
||||||
|
break;
|
||||||
|
//---------------------------------------
|
||||||
|
// Cursor position movement
|
||||||
|
//---------------------------------------
|
||||||
|
case 'H':
|
||||||
|
case 'f':
|
||||||
|
consolePosition(escapeSeq.hasArg[1] ? escapeSeq.absolute.x : 1, escapeSeq.hasArg[0] ? escapeSeq.absolute.y : 1);
|
||||||
|
escapeSeq.state = ESC_NONE;
|
||||||
|
break;
|
||||||
|
//---------------------------------------
|
||||||
|
// Screen clear
|
||||||
|
//---------------------------------------
|
||||||
|
case 'J':
|
||||||
|
consoleCls(escapeSeq.hasArg[0] ? escapeSeq.clear.type : 0);
|
||||||
|
escapeSeq.state = ESC_NONE;
|
||||||
|
break;
|
||||||
|
//---------------------------------------
|
||||||
|
// Line clear
|
||||||
|
//---------------------------------------
|
||||||
|
case 'K':
|
||||||
|
consoleClearLine(escapeSeq.hasArg[0] ? escapeSeq.clear.type : 0);
|
||||||
|
escapeSeq.state = ESC_NONE;
|
||||||
|
break;
|
||||||
|
//---------------------------------------
|
||||||
|
// Save cursor position
|
||||||
|
//---------------------------------------
|
||||||
|
case 's':
|
||||||
|
currentConsole->prevCursorX = currentConsole->cursorX ;
|
||||||
|
currentConsole->prevCursorY = currentConsole->cursorY ;
|
||||||
|
escapeSeq.state = ESC_NONE;
|
||||||
|
break;
|
||||||
|
//---------------------------------------
|
||||||
|
// Load cursor position
|
||||||
|
//---------------------------------------
|
||||||
|
case 'u':
|
||||||
|
currentConsole->cursorX = currentConsole->prevCursorX ;
|
||||||
|
currentConsole->cursorY = currentConsole->prevCursorY ;
|
||||||
|
escapeSeq.state = ESC_NONE;
|
||||||
|
break;
|
||||||
|
//---------------------------------------
|
||||||
|
// Color scan codes
|
||||||
|
//---------------------------------------
|
||||||
|
case 'm':
|
||||||
|
consoleColorStateShift();
|
||||||
|
consoleColorApply();
|
||||||
|
escapeSeq.state = ESC_NONE;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// some sort of unsupported escape; just gloss over it
|
// some sort of unsupported escape; just gloss over it
|
||||||
escapeSeq.state = ESC_NONE;
|
escapeSeq.state = ESC_NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
switch (chr)
|
|
||||||
{
|
|
||||||
case '0':
|
|
||||||
case '1':
|
|
||||||
case '2':
|
|
||||||
case '3':
|
|
||||||
case '4':
|
|
||||||
case '5':
|
|
||||||
case '6':
|
|
||||||
case '7':
|
|
||||||
case '8':
|
|
||||||
case '9':
|
|
||||||
escapeSeq.hasArg[escapeSeq.argIdx] = true;
|
|
||||||
escapeSeq.rawBuf[escapeSeq.argIdx] = escapeSeq.rawBuf[escapeSeq.argIdx] * 10 + (chr - '0');
|
|
||||||
break;
|
|
||||||
case ';':
|
|
||||||
consoleColorStateShift();
|
|
||||||
break;
|
|
||||||
case 'm':
|
|
||||||
consoleColorStateShift();
|
|
||||||
consoleColorApply();
|
|
||||||
escapeSeq.state = ESC_NONE;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// some sort of unsupported escape; just gloss over it
|
switch (chr)
|
||||||
escapeSeq.state = ESC_NONE;
|
{
|
||||||
break;
|
case '0':
|
||||||
|
case '1':
|
||||||
|
case '2':
|
||||||
|
case '3':
|
||||||
|
case '4':
|
||||||
|
case '5':
|
||||||
|
case '6':
|
||||||
|
case '7':
|
||||||
|
case '8':
|
||||||
|
case '9':
|
||||||
|
escapeSeq.hasArg[escapeSeq.argIdx] = true;
|
||||||
|
escapeSeq.rawBuf[escapeSeq.argIdx] = escapeSeq.rawBuf[escapeSeq.argIdx] * 10 + (chr - '0');
|
||||||
|
break;
|
||||||
|
case ';':
|
||||||
|
consoleColorStateShift();
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
consoleColorStateShift();
|
||||||
|
consoleColorApply();
|
||||||
|
escapeSeq.state = ESC_NONE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// some sort of unsupported escape; just gloss over it
|
||||||
|
escapeSeq.state = ESC_NONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
@ -762,18 +753,18 @@ void consoleDebugInit(debugDevice device){
|
|||||||
|
|
||||||
int buffertype = _IONBF;
|
int buffertype = _IONBF;
|
||||||
|
|
||||||
switch(device) {
|
switch(device)
|
||||||
|
{
|
||||||
case debugDevice_SVC:
|
case debugDevice_SVC:
|
||||||
devoptab_list[STD_ERR] = &dotab_svc;
|
devoptab_list[STD_ERR] = &dotab_svc;
|
||||||
buffertype = _IOLBF;
|
buffertype = _IOLBF;
|
||||||
break;
|
break;
|
||||||
case debugDevice_CONSOLE:
|
case debugDevice_CONSOLE:
|
||||||
devoptab_list[STD_ERR] = &dotab_stdout;
|
devoptab_list[STD_ERR] = &dotab_stdout;
|
||||||
break;
|
break;
|
||||||
case debugDevice_NULL:
|
case debugDevice_NULL:
|
||||||
devoptab_list[STD_ERR] = &dotab_null;
|
devoptab_list[STD_ERR] = &dotab_null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
setvbuf(stderr, NULL , buffertype, 0);
|
setvbuf(stderr, NULL , buffertype, 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user