about summary refs log tree commit diff stats
path: root/src/command/cmd_funcs.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2018-03-08 23:11:49 +0000
committerJames Booth <boothj5@gmail.com>2018-03-08 23:11:49 +0000
commita957c545d30750776e5b3307e71d4069e56a9ea5 (patch)
tree908e66be6668b743c9cf6f406c86defb27606d35 /src/command/cmd_funcs.c
parent720dce866eb759a7b5ecdaff7c7d9ceeb6e2487c (diff)
downloadprofani-tty-a957c545d30750776e5b3307e71d4069e56a9ea5.tar.gz
Add max tabs preference for statusbar
Diffstat (limited to 'src/command/cmd_funcs.c')
-rw-r--r--src/command/cmd_funcs.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 1e5b3b55..8901fbca 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -5827,7 +5827,34 @@ cmd_statusbar(ProfWin *window, const char *const command, gchar **args)
     }
 
     if (g_strcmp0(args[0], "maxtabs") == 0) {
+        if (args[1] == NULL) {
+            cons_bad_cmd_usage(command);
+            return TRUE;
+        }
+
+        char *value = args[1];
+        int intval = 0;
+        char *err_msg = NULL;
+        gboolean res = strtoi_range(value, &intval, 0, INT_MAX, &err_msg);
+        if (res) {
+            if (intval < 0 || intval > 10) {
+                cons_bad_cmd_usage(command);
+                return TRUE;
+            }
 
+            prefs_set_statusbartabs(intval);
+            if (intval == 0) {
+                cons_show("Status bar tabs disabled.");
+            } else {
+                cons_show("Status bar tabs set to %d.", intval);
+            }
+            return TRUE;
+        } else {
+            cons_show(err_msg);
+            cons_bad_cmd_usage(command);
+            free(err_msg);
+            return TRUE;
+        }
     }
 
     if (g_strcmp0(args[0], "up") == 0) {