summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2013-07-17 00:37:07 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2013-07-17 14:03:53 +0200
commitc4dae80dd23989d4146475de3d16d1636b190c9d (patch)
treecca4767a14af66639ceead8f85dc8d1d12ca7090 /src
parent5c6131d5eca9910e06e14b0b2c4b72a21ef2e4b4 (diff)
downloadcalcurse-c4dae80dd23989d4146475de3d16d1636b190c9d.tar.gz
calcurse-c4dae80dd23989d4146475de3d16d1636b190c9d.zip
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>
Diffstat (limited to 'src')
-rw-r--r--src/calcurse.c12
-rw-r--r--src/calcurse.h1
-rw-r--r--src/keys.c2
-rw-r--r--src/wins.c7
4 files changed, 19 insertions, 3 deletions
diff --git a/src/calcurse.c b/src/calcurse.c
index 0247ba0..460f4c4 100644
--- a/src/calcurse.c
+++ b/src/calcurse.c
@@ -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
* 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_DOWN, key_generic_scroll_down);
HANDLE_KEY(KEY_GENERIC_QUIT, key_generic_quit);
+ HANDLE_KEY(KEY_GENERIC_CMD, key_generic_cmd);
case KEY_RESIZE:
case ERR:
diff --git a/src/calcurse.h b/src/calcurse.h
index 2dffe6d..e0fe84f 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -434,6 +434,7 @@ enum key {
KEY_GENERIC_SCROLL_DOWN,
KEY_GENERIC_SCROLL_UP,
KEY_GENERIC_GOTO_TODAY,
+ KEY_GENERIC_CMD,
KEY_MOVE_RIGHT,
KEY_MOVE_LEFT,
diff --git a/src/keys.c b/src/keys.c
index 0ef3085..83b1fb3 100644
--- a/src/keys.c
+++ b/src/keys.c
@@ -78,6 +78,7 @@ static struct keydef_s keydef[NBKEYS] = {
{"generic-scroll-down", "C-n"},
{"generic-scroll-up", "C-p"},
{"generic-goto-today", "C-g"},
+ {"generic-command", ":"},
{"move-right", "l L RGT"},
{"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).");
info[KEY_GENERIC_GOTO_TODAY] =
_("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_LEFT] = _("Move to the left.");
info[KEY_MOVE_DOWN] = _("Move down.");
diff --git a/src/wins.c b/src/wins.c
index c200b6e..4cb9b15 100644
--- a/src/wins.c
+++ b/src/wins.c
@@ -621,6 +621,7 @@ void wins_status_bar(void)
struct binding today = { _("Today"), KEY_GENERIC_GOTO_TODAY };
struct binding nview = { _("Nxt View"), KEY_GENERIC_SCROLL_DOWN };
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 down = { _("Down"), KEY_MOVE_DOWN };
struct binding left = { _("Left"), KEY_MOVE_LEFT };
@@ -647,7 +648,7 @@ void wins_status_bar(void)
&gpday, &gnday,
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear,
&draw, &today,
- &conf
+ &conf, &cmd
};
struct binding *bindings_apoint[] = {
@@ -657,7 +658,7 @@ void wins_status_bar(void)
&gpday, &gnday,
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear,
&togo, &today,
- &conf, &appt, &todo, &copy, &paste
+ &conf, &appt, &todo, &copy, &paste, &cmd
};
struct binding *bindings_todo[] = {
@@ -667,7 +668,7 @@ void wins_status_bar(void)
&gpday, &gnday,
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear,
&togo, &today,
- &conf, &appt, &todo, &draw
+ &conf, &appt, &todo, &draw, &cmd
};
enum win active_panel = wins_slctd();