summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-11-18 22:15:54 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2012-11-18 22:52:25 +0100
commit051a512810cab20fb07889a24bcf59c20b842cd1 (patch)
tree7e0fc2b1028d1d6d9e8c0afe269981af497af6c1
parent2a5a1a2b744263d88c73f4694a1cc2bcfd759ed4 (diff)
downloadcalcurse-051a512810cab20fb07889a24bcf59c20b842cd1.tar.gz
calcurse-051a512810cab20fb07889a24bcf59c20b842cd1.zip
calcurse.c: Pull out key_move_*()
Supersedes the "key" parameter from following functions: * key_generic_prev_day() * key_generic_next_day() * key_generic_prev_week() * key_generic_next_week() Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r--src/calcurse.c62
1 files changed, 40 insertions, 22 deletions
diff --git a/src/calcurse.c b/src/calcurse.c
index fefe18e..110b35d 100644
--- a/src/calcurse.c
+++ b/src/calcurse.c
@@ -313,28 +313,41 @@ static inline void key_generic_export(int dummy)
static inline void key_generic_prev_day(int key)
{
- if (wins_slctd() == CAL || key == KEY_GENERIC_PREV_DAY) {
- calendar_move(DAY_PREV, count);
- inday = do_storage(1);
- wins_update(FLAG_CAL | FLAG_APP);
- }
+ calendar_move(DAY_PREV, count);
+ inday = do_storage(1);
+ wins_update(FLAG_CAL | FLAG_APP);
+}
+
+static inline void key_move_left(int key)
+{
+ if (wins_slctd() == CAL)
+ key_generic_prev_day(key);
}
static inline void key_generic_next_day(int key)
{
- if (wins_slctd() == CAL || key == KEY_GENERIC_NEXT_DAY) {
- calendar_move(DAY_NEXT, count);
- inday = do_storage(1);
- wins_update(FLAG_CAL | FLAG_APP);
- }
+ calendar_move(DAY_NEXT, count);
+ inday = do_storage(1);
+ wins_update(FLAG_CAL | FLAG_APP);
+}
+
+static inline void key_move_right(int key)
+{
+ if (wins_slctd() == CAL)
+ key_generic_next_day(key);
}
static inline void key_generic_prev_week(int key)
{
- if (wins_slctd() == CAL || key == KEY_GENERIC_PREV_WEEK) {
- calendar_move(WEEK_PREV, count);
- inday = do_storage(1);
- wins_update(FLAG_CAL | FLAG_APP);
+ calendar_move(WEEK_PREV, count);
+ inday = do_storage(1);
+ wins_update(FLAG_CAL | FLAG_APP);
+}
+
+static inline void key_move_up(int key)
+{
+ if (wins_slctd() == CAL) {
+ key_generic_prev_week(key);
} else if (wins_slctd() == APP) {
if (count >= apoint_hilt())
count = apoint_hilt() - 1;
@@ -353,10 +366,15 @@ static inline void key_generic_prev_week(int key)
static inline void key_generic_next_week(int key)
{
- if (wins_slctd() == CAL || key == KEY_GENERIC_NEXT_WEEK) {
- calendar_move(WEEK_NEXT, count);
- inday = do_storage(1);
- wins_update(FLAG_CAL | FLAG_APP);
+ calendar_move(WEEK_NEXT, count);
+ inday = do_storage(1);
+ wins_update(FLAG_CAL | FLAG_APP);
+}
+
+static inline void key_move_down(int key)
+{
+ if (wins_slctd() == CAL) {
+ key_generic_next_week(key);
} else if (wins_slctd() == APP) {
if (count > inday.nb_events + inday.nb_apoints - apoint_hilt())
count = inday.nb_events + inday.nb_apoints - apoint_hilt();
@@ -602,13 +620,13 @@ int main(int argc, char **argv)
HANDLE_KEY(KEY_GENERIC_IMPORT, key_generic_import);
HANDLE_KEY(KEY_GENERIC_EXPORT, key_generic_export);
HANDLE_KEY(KEY_GENERIC_PREV_DAY, key_generic_prev_day);
- HANDLE_KEY(KEY_MOVE_LEFT, key_generic_prev_day);
+ HANDLE_KEY(KEY_MOVE_LEFT, key_move_left);
HANDLE_KEY(KEY_GENERIC_NEXT_DAY, key_generic_next_day);
- HANDLE_KEY(KEY_MOVE_RIGHT, key_generic_next_day);
+ HANDLE_KEY(KEY_MOVE_RIGHT, key_move_right);
HANDLE_KEY(KEY_GENERIC_PREV_WEEK, key_generic_prev_week);
- HANDLE_KEY(KEY_MOVE_UP, key_generic_prev_week);
+ HANDLE_KEY(KEY_MOVE_UP, key_move_up);
HANDLE_KEY(KEY_GENERIC_NEXT_WEEK, key_generic_next_week);
- HANDLE_KEY(KEY_MOVE_DOWN, key_generic_next_week);
+ HANDLE_KEY(KEY_MOVE_DOWN, key_move_down);
HANDLE_KEY(KEY_GENERIC_PREV_MONTH, key_generic_prev_month);
HANDLE_KEY(KEY_GENERIC_NEXT_MONTH, key_generic_next_month);
HANDLE_KEY(KEY_GENERIC_PREV_YEAR, key_generic_prev_year);