-std::size_t Sys_Print(int level, const char* buf, std::size_t length)
-{
- bool contains_newline = std::find(buf, buf+length, '\n') != buf+length;
-
- if(level == SYS_ERR)
- {
- Sys_LogFile(true);
- }
-
- if (g_hLogFile != 0)
- {
- fwrite(buf, 1, length, g_hLogFile);
- if(contains_newline)
- {
- fflush(g_hLogFile);
- }
- }
-
- if (level != SYS_NOCON)
- {
- if (g_console != 0)
- {
- GtkTextBuffer* buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(g_console));
-
- GtkTextIter iter;
- gtk_text_buffer_get_end_iter(buffer, &iter);
-
- static GtkTextMark* end = gtk_text_buffer_create_mark(buffer, "end", &iter, FALSE);
-
- const GdkColor yellow = { 0, 0xb0ff, 0xb0ff, 0x0000 };
- const GdkColor red = { 0, 0xffff, 0x0000, 0x0000 };
- const GdkColor black = { 0, 0x0000, 0x0000, 0x0000 };
-
- static GtkTextTag* error_tag = gtk_text_buffer_create_tag (buffer, "red_foreground", "foreground-gdk", &red, 0);
- static GtkTextTag* warning_tag = gtk_text_buffer_create_tag (buffer, "yellow_foreground", "foreground-gdk", &yellow, 0);
- static GtkTextTag* standard_tag = gtk_text_buffer_create_tag (buffer, "black_foreground", "foreground-gdk", &black, 0);
- GtkTextTag* tag;
- switch (level)
- {
- case SYS_WRN:
- tag = warning_tag;
- break;
- case SYS_ERR:
- tag = error_tag;
- break;
- case SYS_STD:
- case SYS_VRB:
- default:
- tag = standard_tag;
- break;
- }
-
-
- {
- GtkTextBufferOutputStream textBuffer(buffer, &iter, tag);
- if(!globalCharacterSet().isUTF8())
- {
- BufferedTextOutputStream<GtkTextBufferOutputStream> buffered(textBuffer);
- buffered << StringRange(buf, buf + length);
- }
- else
- {
- textBuffer << StringRange(buf, buf + length);
- }
- }
-
- // update console widget immediatly if we're doing something time-consuming
- if(contains_newline)
- {
- gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(g_console), end);
-
- if(!ScreenUpdates_Enabled() && GTK_WIDGET_REALIZED(g_console))
- {
- ScreenUpdates_process();
- }
- }
- }
- }
- return length;
+std::size_t Sys_Print( int level, const char* buf, std::size_t length ){
+ bool contains_newline = std::find( buf, buf + length, '\n' ) != buf + length;
+
+ if ( level == SYS_ERR ) {
+ Sys_LogFile( true );
+ }
+
+ if ( g_hLogFile != 0 ) {
+ fwrite( buf, 1, length, g_hLogFile );
+ if ( contains_newline ) {
+ fflush( g_hLogFile );
+ }
+ }
+
+ if ( level != SYS_NOCON ) {
+ if ( g_console ) {
+ GtkTextBuffer* buffer = gtk_text_view_get_buffer( g_console );
+
+ GtkTextIter iter;
+ gtk_text_buffer_get_end_iter( buffer, &iter );
+
+ static GtkTextMark* end = gtk_text_buffer_create_mark( buffer, "end", &iter, FALSE );
+
+ const GdkColor yellow = { 0, 0xb0ff, 0xb0ff, 0x0000 };
+ const GdkColor red = { 0, 0xffff, 0x0000, 0x0000 };
+
+ static GtkTextTag* error_tag = gtk_text_buffer_create_tag( buffer, "red_foreground", "foreground-gdk", &red, NULL );
+ static GtkTextTag* warning_tag = gtk_text_buffer_create_tag( buffer, "yellow_foreground", "foreground-gdk", &yellow, NULL );
+ static GtkTextTag* standard_tag = gtk_text_buffer_create_tag( buffer, "black_foreground", NULL );
+ GtkTextTag* tag;
+ switch ( level )
+ {
+ case SYS_WRN:
+ tag = warning_tag;
+ break;
+ case SYS_ERR:
+ tag = error_tag;
+ break;
+ case SYS_STD:
+ case SYS_VRB:
+ default:
+ tag = standard_tag;
+ break;
+ }
+
+
+ {
+ GtkTextBufferOutputStream textBuffer( buffer, &iter, tag );
+ if ( !globalCharacterSet().isUTF8() ) {
+ BufferedTextOutputStream<GtkTextBufferOutputStream> buffered( textBuffer );
+ buffered << StringRange( buf, buf + length );
+ }
+ else
+ {
+ textBuffer << StringRange( buf, buf + length );
+ }
+ }
+
+ // update console widget immediatly if we're doing something time-consuming
+ if ( contains_newline ) {
+ gtk_text_view_scroll_mark_onscreen( g_console, end );
+
+ if ( !ScreenUpdates_Enabled() && gtk_widget_get_realized( g_console ) ) {
+ ScreenUpdates_process();
+ }
+ }
+ }
+ }
+ return length;