aboutsummaryrefslogtreecommitdiff
path: root/listbas.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-07-18 04:29:38 -0400
committerB. Watson <urchlay@slackware.uk>2024-07-18 04:29:38 -0400
commit2ef7e58b7a55257a0fc7c31db7be519b56f9190c (patch)
treedcac33476f5d9f054d4814fdadcddbdff973b5e7 /listbas.c
parentf5cb0cc786ca73197a17b56782c5595ff813f570 (diff)
downloadbw-atari8-tools-2ef7e58b7a55257a0fc7c31db7be519b56f9190c.tar.gz
listbas: Turbo indentation support (seems complete, needs more testing).
Diffstat (limited to 'listbas.c')
-rw-r--r--listbas.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/listbas.c b/listbas.c
index dc267c8..f56b39b 100644
--- a/listbas.c
+++ b/listbas.c
@@ -557,9 +557,38 @@ void aplus_indent_line(const unsigned char tok) {
}
void turbo_indent_line(const unsigned char tok) {
+ if(if_without_then) indent_level++;
+ switch(tok) {
+ case 0x40: /* ELSE */
+ if(first_stmt) {
+ /* gets "outdented" */
+ indent_level--;
+ print_indent();
+ indent_level++;
+ }
+ return;
+ case CMD_FOR: /* FOR */
+ case 0x3c: /* REPEAT */
+ case 0x3e: /* WHILE */
+ case 0x45: /* DO */
+ case 0x4f: /* PROC */
+ if(first_stmt) print_indent();
+ indent_level++;
+ return;
+ case CMD_NEXT: /* NEXT */
+ case 0x3d: /* UNTIL */
+ case 0x3f: /* WEND */
+ case 0x41: /* ENDIF */
+ case 0x46: /* LOOP */
+ case 0x51: /* ENDPROC */
+ indent_level--;
+ break;
+ default: break;
+ }
+ if(first_stmt) print_indent();
}
-/* TODO: IF without THEN: the actual IF line is supposed to get indented,
+/* FIXME: IF without THEN: the actual IF line is supposed to get indented,
but only if there's *not* a THEN. no easy way to look ahead that I've
thought of yet. */
/* Note: BXL's PROCEDURE/EXIT (from toolkit extensions) does
@@ -587,6 +616,7 @@ void bxe_indent_line(const unsigned char tok) {
switch(tok) {
case 0x3c: /* ELSE */
if(first_stmt) {
+ /* gets "outdented" */
indent_level--;
print_indent();
indent_level++;