1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added /time off

This commit is contained in:
James Booth 2014-11-16 01:28:41 +00:00
parent 8c027a56f9
commit cd855d3740
4 changed files with 19 additions and 9 deletions

View File

@ -1409,6 +1409,7 @@ cmd_init(void)
time_ac = autocomplete_new(); time_ac = autocomplete_new();
autocomplete_add(time_ac, "minutes"); autocomplete_add(time_ac, "minutes");
autocomplete_add(time_ac, "seconds"); autocomplete_add(time_ac, "seconds");
autocomplete_add(time_ac, "off");
cmd_history_init(); cmd_history_init();
} }

View File

@ -3043,6 +3043,11 @@ cmd_time(gchar **args, struct cmd_help_t help)
cons_show("Time precision set to seconds."); cons_show("Time precision set to seconds.");
wins_resize_all(); wins_resize_all();
return TRUE; 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 { } else {
cons_show("Usage: %s", help.usage); cons_show("Usage: %s", help.usage);
return TRUE; return TRUE;

View File

@ -906,6 +906,8 @@ _cons_time_setting(void)
char *pref_time = prefs_get_string(PREF_TIME); char *pref_time = prefs_get_string(PREF_TIME);
if (g_strcmp0(pref_time, "minutes") == 0) if (g_strcmp0(pref_time, "minutes") == 0)
cons_show("Time (/time) : minutes"); cons_show("Time (/time) : minutes");
else if (g_strcmp0(pref_time, "off") == 0)
cons_show("Time (/time) : OFF");
else else
cons_show("Time (/time) : seconds"); cons_show("Time (/time) : seconds");

View File

@ -580,15 +580,16 @@ _win_print(ProfWin *window, const char show_char, GDateTime *time,
int colour = COLOUR_ME; int colour = COLOUR_ME;
if ((flags & NO_DATE) == 0) { if ((flags & NO_DATE) == 0) {
gchar *date_fmt; gchar *date_fmt = NULL;
char *time_pref = prefs_get_string(PREF_TIME); char *time_pref = prefs_get_string(PREF_TIME);
if (g_strcmp0(time_pref, "minutes") == 0) { if (g_strcmp0(time_pref, "minutes") == 0) {
date_fmt = g_date_time_format(time, "%H:%M"); 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"); date_fmt = g_date_time_format(time, "%H:%M:%S");
} }
free(time_pref); free(time_pref);
if (date_fmt) {
if ((flags & NO_COLOUR_DATE) == 0) { if ((flags & NO_COLOUR_DATE) == 0) {
wattron(window->win, COLOUR_TIME); wattron(window->win, COLOUR_TIME);
} }
@ -596,6 +597,7 @@ _win_print(ProfWin *window, const char show_char, GDateTime *time,
if ((flags & NO_COLOUR_DATE) == 0) { if ((flags & NO_COLOUR_DATE) == 0) {
wattroff(window->win, COLOUR_TIME); wattroff(window->win, COLOUR_TIME);
} }
}
g_free(date_fmt); g_free(date_fmt);
} }
@ -650,7 +652,7 @@ _win_print_wrapped(WINDOW *win, const char * const message)
int wrap_space = 0; int wrap_space = 0;
if (g_strcmp0(time_pref, "minutes") == 0) { if (g_strcmp0(time_pref, "minutes") == 0) {
wrap_space = 8; wrap_space = 8;
} else { } else if (g_strcmp0(time_pref, "seconds") == 0) {
wrap_space = 11; wrap_space = 11;
} }
free(time_pref); free(time_pref);