From 8f4d68dfc51726bc3f53742524522ad254f66117 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 16 Jul 2024 19:21:51 -0400 Subject: listbas: colorize aplus ops correctly, fix spacing of THEN, NOT, etc. --- aplus_tokens.c | 22 +++++++++++----------- listbas.c | 16 ++++++++++++---- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/aplus_tokens.c b/aplus_tokens.c index 8d2249e..7073e1a 100644 --- a/aplus_tokens.c +++ b/aplus_tokens.c @@ -92,19 +92,19 @@ const int aplus_cmd_size = sizeof(aplus_cmds); const char *aplus_ops[] = { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, ",", /* $12 */ "$", /* $13 */ ":", /* $14 */ ";", /* $15 */ "", /* $16 */ - "GOTO", /* $17 */ - "GOSUB", /* $18 */ - "TO", /* $19 */ - "STEP", /* $1a */ - "THEN", /* $1b */ - "USING", /* $1c */ + " GOTO ", /* $17 */ + " GOSUB ", /* $18 */ + " TO ", /* $19 */ + " STEP ", /* $1a */ + " THEN ", /* $1b */ + " USING ", /* $1c */ "#", /* $1d */ "<=", /* $1e */ "<>", /* $1f */ @@ -117,9 +117,9 @@ const char *aplus_ops[] = { "+", /* $26 */ "-", /* $27 */ "/", /* $28 */ - "NOT", /* $29 */ - "OR", /* $2a */ - "AND", /* $2b */ + " NOT ", /* $29 */ + " OR ", /* $2a */ + " AND ", /* $2b */ "!", /* $2c */ "&", /* $2d */ "(", /* $2e */ diff --git a/listbas.c b/listbas.c index 8c55f99..de375fd 100644 --- a/listbas.c +++ b/listbas.c @@ -492,12 +492,20 @@ CALLBACK(print_cmd) { } void aplus_op_color_on(unsigned char tok) { - switch(tok) { - default: - break; + int c = color_op; + + if((tok >= 0x17 && tok <= 0x1c) || (tok >= 0x29 && tok <= 0x2b)) { + /* keywords */ + c = color_cmd; + } else if(tok >= 0x40) { + /* functions */ + c = color_func; + } else if(tok == 0x38 || tok == 0x39) { + /* unary +/- */ + c = color_const; } - color_on(color_op); + color_on(c); } void op_color_on(unsigned char tok) { -- cgit v1.2.3