about summary refs log tree commit diff
path: root/src/engine/e_console.c
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-03-01 20:03:04 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-03-01 20:03:04 +0000
commit08c4c8e0b71b577835eb9476ffc17626c94266ec (patch)
tree97c6386956b483248e564ccd2b6538d233d5e721 /src/engine/e_console.c
parent0747c2dff9289db6204b82501d03447f3ec6cc99 (diff)
downloadzcatch-08c4c8e0b71b577835eb9476ffc17626c94266ec.tar.gz
zcatch-08c4c8e0b71b577835eb9476ffc17626c94266ec.zip
redone the input system so you can know do keybindings with say etc
Diffstat (limited to 'src/engine/e_console.c')
-rw-r--r--src/engine/e_console.c46
1 files changed, 38 insertions, 8 deletions
diff --git a/src/engine/e_console.c b/src/engine/e_console.c
index 27add750..778fb1a4 100644
--- a/src/engine/e_console.c
+++ b/src/engine/e_console.c
@@ -340,10 +340,14 @@ void console_print(const char *str)
 		print_callback(str);
 }
 
-void console_execute_line(const char *str)
+
+void console_execute_line_stroked(int stroke, const char *str)
 {
 	LEXER_RESULT result;
 	int error;
+	char strokestr[8] = {'0', 0};
+	if(stroke)
+		strokestr[0] = '1';
 
 	if ((error = lex(str, &result)))
 		printf("ERROR: %d\n", error);
@@ -355,16 +359,36 @@ void console_execute_line(const char *str)
 
 		command = console_find_command(name);
 
-		if (command)
+		if(command)
 		{
-			if (console_validate(command, &result))
+			int is_stroke_command = 0;
+			if(name[0] == '+')
 			{
-				char buf[256];
-				str_format(buf, sizeof(buf), "Invalid arguments... Usage: %s %s", command->name, command->params);
-				console_print(buf);
+				/* insert the stroke direction token */
+				int i;
+				for(i = result.num_tokens-2; i > 1; i--)
+				{
+					result.tokens[i+1] = result.tokens[i];
+				}
+				
+				result.tokens[1].type = TOKEN_INT;
+				result.tokens[1].stored_string = strokestr;
+				result.num_tokens++;
+
+				is_stroke_command = 1;
+			}
+			
+			if(stroke || is_stroke_command)
+			{
+				if (console_validate(command, &result))
+				{
+					char buf[256];
+					str_format(buf, sizeof(buf), "Invalid arguments... Usage: %s %s", command->name, command->params);
+					console_print(buf);
+				}
+				else
+					command->callback(&result, command->user_data);
 			}
-			else
-				command->callback(&result, command->user_data);
 		}
 		else
 		{
@@ -375,6 +399,12 @@ void console_execute_line(const char *str)
 	}
 }
 
+void console_execute_line(const char *str)
+{
+	console_execute_line_stroked(1, str);
+}
+
+
 void console_execute_file(const char *filename)
 {
 	IOHANDLE file;