summaryrefslogtreecommitdiff
path: root/console.c
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2005-05-16 13:46:26 +0000
committerDarkvater <Darkvater@openttd.org>2005-05-16 13:46:26 +0000
commitee89f5ab77860ce319e62bab507820660a11d707 (patch)
tree2c210f6d84e74e19b38b5217dd6dd779b7615b7d /console.c
parent2dc7d2b14e4d9ac744630759e94cb80df46f0cda (diff)
downloadopenttd-ee89f5ab77860ce319e62bab507820660a11d707.tar.xz
(svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
- Fix: do not execute emtpy commands anymore
Diffstat (limited to 'console.c')
-rw-r--r--console.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/console.c b/console.c
index 4b35a7e87..88dc36455 100644
--- a/console.c
+++ b/console.c
@@ -151,6 +151,9 @@ static void IConsoleWndProc(Window* w, WindowEvent* e)
SetWindowDirty(w);
}
break;
+ case (WKC_CTRL | 'L'):
+ IConsoleCmdExec("clear");
+ break;
case WKC_BACKSPACE: case WKC_DELETE:
if (DeleteTextBufferChar(&_iconsole_cmdline, e->keypress.keycode)) {
IConsoleResetHistoryPos();
@@ -222,13 +225,19 @@ void IConsoleInit(void)
IConsoleHistoryAdd("");
}
-void IConsoleClear(void)
+void IConsoleClearBuffer(void)
{
uint i;
- for (i = 0; i <= ICON_BUFFER; i++)
+ for (i = 0; i <= ICON_BUFFER; i++) {
free(_iconsole_buffer[i]);
+ _iconsole_buffer[i] = NULL;
+ }
+}
+static void IConsoleClear(void)
+{
free(_iconsole_cmdline.buf);
+ IConsoleClearBuffer();
}
static void IConsoleWriteToLogFile(const char* string)
@@ -1022,6 +1031,8 @@ void IConsoleCmdExec(const char *cmdstr)
bool longtoken = false;
bool foundtoken = false;
+ if (*cmdstr == '\0') return; // don't execute empty commands
+
for (cmdptr = cmdstr; *cmdptr != '\0'; cmdptr++) {
if (!IsValidAsciiChar(*cmdptr)) {
IConsoleError("command contains malformed characters, aborting");