From 2ef7e58b7a55257a0fc7c31db7be519b56f9190c Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Thu, 18 Jul 2024 04:29:38 -0400 Subject: listbas: Turbo indentation support (seems complete, needs more testing). --- listbas.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'listbas.c') 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++; -- cgit v1.2.3