aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-07-11 17:18:08 -0400
committerB. Watson <urchlay@slackware.uk>2024-07-11 17:18:08 -0400
commit6def17acf5ab7b624b710bf3ae9f5714ebf90151 (patch)
treebd52714063cc9f0a6d0455a18a1fefc95dcb04b5
parentb4ae9905e11240d6a4061c03d0e78ff0b3f44229 (diff)
downloadbw-atari8-tools-6def17acf5ab7b624b710bf3ae9f5714ebf90151.tar.gz
listbas: add -d (dots) mode, stopgap for non-UTF8 terminals.
-rw-r--r--listbas.19
-rw-r--r--listbas.c13
-rw-r--r--listbas.rst7
3 files changed, 22 insertions, 7 deletions
diff --git a/listbas.1 b/listbas.1
index e327f89..0fc70b4 100644
--- a/listbas.1
+++ b/listbas.1
@@ -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
diff --git a/listbas.c b/listbas.c
index beacdf0..0a57623 100644
--- a/listbas.c
+++ b/listbas.c
@@ -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.