summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2011-04-11 21:55:41 +0400
committerAndrey Nazarov <skuller@skuller.net>2011-04-22 18:48:48 +0400
commitf5e2f16f16a55b618eca2d985da3affce130d66e (patch)
tree652ac276e3a281484d9573a273332bae3fdb9982
parente0ca17183964e7227af2fff025583a91ce28d3cb (diff)
Normalize Unix console title.
-rw-r--r--src/sys_unix.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/sys_unix.c b/src/sys_unix.c
index 890c356..a7ffcb7 100644
--- a/src/sys_unix.c
+++ b/src/sys_unix.c
@@ -245,7 +245,7 @@ void Sys_ConsoleOutput( const char *text ) {
}
void Sys_SetConsoleTitle( const char *title ) {
- char buffer[MAX_STRING_CHARS];
+ char buf[MAX_STRING_CHARS];
size_t len;
if( !sys_console || !sys_console->integer ) {
@@ -256,10 +256,22 @@ void Sys_SetConsoleTitle( const char *title ) {
return;
}
- len = Q_snprintf( buffer, sizeof( buffer ), "\033]0;%s\007", title );
- if( len < sizeof( buffer ) ) {
- stdout_write( buffer, len );
+ buf[0] = '\033';
+ buf[1] = ']';
+ buf[2] = '0';
+ buf[3] = ';';
+
+ for( len = 4; len < MAX_STRING_CHARS - 1; len++ ) {
+ int c = *title++;
+ if( !c ) {
+ break;
+ }
+ buf[len] = Q_charascii( c );
}
+
+ buf[len++] = '\007';
+
+ stdout_write( buf, len );
}
static void tty_parse_input( const char *text ) {