From 9a094c5c67fa1408c96e556e95f52f15dc5efda6 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 01:50:45 +0100 Subject: Better command-line arguments for TSalis. TSalis may now be started using more standard arguments: "-n", "--new", "-l" and "--load". Also, updated README file to address this and previous changes. --- tsalis/README.md | 17 ++++++++++------- tsalis/src/printer.c | 2 ++ tsalis/src/tsalis.c | 13 +++++-------- 3 files changed, 17 insertions(+), 15 deletions(-) (limited to 'tsalis') diff --git a/tsalis/README.md b/tsalis/README.md index bb50c38..4b9709f 100644 --- a/tsalis/README.md +++ b/tsalis/README.md @@ -15,17 +15,19 @@ let me know! ## List of commands ### Command-line arguments -You may run *TSALIS* from the terminal in any of these three ways (arguments +You may run *TSALIS* from the terminal in any of the following ways (arguments are being represented by *XX*). Note that, upon exit, *SALIS* automatically generates a save (by default called *def.sim*). This save file may be freely renamed and reloaded as needed. -|Arguments |Action | -|:--------------|-------------------------------------------------------------------------------:| -|tsalis |If file *def.sim* exists in directory, loads simulation from that file. | -|tsalis |If file *def.sim* does not exist, creates new simulation (memory size 2^16). | -|tsalis n*XX* |Creates new simulation with memory size 2^*XX*. | -|tsalis l*XX* |Loads simulation from file named *XX*. | +|Arguments |Action | +|:------------------|-------------------------------------------------------------------------------:| +|tsalis |If file *def.sim* exists in directory, loads simulation from that file. | +|tsalis |If file *def.sim* does not exist, creates new simulation (memory size 2^16). | +|tsalis -n *XX* |Creates new simulation with memory size 2^*XX*. | +|tsalis --new *XX* |Creates new simulation with memory size 2^*XX*. | +|tsalis -l *XX* |Loads simulation from file named *XX*. | +|tsalis --load *XX* |Loads simulation from file named *XX*. | ### Keyboard commands |Key |Action | @@ -33,6 +35,7 @@ renamed and reloaded as needed. |Left arrow |Previous page | |Right arrow |Next page | |wasd |Scroll (PROCESS and WORLD page) | +|WA |Fast vertical scroll (PROCESS and WORLD page) | |Q |Scroll to top (PROCESS and WORLD page) | |A |Scroll to left (PROCESS page) | |zx |Zoom in/out (WORLD page) | diff --git a/tsalis/src/printer.c b/tsalis/src/printer.c index c835f24..ec01ada 100644 --- a/tsalis/src/printer.c +++ b/tsalis/src/printer.c @@ -102,12 +102,14 @@ tsp_check(void) return SFALSE; } + endwin(); return STRUE; } void tsp_init(void) { + initscr(); cbreak(); noecho(); curs_set(0); diff --git a/tsalis/src/tsalis.c b/tsalis/src/tsalis.c index 7722ca9..dc57fa4 100644 --- a/tsalis/src/tsalis.c +++ b/tsalis/src/tsalis.c @@ -59,14 +59,11 @@ init(int argc, char **argv) if (argc == 1) { onDefault(); - } else if (argc == 2) { - char cmd = argv[1][0]; - char *val = &argv[1][1]; - - if (cmd == 'n') { - s_init(atoi(val)); - } else if (cmd == 'l') { - onLoad(val); + } else if (argc == 3) { + if (!strcmp(argv[1], "-n") || !strcmp(argv[1], "--new")) { + s_init(atoi(argv[2])); + } else if (!strcmp(argv[1], "-l") || !strcmp(argv[1], "--load")) { + onLoad(argv[2]); } else { fputs("ERROR: Incorrect arguments\n", stderr); exit(1); -- cgit v1.2.1