aboutsummaryrefslogtreecommitdiff
path: root/tsalis
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2024-02-29 01:50:44 +0100
committerPaul Oliver <contact@pauloliver.dev>2024-02-29 01:50:44 +0100
commit0072819204d1f6ed04fbeb102291c97f0ee9c650 (patch)
tree719cae6861b9c46df6b41f38d738c380eee89c8b /tsalis
parent91e7fe9f6fc23f385262f679ce437c174ec31712 (diff)
Allowed longer simulation names
Diffstat (limited to 'tsalis')
-rw-r--r--tsalis/README.md2
-rw-r--r--tsalis/include/tsalis.h2
-rw-r--r--tsalis/src/handler.c1
-rw-r--r--tsalis/src/printer.c11
-rw-r--r--tsalis/src/tsalis.c8
5 files changed, 17 insertions, 7 deletions
diff --git a/tsalis/README.md b/tsalis/README.md
index 8fddfdb..3f9b6ad 100644
--- a/tsalis/README.md
+++ b/tsalis/README.md
@@ -16,7 +16,7 @@ needed. If you run into any difficulties, please let me know!
You may run *TSALIS* from the terminal in any of these three 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 (any name 10 characters or shorter) and reloaded as needed.
+renamed and reloaded as needed.
|Arguments |Action |
|:--------------|-------------------------------------------------------------------------------:|
diff --git a/tsalis/include/tsalis.h b/tsalis/include/tsalis.h
index d60b7c7..3fb3751 100644
--- a/tsalis/include/tsalis.h
+++ b/tsalis/include/tsalis.h
@@ -1,7 +1,7 @@
#ifndef TSALIS_H
#define TSALIS_H
-#define NAME_MAX_SIZE 10
+#define NAME_MAX_SIZE 128
extern sbool g_exit;
extern sbool g_running;
diff --git a/tsalis/src/handler.c b/tsalis/src/handler.c
index 21aa706..ded2d9a 100644
--- a/tsalis/src/handler.c
+++ b/tsalis/src/handler.c
@@ -130,6 +130,7 @@ static void
renameSim(const char *name)
{
if (strlen(name) <= NAME_MAX_SIZE) {
+ clear();
strncpy(g_simName, name, NAME_MAX_SIZE);
}
}
diff --git a/tsalis/src/printer.c b/tsalis/src/printer.c
index a3f60b6..469b803 100644
--- a/tsalis/src/printer.c
+++ b/tsalis/src/printer.c
@@ -1,4 +1,5 @@
#include <stdarg.h>
+#include <string.h>
#include <curses.h>
#include <salis.h>
#include "printer.h"
@@ -714,7 +715,15 @@ tsp_printData(void)
int linev = 1;
int *line = &linev;
PHEADER("SALIS");
- PSIDGET("name", g_simName);
+
+ if (strlen(g_simName) < 24) {
+ PHEADER(g_simName);
+ } else {
+ attron(COLOR_PAIR(PAIR_HEADER));
+ printWidget((*line)++, "%.20s...", g_simName);
+ standend();
+ }
+
PSIDGET("state", g_running ? "running" : "paused");
if (g_autoSaveInterval) {
diff --git a/tsalis/src/tsalis.c b/tsalis/src/tsalis.c
index ab24c61..81c9a3d 100644
--- a/tsalis/src/tsalis.c
+++ b/tsalis/src/tsalis.c
@@ -33,7 +33,7 @@ onLoad(const char *fileName)
FILE *testFile;
if (strlen(fileName) > NAME_MAX_SIZE) {
- fputs("ERROR: File name too long", stderr);
+ fputs("ERROR: File name too long\n", stderr);
exit(1);
}
@@ -44,7 +44,7 @@ onLoad(const char *fileName)
fclose(testFile);
s_load(g_simName);
} else {
- fputs("ERROR: File does not exist", stderr);
+ fputs("ERROR: File does not exist\n", stderr);
exit(1);
}
}
@@ -63,11 +63,11 @@ init(int argc, char **argv)
} else if (cmd == 'l') {
onLoad(val);
} else {
- fputs("ERROR: Incorrect arguments", stderr);
+ fputs("ERROR: Incorrect arguments\n", stderr);
exit(1);
}
} else {
- fputs("ERROR: Incorrect argument count", stderr);
+ fputs("ERROR: Incorrect argument count\n", stderr);
exit(1);
}