aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-07-13 15:31:52 -0400
committerB. Watson <urchlay@slackware.uk>2024-07-13 15:31:58 -0400
commit040863078e5d8c138fd11072ddf3cba061c57dcd (patch)
tree56432ad0f9db8e61b749baff6dd508046cd7c95b
parent97edc9d9d5757888863c56b1fb24ba481d3579ae (diff)
downloadbw-atari8-tools-040863078e5d8c138fd11072ddf3cba061c57dcd.tar.gz
listbas: separate highlight colors for DATA items and REM text; highlight quotes around strings and commas between DATA items as operators.
-rw-r--r--listbas.125
-rw-r--r--listbas.c25
-rw-r--r--listbas.rst28
3 files changed, 44 insertions, 34 deletions
diff --git a/listbas.1 b/listbas.1
index 37c2388..a7751e5 100644
--- a/listbas.1
+++ b/listbas.1
@@ -135,7 +135,8 @@ the \fBSTEP\fP in a \fBFOR\fP command. These are really operators as far as
BASIC is concerned, but it makes more sense to colorize them as commands.
.TP
.B \fBgreen\fP
-Operators (except functions and "command operators").
+Operators (except functions and "command operators"), quotes around
+strings, and commas between \fBDATA\fP elements.
.TP
.B \fBpurple\fP
Functions.
@@ -145,7 +146,10 @@ Numbers (except line numbers at the start of a line) and string
constants (but not the quotes around the string).
.TP
.B \fBcyan\fP
-Line numbers at the start of a line, comments (\fBREM\fP text) and \fBDATA\fP items.
+Line numbers at the start of a line and \fBDATA\fP items.
+.TP
+.B \fBblue\fP
+Comments (\fBREM\fP text).
.TP
.B \fBuncolorized\fP
Variable names.
@@ -156,15 +160,13 @@ never colorized, so they\(aqll appear in the default foreground color
(usually white if the terminal has a black background, or black if the
background is white).
.sp
-Note that nothing is blue in the default color scheme. This is because
-it\(aqs difficult to read on many terminals. Also, black and white are
-not used because presumably, one or the other is the background color
-of the terminal.
+Black and white are not used by default because presumably, one or the
+other is the background color of the terminal.
.SS Customization
.sp
You can customize the colors by using the \fB\-c\fP \fIcolors\fP option, either
on the command line, or in the \fBLISTBAS_OPTS\fP environment variable.
-\fIcolors\fP is a string of exactly 7 characters, each of which must be the
+\fIcolors\fP is a string of exactly 8 characters, each of which must be the
digits \fI0\fP through \fI7\fP to specify a color, or the letter \fIn\fP to specify
no color.
.sp
@@ -181,7 +183,7 @@ Red.
Green.
.TP
.B \fI3\fP
-Yellow (or brown, on some terminals).
+Yellow (or brown/orange, on some terminals).
.TP
.B \fI4\fP
Blue.
@@ -219,16 +221,19 @@ Line numbers (at the start of a line only; \fBGOTO\fP and \fBGOSUB\fP line numbe
are constants).
.TP
.B \fB6\fP
-\fBDATA\fP items and \fBREM\fP text.
+\fBDATA\fP items (but not the commas between them).
.TP
.B \fB7\fP
+\fBREM\fP text.
+.TP
+.B \fB8\fP
Variable names.
.UNINDENT
.sp
So, the default color scheme is equivalent to:
.INDENT 0.0
.INDENT 3.5
-\fB\-c\fP \fI325166n\fP
+\fB\-c\fP \fI3251646n\fP
.UNINDENT
.UNINDENT
.SH NOTES
diff --git a/listbas.c b/listbas.c
index bac42c1..ee6b764 100644
--- a/listbas.c
+++ b/listbas.c
@@ -29,13 +29,15 @@
#define MAG_INV "{inv}"
#define MAG_NORM "{norm}"
-/* colors. don't use blue, it's fugly. */
+/* colors. */
#define NO_COLOR -1
#define C_RED 1
#define C_GREEN 2
#define C_YELLOW 3
+#define C_BLUE 4
#define C_PURPLE 5
#define C_CYAN 6
+#define C_WHITE 7
#define ENV_OPTS "LISTBAS_OPTS"
#define ENV_MAX_ARGS 64
@@ -60,7 +62,8 @@ int color_op = C_GREEN;
int color_func = C_PURPLE;
int color_const = C_RED;
int color_lineno = C_CYAN;
-int color_text = C_CYAN;
+int color_rem = C_BLUE;
+int color_data = C_CYAN;
int color_varnames = NO_COLOR;
int badtok = 0; /* set to 1 if we find a bad token */
@@ -82,16 +85,17 @@ int parse_color(char c) {
void parse_color_scheme(const char *arg) {
if(!arg) return;
- if(strlen(arg) != 7)
- die("Color scheme must be 7 characters.");
+ if(strlen(arg) != 8)
+ die("Color scheme must be 8 characters.");
color_cmd = parse_color(arg[0]);
color_op = parse_color(arg[1]);
color_func = parse_color(arg[2]);
color_const = parse_color(arg[3]);
color_lineno = parse_color(arg[4]);
- color_text = parse_color(arg[5]);
- color_varnames = parse_color(arg[6]);
+ color_rem = parse_color(arg[5]);
+ color_data = parse_color(arg[6]);
+ color_varnames = parse_color(arg[7]);
}
void print_help(void) {
@@ -357,13 +361,14 @@ void print_ata_chr(unsigned char c) {
void print_string(unsigned int pos, unsigned int len) {
inv = 0;
+ if(color) color_on(color_op);
outchr('"');
if(color) color_on(color_const);
while(len--) print_ata_chr(program[pos++]);
if(inv) {
end_inv(0);
}
- if(color) color_off();
+ if(color) color_on(color_op);
outchr('"');
}
@@ -446,18 +451,18 @@ CALLBACK(print_text) {
unsigned char c, is_data = program[pos - 1] == CMD_DATA, comma = 0;
inv = 0;
- if(color) color_on(color_text);
+ if(color) color_on(is_data ? color_data : color_rem);
while(program[pos] != 0x9b) {
c = program[pos++];
if(color && is_data && c == ',') {
- color_off();
+ color_on(color_op);
comma = 1;
} else {
comma = 0;
}
print_ata_chr(c);
if(comma)
- color_on(color_text);
+ color_on(is_data ? color_data : color_rem);
}
if(inv) end_inv(0);
if(color) color_off();
diff --git a/listbas.rst b/listbas.rst
index fa00e18..2743d45 100644
--- a/listbas.rst
+++ b/listbas.rst
@@ -108,7 +108,8 @@ The default color scheme is:
BASIC is concerned, but it makes more sense to colorize them as commands.
**green**
- Operators (except functions and "command operators").
+ Operators (except functions and "command operators"), quotes around
+ strings, and commas between **DATA** elements.
**purple**
Functions.
@@ -118,26 +119,22 @@ The default color scheme is:
constants (but not the quotes around the string).
**cyan**
- Line numbers at the start of a line, comments (**REM** text) and **DATA** items.
+ Line numbers at the start of a line and **DATA** items.
+
+**blue**
+ Comments (**REM** text).
**uncolorized**
Variable names.
-Quotes around strings and commas between **DATA** items are
-never colorized, so they'll appear in the default foreground color
-(usually white if the terminal has a black background, or black if the
-background is white).
-
-Note that nothing is blue in the default color scheme. This is because
-it's difficult to read on many terminals. Also, black and white are
-not used because presumably, one or the other is the background color
-of the terminal.
+Black and white are not used by default because presumably, one or the
+other is the background color of the terminal.
Customization
-------------
You can customize the colors by using the **-c** *colors* option, either
on the command line, or in the **LISTBAS_OPTS** environment variable.
-*colors* is a string of exactly 7 characters, each of which must be the
+*colors* is a string of exactly 8 characters, each of which must be the
digits *0* through *7* to specify a color, or the letter *n* to specify
no color.
@@ -189,14 +186,17 @@ The order they're used in the *colors* argument is:
are constants).
**6**
- **DATA** items and **REM** text.
+ **DATA** items (but not the commas between them).
**7**
+ **REM** text.
+
+**8**
Variable names.
So, the default color scheme is equivalent to:
- **-c** *325166n*
+ **-c** *3251646n*
NOTES
=====