Keep color across wrapped lines

And this works by inserting the same color code on each wrapped line.
This commit is contained in:
jameds 2018-03-21 21:12:48 -07:00 committed by James R
parent 587586f4bb
commit b9b36a44a8
1 changed files with 11 additions and 5 deletions

View File

@ -1106,6 +1106,7 @@ static void CON_Print(char *msg)
{
size_t l;
INT32 controlchars = 0; // for color changing
char color = '\x80'; // keep color across lines
if (msg == NULL)
return;
@ -1131,7 +1132,7 @@ static void CON_Print(char *msg)
{
if (*msg & 0x80)
{
con_line[con_cx++] = *(msg++);
color = con_line[con_cx++] = *(msg++);
controlchars++;
continue;
}
@ -1139,12 +1140,14 @@ static void CON_Print(char *msg)
{
con_cy--;
CON_Linefeed();
color = '\x80';
controlchars = 0;
}
else if (*msg == '\n') // linefeed
{
CON_Linefeed();
controlchars = 0;
con_line[con_cx++] = color;
controlchars = 1;
}
else if (*msg == ' ') // space
{
@ -1152,7 +1155,8 @@ static void CON_Print(char *msg)
if (con_cx - controlchars >= con_width-11)
{
CON_Linefeed();
controlchars = 0;
con_line[con_cx++] = color;
controlchars = 1;
}
}
else if (*msg == '\t')
@ -1167,7 +1171,8 @@ static void CON_Print(char *msg)
if (con_cx - controlchars >= con_width-11)
{
CON_Linefeed();
controlchars = 0;
con_line[con_cx++] = color;
controlchars = 1;
}
}
msg++;
@ -1184,7 +1189,8 @@ static void CON_Print(char *msg)
if ((con_cx - controlchars) + l > con_width-11)
{
CON_Linefeed();
controlchars = 0;
con_line[con_cx++] = color;
controlchars = 1;
}
// a word at a time