aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurora <programming.aurora@gmail.com>2021-01-18 19:45:07 +0000
committerLukas Fleischer <lfleischer@calcurse.org>2021-04-11 19:48:17 -0400
commit9b148900b87b113bc9f30033eff30865a3b43086 (patch)
tree11590016247029fe954e4a170643741a06399288
parent338c640a19013152c90776494b3adf29a69de4a3 (diff)
downloadcalcurse-9b148900b87b113bc9f30033eff30865a3b43086.tar.gz
calcurse-9b148900b87b113bc9f30033eff30865a3b43086.zip
Add generic-prev-view key binding
This can be used to cycle backwards through windows (similarly to generic-change-view). Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
-rw-r--r--src/calcurse.c8
-rw-r--r--src/calcurse.h2
-rw-r--r--src/help.c2
-rw-r--r--src/keys.c3
-rw-r--r--src/wins.c12
5 files changed, 27 insertions, 0 deletions
diff --git a/src/calcurse.c b/src/calcurse.c
index cd143d6..308a332 100644
--- a/src/calcurse.c
+++ b/src/calcurse.c
@@ -80,6 +80,13 @@ static inline void key_generic_change_view(void)
wins_update(FLAG_ALL);
}
+static inline void key_generic_prev_view(void)
+{
+ wins_reset_status_page();
+ wins_slctd_prev();
+ wins_update(FLAG_ALL);
+}
+
static inline void key_generic_other_cmd(void)
{
wins_other_status_page();
@@ -851,6 +858,7 @@ int main(int argc, char **argv)
wtimeout(win[KEY].p, -1);
switch (key) {
HANDLE_KEY(KEY_GENERIC_CHANGE_VIEW, key_generic_change_view);
+ HANDLE_KEY(KEY_GENERIC_PREV_VIEW, key_generic_prev_view);
HANDLE_KEY(KEY_GENERIC_OTHER_CMD, key_generic_other_cmd);
HANDLE_KEY(KEY_GENERIC_GOTO, key_generic_goto);
HANDLE_KEY(KEY_GENERIC_GOTO_TODAY, key_generic_goto_today);
diff --git a/src/calcurse.h b/src/calcurse.h
index 06deaa0..e94be42 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -527,6 +527,7 @@ enum vkey {
KEY_GENERIC_COPY,
KEY_GENERIC_PASTE,
KEY_GENERIC_CHANGE_VIEW,
+ KEY_GENERIC_PREV_VIEW,
KEY_GENERIC_IMPORT,
KEY_GENERIC_EXPORT,
KEY_GENERIC_GOTO,
@@ -1327,6 +1328,7 @@ void wins_sbar_wdec(void);
enum win wins_slctd(void);
void wins_slctd_set(enum win);
void wins_slctd_next(void);
+void wins_slctd_prev(void);
void wins_init(void);
void wins_scrollwin_init(struct scrollwin *, int, int, int, int, const char *);
void wins_scrollwin_resize(struct scrollwin *, int, int, int, int);
diff --git a/src/help.c b/src/help.c
index 40a03b8..ffad2ea 100644
--- a/src/help.c
+++ b/src/help.c
@@ -134,6 +134,8 @@ int display_help(const char *topic)
topic = "copy-paste";
else if (!strcmp(topic, "generic-change-view"))
topic = "tab";
+ else if (!strcmp(topic, "generic-prev-view"))
+ topic = "tab";
else if (!strcmp(topic, "generic-import"))
topic = "import";
else if (!strcmp(topic, "generic-export"))
diff --git a/src/keys.c b/src/keys.c
index a92c7bc..7c57c38 100644
--- a/src/keys.c
+++ b/src/keys.c
@@ -116,6 +116,7 @@ static struct keydef_s keydef[NBVKEYS] = {
{ "generic-copy", "c", gettext_noop("Copy") },
{ "generic-paste", "p ^V", gettext_noop("Paste") },
{ "generic-change-view", "TAB", gettext_noop("Chg Win") },
+ { "generic-prev-view", "KEY_BTAB", gettext_noop("Prev Win") },
{ "generic-import", "i I", gettext_noop("Import") },
{ "generic-export", "x X", gettext_noop("Export") },
{ "generic-goto", "g G", gettext_noop("Go to") },
@@ -664,6 +665,8 @@ void keys_popup_info(enum vkey key)
_("Paste an item at the current position.");
info[KEY_GENERIC_CHANGE_VIEW] =
_("Select next panel in calcurse main screen.");
+ info[KEY_GENERIC_PREV_VIEW] =
+ _("Select previous panel in calcurse main screen.");
info[KEY_GENERIC_IMPORT] = _("Import data from an external file.");
info[KEY_GENERIC_EXPORT] = _("Export data to a new file format.");
info[KEY_GENERIC_GOTO] = _("Select the day to go to.");
diff --git a/src/wins.c b/src/wins.c
index 62689d9..d66ec65 100644
--- a/src/wins.c
+++ b/src/wins.c
@@ -254,6 +254,15 @@ void wins_slctd_next(void)
slctd_win++;
}
+/* Shift-TAB key was hit in the interface, need to select previous window. */
+void wins_slctd_prev(void)
+{
+ if (slctd_win == CAL)
+ slctd_win = TOD;
+ else
+ slctd_win--;
+}
+
static void wins_init_panels(void)
{
wins_scrollwin_init(&sw_cal, win[CAL].y, win[CAL].x,
@@ -651,6 +660,7 @@ void wins_update_bindings(void)
static int bindings_cal[] = {
KEY_GENERIC_HELP, KEY_GENERIC_QUIT, KEY_GENERIC_SAVE,
KEY_GENERIC_RELOAD, KEY_GENERIC_CHANGE_VIEW,
+ KEY_GENERIC_PREV_VIEW,
KEY_GENERIC_SCROLL_DOWN, KEY_GENERIC_SCROLL_UP, KEY_MOVE_UP,
KEY_MOVE_DOWN, KEY_MOVE_LEFT, KEY_MOVE_RIGHT, KEY_GENERIC_GOTO,
KEY_GENERIC_IMPORT, KEY_GENERIC_EXPORT, KEY_START_OF_WEEK,
@@ -666,6 +676,7 @@ void wins_update_bindings(void)
static int bindings_apoint[] = {
KEY_GENERIC_HELP, KEY_GENERIC_QUIT, KEY_GENERIC_SAVE,
KEY_GENERIC_RELOAD, KEY_GENERIC_CHANGE_VIEW,
+ KEY_GENERIC_PREV_VIEW,
KEY_GENERIC_IMPORT, KEY_GENERIC_EXPORT, KEY_ADD_ITEM,
KEY_DEL_ITEM, KEY_EDIT_ITEM, KEY_VIEW_ITEM, KEY_PIPE_ITEM,
KEY_GENERIC_REDRAW, KEY_REPEAT_ITEM, KEY_FLAG_ITEM,
@@ -682,6 +693,7 @@ void wins_update_bindings(void)
static int bindings_todo[] = {
KEY_GENERIC_HELP, KEY_GENERIC_QUIT, KEY_GENERIC_SAVE,
KEY_GENERIC_RELOAD, KEY_GENERIC_CHANGE_VIEW,
+ KEY_GENERIC_PREV_VIEW,
KEY_GENERIC_SCROLL_DOWN, KEY_GENERIC_SCROLL_UP,
KEY_GENERIC_IMPORT, KEY_GENERIC_EXPORT, KEY_ADD_ITEM,
KEY_DEL_ITEM, KEY_EDIT_ITEM, KEY_VIEW_ITEM, KEY_PIPE_ITEM,