some variables moved to static ones in appropriate file to easily handle window update
This commit is contained in:
parent
eef11f8cb7
commit
3d2aab3cb7
175
src/calcurse.c
175
src/calcurse.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: calcurse.c,v 1.53 2007/08/04 14:34:03 culot Exp $ */
|
/* $calcurse: calcurse.c,v 1.54 2007/08/15 15:29:52 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -54,21 +54,15 @@ 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;
|
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;
|
||||||
int first_todo_onscreen = 1;
|
|
||||||
int hilt_app = 0;
|
|
||||||
int hilt_tod = 0;
|
|
||||||
int nb_tod = 0;
|
|
||||||
int sav_hilt_app = 0;
|
int sav_hilt_app = 0;
|
||||||
int sav_hilt_tod = 0;
|
int sav_hilt_tod = 0;
|
||||||
struct sigaction sigact;
|
struct sigaction sigact;
|
||||||
bool do_storage = false;
|
bool do_storage = false;
|
||||||
bool day_changed = false;
|
bool day_changed = false;
|
||||||
char *saved_t_mesg;
|
|
||||||
char *no_color_support =
|
char *no_color_support =
|
||||||
_("Sorry, colors are not supported by your terminal\n"
|
_("Sorry, colors are not supported by your terminal\n"
|
||||||
"(Press [ENTER] to continue)");
|
"(Press [ENTER] to continue)");
|
||||||
@ -101,8 +95,7 @@ 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();
|
||||||
wins_get_config(&conf, &win[STATUS], &win[NOTIFY], &win[APPOINTMENT],
|
wins_get_config();
|
||||||
&win[TODO], &win[CALENDAR]);
|
|
||||||
|
|
||||||
/* Check if terminal supports color. */
|
/* Check if terminal supports color. */
|
||||||
if (has_colors()) {
|
if (has_colors()) {
|
||||||
@ -135,9 +128,9 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
vars_init(&conf);
|
vars_init(&conf);
|
||||||
wins_init(&win[CALENDAR], &win[APPOINTMENT], &win[TODO], &win[STATUS]);
|
wins_init();
|
||||||
wins_slctd_init();
|
wins_slctd_init();
|
||||||
notify_init_bar(&win[NOTIFY]);
|
notify_init_bar();
|
||||||
reset_status_page();
|
reset_status_page();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -148,23 +141,18 @@ main(int argc, char **argv)
|
|||||||
no_data_file = io_check_data_files();
|
no_data_file = io_check_data_files();
|
||||||
custom_load_conf(&conf, background);
|
custom_load_conf(&conf, background);
|
||||||
erase_status_bar();
|
erase_status_bar();
|
||||||
nb_tod = io_load_todo();
|
io_load_todo();
|
||||||
io_load_app();
|
io_load_app();
|
||||||
if (notify_bar()) {
|
if (notify_bar()) {
|
||||||
notify_start_main_thread();
|
notify_start_main_thread();
|
||||||
notify_check_next_app();
|
notify_check_next_app();
|
||||||
}
|
}
|
||||||
wins_get_config(&conf, &win[STATUS], &win[NOTIFY], &win[APPOINTMENT],
|
wins_reinit();
|
||||||
&win[TODO], &win[CALENDAR]);
|
wins_update();
|
||||||
wins_reinit(&conf, &win[STATUS], &win[APPOINTMENT],
|
|
||||||
&win[TODO], &win[CALENDAR], &win[NOTIFY]);
|
|
||||||
wins_update(&conf, &win[STATUS], &win[APPOINTMENT], &win[TODO],
|
|
||||||
hilt_app, hilt_tod, nb_tod, first_todo_onscreen, &saved_t_mesg);
|
|
||||||
io_startup_screen(conf.skip_system_dialogs, no_data_file);
|
io_startup_screen(conf.skip_system_dialogs, no_data_file);
|
||||||
inday = *day_process_storage(0, day_changed, &inday);
|
inday = *day_process_storage(0, day_changed, &inday);
|
||||||
wins_slctd_set(CALENDAR);
|
wins_slctd_set(CALENDAR);
|
||||||
wins_update(&conf, &win[STATUS], &win[APPOINTMENT], &win[TODO],
|
wins_update();
|
||||||
hilt_app, hilt_tod, nb_tod, first_todo_onscreen, &saved_t_mesg);
|
|
||||||
calendar_start_date_thread();
|
calendar_start_date_thread();
|
||||||
|
|
||||||
/* User input */
|
/* User input */
|
||||||
@ -189,12 +177,12 @@ main(int argc, char **argv)
|
|||||||
/* Save previously highlighted event. */
|
/* Save previously highlighted event. */
|
||||||
switch (wins_slctd()) {
|
switch (wins_slctd()) {
|
||||||
case TODO:
|
case TODO:
|
||||||
sav_hilt_tod = hilt_tod;
|
sav_hilt_tod = todo_hilt();
|
||||||
hilt_tod = 0;
|
todo_hilt_set(0);
|
||||||
break;
|
break;
|
||||||
case APPOINTMENT:
|
case APPOINTMENT:
|
||||||
sav_hilt_app = hilt_app;
|
sav_hilt_app = apoint_hilt();
|
||||||
hilt_app = 0;
|
apoint_hilt_set(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -204,17 +192,17 @@ main(int argc, char **argv)
|
|||||||
/* Select the event to highlight. */
|
/* Select the event to highlight. */
|
||||||
switch (wins_slctd()) {
|
switch (wins_slctd()) {
|
||||||
case TODO:
|
case TODO:
|
||||||
if ((sav_hilt_tod == 0) && (nb_tod != 0))
|
if ((sav_hilt_tod == 0) && (todo_nb() != 0))
|
||||||
hilt_tod = 1;
|
todo_hilt_set(1);
|
||||||
else
|
else
|
||||||
hilt_tod = sav_hilt_tod;
|
todo_hilt_set(sav_hilt_tod);
|
||||||
break;
|
break;
|
||||||
case APPOINTMENT:
|
case APPOINTMENT:
|
||||||
if ((sav_hilt_app == 0) &&
|
if ((sav_hilt_app == 0) &&
|
||||||
((inday.nb_events + inday.nb_apoints) != 0))
|
((inday.nb_events + inday.nb_apoints) != 0))
|
||||||
hilt_app = 1;
|
apoint_hilt_set(1);
|
||||||
else
|
else
|
||||||
hilt_app = sav_hilt_app;
|
apoint_hilt_set(sav_hilt_app);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -222,12 +210,7 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CTRL('R'):
|
case CTRL('R'):
|
||||||
wins_reinit(&conf, &win[STATUS],
|
wins_reset();
|
||||||
&win[APPOINTMENT], &win[TODO], &win[CALENDAR],
|
|
||||||
&win[NOTIFY]);
|
|
||||||
wins_update(&conf, &win[STATUS], &win[APPOINTMENT],
|
|
||||||
&win[TODO], hilt_app, hilt_tod,
|
|
||||||
nb_tod, first_todo_onscreen, &saved_t_mesg);
|
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -247,10 +230,11 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
case 'v': /* View function */
|
case 'v': /* View function */
|
||||||
if ((wins_slctd() == APPOINTMENT) && (hilt_app != 0))
|
if ((wins_slctd() == APPOINTMENT) &&
|
||||||
|
(apoint_hilt() != 0))
|
||||||
day_popup_item();
|
day_popup_item();
|
||||||
else if ((wins_slctd() == TODO) && (hilt_tod != 0))
|
else if ((wins_slctd() == TODO) && (todo_hilt() != 0))
|
||||||
item_in_popup(NULL, NULL, saved_t_mesg,
|
item_in_popup(NULL, NULL, todo_saved_mesg(),
|
||||||
_("To do :"));
|
_("To do :"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -275,8 +259,7 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
case 'l':
|
case 'l':
|
||||||
conf.layout =
|
layout_config();
|
||||||
layout_config(conf.layout);
|
|
||||||
break;
|
break;
|
||||||
case 'G':
|
case 'G':
|
||||||
case 'g':
|
case 'g':
|
||||||
@ -287,44 +270,37 @@ main(int argc, char **argv)
|
|||||||
notify_config_bar();
|
notify_config_bar();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
wins_reinit(&conf, &win[STATUS],
|
wins_reinit();
|
||||||
&win[APPOINTMENT], &win[TODO],
|
wins_update();
|
||||||
&win[CALENDAR], &win[NOTIFY]);
|
|
||||||
wins_update(&conf, &win[STATUS],
|
|
||||||
&win[APPOINTMENT], &win[TODO], hilt_app,
|
|
||||||
hilt_tod, nb_tod,
|
|
||||||
first_todo_onscreen, &saved_t_mesg);
|
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
erase_status_bar();
|
erase_status_bar();
|
||||||
config_bar();
|
config_bar();
|
||||||
}
|
}
|
||||||
wins_update(&conf, &win[STATUS], &win[APPOINTMENT],
|
wins_update();
|
||||||
&win[TODO], hilt_app, hilt_tod, nb_tod,
|
|
||||||
first_todo_onscreen, &saved_t_mesg);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CTRL('A'): /* Add an app, whatever panel selected */
|
case CTRL('A'): /* Add an app, whatever panel selected */
|
||||||
apoint_add(&hilt_app);
|
apoint_add();
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CTRL('T'): /* Add a todo, whatever panel selected */
|
case CTRL('T'): /* Add a todo, whatever panel selected */
|
||||||
nb_tod = todo_new_item(nb_tod);
|
todo_new_item();
|
||||||
if (hilt_tod == 0 && nb_tod == 1)
|
if (todo_hilt() == 0 && todo_nb() == 1)
|
||||||
hilt_tod++;
|
todo_hilt_increase();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'A':
|
case 'A':
|
||||||
case 'a': /* Add an item */
|
case 'a': /* Add an item */
|
||||||
switch (wins_slctd()) {
|
switch (wins_slctd()) {
|
||||||
case APPOINTMENT:
|
case APPOINTMENT:
|
||||||
apoint_add(&hilt_app);
|
apoint_add();
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
break;
|
break;
|
||||||
case TODO:
|
case TODO:
|
||||||
nb_tod = todo_new_item(nb_tod);
|
todo_new_item();
|
||||||
if (hilt_tod == 0 && nb_tod == 1)
|
if (todo_hilt() == 0 && todo_nb() == 1)
|
||||||
hilt_tod++;
|
todo_hilt_increase();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -333,46 +309,49 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
case 'E':
|
case 'E':
|
||||||
case 'e': /* Edit an existing item */
|
case 'e': /* Edit an existing item */
|
||||||
if (wins_slctd() == APPOINTMENT && hilt_app != 0)
|
if (wins_slctd() == APPOINTMENT && apoint_hilt() != 0)
|
||||||
day_edit_item(hilt_app);
|
day_edit_item();
|
||||||
else if (wins_slctd() == TODO && hilt_tod != 0)
|
else if (wins_slctd() == TODO && todo_hilt() != 0)
|
||||||
todo_edit_item(hilt_tod);
|
todo_edit_item();
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
case 'd': /* Delete an item */
|
case 'd': /* Delete an item */
|
||||||
if (wins_slctd() == APPOINTMENT && hilt_app != 0)
|
if (wins_slctd() == APPOINTMENT &&
|
||||||
|
apoint_hilt() != 0)
|
||||||
apoint_delete(&conf, &inday.nb_events,
|
apoint_delete(&conf, &inday.nb_events,
|
||||||
&inday.nb_apoints, &hilt_app);
|
&inday.nb_apoints);
|
||||||
else if (wins_slctd() == TODO && hilt_tod != 0)
|
else if (wins_slctd() == TODO && todo_hilt() != 0)
|
||||||
todo_delete(&conf, &nb_tod, &hilt_tod);
|
todo_delete(&conf);
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'R':
|
case 'R':
|
||||||
case 'r':
|
case 'r':
|
||||||
if (wins_slctd() == APPOINTMENT && hilt_app != 0)
|
if (wins_slctd() == APPOINTMENT &&
|
||||||
recur_repeat_item(hilt_app);
|
apoint_hilt() != 0)
|
||||||
|
recur_repeat_item();
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '!':
|
case '!':
|
||||||
if (wins_slctd() == APPOINTMENT && hilt_app != 0)
|
if (wins_slctd() == APPOINTMENT &&
|
||||||
apoint_switch_notify(hilt_app);
|
apoint_hilt() != 0)
|
||||||
|
apoint_switch_notify();
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '+':
|
case '+':
|
||||||
case '-':
|
case '-':
|
||||||
if (wins_slctd() == TODO && hilt_tod != 0) {
|
if (wins_slctd() == TODO && todo_hilt() != 0) {
|
||||||
hilt_tod = todo_chg_priority(ch, hilt_tod);
|
todo_chg_priority(ch);
|
||||||
if (hilt_tod < first_todo_onscreen)
|
if (todo_hilt_pos() < 0)
|
||||||
first_todo_onscreen = hilt_tod;
|
todo_set_first(todo_hilt());
|
||||||
else if (hilt_tod - first_todo_onscreen >=
|
else if (todo_hilt_pos() >=
|
||||||
win[TODO].h - 4)
|
wins_prop(TODO, HEIGHT) - 4)
|
||||||
first_todo_onscreen = hilt_tod
|
todo_set_first(todo_hilt() -
|
||||||
- win[TODO].h + 5;
|
wins_prop(TODO, HEIGHT) + 5);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -423,15 +402,14 @@ main(int argc, char **argv)
|
|||||||
calendar_move_up();
|
calendar_move_up();
|
||||||
} else {
|
} else {
|
||||||
if ((wins_slctd() == APPOINTMENT) &&
|
if ((wins_slctd() == APPOINTMENT) &&
|
||||||
(hilt_app > 1)) {
|
(apoint_hilt() > 1)) {
|
||||||
hilt_app--;
|
apoint_hilt_decrease();
|
||||||
scroll_pad_up(hilt_app,
|
apoint_scroll_pad_up(inday.nb_events);
|
||||||
inday.nb_events);
|
|
||||||
} else if ((wins_slctd() == TODO) &&
|
} else if ((wins_slctd() == TODO) &&
|
||||||
(hilt_tod > 1)) {
|
(todo_hilt() > 1)) {
|
||||||
hilt_tod--;
|
todo_hilt_decrease();
|
||||||
if (hilt_tod < first_todo_onscreen)
|
if (todo_hilt_pos() < 0)
|
||||||
first_todo_onscreen--;
|
todo_first_decrease();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -446,19 +424,18 @@ main(int argc, char **argv)
|
|||||||
calendar_move_down();
|
calendar_move_down();
|
||||||
} else {
|
} else {
|
||||||
if ((wins_slctd() == APPOINTMENT) &&
|
if ((wins_slctd() == APPOINTMENT) &&
|
||||||
(hilt_app < inday.nb_events +
|
(apoint_hilt() < inday.nb_events +
|
||||||
inday.nb_apoints)) {
|
inday.nb_apoints)) {
|
||||||
hilt_app++;
|
apoint_hilt_increase();
|
||||||
scroll_pad_down(hilt_app,
|
apoint_scroll_pad_down(inday.nb_events,
|
||||||
inday.nb_events,
|
wins_prop(APPOINTMENT, HEIGHT));
|
||||||
win[APPOINTMENT].h);
|
|
||||||
}
|
}
|
||||||
if ((wins_slctd() == TODO) &&
|
if ((wins_slctd() == TODO) &&
|
||||||
(hilt_tod < nb_tod)) {
|
(todo_hilt() < todo_nb())) {
|
||||||
++hilt_tod;
|
todo_hilt_increase();
|
||||||
if (hilt_tod - first_todo_onscreen ==
|
if (todo_hilt_pos() ==
|
||||||
win[TODO].h - 4)
|
wins_prop(TODO, HEIGHT) - 4)
|
||||||
first_todo_onscreen++;
|
todo_first_increase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -491,12 +468,10 @@ main(int argc, char **argv)
|
|||||||
day_changed = !day_changed;
|
day_changed = !day_changed;
|
||||||
if ((wins_slctd() == APPOINTMENT) &&
|
if ((wins_slctd() == APPOINTMENT) &&
|
||||||
(inday.nb_events + inday.nb_apoints != 0))
|
(inday.nb_events + inday.nb_apoints != 0))
|
||||||
hilt_app = 1;
|
apoint_hilt_set(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wins_update(&conf, &win[STATUS], &win[APPOINTMENT],
|
wins_update();
|
||||||
&win[TODO], hilt_app, hilt_tod, nb_tod,
|
|
||||||
first_todo_onscreen, &saved_t_mesg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user