aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2020-12-30 17:56:22 -0500
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commit9e926c41c05daae9dd8e6e4af20131d55cf2de03 (patch)
tree173ecbe155b9478f0a2d7b19405af88369916fcf /src
parent7b595584975e6a43ab2cd22cab0a16323c9d1c6b (diff)
Added linenoise library, uninitialised variable + renaming
Diffstat (limited to 'src')
-rw-r--r--src/ctaklm.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/ctaklm.c b/src/ctaklm.c
index b343d11..1342770 100644
--- a/src/ctaklm.c
+++ b/src/ctaklm.c
@@ -1,5 +1,8 @@
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <3rd-party/linenoise.h>
#include <tak.h>
int main(int argc, char **argv) {
@@ -31,4 +34,26 @@ int main(int argc, char **argv) {
generate_place(5,1+5*2, STONE_CAPSTONE, buf);
printf("Generated place: %s\n",buf);
+ char *line;
+ while((line = linenoise("hello> ")) != NULL) {
+ /* Do something with the string. */
+ if (line[0] != '\0' && line[0] != '/') {
+ printf("echo: '%s'\n", line);
+ linenoiseHistoryAdd(line); /* Add to the history. */
+ /* linenoiseHistorySave("history.txt"); /\* Save the history on disk. *\/ */
+ } else if (!strncmp(line,"/historylen",11)) {
+ /* The "/historylen" command will change the history len. */
+ int len = atoi(line+11);
+ linenoiseHistorySetMaxLen(len);
+ } else if (!strncmp(line, "/mask", 5)) {
+ linenoiseMaskModeEnable();
+ } else if (!strncmp(line, "/unmask", 7)) {
+ linenoiseMaskModeDisable();
+ } else if (line[0] == '/') {
+ printf("Unreconized command: %s\n", line);
+ }
+ free(line);
+ }
+ return 0;
+
}