summaryrefslogtreecommitdiff
path: root/src/user/app/kbasic/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/app/kbasic/commands.c')
-rw-r--r--src/user/app/kbasic/commands.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/user/app/kbasic/commands.c b/src/user/app/kbasic/commands.c
index f60f32a..b88e57e 100644
--- a/src/user/app/kbasic/commands.c
+++ b/src/user/app/kbasic/commands.c
@@ -4,6 +4,9 @@
#include "basic.h"
+static int fg_color = 7, bg_color = 0;
+
+
/* Assign a variable a value. */
void assignment()
{
@@ -33,8 +36,6 @@ void assignment()
*var = value;
}
-
-
/* Execute a simple version of the BASIC PRINT statement */
void exec_print()
{
@@ -95,9 +96,26 @@ void input()
var = find_var(token); /* get the input var */
- scanf("%d\n", var); /* read input */
+ scanf("%d", var); /* read input */
/* flush input */
while ((tmp = getchar()) != '\n' && tmp != EOF);
}
+
+/* COLOR statement */
+void color() {
+ get_exp(&fg_color);
+
+ get_token();
+ if (*token == ',') {
+ get_exp(&bg_color);
+ } else if (token_type != DELIMITER) {
+ serror(0);
+ }
+ set_color();
+}
+
+void set_color() {
+ printf("\x1b[%dm\x1b[%dm\x1b[%dm", fg_color % 8 + 30, (fg_color > 7 ? 1 : 22), bg_color % 16 + 40);
+}