summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--console.c15
-rw-r--r--console.h2
-rw-r--r--console_cmds.c14
3 files changed, 27 insertions, 4 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");
diff --git a/console.h b/console.h
index 63555d242..e37f344ab 100644
--- a/console.h
+++ b/console.h
@@ -114,8 +114,8 @@ VARDEF IConsoleModes _iconsole_mode;
// ** console functions ** //
void IConsoleInit(void);
-void IConsoleClear(void);
void IConsoleFree(void);
+void IConsoleClearBuffer(void);
void IConsoleResize(void);
void IConsoleSwitch(void);
void IConsoleClose(void);
diff --git a/console_cmds.c b/console_cmds.c
index 502bc1048..3b2159142 100644
--- a/console_cmds.c
+++ b/console_cmds.c
@@ -268,7 +268,6 @@ DEF_CONSOLE_CMD(ConChangeDirectory)
return true;
}
-
DEF_CONSOLE_CMD(ConPrintWorkingDirectory)
{
const char *path;
@@ -287,6 +286,18 @@ DEF_CONSOLE_CMD(ConPrintWorkingDirectory)
return true;
}
+DEF_CONSOLE_CMD(ConClearBuffer)
+{
+ if (argc == 0) {
+ IConsoleHelp("Clear the console buffer. Usage: 'clear'");
+ return true;
+ }
+
+ IConsoleClearBuffer();
+ InvalidateWindow(WC_CONSOLE, 0);
+ return true;
+}
+
// ********************************* //
// * Network Core Console Commands * //
@@ -1217,6 +1228,7 @@ void IConsoleStdLibRegister(void)
IConsoleCmdRegister("ls", ConListFiles);
IConsoleCmdRegister("cd", ConChangeDirectory);
IConsoleCmdRegister("pwd", ConPrintWorkingDirectory);
+ IConsoleCmdRegister("clear", ConClearBuffer);
IConsoleAliasRegister("dir", "ls");
IConsoleAliasRegister("newmap", "newgame");