aboutsummaryrefslogtreecommitdiffstats
path: root/src/custom.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/custom.c')
-rw-r--r--src/custom.c93
1 files changed, 54 insertions, 39 deletions
diff --git a/src/custom.c b/src/custom.c
index 575960a..2cd385c 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -1,7 +1,7 @@
/*
* Calcurse - text-based organizer
*
- * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org>
+ * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,6 +38,7 @@
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
+#include <langinfo.h>
#include "calcurse.h"
@@ -540,12 +541,12 @@ enum {
SYSTEM_EVENTS,
CONFIRM_QUIT,
CONFIRM_DELETE,
- SYSTEM_DIAGS,
FIRST_DAY_OF_WEEK,
OUTPUT_DATE_FMT,
INPUT_DATE_FMT,
HEADING_POS,
DAY_HEADING_FMT,
+ APPOINTMENT_TIME_FMT,
NB_OPTIONS
};
@@ -570,12 +571,12 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
"general.systemevents = ",
"general.confirmquit = ",
"general.confirmdelete = ",
- "general.systemdialogs = ",
"general.firstdayofweek = ",
"format.outputdate = ",
"format.inputdate = ",
"appearance.headingposition = ",
- "format.dayheading = "
+ "format.dayheading = ",
+ "format.appointmenttime = "
};
const char *panel;
const char *position;
@@ -699,18 +700,10 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
_("(if set to YES, confirmation is required "
"before deleting an event)"));
break;
- case SYSTEM_DIAGS:
- print_bool_option_incolor(win, conf.system_dialogs, y,
- XPOS + strlen(opt[SYSTEM_DIAGS]));
- mvwaddstr(win, y + 1, XPOS,
- _("(if set to YES, messages about loaded "
- "and saved data will be displayed)"));
- break;
case FIRST_DAY_OF_WEEK:
custom_apply_attr(win, ATTR_HIGHEST);
mvwaddstr(win, y, XPOS + strlen(opt[FIRST_DAY_OF_WEEK]),
- ui_calendar_week_begins_on_monday()? _("Monday") :
- _("Sunday"));
+ nl_langinfo(DAY_1 + ui_calendar_get_wday_start()));
custom_remove_attr(win, ATTR_HIGHEST);
mvwaddstr(win, y + 1, XPOS,
_("(specifies the first day of week in the calendar view)"));
@@ -755,6 +748,14 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
mvwaddstr(win, y + 1, XPOS,
_("(Format of the date displayed in the appointments panel)"));
break;
+ case APPOINTMENT_TIME_FMT:
+ custom_apply_attr(win, ATTR_HIGHEST);
+ mvwaddstr(win, y, XPOS + strlen(opt[APPOINTMENT_TIME_FMT]),
+ conf.timefmt);
+ custom_remove_attr(win, ATTR_HIGHEST);
+ mvwaddstr(win, y + 1, XPOS,
+ _("(Format of the time displayed in the appointments panel)"));
+ break;
}
if (hilt)
@@ -780,6 +781,8 @@ static void general_option_edit(int i)
_("Enter a text string (an empty string for the default text)");
const char *output_datefmt_str =
_("Enter the date format (see 'man 3 strftime' for possible formats) ");
+ const char *output_timefmt_str =
+ _("Enter the time format (see 'man 3 strftime' for possible formats) ");
const char *input_datefmt_prefix = _("Enter the date format: ");
const char *periodic_save_str =
_("Enter the delay, in minutes, between automatic saves (0 to disable) ");
@@ -873,9 +876,6 @@ static void general_option_edit(int i)
case CONFIRM_DELETE:
conf.confirm_delete = !conf.confirm_delete;
break;
- case SYSTEM_DIAGS:
- conf.system_dialogs = !conf.system_dialogs;
- break;
case FIRST_DAY_OF_WEEK:
ui_calendar_change_first_day_of_week();
ui_calendar_monthly_view_cache_set_invalid();
@@ -905,6 +905,15 @@ static void general_option_edit(int i)
conf.day_heading[BUFSIZ - 1] = '\0';
}
break;
+ case APPOINTMENT_TIME_FMT:
+ status_mesg(output_timefmt_str, "");
+ strncpy(buf, conf.timefmt, BUFSIZ);
+ buf[BUFSIZ - 1] = '\0';
+ if (updatestring(win[STA].p, &buf, 0, 1) == 0) {
+ strncpy(conf.timefmt, buf, BUFSIZ);
+ conf.timefmt[BUFSIZ - 1] = '\0';
+ }
+ break;
}
mem_free(buf);
@@ -987,10 +996,11 @@ print_keys_bindings(WINDOW * win, int selected_row, int selected_elm,
const int XPOS = 1;
const int EQUALPOS = 23;
const int KEYPOS = 25;
- int noelm, action, y;
+ int noelm, action, y, pos;
+ const char *key = NULL;
noelm = y = 0;
- for (action = 0; action < NBKEYS; action++) {
+ for (action = 0; action < NBVKEYS; action++) {
char *actionstr;
int nbkeys;
@@ -1002,18 +1012,15 @@ print_keys_bindings(WINDOW * win, int selected_row, int selected_elm,
mem_free(actionstr);
mvwaddstr(win, y, EQUALPOS, "=");
if (nbkeys == 0)
- mvwaddstr(win, y, KEYPOS, _("undefined"));
+ mvwaddstr(win, y, KEYPOS, _("UNDEFINED"));
if (action == selected_row)
custom_remove_attr(win, ATTR_HIGHEST);
if (nbkeys > 0) {
if (action == selected_row) {
- const char *key;
- int pos;
-
+ /* Elements may have been added or deleted. */
+ wclrtoeol(win);
pos = KEYPOS;
- while ((key =
- keys_action_nkey(action,
- noelm)) != NULL) {
+ while ((key = keys_action_nkey(action, noelm))) {
if (noelm == selected_elm)
print_key_incolor(win, key,
y, pos);
@@ -1024,8 +1031,9 @@ print_keys_bindings(WINDOW * win, int selected_row, int selected_elm,
pos += utf8_strwidth((char *)key) + 1;
}
} else {
- mvwaddstr(win, y, KEYPOS,
- keys_action_allkeys(action));
+ key = keys_action_allkeys(action);
+ mvwaddstr(win, y, KEYPOS, key);
+ mem_free((char *)key);
}
}
y += yoff;
@@ -1057,9 +1065,11 @@ void custom_keys_config(void)
const int LABELLINES = 3;
clear();
- nbdisplayed = ((notify_bar() ? row - 3 : row - 2) - LABELLINES) / LINESPERKEY;
- wins_scrollwin_init(&kwin, 0, 0, notify_bar() ? row - 3 : row - 2, col, _("keys configuration"));
- wins_scrollwin_set_pad(&kwin, NBKEYS * LINESPERKEY);
+ nbdisplayed = ((notify_bar() ? row - 3 : row - 2) -
+ LABELLINES) / LINESPERKEY;
+ wins_scrollwin_init(&kwin, 0, 0, notify_bar() ? row - 3 : row - 2, col,
+ _("keys configuration"));
+ wins_scrollwin_set_pad(&kwin, NBVKEYS * LINESPERKEY);
wins_scrollwin_draw_deco(&kwin, 0);
custom_keys_config_bar();
selrow = selelm = 0;
@@ -1084,7 +1094,7 @@ void custom_keys_config(void)
}
break;
case KEY_MOVE_DOWN:
- if (selrow < NBKEYS - 1) {
+ if (selrow < NBVKEYS - 1) {
selrow++;
selelm = 0;
if (selrow == lastrow) {
@@ -1115,7 +1125,7 @@ void custom_keys_config(void)
keys_get_label(selrow), 0);
for (;;) {
ch = keys_wgetch(grabwin);
- enum key action = keys_get_action(ch);
+ enum vkey action = keys_get_action(ch);
/* Is the key already used by this action? */
if (action == selrow)
break;
@@ -1154,10 +1164,8 @@ void custom_keys_config(void)
selelm--;
break;
case KEY_GENERIC_QUIT:
- if (keys_check_missing_bindings() != 0) {
- WARN_MSG(_("Some actions do not have any associated "
- "key bindings!"));
- }
+ if (keys_check_undefined())
+ WARN_MSG(_("Some actions are left undefined!"));
wins_scrollwin_delete(&kwin);
return;
}
@@ -1213,7 +1221,10 @@ void custom_config_main(void)
wmove(win[STA].p, 0, 0);
wins_doupdate();
- while ((ch = keys_wgetch(win[KEY].p)) != 'q') {
+ while (1) {
+ ch = keys_wgetch(win[KEY].p);
+ if (keys_get_action(ch) == KEY_GENERIC_QUIT)
+ break;
switch (ch) {
case 'C':
case 'c':
@@ -1231,7 +1242,7 @@ void custom_config_main(void)
old_layout = wins_layout();
custom_layout_config();
if (wins_layout() != old_layout)
- wins_reset();
+ wins_resize();
break;
case 'G':
case 'g':
@@ -1257,7 +1268,11 @@ void custom_config_main(void)
resize = 0;
wins_reset();
}
-
+
+ /* needed to update app list */
+ day_do_storage(0);
+
+ /* wins_update(FLAG_ALL), but with custom bindings */
wins_set_bindings(bindings, ARRAY_SIZE(bindings));
wins_update_border(FLAG_ALL);
wins_update_panels(FLAG_ALL);