hilt_app moved to the static variable hilt

apoint_hilt(), apoint_hilt_set(), apoint_hilt_decrease(), and
apoint_hilt_increase() added
scroll_pad_down() and scroll_pad_up() moved to apoint_scroll_pad_down()
and apoint_scroll_pad_up()
This commit is contained in:
Frederic Culot 2007-08-15 15:33:54 +00:00
parent 470ea56514
commit 2beb88e473
2 changed files with 57 additions and 27 deletions

View File

@ -1,4 +1,4 @@
/* $calcurse: apoint.c,v 1.16 2007/08/12 13:08:03 culot Exp $ */ /* $calcurse: apoint.c,v 1.17 2007/08/15 15:33:54 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -41,6 +41,7 @@
#include "calendar.h" #include "calendar.h"
apoint_llist_t *alist_p; apoint_llist_t *alist_p;
static int hilt = 0;
int apoint_llist_init(void) int apoint_llist_init(void)
{ {
@ -51,6 +52,32 @@ int apoint_llist_init(void)
return 0; return 0;
} }
/* Sets which appointment is highlighted. */
void
apoint_hilt_set(int highlighted)
{
hilt = highlighted;
}
void
apoint_hilt_decrease(void)
{
hilt--;
}
void
apoint_hilt_increase(void)
{
hilt++;
}
/* Return which appointment is highlighted. */
int
apoint_hilt(void)
{
return (hilt);
}
apoint_llist_node_t * apoint_llist_node_t *
apoint_new(char *mesg, long start, long dur, char state) apoint_new(char *mesg, long start, long dur, char state)
{ {
@ -83,7 +110,7 @@ apoint_new(char *mesg, long start, long dur, char state)
* depending if the start time is entered or not. * depending if the start time is entered or not.
*/ */
void void
apoint_add(int *hilt_app) apoint_add(void)
{ {
#define LTIME 6 #define LTIME 6
char *mesg_1 = _("Enter start time ([hh:mm] or [h:mm]), leave blank for an all-day event : "); char *mesg_1 = _("Enter start time ([hh:mm] or [h:mm]), leave blank for an all-day event : ");
@ -173,16 +200,15 @@ apoint_add(int *hilt_app)
event_pointeur = event_new(item_mesg, event_pointeur = event_new(item_mesg,
date2sec(*calendar_get_slctd_day(), 12, 0), Id); date2sec(*calendar_get_slctd_day(), 12, 0), Id);
if (*hilt_app == 0) if (hilt == 0)
(*hilt_app)++; hilt++;
} }
erase_status_bar(); erase_status_bar();
} }
/* Delete an item from the appointment list. */ /* Delete an item from the appointment list. */
void void
apoint_delete(conf_t *conf, unsigned *nb_events, unsigned *nb_apoints, apoint_delete(conf_t *conf, unsigned *nb_events, unsigned *nb_apoints)
int *hilt_app)
{ {
char *choices = "[y/n] "; char *choices = "[y/n] ";
char *del_app_str = _("Do you really want to delete this item ?"); char *del_app_str = _("Do you really want to delete this item ?");
@ -212,7 +238,7 @@ apoint_delete(conf_t *conf, unsigned *nb_events, unsigned *nb_apoints,
if (go_for_deletion) { if (go_for_deletion) {
if (nb_items != 0) { if (nb_items != 0) {
deleted_item_type = deleted_item_type =
day_erase_item(date, *hilt_app, 0); day_erase_item(date, hilt, 0);
if (deleted_item_type == EVNT || if (deleted_item_type == EVNT ||
deleted_item_type == RECUR_EVNT) { deleted_item_type == RECUR_EVNT) {
(*nb_events)--; (*nb_events)--;
@ -227,14 +253,14 @@ apoint_delete(conf_t *conf, unsigned *nb_events, unsigned *nb_apoints,
ierror(errmsg); ierror(errmsg);
/* NOTREACHED */ /* NOTREACHED */
if (*hilt_app > 1) if (hilt > 1)
(*hilt_app)--; hilt--;
if (apad->first_onscreen >= to_be_removed) if (apad->first_onscreen >= to_be_removed)
apad->first_onscreen = apad->first_onscreen =
apad->first_onscreen - apad->first_onscreen -
to_be_removed; to_be_removed;
if (nb_items == 1) if (nb_items == 1)
*hilt_app = 0; hilt = 0;
} }
} }
} }
@ -417,15 +443,15 @@ get_item_line(int item_nb, int nb_events_inday)
* Update (if necessary) the first displayed pad line to make the * Update (if necessary) the first displayed pad line to make the
* appointment panel scroll down next time pnoutrefresh is called. * appointment panel scroll down next time pnoutrefresh is called.
*/ */
void scroll_pad_down(int item_nb, int nb_events_inday, int win_length) void apoint_scroll_pad_down(int nb_events_inday, int win_length)
{ {
int pad_last_line = 0; int pad_last_line = 0;
int item_first_line = 0, item_last_line = 0; int item_first_line = 0, item_last_line = 0;
int borders = 6; int borders = 6;
int awin_length = win_length - borders; int awin_length = win_length - borders;
item_first_line = get_item_line(item_nb, nb_events_inday); item_first_line = get_item_line(hilt, nb_events_inday);
if (item_nb < nb_events_inday) if (hilt < nb_events_inday)
item_last_line = item_first_line; item_last_line = item_first_line;
else else
item_last_line = item_first_line + 1; item_last_line = item_first_line + 1;
@ -438,11 +464,11 @@ void scroll_pad_down(int item_nb, int nb_events_inday, int win_length)
* Update (if necessary) the first displayed pad line to make the * Update (if necessary) the first displayed pad line to make the
* appointment panel scroll up next time pnoutrefresh is called. * appointment panel scroll up next time pnoutrefresh is called.
*/ */
void scroll_pad_up(int item_nb, int nb_events_inday) void apoint_scroll_pad_up(int nb_events_inday)
{ {
int item_first_line = 0; int item_first_line = 0;
item_first_line = get_item_line(item_nb, nb_events_inday); item_first_line = get_item_line(hilt, nb_events_inday);
if (item_first_line < apad->first_onscreen) if (item_first_line < apad->first_onscreen)
apad->first_onscreen = item_first_line; apad->first_onscreen = item_first_line;
} }
@ -496,14 +522,14 @@ apoint_llist_node_t *apoint_recur_s2apoint_s(
* Switch notification state. * Switch notification state.
*/ */
void void
apoint_switch_notify(int item_num) apoint_switch_notify(void)
{ {
apoint_llist_node_t *apoint; apoint_llist_node_t *apoint;
struct day_item_s *p; struct day_item_s *p;
long date; long date;
int apoint_nb = 0, n, need_chk_notify; int apoint_nb = 0, n, need_chk_notify;
p = day_get_item(item_num); p = day_get_item(hilt);
if (p->type != APPT && p->type != RECUR_APPT) if (p->type != APPT && p->type != RECUR_APPT)
return; return;
@ -513,7 +539,7 @@ apoint_switch_notify(int item_num)
recur_apoint_switch_notify(date, p->appt_pos); recur_apoint_switch_notify(date, p->appt_pos);
return; return;
} else if (p->type == APPT) } else if (p->type == APPT)
apoint_nb = day_item_nb(date, item_num, APPT); apoint_nb = day_item_nb(date, hilt, APPT);
n = 0; n = 0;
need_chk_notify = 0; need_chk_notify = 0;
@ -545,7 +571,7 @@ apoint_switch_notify(int item_num)
/* Updates the Appointment panel */ /* Updates the Appointment panel */
void void
apoint_update_panel(window_t *winapp, int hilt_app, int which_pan) apoint_update_panel(window_t *winapp, int which_pan)
{ {
int title_xpos; int title_xpos;
int bordr = 1; int bordr = 1;
@ -561,7 +587,7 @@ apoint_update_panel(window_t *winapp, int hilt_app, int which_pan)
if (slctd_date.dd < 10) if (slctd_date.dd < 10)
title_xpos++; title_xpos++;
date = date2sec(slctd_date, 0, 0); date = date2sec(slctd_date, 0, 0);
day_write_pad(date, app_width, app_length, hilt_app); day_write_pad(date, app_width, app_length, hilt);
/* Print current date in the top right window corner. */ /* Print current date in the top right window corner. */
erase_window_part(awin, 1, title_lines, winapp->w - 2, winapp->h - 2); erase_window_part(awin, 1, title_lines, winapp->w - 2, winapp->h - 2);

View File

@ -1,4 +1,4 @@
/* $calcurse: apoint.h,v 1.8 2007/07/28 13:11:42 culot Exp $ */ /* $calcurse: apoint.h,v 1.9 2007/08/15 15:33:54 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -54,9 +54,13 @@ typedef struct apoint_llist {
extern apoint_llist_t *alist_p; extern apoint_llist_t *alist_p;
int apoint_llist_init(void); int apoint_llist_init(void);
void apoint_hilt_set(int);
void apoint_hilt_decrease(void);
void apoint_hilt_increase(void);
int apoint_hilt(void);
apoint_llist_node_t *apoint_new(char *, long, long, char); apoint_llist_node_t *apoint_new(char *, long, long, char);
void apoint_add(int *hilt_app); void apoint_add(void);
void apoint_delete(conf_t *, unsigned *, unsigned *, int *); void apoint_delete(conf_t *, unsigned *, unsigned *);
unsigned apoint_inday(apoint_llist_node_t *, long); unsigned apoint_inday(apoint_llist_node_t *, long);
void apoint_sec2str(apoint_llist_node_t *, int, long, void apoint_sec2str(apoint_llist_node_t *, int, long,
char *, char *); char *, char *);
@ -65,11 +69,11 @@ apoint_llist_node_t *apoint_scan(FILE *, struct tm, struct tm, char);
void apoint_delete_bynum(long, unsigned); void apoint_delete_bynum(long, unsigned);
void display_item_date(WINDOW *, int, apoint_llist_node_t *, void display_item_date(WINDOW *, int, apoint_llist_node_t *,
int, long, int, int); int, long, int, int);
void scroll_pad_down(int, int, int); void apoint_scroll_pad_down(int, int);
void scroll_pad_up(int, int); void apoint_scroll_pad_up(int);
struct notify_app_s *apoint_check_next(struct notify_app_s *, long); struct notify_app_s *apoint_check_next(struct notify_app_s *, long);
apoint_llist_node_t *apoint_recur_s2apoint_s(recur_apoint_llist_node_t *); apoint_llist_node_t *apoint_recur_s2apoint_s(recur_apoint_llist_node_t *);
void apoint_switch_notify(int); void apoint_switch_notify(void);
void apoint_update_panel(window_t *, int, int); void apoint_update_panel(window_t *, int);
#endif /* CALCURSE_APOINT_H */ #endif /* CALCURSE_APOINT_H */