summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/apoint.c122
-rw-r--r--src/calcurse.c50
-rw-r--r--src/calcurse.h14
-rw-r--r--src/ui-day.c148
-rw-r--r--src/wins.c2
5 files changed, 168 insertions, 168 deletions
diff --git a/src/apoint.c b/src/apoint.c
index 64f9f55..820b7ca 100644
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -42,7 +42,6 @@
#include "calcurse.h"
llist_ts_t alist_p;
-static int hilt;
void apoint_free(struct apoint *apt)
{
@@ -84,28 +83,6 @@ void apoint_llist_free(void)
LLIST_TS_FREE(&alist_p);
}
-/* Sets which appointment is highlighted. */
-void apoint_hilt_set(int highlighted)
-{
- hilt = highlighted;
-}
-
-void apoint_hilt_decrease(int n)
-{
- hilt -= n;
-}
-
-void apoint_hilt_increase(int n)
-{
- hilt += n;
-}
-
-/* Return which appointment is highlighted. */
-int apoint_hilt(void)
-{
- return hilt;
-}
-
static int apoint_cmp_start(struct apoint *a, struct apoint *b)
{
return a->start < b->start ? -1 : (a->start == b->start ? 0 : 1);
@@ -229,58 +206,6 @@ void apoint_delete(struct apoint *apt)
LLIST_TS_UNLOCK(&alist_p);
}
-/*
- * Return the line number of an item (either an appointment or an event) in
- * the appointment panel. This is to help the appointment scroll function
- * to place beggining of the pad correctly.
- */
-static int get_item_line(int item_nb, int nb_events_inday)
-{
- int separator = 2;
- int line = 0;
-
- if (item_nb <= nb_events_inday)
- line = item_nb - 1;
- else
- line = nb_events_inday + separator
- + (item_nb - (nb_events_inday + 1)) * 3 - 1;
- return line;
-}
-
-/*
- * Update (if necessary) the first displayed pad line to make the
- * appointment panel scroll down next time pnoutrefresh is called.
- */
-void apoint_scroll_pad_down(int nb_events_inday, int win_length)
-{
- int pad_last_line = 0;
- int item_first_line = 0, item_last_line = 0;
- int borders = 6;
- int awin_length = win_length - borders;
-
- item_first_line = get_item_line(hilt, nb_events_inday);
- if (hilt < nb_events_inday)
- item_last_line = item_first_line;
- else
- item_last_line = item_first_line + 1;
- pad_last_line = apad.first_onscreen + awin_length;
- if (item_last_line >= pad_last_line)
- apad.first_onscreen = item_last_line - awin_length;
-}
-
-/*
- * Update (if necessary) the first displayed pad line to make the
- * appointment panel scroll up next time pnoutrefresh is called.
- */
-void apoint_scroll_pad_up(int nb_events_inday)
-{
- int item_first_line = 0;
-
- item_first_line = get_item_line(hilt, nb_events_inday);
- if (item_first_line < apad.first_onscreen)
- apad.first_onscreen = item_first_line;
-}
-
static int apoint_starts_after(struct apoint *apt, long *time)
{
return apt->start > *time;
@@ -327,53 +252,6 @@ void apoint_switch_notify(struct apoint *apt)
LLIST_TS_UNLOCK(&alist_p);
}
-/* Updates the Appointment panel */
-void apoint_update_panel(int which_pan)
-{
- int title_xpos;
- int bordr = 1;
- int title_lines = conf.compact_panels ? 1 : 3;
- int app_width = win[APP].w - bordr;
- int app_length = win[APP].h - bordr - title_lines;
- long date;
- struct date slctd_date;
-
- /* variable inits */
- slctd_date = *calendar_get_slctd_day();
- title_xpos = win[APP].w - (strlen(_(monthnames[slctd_date.mm - 1])) + 16);
- if (slctd_date.dd < 10)
- title_xpos++;
- date = date2sec(slctd_date, 0, 0);
- day_write_pad(date, app_width, app_length, (which_pan == APP) ? hilt : 0);
-
- /* Print current date in the top right window corner. */
- erase_window_part(win[APP].p, 1, title_lines, win[APP].w - 2, win[APP].h - 2);
- custom_apply_attr(win[APP].p, ATTR_HIGHEST);
- mvwprintw(win[APP].p, title_lines, title_xpos, "%s %s %d, %d",
- calendar_get_pom(date), _(monthnames[slctd_date.mm - 1]),
- slctd_date.dd, slctd_date.yyyy);
- custom_remove_attr(win[APP].p, ATTR_HIGHEST);
-
- /* Draw the scrollbar if necessary. */
- if ((apad.length >= app_length) || (apad.first_onscreen > 0)) {
- int sbar_length = app_length * app_length / apad.length;
- int highend = app_length * apad.first_onscreen / apad.length;
- unsigned hilt_bar = (which_pan == APP) ? 1 : 0;
- int sbar_top = highend + title_lines + 1;
-
- if ((sbar_top + sbar_length) > win[APP].h - 1)
- sbar_length = win[APP].h - 1 - sbar_top;
- draw_scrollbar(win[APP].p, sbar_top, win[APP].w - 2, sbar_length,
- title_lines + 1, win[APP].h - 1, hilt_bar);
- }
-
- wnoutrefresh(win[APP].p);
- pnoutrefresh(apad.ptrwin, apad.first_onscreen, 0,
- win[APP].y + title_lines + 1, win[APP].x + bordr,
- win[APP].y + win[APP].h - 2 * bordr,
- win[APP].x + win[APP].w - 3 * bordr);
-}
-
void apoint_paste_item(struct apoint *apt, long date)
{
apt->start = date + get_item_time(apt->start);
diff --git a/src/calcurse.c b/src/calcurse.c
index a7500ca..3bb1c8c 100644
--- a/src/calcurse.c
+++ b/src/calcurse.c
@@ -54,9 +54,9 @@ static struct day_items_nb do_storage(int day_changed)
if (day_changed) {
if ((inday.nb_events + inday.nb_apoints) > 0)
- apoint_hilt_set(1);
+ ui_day_hilt_set(1);
else
- apoint_hilt_set(0);
+ ui_day_hilt_set(0);
}
return inday;
@@ -74,8 +74,8 @@ static inline void key_generic_change_view(void)
todo_hilt_set(1);
break;
case APP:
- if ((apoint_hilt() == 0) && ((inday.nb_events + inday.nb_apoints) > 0))
- apoint_hilt_set(1);
+ if ((ui_day_hilt() == 0) && ((inday.nb_events + inday.nb_apoints) > 0))
+ ui_day_hilt_set(1);
break;
default:
break;
@@ -109,8 +109,8 @@ static inline void key_generic_goto_today(void)
static inline void key_view_item(void)
{
- if ((wins_slctd() == APP) && (apoint_hilt() != 0))
- day_popup_item(day_get_item(apoint_hilt()));
+ if ((wins_slctd() == APP) && (ui_day_hilt() != 0))
+ day_popup_item(day_get_item(ui_day_hilt()));
else if ((wins_slctd() == TOD) && (todo_hilt() != 0))
item_in_popup(NULL, NULL, todo_saved_mesg(), _("To do :"));
wins_update(FLAG_ALL);
@@ -160,7 +160,7 @@ static inline void key_add_item(void)
static inline void key_edit_item(void)
{
- if (wins_slctd() == APP && apoint_hilt() != 0) {
+ if (wins_slctd() == APP && ui_day_hilt() != 0) {
ui_day_item_edit();
inday = do_storage(0);
wins_update(FLAG_CAL | FLAG_APP | FLAG_STA);
@@ -172,7 +172,7 @@ static inline void key_edit_item(void)
static inline void key_del_item(void)
{
- if (wins_slctd() == APP && apoint_hilt() != 0) {
+ if (wins_slctd() == APP && ui_day_hilt() != 0) {
ui_day_item_delete(&inday.nb_events, &inday.nb_apoints, reg);
inday = do_storage(0);
wins_update(FLAG_CAL | FLAG_APP | FLAG_STA);
@@ -184,7 +184,7 @@ static inline void key_del_item(void)
static inline void key_generic_copy(void)
{
- if (wins_slctd() == APP && apoint_hilt() != 0) {
+ if (wins_slctd() == APP && ui_day_hilt() != 0) {
ui_day_item_copy(&inday.nb_events, &inday.nb_apoints, reg);
inday = do_storage(0);
wins_update(FLAG_CAL | FLAG_APP);
@@ -202,7 +202,7 @@ static inline void key_generic_paste(void)
static inline void key_repeat_item(void)
{
- if (wins_slctd() == APP && apoint_hilt() != 0)
+ if (wins_slctd() == APP && ui_day_hilt() != 0)
ui_day_item_repeat();
inday = do_storage(0);
wins_update(FLAG_CAL | FLAG_APP | FLAG_STA);
@@ -210,8 +210,8 @@ static inline void key_repeat_item(void)
static inline void key_flag_item(void)
{
- if (wins_slctd() == APP && apoint_hilt() != 0) {
- day_item_switch_notify(day_get_item(apoint_hilt()));
+ if (wins_slctd() == APP && ui_day_hilt() != 0) {
+ day_item_switch_notify(day_get_item(ui_day_hilt()));
inday = do_storage(0);
wins_update(FLAG_APP);
} else if (wins_slctd() == TOD && todo_hilt() != 0) {
@@ -222,7 +222,7 @@ static inline void key_flag_item(void)
static inline void key_pipe_item(void)
{
- if (wins_slctd() == APP && apoint_hilt() != 0)
+ if (wins_slctd() == APP && ui_day_hilt() != 0)
ui_day_item_pipe();
else if (wins_slctd() == TOD && todo_hilt() != 0)
ui_todo_pipe();
@@ -253,8 +253,8 @@ static inline void key_lower_priority(void)
static inline void key_edit_note(void)
{
- if (wins_slctd() == APP && apoint_hilt() != 0) {
- day_edit_note(day_get_item(apoint_hilt()), conf.editor);
+ if (wins_slctd() == APP && ui_day_hilt() != 0) {
+ day_edit_note(day_get_item(ui_day_hilt()), conf.editor);
inday = do_storage(0);
} else if (wins_slctd() == TOD && todo_hilt() != 0)
todo_edit_note(todo_get_item(todo_hilt()), conf.editor);
@@ -263,8 +263,8 @@ static inline void key_edit_note(void)
static inline void key_view_note(void)
{
- if (wins_slctd() == APP && apoint_hilt() != 0)
- day_view_note(day_get_item(apoint_hilt()), conf.pager);
+ if (wins_slctd() == APP && ui_day_hilt() != 0)
+ day_view_note(day_get_item(ui_day_hilt()), conf.pager);
else if (wins_slctd() == TOD && todo_hilt() != 0)
todo_view_note(todo_get_item(todo_hilt()), conf.pager);
wins_update(FLAG_ALL);
@@ -353,10 +353,10 @@ static inline void key_move_up(void)
if (wins_slctd() == CAL) {
key_generic_prev_week();
} else if (wins_slctd() == APP) {
- if (count >= apoint_hilt())
- count = apoint_hilt() - 1;
- apoint_hilt_decrease(count);
- apoint_scroll_pad_up(inday.nb_events);
+ if (count >= ui_day_hilt())
+ count = ui_day_hilt() - 1;
+ ui_day_hilt_decrease(count);
+ ui_day_scroll_pad_up(inday.nb_events);
wins_update(FLAG_APP);
} else if (wins_slctd() == TOD) {
if (count >= todo_hilt())
@@ -380,10 +380,10 @@ static inline void key_move_down(void)
if (wins_slctd() == CAL) {
key_generic_next_week();
} else if (wins_slctd() == APP) {
- if (count > inday.nb_events + inday.nb_apoints - apoint_hilt())
- count = inday.nb_events + inday.nb_apoints - apoint_hilt();
- apoint_hilt_increase(count);
- apoint_scroll_pad_down(inday.nb_events, win[APP].h);
+ if (count > inday.nb_events + inday.nb_apoints - ui_day_hilt())
+ count = inday.nb_events + inday.nb_apoints - ui_day_hilt();
+ ui_day_hilt_increase(count);
+ ui_day_scroll_pad_down(inday.nb_events, win[APP].h);
wins_update(FLAG_APP);
} else if (wins_slctd() == TOD) {
if (count > todo_nb() - todo_hilt())
diff --git a/src/calcurse.h b/src/calcurse.h
index b140fc9..46eb56c 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -610,21 +610,21 @@ struct apoint *apoint_dup(struct apoint *);
void apoint_free(struct apoint *);
void apoint_llist_init(void);
void apoint_llist_free(void);
-void apoint_hilt_set(int);
-void apoint_hilt_decrease(int);
-void apoint_hilt_increase(int);
-int apoint_hilt(void);
+void ui_day_hilt_set(int);
+void ui_day_hilt_decrease(int);
+void ui_day_hilt_increase(int);
+int ui_day_hilt(void);
struct apoint *apoint_new(char *, char *, long, long, char);
unsigned apoint_inday(struct apoint *, long *);
void apoint_sec2str(struct apoint *, long, char *, char *);
void apoint_write(struct apoint *, FILE *);
struct apoint *apoint_scan(FILE *, struct tm, struct tm, char, char *);
void apoint_delete(struct apoint *);
-void apoint_scroll_pad_down(int, int);
-void apoint_scroll_pad_up(int);
+void ui_day_scroll_pad_down(int, int);
+void ui_day_scroll_pad_up(int);
struct notify_app *apoint_check_next(struct notify_app *, long);
void apoint_switch_notify(struct apoint *);
-void apoint_update_panel(int);
+void ui_day_update_panel(int);
void apoint_paste_item(struct apoint *, long);
/* args.c */
diff --git a/src/ui-day.c b/src/ui-day.c
index caf272b..c300699 100644
--- a/src/ui-day.c
+++ b/src/ui-day.c
@@ -36,6 +36,7 @@
#include "calcurse.h"
+static int hilt;
struct day_item day_cut[38] = { { 0, 0, { NULL } } };
/* Request the user to enter a new time. */
@@ -280,7 +281,7 @@ void ui_day_item_edit(void)
struct apoint *a;
int need_check_notify = 0;
- p = day_get_item(apoint_hilt());
+ p = day_get_item(ui_day_hilt());
switch (p->type) {
case RECUR_EVNT:
@@ -383,7 +384,7 @@ void ui_day_item_pipe(void)
if ((pid = shell_exec(NULL, &pout, *arg, arg))) {
fpout = fdopen(pout, "w");
- p = day_get_item(apoint_hilt());
+ p = day_get_item(ui_day_hilt());
switch (p->type) {
case RECUR_EVNT:
recur_event_write(p->item.rev, fpout);
@@ -496,8 +497,8 @@ void ui_day_item_add(void)
} else
event_new(item_mesg, 0L, date2sec(*calendar_get_slctd_day(), 0, 0), Id);
- if (apoint_hilt() == 0)
- apoint_hilt_increase(1);
+ if (ui_day_hilt() == 0)
+ ui_day_hilt_increase(1);
}
calendar_monthly_view_cache_set_invalid();
@@ -530,7 +531,7 @@ void ui_day_item_delete(unsigned *nb_events, unsigned *nb_apoints,
if (nb_items == 0)
return;
- struct day_item *p = day_get_item(apoint_hilt());
+ struct day_item *p = day_get_item(ui_day_hilt());
if (conf.confirm_delete) {
if (status_ask_bool(del_app_str) != 1) {
@@ -564,7 +565,7 @@ void ui_day_item_delete(unsigned *nb_events, unsigned *nb_apoints,
}
ui_day_item_cut_free(reg);
- p = day_cut_item(date, apoint_hilt());
+ p = day_cut_item(date, ui_day_hilt());
day_cut[reg].type = p->type;
day_cut[reg].item = p->item;
@@ -586,12 +587,12 @@ void ui_day_item_delete(unsigned *nb_events, unsigned *nb_apoints,
calendar_monthly_view_cache_set_invalid();
- if (apoint_hilt() > 1)
- apoint_hilt_decrease(1);
+ if (ui_day_hilt() > 1)
+ ui_day_hilt_decrease(1);
if (apad.first_onscreen >= to_be_removed)
apad.first_onscreen = apad.first_onscreen - to_be_removed;
if (nb_items == 1)
- apoint_hilt_set(0);
+ ui_day_hilt_set(0);
}
/*
@@ -639,7 +640,7 @@ void ui_day_item_repeat(void)
struct recur_apoint *ra;
long until, date;
- item_nb = apoint_hilt();
+ item_nb = ui_day_hilt();
p = day_get_item(item_nb);
if (p->type != APPT && p->type != EVNT) {
status_mesg(wrong_type_1, wrong_type_2);
@@ -768,7 +769,7 @@ void ui_day_item_copy(unsigned *nb_events, unsigned *nb_apoints,
return;
ui_day_item_cut_free(reg);
- day_item_fork(day_get_item(apoint_hilt()), &day_cut[reg]);
+ day_item_fork(day_get_item(ui_day_hilt()), &day_cut[reg]);
}
/* Paste a previously cut item. */
@@ -793,6 +794,127 @@ void ui_day_item_paste(unsigned *nb_events, unsigned *nb_apoints,
else
return;
- if (apoint_hilt() == 0)
- apoint_hilt_increase(1);
+ if (ui_day_hilt() == 0)
+ ui_day_hilt_increase(1);
+}
+
+/* Sets which appointment is highlighted. */
+void ui_day_hilt_set(int highlighted)
+{
+ hilt = highlighted;
+}
+
+void ui_day_hilt_decrease(int n)
+{
+ hilt -= n;
+}
+
+void ui_day_hilt_increase(int n)
+{
+ hilt += n;
+}
+
+/* Return which appointment is highlighted. */
+int ui_day_hilt(void)
+{
+ return hilt;
+}
+
+/*
+ * Return the line number of an item (either an appointment or an event) in
+ * the appointment panel. This is to help the appointment scroll function
+ * to place beggining of the pad correctly.
+ */
+static int get_item_line(int item_nb, int nb_events_inday)
+{
+ int separator = 2;
+ int line = 0;
+
+ if (item_nb <= nb_events_inday)
+ line = item_nb - 1;
+ else
+ line = nb_events_inday + separator
+ + (item_nb - (nb_events_inday + 1)) * 3 - 1;
+ return line;
+}
+
+/*
+ * Update (if necessary) the first displayed pad line to make the
+ * appointment panel scroll down next time pnoutrefresh is called.
+ */
+void ui_day_scroll_pad_down(int nb_events_inday, int win_length)
+{
+ int pad_last_line = 0;
+ int item_first_line = 0, item_last_line = 0;
+ int borders = 6;
+ int awin_length = win_length - borders;
+
+ item_first_line = get_item_line(hilt, nb_events_inday);
+ if (hilt < nb_events_inday)
+ item_last_line = item_first_line;
+ else
+ item_last_line = item_first_line + 1;
+ pad_last_line = apad.first_onscreen + awin_length;
+ if (item_last_line >= pad_last_line)
+ apad.first_onscreen = item_last_line - awin_length;
+}
+
+/*
+ * Update (if necessary) the first displayed pad line to make the
+ * appointment panel scroll up next time pnoutrefresh is called.
+ */
+void ui_day_scroll_pad_up(int nb_events_inday)
+{
+ int item_first_line = 0;
+
+ item_first_line = get_item_line(hilt, nb_events_inday);
+ if (item_first_line < apad.first_onscreen)
+ apad.first_onscreen = item_first_line;
+}
+
+/* Updates the Appointment panel */
+void ui_day_update_panel(int which_pan)
+{
+ int title_xpos;
+ int bordr = 1;
+ int title_lines = conf.compact_panels ? 1 : 3;
+ int app_width = win[APP].w - bordr;
+ int app_length = win[APP].h - bordr - title_lines;
+ long date;
+ struct date slctd_date;
+
+ /* variable inits */
+ slctd_date = *calendar_get_slctd_day();
+ title_xpos = win[APP].w - (strlen(_(monthnames[slctd_date.mm - 1])) + 16);
+ if (slctd_date.dd < 10)
+ title_xpos++;
+ date = date2sec(slctd_date, 0, 0);
+ day_write_pad(date, app_width, app_length, (which_pan == APP) ? hilt : 0);
+
+ /* Print current date in the top right window corner. */
+ erase_window_part(win[APP].p, 1, title_lines, win[APP].w - 2, win[APP].h - 2);
+ custom_apply_attr(win[APP].p, ATTR_HIGHEST);
+ mvwprintw(win[APP].p, title_lines, title_xpos, "%s %s %d, %d",
+ calendar_get_pom(date), _(monthnames[slctd_date.mm - 1]),
+ slctd_date.dd, slctd_date.yyyy);
+ custom_remove_attr(win[APP].p, ATTR_HIGHEST);
+
+ /* Draw the scrollbar if necessary. */
+ if ((apad.length >= app_length) || (apad.first_onscreen > 0)) {
+ int sbar_length = app_length * app_length / apad.length;
+ int highend = app_length * apad.first_onscreen / apad.length;
+ unsigned hilt_bar = (which_pan == APP) ? 1 : 0;
+ int sbar_top = highend + title_lines + 1;
+
+ if ((sbar_top + sbar_length) > win[APP].h - 1)
+ sbar_length = win[APP].h - 1 - sbar_top;
+ draw_scrollbar(win[APP].p, sbar_top, win[APP].w - 2, sbar_length,
+ title_lines + 1, win[APP].h - 1, hilt_bar);
+ }
+
+ wnoutrefresh(win[APP].p);
+ pnoutrefresh(apad.ptrwin, apad.first_onscreen, 0,
+ win[APP].y + title_lines + 1, win[APP].x + bordr,
+ win[APP].y + win[APP].h - 2 * bordr,
+ win[APP].x + win[APP].w - 3 * bordr);
}
diff --git a/src/wins.c b/src/wins.c
index e18edf0..85316aa 100644
--- a/src/wins.c
+++ b/src/wins.c
@@ -495,7 +495,7 @@ void wins_update_border(int flags)
void wins_update_panels(int flags)
{
if (flags & FLAG_APP)
- apoint_update_panel(slctd_win);
+ ui_day_update_panel(slctd_win);
if (flags & FLAG_TOD)
todo_update_panel(slctd_win);
if (flags & FLAG_CAL)