engine: client: console: do not let color strings contribute to line length in console
This commit is contained in:
parent
8a0c2577ed
commit
74ad504377
1 changed files with 32 additions and 9 deletions
|
@ -843,11 +843,14 @@ If no console is visible, the notify window will pop up.
|
||||||
*/
|
*/
|
||||||
void Con_Print( const char *txt )
|
void Con_Print( const char *txt )
|
||||||
{
|
{
|
||||||
static int cr_pending = 0;
|
static qboolean cr_pending = false;
|
||||||
|
static qboolean colorstring = false;
|
||||||
static char buf[MAX_PRINT_MSG];
|
static char buf[MAX_PRINT_MSG];
|
||||||
qboolean norefresh = false;
|
|
||||||
static int lastlength = 0;
|
static int lastlength = 0;
|
||||||
static int bufpos = 0;
|
static int bufpos = 0;
|
||||||
|
static int charpos = 0;
|
||||||
|
|
||||||
|
qboolean norefresh = false;
|
||||||
int c, mask = 0;
|
int c, mask = 0;
|
||||||
|
|
||||||
// client not running
|
// client not running
|
||||||
|
@ -873,7 +876,7 @@ void Con_Print( const char *txt )
|
||||||
if( cr_pending )
|
if( cr_pending )
|
||||||
{
|
{
|
||||||
Con_DeleteLastLine();
|
Con_DeleteLastLine();
|
||||||
cr_pending = 0;
|
cr_pending = false;
|
||||||
}
|
}
|
||||||
c = *txt;
|
c = *txt;
|
||||||
|
|
||||||
|
@ -886,23 +889,42 @@ void Con_Print( const char *txt )
|
||||||
{
|
{
|
||||||
Con_AddLine( buf, bufpos, true );
|
Con_AddLine( buf, bufpos, true );
|
||||||
lastlength = CON_LINES_LAST().length;
|
lastlength = CON_LINES_LAST().length;
|
||||||
cr_pending = 1;
|
cr_pending = true;
|
||||||
bufpos = 0;
|
bufpos = 0;
|
||||||
|
charpos = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '\n':
|
case '\n':
|
||||||
Con_AddLine( buf, bufpos, true );
|
Con_AddLine( buf, bufpos, true );
|
||||||
lastlength = CON_LINES_LAST().length;
|
lastlength = CON_LINES_LAST().length;
|
||||||
bufpos = 0;
|
bufpos = 0;
|
||||||
|
charpos = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
||||||
buf[bufpos++] = c | mask;
|
buf[bufpos++] = c | mask;
|
||||||
if(( bufpos >= sizeof( buf ) - 1 ) || bufpos >= ( con.linewidth - 1 ))
|
|
||||||
|
if( IsColorString( txt ))
|
||||||
|
{
|
||||||
|
// first color string character
|
||||||
|
colorstring = true;
|
||||||
|
}
|
||||||
|
else if( colorstring )
|
||||||
|
{
|
||||||
|
// second color string character
|
||||||
|
colorstring = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// not a color string, move char counter
|
||||||
|
charpos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(( bufpos >= sizeof( buf ) - 1 ) || charpos >= ( con.linewidth - 1 ))
|
||||||
{
|
{
|
||||||
Con_AddLine( buf, bufpos, true );
|
Con_AddLine( buf, bufpos, true );
|
||||||
lastlength = CON_LINES_LAST().length;
|
lastlength = CON_LINES_LAST().length;
|
||||||
bufpos = 0;
|
bufpos = 0;
|
||||||
|
charpos = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -918,6 +940,7 @@ void Con_Print( const char *txt )
|
||||||
Con_AddLine( buf, bufpos, lastlength != 0 );
|
Con_AddLine( buf, bufpos, lastlength != 0 );
|
||||||
lastlength = 0;
|
lastlength = 0;
|
||||||
bufpos = 0;
|
bufpos = 0;
|
||||||
|
charpos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pump messages to avoid window hanging
|
// pump messages to avoid window hanging
|
||||||
|
|
Loading…
Add table
Reference in a new issue