From cd855d3740c9fa0574bf15616754b359e4c9e1b1 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 16 Nov 2014 01:28:41 +0000 Subject: Added /time off --- src/command/command.c | 1 + src/command/commands.c | 5 +++++ src/ui/console.c | 2 ++ src/ui/window.c | 20 +++++++++++--------- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/command/command.c b/src/command/command.c index 76f8d5e0..3dcca100 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1409,6 +1409,7 @@ cmd_init(void) time_ac = autocomplete_new(); autocomplete_add(time_ac, "minutes"); autocomplete_add(time_ac, "seconds"); + autocomplete_add(time_ac, "off"); cmd_history_init(); } diff --git a/src/command/commands.c b/src/command/commands.c index 2393a72c..3e3f7b0c 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -3043,6 +3043,11 @@ cmd_time(gchar **args, struct cmd_help_t help) cons_show("Time precision set to seconds."); wins_resize_all(); return TRUE; + } else if (g_strcmp0(args[0], "off") == 0) { + prefs_set_string(PREF_TIME, "off"); + cons_show("Time display disabled."); + wins_resize_all(); + return TRUE; } else { cons_show("Usage: %s", help.usage); return TRUE; diff --git a/src/ui/console.c b/src/ui/console.c index 8d4e041e..5e77a9aa 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -906,6 +906,8 @@ _cons_time_setting(void) char *pref_time = prefs_get_string(PREF_TIME); if (g_strcmp0(pref_time, "minutes") == 0) cons_show("Time (/time) : minutes"); + else if (g_strcmp0(pref_time, "off") == 0) + cons_show("Time (/time) : OFF"); else cons_show("Time (/time) : seconds"); diff --git a/src/ui/window.c b/src/ui/window.c index 6ac0cedb..41590e44 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -580,21 +580,23 @@ _win_print(ProfWin *window, const char show_char, GDateTime *time, int colour = COLOUR_ME; if ((flags & NO_DATE) == 0) { - gchar *date_fmt; + gchar *date_fmt = NULL; char *time_pref = prefs_get_string(PREF_TIME); if (g_strcmp0(time_pref, "minutes") == 0) { date_fmt = g_date_time_format(time, "%H:%M"); - } else { + } else if (g_strcmp0(time_pref, "seconds") == 0) { date_fmt = g_date_time_format(time, "%H:%M:%S"); } free(time_pref); - if ((flags & NO_COLOUR_DATE) == 0) { - wattron(window->win, COLOUR_TIME); - } - wprintw(window->win, "%s %c ", date_fmt, show_char); - if ((flags & NO_COLOUR_DATE) == 0) { - wattroff(window->win, COLOUR_TIME); + if (date_fmt) { + if ((flags & NO_COLOUR_DATE) == 0) { + wattron(window->win, COLOUR_TIME); + } + wprintw(window->win, "%s %c ", date_fmt, show_char); + if ((flags & NO_COLOUR_DATE) == 0) { + wattroff(window->win, COLOUR_TIME); + } } g_free(date_fmt); } @@ -650,7 +652,7 @@ _win_print_wrapped(WINDOW *win, const char * const message) int wrap_space = 0; if (g_strcmp0(time_pref, "minutes") == 0) { wrap_space = 8; - } else { + } else if (g_strcmp0(time_pref, "seconds") == 0) { wrap_space = 11; } free(time_pref); -- cgit 1.4.1-2-gfad0