diff options
author | B. Watson <urchlay@slackware.uk> | 2024-07-11 17:18:08 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-07-11 17:18:08 -0400 |
commit | 6def17acf5ab7b624b710bf3ae9f5714ebf90151 (patch) | |
tree | bd52714063cc9f0a6d0455a18a1fefc95dcb04b5 | |
parent | b4ae9905e11240d6a4061c03d0e78ff0b3f44229 (diff) | |
download | bw-atari8-tools-6def17acf5ab7b624b710bf3ae9f5714ebf90151.tar.gz |
listbas: add -d (dots) mode, stopgap for non-UTF8 terminals.
-rw-r--r-- | listbas.1 | 9 | ||||
-rw-r--r-- | listbas.c | 13 | ||||
-rw-r--r-- | listbas.rst | 7 |
3 files changed, 22 insertions, 7 deletions
@@ -27,12 +27,12 @@ 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-09" "0.2.1" "Urchlay's Atari 8-bit Tools" +.TH "LISTBAS" 1 "2024-07-11" "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 .sp -listbas [\fB\-v\fP] [\fB\-i\fP] [\fB\-a\fP | \fB\-m\fP ] \fBinput\-file\fP +listbas [\fB\-v\fP] [\fB\-i\fP] [\fB\-b\fP] [\fB\-d\fP ] [\fB\-a\fP | \fB\-m\fP ] \fBinput\-file\fP .SH DESCRIPTION .sp \fBlistbas\fP acts like the \fILIST\fP command in BASIC. It reads a @@ -53,6 +53,11 @@ used with redirection; \fBlistbas\fP will not write ATASCII to the terminal. Use bold, for color output. This may make it easier to read on some terminals. Or, it may hurt your eyes... .TP +.B \fB\-d\fP +Print dots rather than Unicode/UTF\-8 characters. Color and inverse +video are still supported in this mode. Use this only if your +terminal \fIreally\fP doesn\(aqt support Unicode (e.g. \fBrxvt\fP(1)). +.TP .B \fB\-i\fP Include the immediate mode command (line 32768) in the output. .TP @@ -20,16 +20,17 @@ #define C_CYAN 6 int immediate = 0, utf8 = 1, magazine = 0, inv = 0, - color = 1, bold = 0, badtok = 0; + color = 1, bold = 0, badtok = 0, dots = 0; const char **table = ata2utf; FILE *outfh; void print_help(void) { - printf("Usage: %s [-a] [-b] [-i] [-m] [-n] [-v] <inputfile>\n", self); + printf("Usage: %s [-a] [-b] [-d] [-i] [-m] [-n] [-v] <inputfile>\n", self); printf(" -a: output raw ATASCII.\n"); printf(" -b: use bold for color output.\n"); + printf(" -d: use dots instead of Unicode/UTF-8.\n"); printf(" -i: show immediate mode command (line 32768).\n"); printf(" -m: magazine style listing (see a8cat(1)).\n"); printf(" -n: disable color syntax highlighting.\n"); @@ -39,7 +40,7 @@ void print_help(void) { void parse_args(int argc, char **argv) { int opt; - while( (opt = getopt(argc, argv, "viamnbh")) != -1) { + while( (opt = getopt(argc, argv, "viamnbdh")) != -1) { switch(opt) { case 'v': verbose = 1; break; case 'i': immediate = 1; break; @@ -47,6 +48,7 @@ void parse_args(int argc, char **argv) { case 'm': utf8 = 0 ; magazine = 1; color = 0; table = ata2mag; break; case 'n': color = 0; break; case 'b': bold = 1; break; + case 'd': dots = 1; break; case 'h': print_help(); exit(0); default: print_help(); @@ -178,7 +180,10 @@ void print_ata_chr(unsigned char c) { end_inv(c); } } - fputs(table[c & 0x7f], outfh); + if(dots) + fputc(isprint(c & 0x7f) ? c & 0x7f : '.', outfh); + else + fputs(table[c & 0x7f], outfh); } void print_string(unsigned int pos, unsigned int len) { diff --git a/listbas.rst b/listbas.rst index 881da5f..d0c6e61 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**] [**-a** | **-m** ] **input-file** +listbas [**-v**] [**-i**] [**-b**] [**-d** ] [**-a** | **-m** ] **input-file** DESCRIPTION =========== @@ -37,6 +37,11 @@ List options Use bold, for color output. This may make it easier to read on some terminals. Or, it may hurt your eyes... +**-d** + Print dots rather than Unicode/UTF-8 characters. Color and inverse + video are still supported in this mode. Use this only if your + terminal *really* doesn't support Unicode (e.g. **rxvt**\(1)). + **-i** Include the immediate mode command (line 32768) in the output. |