Add command prompt

This adds support for vim-style command mode. The command mode can be
entered with pressing ":" (by default, the key binding is configurable).

Currently, no command is supported. Support for various commands will be
added later.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2013-07-17 00:37:07 +02:00
parent 5c6131d5ec
commit c4dae80dd2
4 changed files with 19 additions and 3 deletions

View File

@ -488,6 +488,17 @@ static inline void key_generic_quit(void)
} }
} }
static inline void key_generic_cmd(void)
{
char cmd[BUFSIZ] = "";
status_mesg(_("Command:"), "");
if (getstring(win[STA].p, cmd, BUFSIZ, 0, 1) != GETSTRING_VALID)
return;
wins_update(FLAG_STA);
}
/* /*
* Calcurse is a text-based personal organizer which helps keeping track * Calcurse is a text-based personal organizer which helps keeping track
* of events and everyday tasks. It contains a calendar, a 'todo' list, * of events and everyday tasks. It contains a calendar, a 'todo' list,
@ -659,6 +670,7 @@ int main(int argc, char **argv)
HANDLE_KEY(KEY_GENERIC_SCROLL_UP, key_generic_scroll_up); HANDLE_KEY(KEY_GENERIC_SCROLL_UP, key_generic_scroll_up);
HANDLE_KEY(KEY_GENERIC_SCROLL_DOWN, key_generic_scroll_down); HANDLE_KEY(KEY_GENERIC_SCROLL_DOWN, key_generic_scroll_down);
HANDLE_KEY(KEY_GENERIC_QUIT, key_generic_quit); HANDLE_KEY(KEY_GENERIC_QUIT, key_generic_quit);
HANDLE_KEY(KEY_GENERIC_CMD, key_generic_cmd);
case KEY_RESIZE: case KEY_RESIZE:
case ERR: case ERR:

View File

@ -434,6 +434,7 @@ enum key {
KEY_GENERIC_SCROLL_DOWN, KEY_GENERIC_SCROLL_DOWN,
KEY_GENERIC_SCROLL_UP, KEY_GENERIC_SCROLL_UP,
KEY_GENERIC_GOTO_TODAY, KEY_GENERIC_GOTO_TODAY,
KEY_GENERIC_CMD,
KEY_MOVE_RIGHT, KEY_MOVE_RIGHT,
KEY_MOVE_LEFT, KEY_MOVE_LEFT,

View File

@ -78,6 +78,7 @@ static struct keydef_s keydef[NBKEYS] = {
{"generic-scroll-down", "C-n"}, {"generic-scroll-down", "C-n"},
{"generic-scroll-up", "C-p"}, {"generic-scroll-up", "C-p"},
{"generic-goto-today", "C-g"}, {"generic-goto-today", "C-g"},
{"generic-command", ":"},
{"move-right", "l L RGT"}, {"move-right", "l L RGT"},
{"move-left", "h H LFT"}, {"move-left", "h H LFT"},
@ -513,6 +514,7 @@ void keys_popup_info(enum key key)
_("Scroll window up (e.g. when displaying text inside a popup window)."); _("Scroll window up (e.g. when displaying text inside a popup window).");
info[KEY_GENERIC_GOTO_TODAY] = info[KEY_GENERIC_GOTO_TODAY] =
_("Go to today, whichever panel is selected."); _("Go to today, whichever panel is selected.");
info[KEY_GENERIC_CMD] = _("Enter command mode.");
info[KEY_MOVE_RIGHT] = _("Move to the right."); info[KEY_MOVE_RIGHT] = _("Move to the right.");
info[KEY_MOVE_LEFT] = _("Move to the left."); info[KEY_MOVE_LEFT] = _("Move to the left.");
info[KEY_MOVE_DOWN] = _("Move down."); info[KEY_MOVE_DOWN] = _("Move down.");

View File

@ -621,6 +621,7 @@ void wins_status_bar(void)
struct binding today = { _("Today"), KEY_GENERIC_GOTO_TODAY }; struct binding today = { _("Today"), KEY_GENERIC_GOTO_TODAY };
struct binding nview = { _("Nxt View"), KEY_GENERIC_SCROLL_DOWN }; struct binding nview = { _("Nxt View"), KEY_GENERIC_SCROLL_DOWN };
struct binding pview = { _("Prv View"), KEY_GENERIC_SCROLL_UP }; struct binding pview = { _("Prv View"), KEY_GENERIC_SCROLL_UP };
struct binding cmd = { _("Command"), KEY_GENERIC_CMD };
struct binding up = { _("Up"), KEY_MOVE_UP }; struct binding up = { _("Up"), KEY_MOVE_UP };
struct binding down = { _("Down"), KEY_MOVE_DOWN }; struct binding down = { _("Down"), KEY_MOVE_DOWN };
struct binding left = { _("Left"), KEY_MOVE_LEFT }; struct binding left = { _("Left"), KEY_MOVE_LEFT };
@ -647,7 +648,7 @@ void wins_status_bar(void)
&gpday, &gnday, &gpday, &gnday,
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear, &gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear,
&draw, &today, &draw, &today,
&conf &conf, &cmd
}; };
struct binding *bindings_apoint[] = { struct binding *bindings_apoint[] = {
@ -657,7 +658,7 @@ void wins_status_bar(void)
&gpday, &gnday, &gpday, &gnday,
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear, &gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear,
&togo, &today, &togo, &today,
&conf, &appt, &todo, &copy, &paste &conf, &appt, &todo, &copy, &paste, &cmd
}; };
struct binding *bindings_todo[] = { struct binding *bindings_todo[] = {
@ -667,7 +668,7 @@ void wins_status_bar(void)
&gpday, &gnday, &gpday, &gnday,
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear, &gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear,
&togo, &today, &togo, &today,
&conf, &appt, &todo, &draw &conf, &appt, &todo, &draw, &cmd
}; };
enum win active_panel = wins_slctd(); enum win active_panel = wins_slctd();