summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-06-26 13:54:52 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2012-06-30 14:34:35 +0200
commit318e685ffe73587a01049d92aa0f60a46c1cfb16 (patch)
tree3e523f07c69b3ffb20fa94f888dd98e4d2ea3eaa
parent02c90ba53a658686bad5cb5f88c555d9eef06399 (diff)
downloadcalcurse-318e685ffe73587a01049d92aa0f60a46c1cfb16.tar.gz
calcurse-318e685ffe73587a01049d92aa0f60a46c1cfb16.zip
Add an item parameter to various day_*() functions
These functions operate on arbitrary items. Pull out the code that gets the currently selected item, get the current selection when one of the functions is called and pass it as a parameter. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r--src/calcurse.c8
-rw-r--r--src/calcurse.h8
-rw-r--r--src/day.c15
3 files changed, 12 insertions, 19 deletions
diff --git a/src/calcurse.c b/src/calcurse.c
index 43d00fc..962f665 100644
--- a/src/calcurse.c
+++ b/src/calcurse.c
@@ -219,7 +219,7 @@ int main(int argc, char **argv)
case KEY_VIEW_ITEM:
if ((wins_slctd() == APP) && (apoint_hilt() != 0))
- day_popup_item();
+ day_popup_item(day_get_item(apoint_hilt()));
else if ((wins_slctd() == TOD) && (todo_hilt() != 0))
item_in_popup(NULL, NULL, todo_saved_mesg(), _("To do :"));
wins_update(FLAG_ALL);
@@ -311,7 +311,7 @@ int main(int argc, char **argv)
case KEY_FLAG_ITEM:
if (wins_slctd() == APP && apoint_hilt() != 0) {
- day_item_switch_notify();
+ day_item_switch_notify(day_get_item(apoint_hilt()));
inday = do_storage(0);
wins_update(FLAG_APP);
} else if (wins_slctd() == TOD && todo_hilt() != 0) {
@@ -342,7 +342,7 @@ int main(int argc, char **argv)
case KEY_EDIT_NOTE:
if (wins_slctd() == APP && apoint_hilt() != 0) {
- day_edit_note(conf.editor);
+ day_edit_note(day_get_item(apoint_hilt()), conf.editor);
inday = do_storage(0);
} else if (wins_slctd() == TOD && todo_hilt() != 0)
todo_edit_note(conf.editor);
@@ -351,7 +351,7 @@ int main(int argc, char **argv)
case KEY_VIEW_NOTE:
if (wins_slctd() == APP && apoint_hilt() != 0)
- day_view_note(conf.pager);
+ day_view_note(day_get_item(apoint_hilt()), conf.pager);
else if (wins_slctd() == TOD && todo_hilt() != 0)
todo_view_note(conf.pager);
wins_update(FLAG_ALL);
diff --git a/src/calcurse.h b/src/calcurse.h
index 4f1da72..78bd752 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -671,16 +671,16 @@ struct day_items_nb *day_process_storage(struct date *, unsigned,
void day_write_pad(long, int, int, int);
void day_write_stdout(long, const char *, const char *, const char *,
const char *);
-void day_popup_item(void);
+void day_popup_item(struct day_item *);
int day_check_if_item(struct date);
unsigned day_chk_busy_slices(struct date, int, int *);
int day_cut_item(long, int);
int day_paste_item(long, int);
struct day_item *day_get_item(int);
int day_item_nb(long, int, int);
-void day_edit_note(const char *);
-void day_view_note(const char *);
-void day_item_switch_notify(void);
+void day_edit_note(struct day_item *, const char *);
+void day_view_note(struct day_item *, const char *);
+void day_item_switch_notify(struct day_item *);
/* dmon.c */
void dmon_start(int);
diff --git a/src/day.c b/src/day.c
index e4a0265..5d67d46 100644
--- a/src/day.c
+++ b/src/day.c
@@ -480,10 +480,8 @@ void day_write_stdout(long date, const char *fmt_apt, const char *fmt_rapt,
}
/* Display an item inside a popup window. */
-void day_popup_item(void)
+void day_popup_item(struct day_item *day)
{
- struct day_item *day = day_get_item(apoint_hilt());
-
if (day->type == EVNT || day->type == RECUR_EVNT) {
item_in_popup(NULL, NULL, day_item_get_mesg(day), _("Event :"));
} else if (day->type == APPT || day->type == RECUR_APPT) {
@@ -681,12 +679,10 @@ int day_item_nb(long date, int day_num, int type)
}
/* Attach a note to an appointment or event. */
-void day_edit_note(const char *editor)
+void day_edit_note(struct day_item *p, const char *editor)
{
- struct day_item *p;
char *note;
- p = day_get_item(apoint_hilt());
note = day_item_get_note(p);
edit_note(&note, editor);
@@ -707,17 +703,14 @@ void day_edit_note(const char *editor)
}
/* View a note previously attached to an appointment or event */
-void day_view_note(const char *pager)
+void day_view_note(struct day_item *p, const char *pager)
{
- struct day_item *p = day_get_item(apoint_hilt());
view_note(day_item_get_note(p), pager);
}
/* Switch notification state for an item. */
-void day_item_switch_notify(void)
+void day_item_switch_notify(struct day_item *p)
{
- struct day_item *p = day_get_item(apoint_hilt());
-
switch (p->type) {
case RECUR_APPT:
recur_apoint_switch_notify(p->item.rapt);