aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--listbas.114
-rw-r--r--listbas.c34
-rw-r--r--listbas.rst5
3 files changed, 36 insertions, 17 deletions
diff --git a/listbas.1 b/listbas.1
index baf8847..9e458a5 100644
--- a/listbas.1
+++ b/listbas.1
@@ -32,7 +32,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
listbas \- List the source of a tokenized Atari 8-bit BASIC program
.SH SYNOPSIS
.sp
-listbas [\fB\-v\fP] [\fB\-i\fP] [\fB\-b\fP] [\fB\-d\fP ] [\fB\-a\fP | \fB\-m\fP ] \fBinput\-file\fP
+listbas [\fB\-a\fP | \fB\-d\fP | \fB\-m\fP | \fB\-x\fP | \fB\-U\fP] [\fB\-b\fP] [\fB\-u\fP] [\fB\-i\fP] [\fB\-l\fP] [\fB\-n\fP | \fB\-C\fP] [\fB\-v\fP] [\fB\-c\fP \fIcolors\fP] \fBinput\-file\fP
.SH DESCRIPTION
.sp
\fBlistbas\fP acts like the \fILIST\fP command in BASIC. It reads a
@@ -80,6 +80,9 @@ because you can\(aqt tell what the dots are supposed to represent.
.B \fB\-i\fP
Include the immediate mode command (line 32768) in the output.
.TP
+.B \fB\-l\fP
+Do not print line numbers.
+.TP
.B \fB\-C\fP
Enable color syntax highlighting. This option is enabled by default;
the \fB\-C\fP option is provided so you can override \fB\-n\fP in
@@ -269,6 +272,15 @@ on variable\-protected programs.
.sp
\-\-
.sp
+The color and inverse/bold/underline support assumes your terminal supports
+ANSI/VT220 escape codes... but it does \fInot\fP use \fBcurses\fP(3X) or
+\fBterminfo\fP(5), or even look at \fBTERM\fP in the environment. It just
+blindly emits the escape codes. Likewise, Unicode characters are printed
+in UTF\-8 encoding, without actually checking whether the terminal or the
+current locale supports UTF\-8.
+.sp
+\-\-
+.sp
I thought about adding an HTML output option, but there\(aqs no need: if you want
a colorful listing of an Atari BASIC program, install \fBaha\fP(1) from
\fI\%https://github.com/theZiz/aha\fP (or your distro\(aqs package repo) and run
diff --git a/listbas.c b/listbas.c
index 5f045c6..26d03a1 100644
--- a/listbas.c
+++ b/listbas.c
@@ -52,10 +52,11 @@
int output_mode = M_UTF8;
-int bold = 0; /* 1 with -b */
-int color = 1; /* 0 with -n */
-int immediate = 0; /* 1 with -i */
-int underline = 0; /* 1 with -u */
+int bold = 0; /* 1 with -b */
+int color = 1; /* 0 with -n */
+int immediate = 0; /* 1 with -i */
+int underline = 0; /* 1 with -u */
+int skip_lineno = 0; /* 1 with -l */
int color_cmd = C_YELLOW;
int color_op = C_GREEN;
@@ -66,9 +67,9 @@ 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 */
-int inv = 0; /* set to 1 when we're printing inverse */
-int cur_color = -1; /* -1 = 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 cur_color = -1; /* -1 = no color */
FILE *outfh;
int parse_color(char c) {
@@ -99,7 +100,7 @@ void parse_color_scheme(const char *arg) {
}
void print_help(void) {
- printf("Usage: %s [-a | -d | -m | -x] [-b] [-i] [-n] [-v] [-c *colors*] <inputfile>\n", self);
+ printf("Usage: %s [-a|-d|-m|-x|-U] [-b] [-i] [-l] [-u] [-n|-C] [-v] [-c *colors*] <inputfile>\n", self);
printf(" -U: output ATASCII as Unicode/UTF-8 (this is the default).\n");
printf(" -a: output raw ATASCII.\n");
printf(" -d: use dots instead of Unicode/UTF-8.\n");
@@ -107,6 +108,7 @@ void print_help(void) {
printf(" -x: XL international character set (UTF-8).\n");
printf(" -b: use bold for color output.\n");
printf(" -i: show immediate mode command (line 32768).\n");
+ printf(" -l: don't print line numbers.\n");
printf(" -C: enable color syntax highlighting (this is the default).\n");
printf(" -n: disable color syntax highlighting.\n");
printf(" -u: use underline for inverse video.\n");
@@ -119,19 +121,20 @@ void parse_args(int argc, char **argv, int from_env) {
optind = 1;
- while( (opt = getopt(argc, argv, "UCviamnbdhxuc:")) != -1) {
+ while( (opt = getopt(argc, argv, "UCviamnbdhxulc:")) != -1) {
switch(opt) {
case 'U': output_mode = M_UTF8; break;
case 'a': output_mode = M_ATASCII; break;
case 'm': output_mode = M_MAG; break;
case 'd': output_mode = M_DOTS; break;
case 'x': output_mode = M_UTF8_I; break;
- case 'v': verbose = 1; break;
- case 'i': immediate = 1; break;
- case 'b': bold = 1; break;
- case 'u': underline = 1; break;
- case 'C': color = 1; break;
- case 'n': color = 0; break;
+ case 'v': verbose = 1; break;
+ case 'i': immediate = 1; break;
+ case 'b': bold = 1; break;
+ case 'u': underline = 1; break;
+ case 'C': color = 1; break;
+ case 'n': color = 0; break;
+ case 'l': skip_lineno = 1; break;
case 'c': parse_color_scheme(optarg); break;
case 'h': print_help(); exit(0);
default:
@@ -374,6 +377,7 @@ void print_string(unsigned int pos, unsigned int len) {
}
CALLBACK(print_lineno) {
+ if(skip_lineno) return;
if(color) color_on(color_lineno);
fprintf(outfh, "%d ", lineno);
if(color) color_off();
diff --git a/listbas.rst b/listbas.rst
index bef304e..ffd2bad 100644
--- a/listbas.rst
+++ b/listbas.rst
@@ -11,7 +11,7 @@ List the source of a tokenized Atari 8-bit BASIC program
SYNOPSIS
========
-listbas [**-v**] [**-i**] [**-b**] [**-d** ] [**-a** | **-m** ] **input-file**
+listbas [**-a** | **-d** | **-m** | **-x** | **-U**] [**-b**] [**-u**] [**-i**] [**-l**] [**-n** | **-C**] [**-v**] [**-c** *colors*] **input-file**
DESCRIPTION
===========
@@ -64,6 +64,9 @@ Other options
**-i**
Include the immediate mode command (line 32768) in the output.
+**-l**
+ Do not print line numbers.
+
**-C**
Enable color syntax highlighting. This option is enabled by default;
the **-C** option is provided so you can override **-n** in