about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-11-16 00:40:54 +0000
committerJames Booth <boothj5@gmail.com>2014-11-16 00:40:54 +0000
commit40dc8e2c495deac830403872346dff9dd2b24499 (patch)
treeb5d15c22eec80ce7c637721b61ac2ce92955e440 /src/command
parent1479a5e134004568245996a22418dadb6b6da6f6 (diff)
downloadprofani-tty-40dc8e2c495deac830403872346dff9dd2b24499.tar.gz
Added /time setting
Diffstat (limited to 'src/command')
-rw-r--r--src/command/command.c19
-rw-r--r--src/command/commands.c19
-rw-r--r--src/command/commands.h1
3 files changed, 37 insertions, 2 deletions
diff --git a/src/command/command.c b/src/command/command.c
index f4add150..76f8d5e0 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -597,6 +597,14 @@ static struct cmd_t command_defs[] =
           "Enable or disable word wrapping.",
           NULL } } },
 
+    { "/time",
+        cmd_time, parse_args, 1, 1, &cons_time_setting,
+        { "/time minutes|seconds", "Time display.",
+        { "/time minutes|seconds",
+          "---------------------",
+          "Configure time precision for the main window.",
+          NULL } } },
+
     { "/notify",
         cmd_notify, parse_args, 2, 3, &cons_notify_setting,
         { "/notify [type value]|[type setting value]", "Control various desktop noficiations.",
@@ -1071,6 +1079,7 @@ static Autocomplete form_ac;
 static Autocomplete form_field_multi_ac;
 static Autocomplete occupants_ac;
 static Autocomplete occupants_default_ac;
+static Autocomplete time_ac;
 
 /*
  * Initialise command autocompleter and history
@@ -1397,6 +1406,10 @@ cmd_init(void)
     autocomplete_add(occupants_default_ac, "show");
     autocomplete_add(occupants_default_ac, "hide");
 
+    time_ac = autocomplete_new();
+    autocomplete_add(time_ac, "minutes");
+    autocomplete_add(time_ac, "seconds");
+
     cmd_history_init();
 }
 
@@ -1450,6 +1463,7 @@ cmd_uninit(void)
     autocomplete_free(form_field_multi_ac);
     autocomplete_free(occupants_ac);
     autocomplete_free(occupants_default_ac);
+    autocomplete_free(time_ac);
 }
 
 gboolean
@@ -1620,6 +1634,7 @@ cmd_reset_autocomplete()
     autocomplete_reset(form_field_multi_ac);
     autocomplete_reset(occupants_ac);
     autocomplete_reset(occupants_default_ac);
+    autocomplete_reset(time_ac);
 
     if (ui_current_win_type() == WIN_MUC_CONFIG) {
         ProfWin *window = wins_get_current();
@@ -1885,8 +1900,8 @@ _cmd_complete_parameters(char *input, int *size)
         }
     }
 
-    gchar *cmds[] = { "/help", "/prefs", "/disco", "/close", "/wins", "/subject", "/room" };
-    Autocomplete completers[] = { help_ac, prefs_ac, disco_ac, close_ac, wins_ac, subject_ac, room_ac };
+    gchar *cmds[] = { "/help", "/prefs", "/disco", "/close", "/wins", "/subject", "/room", "/time" };
+    Autocomplete completers[] = { help_ac, prefs_ac, disco_ac, close_ac, wins_ac, subject_ac, room_ac, time_ac };
 
     for (i = 0; i < ARRAY_SIZE(cmds); i++) {
         result = autocomplete_param_with_ac(input, size, cmds[i], completers[i], TRUE);
diff --git a/src/command/commands.c b/src/command/commands.c
index 3ae0015d..2393a72c 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -3031,6 +3031,25 @@ cmd_wrap(gchar **args, struct cmd_help_t help)
 }
 
 gboolean
+cmd_time(gchar **args, struct cmd_help_t help)
+{
+    if (g_strcmp0(args[0], "minutes") == 0) {
+        prefs_set_string(PREF_TIME, "minutes");
+        cons_show("Time precision set to minutes.");
+        wins_resize_all();
+        return TRUE;
+    } else if (g_strcmp0(args[0], "seconds") == 0) {
+        prefs_set_string(PREF_TIME, "seconds");
+        cons_show("Time precision set to seconds.");
+        wins_resize_all();
+        return TRUE;
+    } else {
+        cons_show("Usage: %s", help.usage);
+        return TRUE;
+    }
+}
+
+gboolean
 cmd_states(gchar **args, struct cmd_help_t help)
 {
     gboolean result = _cmd_set_boolean_preference(args[0], help, "Sending chat states",
diff --git a/src/command/commands.h b/src/command/commands.h
index 87c05453..b5646caf 100644
--- a/src/command/commands.h
+++ b/src/command/commands.h
@@ -134,6 +134,7 @@ gboolean cmd_role(gchar **args, struct cmd_help_t help);
 gboolean cmd_privileges(gchar **args, struct cmd_help_t help);
 gboolean cmd_presence(gchar **args, struct cmd_help_t help);
 gboolean cmd_wrap(gchar **args, struct cmd_help_t help);
+gboolean cmd_time(gchar **args, struct cmd_help_t help);
 
 gboolean cmd_form_field(char *tag, gchar **args);