Add key binding for pipe-item command

This removes the need of reading the whole data file and find matching
entries if we want to parse appointments in external programs.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2011-06-29 19:26:29 +02:00
parent 9e60084262
commit 309fa84cb7
5 changed files with 33 additions and 7 deletions

View File

@ -368,6 +368,13 @@ main (int argc, char **argv)
do_storage = 1;
break;
case KEY_PIPE_ITEM:
if (wins_slctd () == APP && apoint_hilt () != 0)
day_pipe_item (&conf);
else if (wins_slctd () == TOD && todo_hilt () != 0)
todo_pipe_item ();
break;
case KEY_RAISE_PRIORITY:
case KEY_LOWER_PRIORITY:
if (wins_slctd () == TOD && todo_hilt () != 0)

View File

@ -401,6 +401,7 @@ enum key {
KEY_DEL_ITEM,
KEY_EDIT_ITEM,
KEY_VIEW_ITEM,
KEY_PIPE_ITEM,
KEY_FLAG_ITEM,
KEY_REPEAT_ITEM,
KEY_EDIT_NOTE,

View File

@ -56,6 +56,7 @@ typedef enum
HELP_EXPORT,
HELP_DISPLACEMENT,
HELP_VIEW,
HELP_PIPE,
HELP_TAB,
HELP_GOTO,
HELP_DELETE,
@ -296,6 +297,10 @@ wanted_page (int ch)
page = HELP_VIEW;
break;
case KEY_PIPE_ITEM:
page = HELP_PIPE;
break;
case KEY_RAISE_PRIORITY:
case KEY_LOWER_PRIORITY:
page = HELP_PRIORITY;
@ -451,6 +456,14 @@ help_screen (void)
"Calcurse screen."),
keys_action_firstkey (KEY_VIEW_ITEM));
hscr[HELP_PIPE].title = _("Pipe\n");
(void)snprintf (hscr[HELP_PIPE].text, HELPTEXTSIZ,
_("Pipe the selected item to an external program.\n"
"\nPress the '%s' key to pipe the currently selected appointment or\n"
"todo entry to an external program.\n"
"\nYou will be driven back to calcurse as soon as the program exits.\n"),
keys_action_firstkey (KEY_PIPE_ITEM));
hscr[HELP_TAB].title = _("Tab\n");
(void)snprintf (hscr[HELP_TAB].text, HELPTEXTSIZ,
_("Switch between panels.\n"

View File

@ -91,6 +91,7 @@ static struct keydef_s keydef[NBKEYS] = {
{"del-item", "d D"},
{"edit-item", "e E"},
{"view-item", "v V"},
{"pipe-item", "|"},
{"flag-item", "!"},
{"repeat", "r R"},
{"edit-note", "n N"},
@ -567,6 +568,8 @@ keys_popup_info (enum key key)
_("Flag the currently selected item as important.");
info[KEY_REPEAT_ITEM] =
_("Repeat an item");
info[KEY_PIPE_ITEM] =
_("Pipe the currently selected item to an external program.");
info[KEY_EDIT_NOTE] =
_("Attach (or edit if one exists) a note to the currently selected item");
info[KEY_VIEW_NOTE] =

View File

@ -642,8 +642,8 @@ wins_launch_external (char *file, char *cmd)
}
#define NB_CAL_CMDS 27 /* number of commands while in cal view */
#define NB_APP_CMDS 31 /* same thing while in appointment view */
#define NB_TOD_CMDS 30 /* same thing while in todo view */
#define NB_APP_CMDS 32 /* same thing while in appointment view */
#define NB_TOD_CMDS 31 /* same thing while in todo view */
#define TOTAL_CMDS NB_CAL_CMDS + NB_APP_CMDS + NB_TOD_CMDS
#define CMDS_PER_LINE 6 /* max number of commands per line */
@ -695,6 +695,7 @@ wins_status_bar (void)
struct binding del = {_("Del Item"), KEY_DEL_ITEM};
struct binding edit = {_("Edit Itm"), KEY_EDIT_ITEM};
struct binding view = {_("View"), KEY_VIEW_ITEM};
struct binding pipe = {_("Pipe"), KEY_PIPE_ITEM};
struct binding flag = {_("Flag Itm"), KEY_FLAG_ITEM};
struct binding rept = {_("Repeat"), KEY_REPEAT_ITEM};
struct binding enote = {_("EditNote"), KEY_EDIT_NOTE};
@ -709,13 +710,14 @@ wins_status_bar (void)
&gnday, &gpday, &gnweek, &gpweek, &draw, &othr, &today, &conf, &othr,
/* appointment keys */
&help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view,
&draw, &othr, &rept, &flag, &enote, &vnote, &up, &down, &gnday, &gpday,
&gnweek, &gpweek, &togo, &othr, &today, &conf, &appt, &todo, &cut, &paste,
&othr,
&pipe, &othr, &draw, &rept, &flag, &enote, &vnote, &up, &down, &gnday,
&gpday, &gnweek, &gpweek, &othr, &togo, &today, &conf, &appt, &todo, &cut,
&paste, &othr,
/* todo keys */
&help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view,
&flag, &othr, &rprio, &lprio, &enote, &vnote, &up, &down, &gnday, &gpday,
&gnweek, &gpweek, &togo, &othr, &today, &conf, &appt, &todo, &draw, &othr
&pipe, &othr, &flag, &rprio, &lprio, &enote, &vnote, &up, &down, &gnday,
&gpday, &gnweek, &gpweek, &othr, &togo, &today, &conf, &appt, &todo, &draw,
&othr
};
/* Drawing the keybinding with attribute and label without. */