File diff r13023:9f6499c8d4fb → r13024:48c81d0b078a
src/console_gui.cpp
Show inline comments
 
@@ -120,49 +120,49 @@ struct IConsoleLine {
 
	}
 
};
 

	
 
/* static */ IConsoleLine *IConsoleLine::front = NULL;
 
/* static */ int IConsoleLine::size  = 0;
 

	
 

	
 
/* ** main console cmd buffer ** */
 
static Textbuf _iconsole_cmdline;
 
static char *_iconsole_history[ICON_HISTORY_SIZE];
 
static byte _iconsole_historypos;
 
IConsoleModes _iconsole_mode;
 

	
 
/* *************** *
 
 *  end of header  *
 
 * *************** */
 

	
 
static void IConsoleClearCommand()
 
{
 
	memset(_iconsole_cmdline.buf, 0, ICON_CMDLN_SIZE);
 
	_iconsole_cmdline.size = 1; // only terminating zero
 
	_iconsole_cmdline.width = 0;
 
	_iconsole_cmdline.caretpos = 0;
 
	_iconsole_cmdline.caretxoffs = 0;
 
	InvalidateWindow(WC_CONSOLE, 0);
 
	SetWindowDirty(WC_CONSOLE, 0);
 
}
 

	
 
static inline void IConsoleResetHistoryPos() {_iconsole_historypos = ICON_HISTORY_SIZE - 1;}
 

	
 

	
 
static void IConsoleHistoryAdd(const char *cmd);
 
static void IConsoleHistoryNavigate(int direction);
 

	
 
/** Widgets of the console window. */
 
enum ConsoleWidgets {
 
	CW_BACKGROUND, ///< Background of the console
 
};
 

	
 
static const struct NWidgetPart _nested_console_window_widgets[] = {
 
	NWidget(WWT_EMPTY, INVALID_COLOUR, CW_BACKGROUND), SetResize(1, 1),
 
};
 

	
 
static const WindowDesc _console_window_desc(
 
	0, 0, 0, 0, 0, 0,
 
	WC_CONSOLE, WC_NONE,
 
	0,
 
	NULL, _nested_console_window_widgets, lengthof(_nested_console_window_widgets)
 
);
 

	
 
@@ -449,26 +449,26 @@ static void IConsoleHistoryNavigate(int 
 
	if (direction < 0) {
 
		while (i > 0 && _iconsole_history[i] == NULL) i--;
 
	}
 

	
 
	_iconsole_historypos = i;
 
	IConsoleClearCommand();
 
	/* copy history to 'command prompt / bash' */
 
	assert(_iconsole_history[i] != NULL && IsInsideMM(i, 0, ICON_HISTORY_SIZE));
 
	ttd_strlcpy(_iconsole_cmdline.buf, _iconsole_history[i], _iconsole_cmdline.maxsize);
 
	UpdateTextBufferSize(&_iconsole_cmdline);
 
}
 

	
 
/**
 
 * Handle the printing of text entered into the console or redirected there
 
 * by any other means. Text can be redirected to other clients in a network game
 
 * as well as to a logfile. If the network server is a dedicated server, all activities
 
 * are also logged. All lines to print are added to a temporary buffer which can be
 
 * used as a history to print them onscreen
 
 * @param colour_code the colour of the command. Red in case of errors, etc.
 
 * @param string the message entered or output on the console (notice, error, etc.)
 
 */
 
void IConsoleGUIPrint(ConsoleColour colour_code, char *str)
 
{
 
	new IConsoleLine(str, (TextColour)colour_code);
 
	InvalidateWindow(WC_CONSOLE, 0);
 
	SetWindowDirty(WC_CONSOLE, 0);
 
}