store_day() moved to day_process_storage()
enum window_number moved to vars.h get_screen_config() updated to use window_t type
This commit is contained in:
parent
45bb65907d
commit
9eb077845b
340
src/calcurse.c
340
src/calcurse.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: calcurse.c,v 1.46 2007/07/01 17:40:38 culot Exp $ */
|
/* $calcurse: calcurse.c,v 1.47 2007/07/20 19:03:11 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -59,8 +59,6 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Variables for appointments */
|
/* Variables for appointments */
|
||||||
int number_apoints_inday;
|
|
||||||
int number_events_inday;
|
|
||||||
int first_app_onscreen = 0;
|
int first_app_onscreen = 0;
|
||||||
int hilt_app = 0, sav_hilt_app;
|
int hilt_app = 0, sav_hilt_app;
|
||||||
|
|
||||||
@ -70,28 +68,26 @@ int first_todo_onscreen = 1;
|
|||||||
char *saved_t_mesg;
|
char *saved_t_mesg;
|
||||||
|
|
||||||
/* Variables to handle calcurse windows */
|
/* Variables to handle calcurse windows */
|
||||||
int x_cal, y_cal, x_app, y_app, x_tod, y_tod, x_bar, y_bar, x_not, y_not;
|
|
||||||
int nl_app, nc_app, nl_tod, nc_tod;
|
|
||||||
int nl_bar, nc_bar, nl_not, nc_not;
|
|
||||||
int which_pan = 0;
|
int which_pan = 0;
|
||||||
enum window_number {CALENDAR, APPOINTMENT, TODO};
|
|
||||||
|
|
||||||
/* External functions */
|
/* External functions */
|
||||||
static void init_vars(conf_t *conf);
|
static void init_vars(conf_t *conf);
|
||||||
static void init_wins(void);
|
static void init_wins(window_t *, window_t *, window_t *, window_t *);
|
||||||
static void reinit_wins(conf_t *conf);
|
static void reinit_wins(conf_t *conf, window_t *, window_t *, window_t *,
|
||||||
static void add_item(void);
|
window_t *, window_t *);
|
||||||
static void update_todo_panel(void);
|
static void add_item(window_t *winbar);
|
||||||
static void update_app_panel(void);
|
static void update_todo_panel(window_t *wintod);
|
||||||
static void store_day(date_t *, bool);
|
static void update_app_panel(window_t *winapp);
|
||||||
static void get_screen_config(conf_t *conf);
|
static void get_screen_config(conf_t *conf, window_t *, window_t *, window_t *,
|
||||||
static void update_windows(int surrounded_window, conf_t *conf);
|
window_t *, window_t *);
|
||||||
|
static void update_windows(int surrounded_window, conf_t *conf, window_t *,
|
||||||
|
window_t *, window_t *);
|
||||||
static void general_config(conf_t *conf);
|
static void general_config(conf_t *conf);
|
||||||
static void config_notify_bar(void);
|
static void config_notify_bar(void);
|
||||||
static void print_general_options(WINDOW *win, conf_t *conf);
|
static void print_general_options(WINDOW *win, conf_t *conf);
|
||||||
static void print_notify_options(WINDOW *win, int col);
|
static void print_notify_options(WINDOW *win, int col);
|
||||||
static void print_option_incolor(WINDOW *win, bool option, int pos_x, int pos_y);
|
static void print_option_incolor(WINDOW *win, bool option, int pos_x, int pos_y);
|
||||||
static void del_item(conf_t *conf);
|
static void del_item(conf_t *conf, day_items_nb_t *inday, window_t *winbar);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -132,6 +128,8 @@ int
|
|||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
conf_t conf;
|
conf_t conf;
|
||||||
|
window_t win[NBWINS];
|
||||||
|
day_items_nb_t inday;
|
||||||
int ch, background, foreground;
|
int ch, background, foreground;
|
||||||
int non_interactive;
|
int non_interactive;
|
||||||
int no_data_file = 1;
|
int no_data_file = 1;
|
||||||
@ -170,7 +168,8 @@ main(int argc, char **argv)
|
|||||||
curs_set(0); /* make cursor invisible */
|
curs_set(0); /* make cursor invisible */
|
||||||
calendar_set_current_date();
|
calendar_set_current_date();
|
||||||
notify_init_vars();
|
notify_init_vars();
|
||||||
get_screen_config(&conf);
|
get_screen_config(&conf, &win[STATUS], &win[NOTIFY], &win[APPOINTMENT],
|
||||||
|
&win[TODO], &win[CALENDAR]);
|
||||||
|
|
||||||
/* Check if terminal supports color. */
|
/* Check if terminal supports color. */
|
||||||
if (has_colors()) {
|
if (has_colors()) {
|
||||||
@ -201,8 +200,8 @@ main(int argc, char **argv)
|
|||||||
colorize = false;
|
colorize = false;
|
||||||
|
|
||||||
init_vars(&conf);
|
init_vars(&conf);
|
||||||
init_wins();
|
init_wins(&win[CALENDAR], &win[APPOINTMENT], &win[TODO], &win[STATUS]);
|
||||||
notify_init_bar(nl_not, nc_not, y_not, x_not);
|
notify_init_bar(&win[NOTIFY]);
|
||||||
reset_status_page();
|
reset_status_page();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -211,18 +210,21 @@ main(int argc, char **argv)
|
|||||||
* the todo list, appointments and events.
|
* the todo list, appointments and events.
|
||||||
*/
|
*/
|
||||||
no_data_file = check_data_files();
|
no_data_file = check_data_files();
|
||||||
custom_load_conf(&conf, background, nc_bar, nl_bar);
|
custom_load_conf(&conf, background, &win[STATUS]);
|
||||||
nb_tod = load_todo();
|
nb_tod = load_todo();
|
||||||
load_app();
|
load_app();
|
||||||
if (notify_bar()) {
|
if (notify_bar()) {
|
||||||
notify_start_main_thread();
|
notify_start_main_thread();
|
||||||
notify_check_next_app();
|
notify_check_next_app();
|
||||||
}
|
}
|
||||||
get_screen_config(&conf);
|
get_screen_config(&conf, &win[STATUS], &win[NOTIFY], &win[APPOINTMENT],
|
||||||
reinit_wins(&conf);
|
&win[TODO], &win[CALENDAR]);
|
||||||
|
reinit_wins(&conf, &win[STATUS], &win[APPOINTMENT], &win[TODO],
|
||||||
|
&win[CALENDAR], &win[NOTIFY]);
|
||||||
startup_screen(conf.skip_system_dialogs, no_data_file);
|
startup_screen(conf.skip_system_dialogs, no_data_file);
|
||||||
store_day(0, day_changed);
|
inday = *day_process_storage(0, day_changed, &inday);
|
||||||
update_windows(CALENDAR, &conf);
|
update_windows(CALENDAR, &conf, &win[STATUS], &win[APPOINTMENT],
|
||||||
|
&win[TODO]);
|
||||||
calendar_start_date_thread();
|
calendar_start_date_thread();
|
||||||
|
|
||||||
/* User input */
|
/* User input */
|
||||||
@ -260,8 +262,8 @@ main(int argc, char **argv)
|
|||||||
/* Select the event to highlight. */
|
/* Select the event to highlight. */
|
||||||
if (which_pan == APPOINTMENT) {
|
if (which_pan == APPOINTMENT) {
|
||||||
if ((sav_hilt_app == 0)
|
if ((sav_hilt_app == 0)
|
||||||
&& ( (number_events_inday +
|
&& ((inday.nb_events +
|
||||||
number_apoints_inday) != 0))
|
inday.nb_apoints) != 0))
|
||||||
hilt_app = 1;
|
hilt_app = 1;
|
||||||
else
|
else
|
||||||
hilt_app = sav_hilt_app;
|
hilt_app = sav_hilt_app;
|
||||||
@ -274,7 +276,8 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CTRL('R'):
|
case CTRL('R'):
|
||||||
reinit_wins(&conf);
|
reinit_wins(&conf, &win[STATUS], &win[APPOINTMENT],
|
||||||
|
&win[TODO], &win[CALENDAR], &win[NOTIFY]);
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -285,7 +288,8 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
case 'G':
|
case 'G':
|
||||||
case 'g': /* Goto function */
|
case 'g': /* Goto function */
|
||||||
erase_window_part(swin, 0, 0, nc_bar, nl_bar);
|
erase_window_part(swin, 0, 0, win[STATUS].w,
|
||||||
|
win[STATUS].h);
|
||||||
calendar_set_current_date();
|
calendar_set_current_date();
|
||||||
calendar_change_day();
|
calendar_change_day();
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
@ -303,7 +307,8 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
case 'C':
|
case 'C':
|
||||||
case 'c': /* Configuration menu */
|
case 'c': /* Configuration menu */
|
||||||
erase_window_part(swin, 0, 0, nc_bar, nl_bar);
|
erase_window_part(swin, 0, 0, win[STATUS].w,
|
||||||
|
win[STATUS].h);
|
||||||
config_bar();
|
config_bar();
|
||||||
while ((ch = wgetch(swin)) != 'q') {
|
while ((ch = wgetch(swin)) != 'q') {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
@ -315,8 +320,8 @@ main(int argc, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
colorize = false;
|
colorize = false;
|
||||||
erase_window_part(swin, 0, 0,
|
erase_window_part(swin, 0, 0,
|
||||||
nc_bar,
|
win[STATUS].w,
|
||||||
nl_bar);
|
win[STATUS].h);
|
||||||
mvwprintw(swin, 0, 0,
|
mvwprintw(swin, 0, 0,
|
||||||
_(no_color_support));
|
_(no_color_support));
|
||||||
wgetch(swin);
|
wgetch(swin);
|
||||||
@ -336,16 +341,20 @@ main(int argc, char **argv)
|
|||||||
config_notify_bar();
|
config_notify_bar();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
reinit_wins(&conf);
|
reinit_wins(&conf, &win[STATUS],
|
||||||
|
&win[APPOINTMENT], &win[TODO],
|
||||||
|
&win[CALENDAR], &win[NOTIFY]);
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
erase_window_part(swin, 0, 0, nc_bar, nl_bar);
|
erase_window_part(swin, 0, 0, win[STATUS].w,
|
||||||
|
win[STATUS].h);
|
||||||
config_bar();
|
config_bar();
|
||||||
}
|
}
|
||||||
update_windows(which_pan, &conf);
|
update_windows(which_pan, &conf, &win[STATUS],
|
||||||
|
&win[APPOINTMENT], &win[TODO]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CTRL('A'): /* Add an app, whatever panel selected */
|
case CTRL('A'): /* Add an app, whatever panel selected */
|
||||||
add_item();
|
add_item(&win[STATUS]);
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -358,7 +367,7 @@ main(int argc, char **argv)
|
|||||||
case 'A':
|
case 'A':
|
||||||
case 'a': /* Add an item */
|
case 'a': /* Add an item */
|
||||||
if (which_pan == APPOINTMENT) {
|
if (which_pan == APPOINTMENT) {
|
||||||
add_item();
|
add_item(&win[STATUS]);
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
} else if (which_pan == TODO) {
|
} else if (which_pan == TODO) {
|
||||||
nb_tod = todo_new_item(nb_tod);
|
nb_tod = todo_new_item(nb_tod);
|
||||||
@ -378,7 +387,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
case 'd': /* Delete an item */
|
case 'd': /* Delete an item */
|
||||||
del_item(&conf);
|
del_item(&conf, &inday, &win[STATUS]);
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -402,14 +411,14 @@ main(int argc, char **argv)
|
|||||||
if (hilt_tod < first_todo_onscreen)
|
if (hilt_tod < first_todo_onscreen)
|
||||||
first_todo_onscreen = hilt_tod;
|
first_todo_onscreen = hilt_tod;
|
||||||
else if (hilt_tod - first_todo_onscreen >=
|
else if (hilt_tod - first_todo_onscreen >=
|
||||||
nl_tod - 4)
|
win[TODO].h - 4)
|
||||||
first_todo_onscreen = hilt_tod
|
first_todo_onscreen = hilt_tod
|
||||||
- nl_tod + 5;
|
- win[TODO].h + 5;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '?': /* Online help system */
|
case '?': /* Online help system */
|
||||||
status_bar(which_pan, nc_bar, nl_bar);
|
status_bar(which_pan, &win[STATUS]);
|
||||||
help_screen(which_pan);
|
help_screen(which_pan);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -458,7 +467,7 @@ main(int argc, char **argv)
|
|||||||
(hilt_app > 1)) {
|
(hilt_app > 1)) {
|
||||||
hilt_app--;
|
hilt_app--;
|
||||||
scroll_pad_up(hilt_app,
|
scroll_pad_up(hilt_app,
|
||||||
number_events_inday);
|
inday.nb_events);
|
||||||
} else if ((which_pan == TODO) &&
|
} else if ((which_pan == TODO) &&
|
||||||
(hilt_tod > 1)) {
|
(hilt_tod > 1)) {
|
||||||
hilt_tod--;
|
hilt_tod--;
|
||||||
@ -478,18 +487,18 @@ main(int argc, char **argv)
|
|||||||
calendar_move_down();
|
calendar_move_down();
|
||||||
} else {
|
} else {
|
||||||
if ((which_pan == APPOINTMENT) &&
|
if ((which_pan == APPOINTMENT) &&
|
||||||
(hilt_app < number_events_inday +
|
(hilt_app < inday.nb_events +
|
||||||
number_apoints_inday)) {
|
inday.nb_apoints)) {
|
||||||
hilt_app++;
|
hilt_app++;
|
||||||
scroll_pad_down(hilt_app,
|
scroll_pad_down(hilt_app,
|
||||||
number_events_inday,
|
inday.nb_events,
|
||||||
nl_app);
|
win[APPOINTMENT].h);
|
||||||
}
|
}
|
||||||
if ((which_pan == TODO) &&
|
if ((which_pan == TODO) &&
|
||||||
(hilt_tod < nb_tod)) {
|
(hilt_tod < nb_tod)) {
|
||||||
++hilt_tod;
|
++hilt_tod;
|
||||||
if (hilt_tod - first_todo_onscreen ==
|
if (hilt_tod - first_todo_onscreen ==
|
||||||
nl_tod - 4)
|
win[TODO].h - 4)
|
||||||
first_todo_onscreen++;
|
first_todo_onscreen++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -509,7 +518,8 @@ main(int argc, char **argv)
|
|||||||
calendar_stop_date_thread();
|
calendar_stop_date_thread();
|
||||||
return (EXIT_SUCCESS);
|
return (EXIT_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
erase_window_part(swin, 0, 0, nc_bar, nl_bar);
|
erase_window_part(swin, 0, 0,
|
||||||
|
win[STATUS].w, win[STATUS].h);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -522,18 +532,19 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
} /* end case statement */
|
} /* end case statement */
|
||||||
if (do_storage) {
|
if (do_storage) {
|
||||||
store_day(calendar_get_slctd_day(), day_changed);
|
inday = *day_process_storage(calendar_get_slctd_day(),
|
||||||
|
day_changed, &inday);
|
||||||
do_storage = !do_storage;
|
do_storage = !do_storage;
|
||||||
if (day_changed) {
|
if (day_changed) {
|
||||||
sav_hilt_app = 0;
|
sav_hilt_app = 0;
|
||||||
day_changed = !day_changed;
|
day_changed = !day_changed;
|
||||||
if ((which_pan == APPOINTMENT) &&
|
if ((which_pan == APPOINTMENT) &&
|
||||||
(number_events_inday + number_apoints_inday
|
(inday.nb_events + inday.nb_apoints != 0))
|
||||||
!= 0))
|
|
||||||
hilt_app = 1;
|
hilt_app = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_windows(which_pan, &conf);
|
update_windows(which_pan, &conf, &win[STATUS],
|
||||||
|
&win[APPOINTMENT], &win[TODO]);
|
||||||
}
|
}
|
||||||
} /* end of interactive mode */
|
} /* end of interactive mode */
|
||||||
|
|
||||||
@ -574,7 +585,8 @@ init_vars(conf_t *conf)
|
|||||||
* selected window.
|
* selected window.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
update_windows(int surrounded_window, conf_t *conf)
|
update_windows(int surrounded_window, conf_t *conf, window_t *winbar,
|
||||||
|
window_t *winapp, window_t *wintod)
|
||||||
{
|
{
|
||||||
switch (surrounded_window) {
|
switch (surrounded_window) {
|
||||||
|
|
||||||
@ -603,10 +615,10 @@ update_windows(int surrounded_window, conf_t *conf)
|
|||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
update_app_panel();
|
update_app_panel(winapp);
|
||||||
update_todo_panel();
|
update_todo_panel(wintod);
|
||||||
calendar_update_panel(cwin);
|
calendar_update_panel(cwin);
|
||||||
status_bar(surrounded_window, nc_bar, nl_bar);
|
status_bar(surrounded_window, winbar);
|
||||||
if (notify_bar())
|
if (notify_bar())
|
||||||
notify_update_bar();
|
notify_update_bar();
|
||||||
wmove(swin, 0, 0);
|
wmove(swin, 0, 0);
|
||||||
@ -616,72 +628,114 @@ update_windows(int surrounded_window, conf_t *conf)
|
|||||||
/*
|
/*
|
||||||
* Get the screen size and recalculate the windows configurations.
|
* Get the screen size and recalculate the windows configurations.
|
||||||
*/
|
*/
|
||||||
void get_screen_config(conf_t *conf)
|
void get_screen_config(conf_t *conf, window_t *status, window_t *notify,
|
||||||
|
window_t *apts, window_t *todo, window_t *calr)
|
||||||
{
|
{
|
||||||
/* Get the screen configuration */
|
/* Get the screen configuration */
|
||||||
getmaxyx(stdscr, row, col);
|
getmaxyx(stdscr, row, col);
|
||||||
|
|
||||||
/* fixed values for status, notification bars and calendar */
|
/* fixed values for status, notification bars and calendar */
|
||||||
nl_bar = 2; nc_bar = col;
|
status->h = 2;
|
||||||
y_bar = row - nl_bar; x_bar = 0;
|
status->w = col;
|
||||||
|
status->y = row - status->h;
|
||||||
|
status->x = 0;
|
||||||
|
|
||||||
if (notify_bar()) {
|
if (notify_bar()) {
|
||||||
nl_not = 1; nc_not = col;
|
notify->h = 1;
|
||||||
y_not = y_bar - 1; x_not = 0;
|
notify->w = col;
|
||||||
|
notify->y = status->y - 1;
|
||||||
|
notify->x = 0;
|
||||||
} else {
|
} else {
|
||||||
nl_not = nc_not = y_not = x_not = 0;
|
notify->h = 0;
|
||||||
|
notify->w = 0;
|
||||||
|
notify->y = 0;
|
||||||
|
notify->x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conf->layout <= 4) { /* APPOINTMENT is the biggest panel */
|
if (conf->layout <= 4) { /* APPOINTMENT is the biggest panel */
|
||||||
nc_app = col - CALWIDTH;
|
apts->w = col - CALWIDTH;
|
||||||
nl_app = row - (nl_bar + nl_not);
|
apts->h = row - (status->h + notify->h);
|
||||||
nc_tod = CALWIDTH;
|
todo->w = CALWIDTH;
|
||||||
nl_tod = row - (CALHEIGHT + nl_bar + nl_not);
|
todo->h = row - (CALHEIGHT + status->h + notify->h);
|
||||||
} else { /* TODO is the biggest panel */
|
} else { /* TODO is the biggest panel */
|
||||||
nc_tod = col - CALWIDTH;
|
todo->w = col - CALWIDTH;
|
||||||
nl_tod = row - (nl_bar + nl_not);
|
todo->h = row - (status->h + notify->h);
|
||||||
nc_app = CALWIDTH;
|
apts->w = CALWIDTH;
|
||||||
nl_app = row - (CALHEIGHT + nl_bar + nl_not);
|
apts->h = row - (CALHEIGHT + status->h + notify->h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* defining the layout */
|
/* defining the layout */
|
||||||
switch (conf->layout) {
|
switch (conf->layout) {
|
||||||
case 1:
|
case 1:
|
||||||
y_app = 0; x_app = 0; y_cal = 0;
|
apts->y = 0;
|
||||||
x_tod = nc_app; y_tod = CALHEIGHT; x_cal = nc_app;
|
apts->x = 0;
|
||||||
|
calr->y = 0;
|
||||||
|
todo->x = apts->w;
|
||||||
|
todo->y = CALHEIGHT;
|
||||||
|
calr->x = apts->w;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
y_app = 0; x_app = 0; y_tod = 0;
|
apts->y = 0;
|
||||||
x_tod = nc_app; x_cal = nc_app; y_cal = nl_tod;
|
apts->x = 0;
|
||||||
|
todo->y = 0;
|
||||||
|
todo->x = apts->w;
|
||||||
|
calr->x = apts->w;
|
||||||
|
calr->y = todo->h;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
y_app = 0; x_tod = 0; x_cal = 0; y_cal = 0;
|
apts->y = 0;
|
||||||
x_app = CALWIDTH; y_tod = CALHEIGHT;
|
todo->x = 0;
|
||||||
|
calr->x = 0;
|
||||||
|
calr->y = 0;
|
||||||
|
apts->x = CALWIDTH;
|
||||||
|
todo->y = CALHEIGHT;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
y_app = 0; x_tod = 0; y_tod = 0; x_cal = 0;
|
apts->y = 0;
|
||||||
x_app = CALWIDTH; y_cal = nl_tod;
|
todo->x = 0;
|
||||||
|
todo->y = 0;
|
||||||
|
calr->x = 0;
|
||||||
|
apts->x = CALWIDTH;
|
||||||
|
calr->y = todo->h;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
y_tod = 0; x_tod = 0; y_cal = 0;
|
todo->y = 0;
|
||||||
y_app = CALHEIGHT; x_app = nc_tod; x_cal = nc_tod;
|
todo->x = 0;
|
||||||
|
calr->y = 0;
|
||||||
|
apts->y = CALHEIGHT;
|
||||||
|
apts->x = todo->w;
|
||||||
|
calr->x = todo->w;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
y_tod = 0; x_tod = 0; y_app = 0;
|
todo->y = 0;
|
||||||
x_app = nc_tod; x_cal = nc_tod; y_cal = nl_app;
|
todo->x = 0;
|
||||||
|
apts->y = 0;
|
||||||
|
apts->x = todo->w;
|
||||||
|
calr->x = todo->w;
|
||||||
|
calr->y = apts->h;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
y_tod = 0; x_app = 0; x_cal = 0; y_cal = 0;
|
todo->y = 0;
|
||||||
x_tod = CALWIDTH; y_app = CALHEIGHT;
|
apts->x = 0;
|
||||||
|
calr->x = 0;
|
||||||
|
calr->y = 0;
|
||||||
|
todo->x = CALWIDTH;
|
||||||
|
apts->y = CALHEIGHT;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
y_tod = 0; x_app = 0; x_cal = 0; y_app = 0;
|
todo->y = 0;
|
||||||
x_tod = CALWIDTH; y_cal = nl_app;
|
apts->x = 0;
|
||||||
|
calr->x = 0;
|
||||||
|
apts->y = 0;
|
||||||
|
todo->x = CALWIDTH;
|
||||||
|
calr->y = apts->h;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create all the windows */
|
/* Create all the windows */
|
||||||
void init_wins(void)
|
void init_wins(window_t *wincal, window_t *winapp, window_t *wintod,
|
||||||
|
window_t *winbar)
|
||||||
{
|
{
|
||||||
char label[BUFSIZ];
|
char label[BUFSIZ];
|
||||||
|
|
||||||
@ -689,18 +743,18 @@ void init_wins(void)
|
|||||||
* Create the three main windows plus the status bar and the pad used to
|
* Create the three main windows plus the status bar and the pad used to
|
||||||
* display appointments and event.
|
* display appointments and event.
|
||||||
*/
|
*/
|
||||||
cwin = newwin(CALHEIGHT, CALWIDTH, y_cal, x_cal);
|
cwin = newwin(CALHEIGHT, CALWIDTH, wincal->y, wincal->x);
|
||||||
snprintf(label, BUFSIZ, _("Calendar"));
|
snprintf(label, BUFSIZ, _("Calendar"));
|
||||||
win_show(cwin, label);
|
win_show(cwin, label);
|
||||||
awin = newwin(nl_app, nc_app, y_app, x_app);
|
awin = newwin(winapp->h, winapp->w, winapp->y, winapp->x);
|
||||||
snprintf(label, BUFSIZ, _("Appointments"));
|
snprintf(label, BUFSIZ, _("Appointments"));
|
||||||
win_show(awin, label);
|
win_show(awin, label);
|
||||||
apad->width = nc_app - 3;
|
apad->width = winapp->w - 3;
|
||||||
apad->ptrwin = newpad(apad->length, apad->width);
|
apad->ptrwin = newpad(apad->length, apad->width);
|
||||||
twin = newwin(nl_tod, nc_tod, y_tod, x_tod);
|
twin = newwin(wintod->h, wintod->w, wintod->y, wintod->x);
|
||||||
snprintf(label, BUFSIZ, _("ToDo"));
|
snprintf(label, BUFSIZ, _("ToDo"));
|
||||||
win_show(twin, label);
|
win_show(twin, label);
|
||||||
swin = newwin(nl_bar, nc_bar, y_bar, x_bar);
|
swin = newwin(winbar->h, winbar->w, winbar->y, winbar->x);
|
||||||
|
|
||||||
/* Enable function keys (i.e. arrow keys) in those windows */
|
/* Enable function keys (i.e. arrow keys) in those windows */
|
||||||
keypad(swin, TRUE);
|
keypad(swin, TRUE);
|
||||||
@ -713,7 +767,8 @@ void init_wins(void)
|
|||||||
* Delete the existing windows and recreate them with their new
|
* Delete the existing windows and recreate them with their new
|
||||||
* size and placement.
|
* size and placement.
|
||||||
*/
|
*/
|
||||||
void reinit_wins(conf_t *conf)
|
void reinit_wins(conf_t *conf, window_t *winbar, window_t *winapp,
|
||||||
|
window_t *wintod, window_t *wincal, window_t *winnot)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
delwin(swin);
|
delwin(swin);
|
||||||
@ -721,11 +776,11 @@ void reinit_wins(conf_t *conf)
|
|||||||
delwin(awin);
|
delwin(awin);
|
||||||
delwin(apad->ptrwin);
|
delwin(apad->ptrwin);
|
||||||
delwin(twin);
|
delwin(twin);
|
||||||
get_screen_config(conf);
|
get_screen_config(conf, winbar, winnot, winapp, wintod, wincal);
|
||||||
init_wins();
|
init_wins(wincal, winapp, wintod, winbar);
|
||||||
if (notify_bar())
|
if (notify_bar())
|
||||||
notify_reinit_bar(nl_not, nc_not, y_not, x_not);
|
notify_reinit_bar(winnot->h, winnot->w, winnot->y, winnot->x);
|
||||||
update_windows(which_pan, conf);
|
update_windows(which_pan, conf, winbar, winapp, wintod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* General configuration */
|
/* General configuration */
|
||||||
@ -1045,13 +1100,13 @@ void print_option_incolor(WINDOW *win, bool option, int pos_y, int pos_x)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Delete an event from the ToDo or Appointment lists */
|
/* Delete an event from the ToDo or Appointment lists */
|
||||||
void del_item(conf_t *conf)
|
void del_item(conf_t *conf, day_items_nb_t *inday, window_t *winbar)
|
||||||
{
|
{
|
||||||
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 ?");
|
||||||
char *del_todo_str = _("Do you really want to delete this task ?");
|
char *del_todo_str = _("Do you really want to delete this task ?");
|
||||||
long date;
|
long date;
|
||||||
int nb_items = number_apoints_inday + number_events_inday;
|
int nb_items = inday->nb_apoints + inday->nb_events;
|
||||||
bool go_for_deletion = false;
|
bool go_for_deletion = false;
|
||||||
bool go_for_todo_del = false;
|
bool go_for_todo_del = false;
|
||||||
int to_be_removed;
|
int to_be_removed;
|
||||||
@ -1068,7 +1123,8 @@ void del_item(conf_t *conf)
|
|||||||
if ( (answer == 'y') && (nb_items != 0) )
|
if ( (answer == 'y') && (nb_items != 0) )
|
||||||
go_for_deletion = true;
|
go_for_deletion = true;
|
||||||
else {
|
else {
|
||||||
erase_window_part(swin, 0, 0, nc_bar, nl_bar);
|
erase_window_part(swin, 0, 0, winbar->w,
|
||||||
|
winbar->h);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -1081,11 +1137,11 @@ void del_item(conf_t *conf)
|
|||||||
day_erase_item(date, hilt_app, 0);
|
day_erase_item(date, hilt_app, 0);
|
||||||
if (deleted_item_type == EVNT ||
|
if (deleted_item_type == EVNT ||
|
||||||
deleted_item_type == RECUR_EVNT) {
|
deleted_item_type == RECUR_EVNT) {
|
||||||
number_events_inday--;
|
inday->nb_events--;
|
||||||
to_be_removed = 1;
|
to_be_removed = 1;
|
||||||
} else if (deleted_item_type == APPT ||
|
} else if (deleted_item_type == APPT ||
|
||||||
deleted_item_type == RECUR_APPT) {
|
deleted_item_type == RECUR_APPT) {
|
||||||
number_apoints_inday--;
|
inday->nb_apoints--;
|
||||||
to_be_removed = 3;
|
to_be_removed = 3;
|
||||||
} else if (deleted_item_type == 0) {
|
} else if (deleted_item_type == 0) {
|
||||||
to_be_removed = 0;
|
to_be_removed = 0;
|
||||||
@ -1111,7 +1167,8 @@ void del_item(conf_t *conf)
|
|||||||
if ( (answer == 'y') && (nb_tod > 0) ) {
|
if ( (answer == 'y') && (nb_tod > 0) ) {
|
||||||
go_for_todo_del = true;
|
go_for_todo_del = true;
|
||||||
} else {
|
} else {
|
||||||
erase_window_part(swin, 0, 0, nc_bar, nl_bar);
|
erase_window_part(swin, 0, 0, winbar->w,
|
||||||
|
winbar->h);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -1131,7 +1188,7 @@ void del_item(conf_t *conf)
|
|||||||
* Add an item in either the appointment or the event list,
|
* Add an item in either the appointment or the event list,
|
||||||
* depending if the start time is entered or not.
|
* depending if the start time is entered or not.
|
||||||
*/
|
*/
|
||||||
void add_item(void)
|
void add_item(window_t *winbar)
|
||||||
{
|
{
|
||||||
#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 : ");
|
||||||
@ -1224,25 +1281,25 @@ void add_item(void)
|
|||||||
if (hilt_app == 0)
|
if (hilt_app == 0)
|
||||||
hilt_app++;
|
hilt_app++;
|
||||||
}
|
}
|
||||||
erase_window_part(swin, 0, 0, nc_bar, nl_bar);
|
erase_window_part(swin, 0, 0, winbar->w, winbar->h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Updates the ToDo panel */
|
/* Updates the ToDo panel */
|
||||||
void update_todo_panel(void)
|
void update_todo_panel(window_t *wintod)
|
||||||
{
|
{
|
||||||
struct todo_s *i;
|
struct todo_s *i;
|
||||||
int len = nc_tod - 6;
|
int len = wintod->w - 6;
|
||||||
int num_todo = 0;
|
int num_todo = 0;
|
||||||
int y_offset = 3, x_offset = 1;
|
int y_offset = 3, x_offset = 1;
|
||||||
int t_realpos = -1;
|
int t_realpos = -1;
|
||||||
int title_lines = 3;
|
int title_lines = 3;
|
||||||
int todo_lines = 1;
|
int todo_lines = 1;
|
||||||
int max_items = nl_tod - 4;
|
int max_items = wintod->h - 4;
|
||||||
int incolor = -1;
|
int incolor = -1;
|
||||||
char mesg[BUFSIZ] = "";
|
char mesg[BUFSIZ] = "";
|
||||||
|
|
||||||
/* Print todo item in the panel. */
|
/* Print todo item in the panel. */
|
||||||
erase_window_part(twin, 1, title_lines, nc_tod - 2, nl_tod - 2);
|
erase_window_part(twin, 1, title_lines, wintod->w - 2, wintod->h - 2);
|
||||||
for (i = todolist; i != 0; i = i->next) {
|
for (i = todolist; i != 0; i = i->next) {
|
||||||
num_todo++;
|
num_todo++;
|
||||||
t_realpos = num_todo - first_todo_onscreen;
|
t_realpos = num_todo - first_todo_onscreen;
|
||||||
@ -1265,10 +1322,10 @@ void update_todo_panel(void)
|
|||||||
bool hilt_bar = (which_pan == TODO) ? true : false;
|
bool hilt_bar = (which_pan == TODO) ? true : false;
|
||||||
int sbar_top = highend + title_lines;
|
int sbar_top = highend + title_lines;
|
||||||
|
|
||||||
if ((sbar_top + sbar_length) > nl_tod - 1)
|
if ((sbar_top + sbar_length) > wintod->h - 1)
|
||||||
sbar_length = nl_tod - 1 - sbar_top;
|
sbar_length = wintod->h - 1 - sbar_top;
|
||||||
draw_scrollbar(twin, sbar_top, nc_tod - 2,
|
draw_scrollbar(twin, sbar_top, wintod->w - 2,
|
||||||
sbar_length, title_lines, nl_tod - 1, hilt_bar);
|
sbar_length, title_lines, wintod->h - 1, hilt_bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
wnoutrefresh(twin);
|
wnoutrefresh(twin);
|
||||||
@ -1276,27 +1333,26 @@ void update_todo_panel(void)
|
|||||||
|
|
||||||
/* Updates the Appointment panel */
|
/* Updates the Appointment panel */
|
||||||
void
|
void
|
||||||
update_app_panel(void)
|
update_app_panel(window_t *winapp)
|
||||||
{
|
{
|
||||||
int title_xpos;
|
int title_xpos;
|
||||||
int bordr = 1;
|
int bordr = 1;
|
||||||
int title_lines = 3;
|
int title_lines = 3;
|
||||||
int app_width = nc_app - bordr;
|
int app_width = winapp->w - bordr;
|
||||||
int app_length = nl_app - bordr - title_lines;
|
int app_length = winapp->h - bordr - title_lines;
|
||||||
long date;
|
long date;
|
||||||
date_t current_date, slctd_date;
|
date_t slctd_date;
|
||||||
|
|
||||||
/* variable inits */
|
/* variable inits */
|
||||||
slctd_date = *calendar_get_slctd_day();
|
slctd_date = *calendar_get_slctd_day();
|
||||||
title_xpos = nc_app - (strlen(_(monthnames[slctd_date.mm - 1])) + 11);
|
title_xpos = winapp->w - (strlen(_(monthnames[slctd_date.mm - 1])) + 11);
|
||||||
if (slctd_date.dd < 10)
|
if (slctd_date.dd < 10)
|
||||||
title_xpos++;
|
title_xpos++;
|
||||||
calendar_store_current_date(¤t_date);
|
date = date2sec(slctd_date, 0, 0);
|
||||||
date = date2sec(current_date, 0, 0);
|
|
||||||
day_write_pad(date, app_width, app_length, hilt_app);
|
day_write_pad(date, app_width, app_length, hilt_app);
|
||||||
|
|
||||||
/* 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, nc_app - 2, nl_app - 2);
|
erase_window_part(awin, 1, title_lines, winapp->w - 2, winapp->h - 2);
|
||||||
custom_apply_attr(awin, ATTR_HIGHEST);
|
custom_apply_attr(awin, ATTR_HIGHEST);
|
||||||
mvwprintw(awin, title_lines, title_xpos, "%s %d, %d",
|
mvwprintw(awin, title_lines, title_xpos, "%s %d, %d",
|
||||||
_(monthnames[slctd_date.mm - 1]), slctd_date.dd, slctd_date.yyyy);
|
_(monthnames[slctd_date.mm - 1]), slctd_date.dd, slctd_date.yyyy);
|
||||||
@ -1310,46 +1366,14 @@ update_app_panel(void)
|
|||||||
bool hilt_bar = (which_pan == APPOINTMENT) ? true : false;
|
bool hilt_bar = (which_pan == APPOINTMENT) ? true : false;
|
||||||
int sbar_top = highend + title_lines + 1;
|
int sbar_top = highend + title_lines + 1;
|
||||||
|
|
||||||
if ((sbar_top + sbar_length) > nl_app - 1)
|
if ((sbar_top + sbar_length) > winapp->h - 1)
|
||||||
sbar_length = nl_app - 1 - sbar_top;
|
sbar_length = winapp->h - 1 - sbar_top;
|
||||||
draw_scrollbar(awin, sbar_top, nc_app - 2, sbar_length,
|
draw_scrollbar(awin, sbar_top, winapp->w - 2, sbar_length,
|
||||||
title_lines + 1, nl_app - 1, hilt_bar);
|
title_lines + 1, winapp->h - 1, hilt_bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
wnoutrefresh(awin);
|
wnoutrefresh(awin);
|
||||||
pnoutrefresh(apad->ptrwin, apad->first_onscreen, 0,
|
pnoutrefresh(apad->ptrwin, apad->first_onscreen, 0,
|
||||||
y_app + title_lines + 1, x_app + bordr,
|
winapp->y + title_lines + 1, winapp->x + bordr,
|
||||||
y_app + nl_app - 2*bordr, x_app + nc_app - 3*bordr);
|
winapp->y + winapp->h - 2*bordr, winapp->x + winapp->w - 3*bordr);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Store the events and appointments for the selected day, and write
|
|
||||||
* those items in a pad. If selected day is null, then store items for current
|
|
||||||
* day. This is useful to speed up the appointment panel update.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
store_day(date_t *slctd_date, bool day_changed)
|
|
||||||
{
|
|
||||||
long date;
|
|
||||||
date_t day;
|
|
||||||
|
|
||||||
if (slctd_date)
|
|
||||||
day = *slctd_date;
|
|
||||||
else
|
|
||||||
calendar_store_current_date(&day);
|
|
||||||
|
|
||||||
date = date2sec(day, 0, 0);
|
|
||||||
|
|
||||||
/* Inits */
|
|
||||||
if (apad->length != 0)
|
|
||||||
delwin(apad->ptrwin);
|
|
||||||
|
|
||||||
/* Store the events and appointments (recursive and normal items). */
|
|
||||||
apad->length = day_store_items(date,
|
|
||||||
&number_events_inday, &number_apoints_inday);
|
|
||||||
|
|
||||||
/* Create the new pad with its new length. */
|
|
||||||
if (day_changed)
|
|
||||||
apad->first_onscreen = 0;
|
|
||||||
apad->ptrwin = newpad(apad->length, apad->width);
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user