aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--listbas.113
-rw-r--r--listbas.c58
-rw-r--r--listbas.rst13
3 files changed, 46 insertions, 38 deletions
diff --git a/listbas.1 b/listbas.1
index ab5cabf..37c2388 100644
--- a/listbas.1
+++ b/listbas.1
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
-.TH "LISTBAS" 1 "2024-07-12" "0.2.1" "Urchlay's Atari 8-bit Tools"
+.TH "LISTBAS" 1 "2024-07-13" "0.2.1" "Urchlay's Atari 8-bit Tools"
.SH NAME
listbas \- List the source of a tokenized Atari 8-bit BASIC program
.SH SYNOPSIS
@@ -145,13 +145,13 @@ 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 elements.
+Line numbers at the start of a line, comments (\fBREM\fP text) and \fBDATA\fP items.
.TP
.B \fBuncolorized\fP
Variable names.
.UNINDENT
.sp
-Quotes around strings and commas between \fBDATA\fP elements are
+Quotes around strings and commas between \fBDATA\fP items are
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).
@@ -164,7 +164,7 @@ of the terminal.
.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 6 characters, each of which must be the
+\fIcolors\fP is a string of exactly 7 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
@@ -219,13 +219,16 @@ 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.
+.TP
+.B \fB7\fP
Variable names.
.UNINDENT
.sp
So, the default color scheme is equivalent to:
.INDENT 0.0
.INDENT 3.5
-\fB\-c\fP \fI32516n\fP
+\fB\-c\fP \fI325166n\fP
.UNINDENT
.UNINDENT
.SH NOTES
diff --git a/listbas.c b/listbas.c
index b0e2253..bac42c1 100644
--- a/listbas.c
+++ b/listbas.c
@@ -59,11 +59,12 @@ int color_cmd = C_YELLOW;
int color_op = C_GREEN;
int color_func = C_PURPLE;
int color_const = C_RED;
-int color_lnum_text = C_CYAN;
+int color_lineno = C_CYAN;
+int color_text = C_CYAN;
int color_varnames = NO_COLOR;
-int badtok = 0; /* set to 1 if we find a bad token */
-int inv = 0; /* set to 1 when we're printing inverse */
+int badtok = 0; /* set to 1 if we find a bad token */
+int inv = 0; /* set to 1 when we're printing inverse */
int cur_color = -1; /* -1 = no color */
FILE *outfh;
@@ -81,15 +82,16 @@ int parse_color(char c) {
void parse_color_scheme(const char *arg) {
if(!arg) return;
- if(strlen(arg) != 6)
- die("Color scheme must be 6 characters.");
+ if(strlen(arg) != 7)
+ die("Color scheme must be 7 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_lnum_text = parse_color(arg[4]);
- color_varnames = parse_color(arg[5]);
+ color_lineno = parse_color(arg[4]);
+ color_text = parse_color(arg[5]);
+ color_varnames = parse_color(arg[6]);
}
void print_help(void) {
@@ -254,22 +256,22 @@ void print_number(unsigned int pos) {
need to be printed that way. */
int affects_inv(unsigned char c) {
switch(c) {
- case 0x1b:
- case 0x1c:
- case 0x1d:
- case 0x1e:
- case 0x1f:
- case 0x9b:
- case 0x9c:
- case 0x9d:
- case 0x9e:
- case 0x9f:
- case 0x7d:
- case 0x7e:
- case 0x7f:
- case 0xfd:
- case 0xfe:
- case 0xff:
+ case 0x1b: /* esc */
+ case 0x1c: /* up */
+ case 0x1d: /* down */
+ case 0x1e: /* left */
+ case 0x1f: /* right */
+ case 0x9b: /* EOL */
+ case 0x9c: /* del line */
+ case 0x9d: /* ins line */
+ case 0x9e: /* clear tab */
+ case 0x9f: /* set tab */
+ case 0x7d: /* cls */
+ case 0x7e: /* BS */
+ case 0x7f: /* tab */
+ case 0xfd: /* bell */
+ case 0xfe: /* del chr */
+ case 0xff: /* ins chr */
return 0;
default:
return 1;
@@ -366,7 +368,7 @@ void print_string(unsigned int pos, unsigned int len) {
}
CALLBACK(print_lineno) {
- if(color) color_on(color_lnum_text);
+ if(color) color_on(color_lineno);
fprintf(outfh, "%d ", lineno);
if(color) color_off();
}
@@ -404,8 +406,8 @@ CALLBACK(print_op) {
if(color) {
if(tok > 0x3c)
color_on(color_func);
- else if(tok == OP_UMINUS)
- color_on(color_const); /* show leading - in same color as the number */
+ else if(tok == OP_UMINUS || tok == OP_UPLUS)
+ color_on(color_const); /* show leading sign in same color as the number */
else if((tok >= 0x17 && tok <= 0x1b) || (tok >= 0x28 && tok <= 0x2a))
color_on(color_cmd);
else
@@ -444,7 +446,7 @@ CALLBACK(print_text) {
unsigned char c, is_data = program[pos - 1] == CMD_DATA, comma = 0;
inv = 0;
- if(color) color_on(color_lnum_text);
+ if(color) color_on(color_text);
while(program[pos] != 0x9b) {
c = program[pos++];
if(color && is_data && c == ',') {
@@ -455,7 +457,7 @@ CALLBACK(print_text) {
}
print_ata_chr(c);
if(comma)
- color_on(color_lnum_text);
+ color_on(color_text);
}
if(inv) end_inv(0);
if(color) color_off();
diff --git a/listbas.rst b/listbas.rst
index 8e86440..fa00e18 100644
--- a/listbas.rst
+++ b/listbas.rst
@@ -118,12 +118,12 @@ 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** elements.
+ Line numbers at the start of a line, comments (**REM** text) and **DATA** items.
**uncolorized**
Variable names.
-Quotes around strings and commas between **DATA** elements are
+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).
@@ -137,7 +137,7 @@ 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 6 characters, each of which must be the
+*colors* is a string of exactly 7 characters, each of which must be the
digits *0* through *7* to specify a color, or the letter *n* to specify
no color.
@@ -153,7 +153,7 @@ The colors are the standard ANSI ones, plus *n*:
Green.
*3*
- Yellow (or brown, on some terminals).
+ Yellow (or brown/orange, on some terminals).
*4*
Blue.
@@ -189,11 +189,14 @@ The order they're used in the *colors* argument is:
are constants).
**6**
+ **DATA** items and **REM** text.
+
+**7**
Variable names.
So, the default color scheme is equivalent to:
- **-c** *32516n*
+ **-c** *325166n*
NOTES
=====