aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xChangeLog6
-rwxr-xr-xsrc/custom.c64
-rwxr-xr-xsrc/day.c14
-rwxr-xr-xsrc/io.c7
-rwxr-xr-xsrc/keys.c45
-rwxr-xr-xsrc/keys.h7
-rwxr-xr-xsrc/recur.c4
-rwxr-xr-xsrc/todo.c4
-rwxr-xr-xsrc/utils.c6
9 files changed, 102 insertions, 55 deletions
diff --git a/ChangeLog b/ChangeLog
index 324b158..f0eefe7 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,13 @@
+2008-12-08 Frederic Culot <frederic@culot.org>
+
+ * src/custom.c (custom_color_config_bar): new function
+
2008-12-07 Frederic Culot <frederic@culot.org>
* src/keys.c: arrow keys can now also be used to define key
bindings
+
+ * src/keys.c (keys_check_missing_bindings): new function
2008-12-06 Frederic Culot <frederic@culot.org>
diff --git a/src/custom.c b/src/custom.c
index 1c3217e..6263008 100755
--- a/src/custom.c
+++ b/src/custom.c
@@ -1,4 +1,4 @@
-/* $calcurse: custom.c,v 1.28 2008/12/07 09:20:38 culot Exp $ */
+/* $calcurse: custom.c,v 1.29 2008/12/08 19:17:07 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -432,6 +432,26 @@ custom_confwin_init (window_t *confwin, char *label)
}
}
+static void
+custom_color_config_bar (void)
+{
+ binding_t quit = {_("Exit"), KEY_GENERIC_QUIT};
+ binding_t select = {_("Select"), KEY_GENERIC_SELECT};
+ binding_t nocolor = {_("No color"), KEY_GENERIC_CANCEL};
+ binding_t up = {_("Up"), KEY_MOVE_UP};
+ binding_t down = {_("Down"), KEY_MOVE_DOWN};
+ binding_t left = {_("Left"), KEY_MOVE_LEFT};
+ binding_t right = {_("Right"), KEY_MOVE_RIGHT};
+
+
+ binding_t *binding[] = {
+ &quit, &nocolor, &up, &down, &left, &right, &select
+ };
+ int binding_size = sizeof (binding) / sizeof (binding[0]);
+
+ keys_display_bindings_bar (win[STA].p, binding, 0, binding_size);
+}
+
/*
* Used to display available colors in color configuration menu.
* This is useful for window resizing.
@@ -444,7 +464,6 @@ display_color_config (window_t *cwin, int *mark_fore, int *mark_back,
#define DEFAULTCOLOR 255
#define DEFAULTCOLOR_EXT -1
#define CURSOR (32 | A_REVERSE)
-#define SPACE 32
#define MARK 88
char *fore_txt = _("Foreground");
@@ -452,9 +471,6 @@ display_color_config (window_t *cwin, int *mark_fore, int *mark_back,
char *default_txt = _("(terminal's default)");
char *bar = " ";
char *box = "[ ]";
- char *choose_color_1 = _("Use 'X' or SPACE to select a color, "
- "'H/L' 'J/K' or arrow keys to move");
- char *choose_color_2 = _("('0' for no color, 'Q' to exit) :");
char label[BUFSIZ];
const unsigned Y = 3;
const unsigned XOFST = 5;
@@ -559,7 +575,7 @@ display_color_config (window_t *cwin, int *mark_fore, int *mark_back,
}
mvwaddch (cwin->p, pos[cursor][YPOS], pos[cursor][XPOS] + 1, CURSOR);
- status_mesg (choose_color_1, choose_color_2);
+ custom_color_config_bar ();
wnoutrefresh (win[STA].p);
wnoutrefresh (cwin->p);
doupdate ();
@@ -585,7 +601,7 @@ custom_color_config (void)
display_color_config (&conf_win, &mark_fore, &mark_back, cursor,
need_reset, theme_changed);
- while ((ch = wgetch (win[STA].p)) != 'q')
+ while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT)
{
need_reset = 0;
theme_changed = 0;
@@ -599,9 +615,7 @@ custom_color_config (void)
need_reset = 1;
break;
- case SPACE:
- case 'X':
- case 'x':
+ case KEY_GENERIC_SELECT:
colorize = true;
need_reset = 1;
theme_changed = 1;
@@ -611,35 +625,27 @@ custom_color_config (void)
mark_fore = cursor;
break;
- case KEY_DOWN:
- case 'J':
- case 'j':
+ case KEY_MOVE_DOWN:
if (cursor < SIZE - 1)
++cursor;
break;
- case KEY_UP:
- case 'K':
- case 'k':
+ case KEY_MOVE_UP:
if (cursor > 0)
--cursor;
break;
- case KEY_LEFT:
- case 'H':
- case 'h':
+ case KEY_MOVE_LEFT:
if (cursor > NBUSERCOLORS)
cursor -= (NBUSERCOLORS + 1);
break;
- case KEY_RIGHT:
- case 'L':
- case 'l':
+ case KEY_MOVE_RIGHT:
if (cursor <= NBUSERCOLORS)
cursor += (NBUSERCOLORS + 1);
break;
- case '0':
+ case KEY_GENERIC_CANCEL:
colorize = false;
need_reset = 1;
break;
@@ -1073,7 +1079,9 @@ custom_keys_config (void)
delwin (grabwin);
}
while (used);
- selelm++;
+ nbrowelm++;
+ if (selelm < nbrowelm - 1)
+ selelm++;
#undef WINROW
#undef WINCOL
break;
@@ -1081,10 +1089,16 @@ custom_keys_config (void)
keystr = keys_action_nkey (selrow, selelm);
keyval = keys_str2int (keystr);
keys_remove_binding (keyval, selrow);
- if (selelm > 0)
+ nbrowelm--;
+ if (selelm > 0 && selelm <= nbrowelm)
selelm--;
break;
case KEY_GENERIC_QUIT:
+ if (keys_check_missing_bindings () != 0)
+ {
+ ERROR_MSG (_("Some actions do not have any associated "
+ "key bindings!"));
+ }
wins_scrollwin_delete (&kwin);
return;
}
diff --git a/src/day.c b/src/day.c
index 640f69f..4b0e067 100755
--- a/src/day.c
+++ b/src/day.c
@@ -1,4 +1,4 @@
-/* $calcurse: day.c,v 1.39 2008/12/07 09:20:38 culot Exp $ */
+/* $calcurse: day.c,v 1.40 2008/12/08 19:17:07 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -736,7 +736,7 @@ day_edit_item (conf_t *conf)
case RECUR_EVNT:
re = recur_get_event (date, day_item_nb (date, item_num, RECUR_EVNT));
status_mesg (_("Edit: (1)Description or (2)Repetition?"), "[1/2] ");
- while (ch != '1' && ch != '2' && ch != KEY_GENERIC_ESCAPE)
+ while (ch != '1' && ch != '2' && ch != KEY_GENERIC_CANCEL)
ch = wgetch (win[STA].p);
switch (ch)
{
@@ -759,7 +759,7 @@ day_edit_item (conf_t *conf)
status_mesg (_("Edit: (1)Start time, (2)End time, "
"(3)Description or (4)Repetition?"), "[1/2/3/4] ");
while (ch != STRT && ch != END && ch != DESC &&
- ch != REPT && ch != KEY_GENERIC_ESCAPE)
+ ch != REPT && ch != KEY_GENERIC_CANCEL)
ch = wgetch (win[STA].p);
switch (ch)
{
@@ -775,7 +775,7 @@ day_edit_item (conf_t *conf)
case REPT:
update_rept (&ra->rpt, ra->start, conf);
break;
- case KEY_GENERIC_ESCAPE:
+ case KEY_GENERIC_CANCEL:
return;
}
break;
@@ -783,7 +783,7 @@ day_edit_item (conf_t *conf)
a = apoint_get (date, day_item_nb (date, item_num, APPT));
status_mesg (_("Edit: (1)Start time, (2)End time "
"or (3)Description?"), "[1/2/3] ");
- while (ch != STRT && ch != END && ch != DESC && ch != KEY_GENERIC_ESCAPE)
+ while (ch != STRT && ch != END && ch != DESC && ch != KEY_GENERIC_CANCEL)
ch = wgetch (win[STA].p);
switch (ch)
{
@@ -796,7 +796,7 @@ day_edit_item (conf_t *conf)
case DESC:
update_desc (&a->mesg);
break;
- case KEY_GENERIC_ESCAPE:
+ case KEY_GENERIC_CANCEL:
return;
}
break;
@@ -852,7 +852,7 @@ day_erase_item (long date, int item_number, erase_flag_e flag)
{
if (flag == ERASE_FORCE_ONLY_NOTE)
ch = 'a';
- while ((ch != 'a') && (ch != 'o') && (ch != KEY_GENERIC_ESCAPE))
+ while ((ch != 'a') && (ch != 'o') && (ch != KEY_GENERIC_CANCEL))
{
status_mesg (erase_warning, erase_choice);
ch = wgetch (win[STA].p);
diff --git a/src/io.c b/src/io.c
index cc56b97..de3950b 100755
--- a/src/io.c
+++ b/src/io.c
@@ -1,4 +1,4 @@
-/* $calcurse: io.c,v 1.45 2008/12/07 09:20:38 culot Exp $ */
+/* $calcurse: io.c,v 1.46 2008/12/08 19:17:07 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -1707,7 +1707,6 @@ ical_unformat_line (char *line)
static char *
ical_unfold_content (FILE *fd, char *line, unsigned *lineno)
{
- const int CHAR_SPACE = 32;
char *content;
int c;
@@ -1718,7 +1717,7 @@ ical_unfold_content (FILE *fd, char *line, unsigned *lineno)
for (;;)
{
c = getc (fd);
- if (c == CHAR_SPACE || c == TAB)
+ if (c == SPACE || c == TAB)
{
char buf[BUFSIZ];
@@ -2703,7 +2702,7 @@ void
io_log_print (io_file_t *log, int line, char *msg)
{
if (log && log->fd)
- fprintf (log->fd, "[%d]: %s\n", line, msg);
+ fprintf (log->fd, "line %d: %s\n", line, msg);
}
void
diff --git a/src/keys.c b/src/keys.c
index c3fbde4..9b5a661 100755
--- a/src/keys.c
+++ b/src/keys.c
@@ -1,4 +1,4 @@
-/* $calcurse: keys.c,v 1.7 2008/12/07 09:20:38 culot Exp $ */
+/* $calcurse: keys.c,v 1.8 2008/12/08 19:17:07 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -50,6 +50,7 @@ static keys_e actions[MAXKEYVAL];
static struct keydef_s keydef[NBKEYS] = {
{"generic-escape", "ESC"},
+ {"generic-select", "SPC"},
{"generic-credits", "@"},
{"generic-help", "?"},
{"generic-quit", "q Q"},
@@ -105,9 +106,10 @@ dump_intro (FILE *fd)
"#\n"
"# To define bindings which use the CONTROL key, prefix the key with "
"'C-'.\n"
- "# The escape and horizontal Tab key can be specified using the 'ESC'\n"
- "# and 'TAB' keyword, respectively. Arrow keys can also be specified\n"
- "# with the UP, DWN, LFT, RGT keywords.\n#\n"
+ "# The escape, space bar and horizontal Tab key can be specified using\n"
+ "# the 'ESC', 'SPC' and 'TAB' keyword, respectively.\n"
+ "# Arrow keys can also be specified with the UP, DWN, LFT, RGT keywords."
+ "\n#\n"
"# A description of what each ACTION keyword is used for is available\n"
"# from calcurse online configuration menu.\n");
@@ -164,8 +166,13 @@ keys_getch (WINDOW *win)
int ch;
ch = wgetch (win);
-
- return keys_get_action (ch);
+ switch (ch)
+ {
+ case KEY_RESIZE:
+ return KEY_RESIZE;
+ default:
+ return keys_get_action (ch);
+ }
}
static void
@@ -253,6 +260,7 @@ keys_str2int (char *key)
{
const string_t CONTROL_KEY = STRING_BUILD ("C-");
const string_t TAB_KEY = STRING_BUILD ("TAB");
+ const string_t SPACE_KEY = STRING_BUILD ("SPC");
const string_t ESCAPE_KEY = STRING_BUILD ("ESC");
const string_t CURSES_KEY_UP = STRING_BUILD ("UP");
const string_t CURSES_KEY_DOWN = STRING_BUILD ("DWN");
@@ -273,6 +281,8 @@ keys_str2int (char *key)
return TAB;
else if (!strncmp (key, ESCAPE_KEY.str, ESCAPE_KEY.len))
return ESCAPE;
+ else if (!strncmp (key, SPACE_KEY.str, SPACE_KEY.len))
+ return SPACE;
else if (!strncmp (key, CURSES_KEY_UP.str, CURSES_KEY_UP.len))
return KEY_UP;
else if (!strncmp (key, CURSES_KEY_DOWN.str, CURSES_KEY_DOWN.len))
@@ -293,6 +303,8 @@ keys_int2str (int key)
{
case TAB:
return "TAB";
+ case SPACE:
+ return "SPC";
case ESCAPE:
return "ESC";
case KEY_UP:
@@ -348,7 +360,7 @@ keys_action_allkeys (keys_e action)
{
static char keystr[BUFSIZ];
struct key_str_s *i;
- const char *SPACE = " ";
+ const char *CHAR_SPACE = " ";
if (keys[action] == NULL)
return NULL;
@@ -357,7 +369,7 @@ keys_action_allkeys (keys_e action)
{
const int MAXLEN = sizeof (keystr) - 1 - strlen (keystr);
strncat (keystr, i->str, MAXLEN - 1);
- strncat (keystr, SPACE, 1);
+ strncat (keystr, CHAR_SPACE, 1);
}
return keystr;
@@ -442,8 +454,10 @@ keys_popup_info (keys_e key)
char *info[NBKEYS];
WINDOW *infowin;
- info[KEY_GENERIC_ESCAPE] =
+ info[KEY_GENERIC_CANCEL] =
_("Cancel the ongoing action.");
+ info[KEY_GENERIC_SELECT] =
+ _("Select the highlighted item.");
info[KEY_GENERIC_CREDITS] =
_("Print general information about calcurse's authors, license, etc.");
info[KEY_GENERIC_HELP] =
@@ -545,3 +559,16 @@ keys_save_bindings (FILE *fd)
for (i = 0; i < NBKEYS; i++)
fprintf (fd, "%s %s\n", keydef[i].label, keys_action_allkeys (i));
}
+
+int
+keys_check_missing_bindings (void)
+{
+ int i;
+
+ for (i = 0; i < NBKEYS; i++)
+ {
+ if (keys[i] == 0)
+ return 1;
+ }
+ return 0;
+}
diff --git a/src/keys.h b/src/keys.h
index 6f55cbb..1ed24a4 100755
--- a/src/keys.h
+++ b/src/keys.h
@@ -1,4 +1,4 @@
-/* $calcurse: keys.h,v 1.5 2008/11/25 20:48:58 culot Exp $ */
+/* $calcurse: keys.h,v 1.6 2008/12/08 19:17:07 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -31,6 +31,7 @@
#define CTRL(x) ((x) & CTRLVAL)
#define ESCAPE 27
#define TAB 9
+#define SPACE 32
#define KEYS_KEYLEN 3 /* length of each keybinding */
#define KEYS_LABELEN 8 /* length of command description */
@@ -38,7 +39,8 @@
typedef enum
{
- KEY_GENERIC_ESCAPE,
+ KEY_GENERIC_CANCEL,
+ KEY_GENERIC_SELECT,
KEY_GENERIC_CREDITS,
KEY_GENERIC_HELP,
KEY_GENERIC_QUIT,
@@ -103,5 +105,6 @@ char *keys_action_allkeys (keys_e);
void keys_display_bindings_bar (WINDOW *, binding_t **, int, int);
void keys_popup_info (keys_e);
void keys_save_bindings (FILE *);
+int keys_check_missing_bindings (void);
#endif /* CALCURSE_KEYS_H */
diff --git a/src/recur.c b/src/recur.c
index f6c46e8..56adf1e 100755
--- a/src/recur.c
+++ b/src/recur.c
@@ -1,4 +1,4 @@
-/* $calcurse: recur.c,v 1.40 2008/12/07 09:20:38 culot Exp $ */
+/* $calcurse: recur.c,v 1.41 2008/12/08 19:17:07 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -694,7 +694,7 @@ recur_repeat_item (conf_t *conf)
}
while ((ch != 'D') && (ch != 'W') && (ch != 'M')
- && (ch != 'Y') && (ch != KEY_GENERIC_ESCAPE))
+ && (ch != 'Y') && (ch != KEY_GENERIC_CANCEL))
{
status_mesg (mesg_type_1, mesg_type_2);
ch = wgetch (win[STA].p);
diff --git a/src/todo.c b/src/todo.c
index 6f17729..6da9c42 100755
--- a/src/todo.c
+++ b/src/todo.c
@@ -1,4 +1,4 @@
-/* $calcurse: todo.c,v 1.25 2008/12/07 09:20:38 culot Exp $ */
+/* $calcurse: todo.c,v 1.26 2008/12/08 19:17:07 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -274,7 +274,7 @@ todo_delete (conf_t *conf)
if (has_note == 0)
answer = 't';
- while (answer != 't' && answer != 'n' && answer != KEY_GENERIC_ESCAPE)
+ while (answer != 't' && answer != 'n' && answer != KEY_GENERIC_CANCEL)
{
status_mesg (erase_warning, erase_choice);
answer = wgetch (win[STA].p);
diff --git a/src/utils.c b/src/utils.c
index 31a4bf4..b04f023 100755
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,4 +1,4 @@
-/* $calcurse: utils.c,v 1.55 2008/12/07 09:20:38 culot Exp $ */
+/* $calcurse: utils.c,v 1.56 2008/12/08 19:17:07 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -226,9 +226,7 @@ showcursor (WINDOW *win, int y, int pos, char *str, int l, int offset)
nc = str + pos;
wmove (win, y, pos - offset);
-#define SPACE 32
(pos >= l) ? waddch (win, SPACE | A_REVERSE) : waddch (win, *nc | A_REVERSE);
-#undef SPACE
}
/* Print the string at the desired position. */
@@ -368,7 +366,7 @@ getstring (WINDOW *win, char *str, int l, int x, int y)
newpos++;
break;
- case KEY_GENERIC_ESCAPE: /* cancel editing */
+ case KEY_GENERIC_CANCEL: /* cancel editing */
return (GETSTRING_ESC);
break;