routines updated to handle new window_t and window_e types

This commit is contained in:
Frederic Culot 2007-10-21 13:42:34 +00:00
parent 15ea040780
commit 53ead324ad
8 changed files with 139 additions and 140 deletions

View File

@ -1,4 +1,4 @@
/* $calcurse: apoint.c,v 1.17 2007/08/15 15:33:54 culot Exp $ */ /* $calcurse: apoint.c,v 1.18 2007/10/21 13:42:34 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -132,14 +132,14 @@ apoint_add(void)
/* Get the starting time */ /* Get the starting time */
while (check_time(item_time) != 1) { while (check_time(item_time) != 1) {
status_mesg(mesg_1, ""); status_mesg(mesg_1, "");
if (getstring(swin, item_time, LTIME, 0, 1) != if (getstring(win[STA].p, item_time, LTIME, 0, 1) !=
GETSTRING_ESC) { GETSTRING_ESC) {
if (strlen(item_time) == 0){ if (strlen(item_time) == 0){
is_appointment = 0; is_appointment = 0;
break; break;
} else if (check_time(item_time) != 1) { } else if (check_time(item_time) != 1) {
status_mesg(format_message_1, enter_str); status_mesg(format_message_1, enter_str);
wgetch(swin); wgetch(win[STA].p);
} else } else
sscanf(item_time, "%u:%u", &heures, &minutes); sscanf(item_time, "%u:%u", &heures, &minutes);
} else } else
@ -154,12 +154,12 @@ apoint_add(void)
item_time[0] = '\0'; item_time[0] = '\0';
while (check_time(item_time) == 0) { while (check_time(item_time) == 0) {
status_mesg(mesg_2, ""); status_mesg(mesg_2, "");
if (getstring(swin, item_time, LTIME, 0, 1) != if (getstring(win[STA].p, item_time, LTIME, 0, 1) !=
GETSTRING_VALID) GETSTRING_VALID)
return; //nothing entered, cancel adding of event return; //nothing entered, cancel adding of event
else if (check_time(item_time) == 0) { else if (check_time(item_time) == 0) {
status_mesg(format_message_2, enter_str); status_mesg(format_message_2, enter_str);
wgetch(swin); wgetch(win[STA].p);
} else { } else {
if (check_time(item_time) == 2) if (check_time(item_time) == 2)
apoint_duration = atoi(item_time); apoint_duration = atoi(item_time);
@ -186,7 +186,7 @@ apoint_add(void)
Id = 1; Id = 1;
status_mesg(mesg_3, ""); status_mesg(mesg_3, "");
if (getstring(swin, item_mesg, BUFSIZ, 0, 1) == if (getstring(win[STA].p, item_mesg, BUFSIZ, 0, 1) ==
GETSTRING_VALID) { GETSTRING_VALID) {
if (is_appointment) { if (is_appointment) {
apoint_start = apoint_start =
@ -224,7 +224,7 @@ apoint_delete(conf_t *conf, unsigned *nb_events, unsigned *nb_apoints)
if (conf->confirm_delete) { if (conf->confirm_delete) {
status_mesg(del_app_str, choices); status_mesg(del_app_str, choices);
answer = wgetch(swin); answer = wgetch(win[STA].p);
if ( (answer == 'y') && (nb_items != 0) ) if ( (answer == 'y') && (nb_items != 0) )
go_for_deletion = true; go_for_deletion = true;
else { else {
@ -417,7 +417,7 @@ void display_item_date(WINDOW *win, int incolor, apoint_llist_node_t *i,
else else
mvwprintw(win, y, x, " - %s -> %s", a_st, a_end); mvwprintw(win, y, x, " - %s -> %s", a_st, a_end);
if (incolor == 0) if (incolor == 0)
custom_remove_attr(awin, ATTR_HIGHEST); custom_remove_attr(win, ATTR_HIGHEST);
} }
/* /*
@ -590,28 +590,29 @@ apoint_update_panel(window_t *winapp, int which_pan)
day_write_pad(date, app_width, app_length, hilt); 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(win[APP].p, 1, title_lines, winapp->w - 2,
custom_apply_attr(awin, ATTR_HIGHEST); winapp->h - 2);
mvwprintw(awin, title_lines, title_xpos, "%s %s %d, %d", 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]), calendar_get_pom(date), _(monthnames[slctd_date.mm - 1]),
slctd_date.dd, slctd_date.yyyy); slctd_date.dd, slctd_date.yyyy);
custom_remove_attr(awin, ATTR_HIGHEST); custom_remove_attr(win[APP].p, ATTR_HIGHEST);
/* Draw the scrollbar if necessary. */ /* Draw the scrollbar if necessary. */
if ((apad->length >= app_length)||(apad->first_onscreen > 0)) { if ((apad->length >= app_length)||(apad->first_onscreen > 0)) {
float ratio = ((float) app_length) / ((float) apad->length); float ratio = ((float) app_length) / ((float) apad->length);
int sbar_length = (int) (ratio * app_length); int sbar_length = (int) (ratio * app_length);
int highend = (int) (ratio * apad->first_onscreen); int highend = (int) (ratio * apad->first_onscreen);
bool hilt_bar = (which_pan == APPOINTMENT) ? true : false; bool hilt_bar = (which_pan == APP) ? true : false;
int sbar_top = highend + title_lines + 1; int sbar_top = highend + title_lines + 1;
if ((sbar_top + sbar_length) > winapp->h - 1) if ((sbar_top + sbar_length) > winapp->h - 1)
sbar_length = winapp->h - 1 - sbar_top; sbar_length = winapp->h - 1 - sbar_top;
draw_scrollbar(awin, sbar_top, winapp->w - 2, sbar_length, draw_scrollbar(win[APP].p, sbar_top, winapp->w - 2, sbar_length,
title_lines + 1, winapp->h - 1, hilt_bar); title_lines + 1, winapp->h - 1, hilt_bar);
} }
wnoutrefresh(awin); wnoutrefresh(win[APP].p);
pnoutrefresh(apad->ptrwin, apad->first_onscreen, 0, pnoutrefresh(apad->ptrwin, apad->first_onscreen, 0,
winapp->y + title_lines + 1, winapp->x + bordr, winapp->y + title_lines + 1, winapp->x + bordr,
winapp->y + winapp->h - 2*bordr, winapp->x + winapp->w - 3*bordr); winapp->y + winapp->h - 2*bordr, winapp->x + winapp->w - 3*bordr);

View File

@ -1,4 +1,4 @@
/* $calcurse: calcurse.c,v 1.56 2007/10/07 17:13:10 culot Exp $ */ /* $calcurse: calcurse.c,v 1.57 2007/10/21 13:42:34 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -152,7 +152,7 @@ main(int argc, char **argv)
wins_update(); wins_update();
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(CAL);
wins_update(); wins_update();
calendar_start_date_thread(); calendar_start_date_thread();
@ -160,7 +160,7 @@ main(int argc, char **argv)
for (;;) { for (;;) {
do_update = true; do_update = true;
ch = wgetch(swin); ch = wgetch(win[STA].p);
switch (ch) { switch (ch) {
@ -178,11 +178,11 @@ main(int argc, char **argv)
reset_status_page(); reset_status_page();
/* Save previously highlighted event. */ /* Save previously highlighted event. */
switch (wins_slctd()) { switch (wins_slctd()) {
case TODO: case TOD:
sav_hilt_tod = todo_hilt(); sav_hilt_tod = todo_hilt();
todo_hilt_set(0); todo_hilt_set(0);
break; break;
case APPOINTMENT: case APP:
sav_hilt_app = apoint_hilt(); sav_hilt_app = apoint_hilt();
apoint_hilt_set(0); apoint_hilt_set(0);
break; break;
@ -193,13 +193,13 @@ main(int argc, char **argv)
/* Select the event to highlight. */ /* Select the event to highlight. */
switch (wins_slctd()) { switch (wins_slctd()) {
case TODO: case TOD:
if ((sav_hilt_tod == 0) && (todo_nb() != 0)) if ((sav_hilt_tod == 0) && (todo_nb() != 0))
todo_hilt_set(1); todo_hilt_set(1);
else else
todo_hilt_set(sav_hilt_tod); todo_hilt_set(sav_hilt_tod);
break; break;
case APPOINTMENT: case APP:
if ((sav_hilt_app == 0) && if ((sav_hilt_app == 0) &&
((inday.nb_events + inday.nb_apoints) != 0)) ((inday.nb_events + inday.nb_apoints) != 0))
apoint_hilt_set(1); apoint_hilt_set(1);
@ -227,31 +227,29 @@ main(int argc, char **argv)
case 'V': case 'V':
case 'v': /* View function */ case 'v': /* View function */
if ((wins_slctd() == APPOINTMENT) && if ((wins_slctd() == APP) && (apoint_hilt() != 0))
(apoint_hilt() != 0))
day_popup_item(); day_popup_item();
else if ((wins_slctd() == TODO) && (todo_hilt() != 0)) else if ((wins_slctd() == TOD) && (todo_hilt() != 0))
item_in_popup(NULL, NULL, todo_saved_mesg(), item_in_popup(NULL, NULL, todo_saved_mesg(),
_("To do :")); _("To do :"));
break; break;
case 'C': case 'C':
case 'c': /* Configuration menu */ case 'c': /* Configuration menu */
erase_status_bar(); erase_status_bar();
config_bar(); config_bar();
while ((ch = wgetch(swin)) != 'q') { while ((ch = wgetch(win[STA].p)) != 'q') {
switch (ch) { switch (ch) {
case 'C': case 'C':
case 'c': case 'c':
if (has_colors()) { if (has_colors())
custom_color_config( custom_color_config();
notify_bar()); else {
} else {
colorize = false; colorize = false;
erase_status_bar(); erase_status_bar();
mvwprintw(swin, 0, 0, mvwprintw(win[STA].p, 0, 0,
_(no_color_support)); _(no_color_support));
wgetch(swin); wgetch(win[STA].p);
} }
break; break;
case 'L': case 'L':
@ -267,7 +265,7 @@ main(int argc, char **argv)
notify_config_bar(); notify_config_bar();
break; break;
} }
wins_reinit(); wins_reset();
wins_update(); wins_update();
do_storage = true; do_storage = true;
erase_status_bar(); erase_status_bar();
@ -290,11 +288,11 @@ main(int argc, char **argv)
case 'A': case 'A':
case 'a': /* Add an item */ case 'a': /* Add an item */
switch (wins_slctd()) { switch (wins_slctd()) {
case APPOINTMENT: case APP:
apoint_add(); apoint_add();
do_storage = true; do_storage = true;
break; break;
case TODO: case TOD:
todo_new_item(); todo_new_item();
if (todo_hilt() == 0 && todo_nb() == 1) if (todo_hilt() == 0 && todo_nb() == 1)
todo_hilt_increase(); todo_hilt_increase();
@ -306,49 +304,45 @@ 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 && apoint_hilt() != 0) if (wins_slctd() == APP && apoint_hilt() != 0)
day_edit_item(); day_edit_item();
else if (wins_slctd() == TODO && todo_hilt() != 0) else if (wins_slctd() == TOD && todo_hilt() != 0)
todo_edit_item(); 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 && if (wins_slctd() == APP && apoint_hilt() != 0)
apoint_hilt() != 0)
apoint_delete(&conf, &inday.nb_events, apoint_delete(&conf, &inday.nb_events,
&inday.nb_apoints); &inday.nb_apoints);
else if (wins_slctd() == TODO && todo_hilt() != 0) else if (wins_slctd() == TOD && todo_hilt() != 0)
todo_delete(&conf); todo_delete(&conf);
do_storage = true; do_storage = true;
break; break;
case 'R': case 'R':
case 'r': case 'r':
if (wins_slctd() == APPOINTMENT && if (wins_slctd() == APP && apoint_hilt() != 0)
apoint_hilt() != 0)
recur_repeat_item(); recur_repeat_item();
do_storage = true; do_storage = true;
break; break;
case '!': case '!':
if (wins_slctd() == APPOINTMENT && if (wins_slctd() == APP && apoint_hilt() != 0)
apoint_hilt() != 0)
apoint_switch_notify(); apoint_switch_notify();
do_storage = true; do_storage = true;
break; break;
case '+': case '+':
case '-': case '-':
if (wins_slctd() == TODO && todo_hilt() != 0) { if (wins_slctd() == TOD && todo_hilt() != 0) {
todo_chg_priority(ch); todo_chg_priority(ch);
if (todo_hilt_pos() < 0) if (todo_hilt_pos() < 0)
todo_set_first(todo_hilt()); todo_set_first(todo_hilt());
else if (todo_hilt_pos() >= else if (todo_hilt_pos() >= win[TOD].h - 4)
wins_prop(TODO, HEIGHT) - 4)
todo_set_first(todo_hilt() - todo_set_first(todo_hilt() -
wins_prop(TODO, HEIGHT) + 5); win[TOD].h + 5);
} }
break; break;
@ -371,7 +365,7 @@ main(int argc, char **argv)
case ('L'): case ('L'):
case ('l'): case ('l'):
case CTRL('L'): case CTRL('L'):
if (wins_slctd() == CALENDAR || ch == CTRL('L')) { if (wins_slctd() == CAL || ch == CTRL('L')) {
do_storage = true; do_storage = true;
day_changed = true; day_changed = true;
calendar_move_right(); calendar_move_right();
@ -382,7 +376,7 @@ main(int argc, char **argv)
case ('H'): case ('H'):
case ('h'): case ('h'):
case CTRL('H'): case CTRL('H'):
if (wins_slctd() == CALENDAR || ch == CTRL('H')) { if (wins_slctd() == CAL || ch == CTRL('H')) {
do_storage = true; do_storage = true;
day_changed = true; day_changed = true;
calendar_move_left(); calendar_move_left();
@ -393,16 +387,16 @@ main(int argc, char **argv)
case ('K'): case ('K'):
case ('k'): case ('k'):
case CTRL('K'): case CTRL('K'):
if (wins_slctd() == CALENDAR || ch == CTRL('K')) { if (wins_slctd() == CAL || ch == CTRL('K')) {
do_storage = true; do_storage = true;
day_changed = true; day_changed = true;
calendar_move_up(); calendar_move_up();
} else { } else {
if ((wins_slctd() == APPOINTMENT) && if ((wins_slctd() == APP) &&
(apoint_hilt() > 1)) { (apoint_hilt() > 1)) {
apoint_hilt_decrease(); apoint_hilt_decrease();
apoint_scroll_pad_up(inday.nb_events); apoint_scroll_pad_up(inday.nb_events);
} else if ((wins_slctd() == TODO) && } else if ((wins_slctd() == TOD) &&
(todo_hilt() > 1)) { (todo_hilt() > 1)) {
todo_hilt_decrease(); todo_hilt_decrease();
if (todo_hilt_pos() < 0) if (todo_hilt_pos() < 0)
@ -415,23 +409,22 @@ main(int argc, char **argv)
case ('J'): case ('J'):
case ('j'): case ('j'):
case CTRL('J'): case CTRL('J'):
if (wins_slctd() == CALENDAR || ch == CTRL('J')) { if (wins_slctd() == CAL || ch == CTRL('J')) {
do_storage = true; do_storage = true;
day_changed = true; day_changed = true;
calendar_move_down(); calendar_move_down();
} else { } else {
if ((wins_slctd() == APPOINTMENT) && if ((wins_slctd() == APP) &&
(apoint_hilt() < inday.nb_events + (apoint_hilt() < inday.nb_events +
inday.nb_apoints)) { inday.nb_apoints)) {
apoint_hilt_increase(); apoint_hilt_increase();
apoint_scroll_pad_down(inday.nb_events, apoint_scroll_pad_down(inday.nb_events,
wins_prop(APPOINTMENT, HEIGHT)); win[APP].h);
} }
if ((wins_slctd() == TODO) && if ((wins_slctd() == TOD) &&
(todo_hilt() < todo_nb())) { (todo_hilt() < todo_nb())) {
todo_hilt_increase(); todo_hilt_increase();
if (todo_hilt_pos() == if (todo_hilt_pos() == win[TOD].h - 4)
wins_prop(TODO, HEIGHT) - 4)
todo_first_increase(); todo_first_increase();
} }
} }
@ -444,7 +437,7 @@ main(int argc, char **argv)
if (conf.confirm_quit) { if (conf.confirm_quit) {
status_mesg(_(quit_message), choices); status_mesg(_(quit_message), choices);
ch = wgetch(swin); ch = wgetch(win[STA].p);
if ( ch == 'y' ) if ( ch == 'y' )
exit_calcurse(EXIT_SUCCESS); exit_calcurse(EXIT_SUCCESS);
else { else {
@ -467,7 +460,7 @@ main(int argc, char **argv)
if (day_changed) { if (day_changed) {
sav_hilt_app = 0; sav_hilt_app = 0;
day_changed = !day_changed; day_changed = !day_changed;
if ((wins_slctd() == APPOINTMENT) && if ((wins_slctd() == APP) &&
(inday.nb_events + inday.nb_apoints != 0)) (inday.nb_events + inday.nb_apoints != 0))
apoint_hilt_set(1); apoint_hilt_set(1);
} }

View File

@ -1,4 +1,4 @@
/* $calcurse: calendar.c,v 1.11 2007/10/16 19:11:10 culot Exp $ */ /* $calcurse: calendar.c,v 1.12 2007/10/21 13:42:34 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -75,7 +75,7 @@ calendar_date_thread(void *arg)
} }
calendar_set_current_date(); calendar_set_current_date();
calendar_update_panel(cwin); calendar_update_panel(win[CAL].p);
} }
pthread_exit((void*) 0); pthread_exit((void*) 0);
@ -347,7 +347,8 @@ calendar_change_day(void)
while (wrong_day) { while (wrong_day) {
status_mesg(request_date, ""); status_mesg(request_date, "");
if (getstring(swin, selected_day, LDAY, 0, 1) == GETSTRING_ESC) if (getstring(win[STA].p, selected_day, LDAY, 0, 1) ==
GETSTRING_ESC)
return; return;
else { else {
if (strlen(selected_day) == 0) { if (strlen(selected_day) == 0) {
@ -385,7 +386,7 @@ calendar_change_day(void)
if (wrong_day) { if (wrong_day) {
status_mesg(mesg_line1, mesg_line2); status_mesg(mesg_line1, mesg_line2);
wgetch(swin); wgetch(win[STA].p);
} }
} }
} }

View File

@ -1,4 +1,4 @@
/* $calcurse: day.c,v 1.29 2007/08/15 15:37:10 culot Exp $ */ /* $calcurse: day.c,v 1.30 2007/10/21 13:42:34 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -439,10 +439,10 @@ day_edit_time(long time) {
while (1) { while (1) {
status_mesg(msg_time, ""); status_mesg(msg_time, "");
timestr = date_sec2hour_str(time); timestr = date_sec2hour_str(time);
updatestring(swin, &timestr, 0, 1); updatestring(win[STA].p, &timestr, 0, 1);
if (check_time(timestr) != 1 || strlen(timestr) == 0) { if (check_time(timestr) != 1 || strlen(timestr) == 0) {
status_mesg(fmt_msg, enter_str); status_mesg(fmt_msg, enter_str);
wgetch(swin); wgetch(win[STA].p);
} else } else
return timestr; return timestr;
} }
@ -505,7 +505,7 @@ day_edit_item(void)
rpt = re->rpt; rpt = re->rpt;
status_mesg(msg_event_recur, choice_event_recur); status_mesg(msg_event_recur, choice_event_recur);
while (ch != STRT && ch != END && ch != ESCAPE) while (ch != STRT && ch != END && ch != ESCAPE)
ch = wgetch(swin); ch = wgetch(win[STA].p);
if (ch == ESCAPE) if (ch == ESCAPE)
return; return;
else else
@ -521,14 +521,14 @@ day_edit_item(void)
status_mesg(msg_recur, choice_recur); status_mesg(msg_recur, choice_recur);
while (ch != STRT && ch != END && ch != DESC && while (ch != STRT && ch != END && ch != DESC &&
ch != REPT && ch != ESCAPE) ch != REPT && ch != ESCAPE)
ch = wgetch(swin); ch = wgetch(win[STA].p);
if (ch == ESCAPE) if (ch == ESCAPE)
return; return;
break; break;
case APPT: case APPT:
status_mesg(msg_norecur, choice_norecur); status_mesg(msg_norecur, choice_norecur);
while (ch != STRT && ch != END && ch != DESC && ch != ESCAPE) while (ch != STRT && ch != END && ch != DESC && ch != ESCAPE)
ch = wgetch(swin); ch = wgetch(win[STA].p);
if (ch == ESCAPE) if (ch == ESCAPE)
return; return;
break; break;
@ -547,7 +547,7 @@ day_edit_item(void)
valid_date = 1; valid_date = 1;
} else { } else {
status_mesg(error_msg, enter_str); status_mesg(error_msg, enter_str);
wgetch(swin); wgetch(win[STA].p);
} }
} }
break; break;
@ -566,7 +566,7 @@ day_edit_item(void)
break; break;
case DESC: case DESC:
status_mesg(mesg_desc, ""); status_mesg(mesg_desc, "");
updatestring(swin, &p->mesg, 0, 1); updatestring(win[STA].p, &p->mesg, 0, 1);
break; break;
case REPT: case REPT:
while ( (ch != 'D') && (ch != 'W') && (ch != 'M') while ( (ch != 'D') && (ch != 'W') && (ch != 'M')
@ -574,7 +574,7 @@ day_edit_item(void)
status_mesg(mesg_type_1, mesg_type_2); status_mesg(mesg_type_1, mesg_type_2);
typestr = (char *)malloc(sizeof(char) * 2); typestr = (char *)malloc(sizeof(char) * 2);
*typestr = recur_def2char(rpt->type); *typestr = recur_def2char(rpt->type);
cancel = updatestring(swin, &typestr, 0, 1); cancel = updatestring(win[STA].p, &typestr, 0, 1);
ch = toupper(*typestr); ch = toupper(*typestr);
free(typestr); free(typestr);
if (cancel) if (cancel)
@ -584,7 +584,7 @@ day_edit_item(void)
status_mesg(mesg_freq_1, ""); status_mesg(mesg_freq_1, "");
freqstr = (char *) malloc(BUFSIZ); freqstr = (char *) malloc(BUFSIZ);
snprintf(freqstr, BUFSIZ, "%d", rpt->freq); snprintf(freqstr, BUFSIZ, "%d", rpt->freq);
cancel = updatestring(swin, &freqstr, 0, 1); cancel = updatestring(win[STA].p, &freqstr, 0, 1);
newfreq = atoi(freqstr); newfreq = atoi(freqstr);
free(freqstr); free(freqstr);
if (cancel) if (cancel)
@ -592,14 +592,14 @@ day_edit_item(void)
else { else {
if (newfreq == 0) { if (newfreq == 0) {
status_mesg(mesg_wrong_freq, enter_str); status_mesg(mesg_wrong_freq, enter_str);
wgetch(swin); wgetch(win[STA].p);
} }
} }
} }
while (!date_entered) { while (!date_entered) {
status_mesg(mesg_until_1, ""); status_mesg(mesg_until_1, "");
timestr = date_sec2date_str(rpt->until); timestr = date_sec2date_str(rpt->until);
cancel = updatestring(swin, &timestr, 0, 1); cancel = updatestring(win[STA].p, &timestr, 0, 1);
if (cancel) { if (cancel) {
free(timestr); free(timestr);
return; return;
@ -622,14 +622,14 @@ day_edit_item(void)
if (rpt->until < p->start) { if (rpt->until < p->start) {
status_mesg(error_msg, status_mesg(error_msg,
enter_str); enter_str);
wgetch(swin); wgetch(win[STA].p);
date_entered = 0; date_entered = 0;
} else } else
date_entered = 1; date_entered = 1;
} else { } else {
status_mesg(mesg_wrong_date, status_mesg(mesg_wrong_date,
mesg_possible_fmts); mesg_possible_fmts);
wgetch(swin); wgetch(win[STA].p);
date_entered = 0; date_entered = 0;
} }
} }
@ -691,7 +691,7 @@ int day_erase_item(long date, int item_number, int force_erase) {
} else { } else {
while ( (ch != 'a') && (ch != 'o') && (ch != ESCAPE)) { while ( (ch != 'a') && (ch != 'o') && (ch != ESCAPE)) {
status_mesg(erase_warning, erase_choice); status_mesg(erase_warning, erase_choice);
ch = wgetch(swin); ch = wgetch(win[STA].p);
} }
if (ch == 'a') { if (ch == 'a') {
delete_whole = 1; delete_whole = 1;

View File

@ -1,4 +1,4 @@
/* $calcurse: io.c,v 1.22 2007/09/16 15:41:53 culot Exp $ */ /* $calcurse: io.c,v 1.23 2007/10/21 13:42:34 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -92,14 +92,14 @@ progress_bar(progress_bar_t type, int progress)
} }
/* Draw the progress bar. */ /* Draw the progress bar. */
mvwprintw(swin, 1, ipos, barchar); mvwprintw(win[STA].p, 1, ipos, barchar);
mvwprintw(swin, 1, epos[STEPS - 1], barchar); mvwprintw(win[STA].p, 1, epos[STEPS - 1], barchar);
custom_apply_attr(swin, ATTR_HIGHEST); custom_apply_attr(win[STA].p, ATTR_HIGHEST);
for (i = ipos + 1; i < epos[progress]; i++) for (i = ipos + 1; i < epos[progress]; i++)
mvwaddch(swin, 1, i, ' ' | A_REVERSE); mvwaddch(win[STA].p, 1, i, ' ' | A_REVERSE);
custom_remove_attr(swin, ATTR_HIGHEST); custom_remove_attr(win[STA].p, ATTR_HIGHEST);
wmove(swin, 0, 0); wmove(win[STA].p, 0, 0);
wrefresh(swin); wrefresh(win[STA].p);
usleep(SLEEPTIME); usleep(SLEEPTIME);
} }
@ -135,11 +135,11 @@ io_get_export_stream(void)
while (stream == NULL) { while (stream == NULL) {
status_mesg(question, ""); status_mesg(question, "");
updatestring(swin, &stream_name, 0, 1); updatestring(win[STA].p, &stream_name, 0, 1);
stream = fopen(stream_name, "w"); stream = fopen(stream_name, "w");
if (stream == NULL) { if (stream == NULL) {
status_mesg(wrong_name, press_enter); status_mesg(wrong_name, press_enter);
wgetch(swin); wgetch(win[STA].p);
} }
} }
free(stream_name); free(stream_name);
@ -521,7 +521,7 @@ io_save_cal(conf_t *conf)
/* Print a message telling data were saved */ /* Print a message telling data were saved */
if (!conf->skip_system_dialogs) { if (!conf->skip_system_dialogs) {
status_mesg(save_success, enter); status_mesg(save_success, enter);
wgetch(swin); wgetch(win[STA].p);
} }
} }
@ -685,7 +685,7 @@ io_load_todo(void)
data_file = fopen(path_todo, "r"); data_file = fopen(path_todo, "r");
if (data_file == NULL) { if (data_file == NULL) {
status_mesg(mesg_line1, mesg_line2); status_mesg(mesg_line1, mesg_line2);
wgetch(swin); wgetch(win[STA].p);
} }
for (;;) { for (;;) {
c = getc(data_file); c = getc(data_file);
@ -767,10 +767,10 @@ io_startup_screen(bool skip_dialogs, int no_data_file)
if (no_data_file != 0) { if (no_data_file != 0) {
status_mesg(welcome_mesg, enter); status_mesg(welcome_mesg, enter);
wgetch(swin); wgetch(win[STA].p);
} else if (!skip_dialogs) { } else if (!skip_dialogs) {
status_mesg(data_mesg, enter); status_mesg(data_mesg, enter);
wgetch(swin); wgetch(win[STA].p);
} }
} }
@ -820,6 +820,6 @@ io_export_data(export_mode_t mode, conf_t *conf)
if (!conf->skip_system_dialogs && mode == IO_EXPORT_INTERACTIVE) { if (!conf->skip_system_dialogs && mode == IO_EXPORT_INTERACTIVE) {
status_mesg(success, enter); status_mesg(success, enter);
wgetch(swin); wgetch(win[STA].p);
} }
} }

View File

@ -1,4 +1,4 @@
/* $calcurse: recur.c,v 1.29 2007/08/15 15:37:31 culot Exp $ */ /* $calcurse: recur.c,v 1.30 2007/10/21 13:42:34 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -608,14 +608,14 @@ recur_repeat_item(void)
p = day_get_item(item_nb); p = day_get_item(item_nb);
if (p->type != APPT && p->type != EVNT) { if (p->type != APPT && p->type != EVNT) {
status_mesg(wrong_type_1, wrong_type_2); status_mesg(wrong_type_1, wrong_type_2);
ch = wgetch(swin); ch = wgetch(win[STA].p);
return; return;
} }
while ( (ch != 'D') && (ch != 'W') && (ch != 'M') while ( (ch != 'D') && (ch != 'W') && (ch != 'M')
&& (ch != 'Y') && (ch != ESCAPE) ) { && (ch != 'Y') && (ch != ESCAPE) ) {
status_mesg(mesg_type_1, mesg_type_2); status_mesg(mesg_type_1, mesg_type_2);
ch = wgetch(swin); ch = wgetch(win[STA].p);
ch = toupper(ch); ch = toupper(ch);
} }
if (ch == ESCAPE) { if (ch == ESCAPE) {
@ -627,12 +627,12 @@ recur_repeat_item(void)
while (freq == 0) { while (freq == 0) {
status_mesg(mesg_freq_1, ""); status_mesg(mesg_freq_1, "");
if (getstring(swin, user_input, BUFSIZ, 0, 1) == if (getstring(win[STA].p, user_input, BUFSIZ, 0, 1) ==
GETSTRING_VALID) { GETSTRING_VALID) {
freq = atoi(user_input); freq = atoi(user_input);
if (freq == 0) { if (freq == 0) {
status_mesg(mesg_wrong_freq, wrong_type_2); status_mesg(mesg_wrong_freq, wrong_type_2);
wgetch(swin); wgetch(win[STA].p);
} }
user_input[0] = '\0'; user_input[0] = '\0';
} else } else
@ -641,7 +641,8 @@ recur_repeat_item(void)
while (!date_entered) { while (!date_entered) {
status_mesg(mesg_until_1, ""); status_mesg(mesg_until_1, "");
if (getstring(swin, user_input, 11, 0, 1) == GETSTRING_VALID) { if (getstring(win[STA].p, user_input, 11, 0, 1) ==
GETSTRING_VALID) {
if (strlen(user_input) == 1 && if (strlen(user_input) == 1 &&
strncmp(user_input, "0", 1) == 0 ) { strncmp(user_input, "0", 1) == 0 ) {
until = 0; until = 0;
@ -660,7 +661,7 @@ recur_repeat_item(void)
if (until < p->start) { if (until < p->start) {
status_mesg(mesg_older, status_mesg(mesg_older,
wrong_type_2); wrong_type_2);
wgetch(swin); wgetch(win[STA].p);
date_entered = 0; date_entered = 0;
} else { } else {
date_entered = 1; date_entered = 1;

View File

@ -1,4 +1,4 @@
/* $calcurse: todo.c,v 1.14 2007/08/15 15:35:25 culot Exp $ */ /* $calcurse: todo.c,v 1.15 2007/10/21 13:42:34 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -124,11 +124,11 @@ todo_new_item(void)
char todo_input[BUFSIZ] = ""; char todo_input[BUFSIZ] = "";
status_mesg(mesg, ""); status_mesg(mesg, "");
if (getstring(swin, todo_input, BUFSIZ, 0, 1) == if (getstring(win[STA].p, todo_input, BUFSIZ, 0, 1) ==
GETSTRING_VALID) { GETSTRING_VALID) {
while ( (ch < '1') || (ch > '9') ) { while ( (ch < '1') || (ch > '9') ) {
status_mesg(mesg_id, ""); status_mesg(mesg_id, "");
ch = wgetch(swin); ch = wgetch(win[STA].p);
} }
todo_add(todo_input, ch - '0'); todo_add(todo_input, ch - '0');
todos++; todos++;
@ -191,7 +191,7 @@ todo_delete(conf_t *conf)
if (conf->confirm_delete) { if (conf->confirm_delete) {
status_mesg(del_todo_str, choices); status_mesg(del_todo_str, choices);
answer = wgetch(swin); answer = wgetch(win[STA].p);
if ( (answer == 'y') && (todos > 0) ) { if ( (answer == 'y') && (todos > 0) ) {
go_for_todo_del = true; go_for_todo_del = true;
} else { } else {
@ -290,7 +290,7 @@ todo_edit_item(void)
status_mesg(mesg, ""); status_mesg(mesg, "");
i = todo_get_item(hilt); i = todo_get_item(hilt);
updatestring(swin, &i->mesg, 0, 1); updatestring(win[STA].p, &i->mesg, 0, 1);
} }
/* Updates the ToDo panel. */ /* Updates the ToDo panel. */
@ -309,7 +309,8 @@ todo_update_panel(window_t *wintod, int which_pan)
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, wintod->w - 2, wintod->h - 2); erase_window_part(win[TOD].p, 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; t_realpos = num_todo - first;
@ -319,7 +320,7 @@ todo_update_panel(window_t *wintod, int which_pan)
if (t_realpos >= 0 && t_realpos < max_items) { if (t_realpos >= 0 && t_realpos < max_items) {
snprintf(mesg, BUFSIZ, "%d. ", i->id); snprintf(mesg, BUFSIZ, "%d. ", i->id);
strncat(mesg, i->mesg, strlen(i->mesg)); strncat(mesg, i->mesg, strlen(i->mesg));
display_item(twin, incolor, mesg, 0, display_item(win[TOD].p, incolor, mesg, 0,
len, y_offset, x_offset); len, y_offset, x_offset);
y_offset = y_offset + todo_lines; y_offset = y_offset + todo_lines;
} }
@ -330,14 +331,14 @@ todo_update_panel(window_t *wintod, int which_pan)
float ratio = ((float) max_items) / ((float) todos); float ratio = ((float) max_items) / ((float) todos);
int sbar_length = (int) (ratio * (max_items + 1)); int sbar_length = (int) (ratio * (max_items + 1));
int highend = (int) (ratio * first); int highend = (int) (ratio * first);
bool hilt_bar = (which_pan == TODO) ? true : false; bool hilt_bar = (which_pan == TOD) ? true : false;
int sbar_top = highend + title_lines; int sbar_top = highend + title_lines;
if ((sbar_top + sbar_length) > wintod->h - 1) if ((sbar_top + sbar_length) > wintod->h - 1)
sbar_length = wintod->h - 1 - sbar_top; sbar_length = wintod->h - 1 - sbar_top;
draw_scrollbar(twin, sbar_top, wintod->w - 2, draw_scrollbar(win[TOD].p, sbar_top, wintod->w - 2,
sbar_length, title_lines, wintod->h - 1, hilt_bar); sbar_length, title_lines, wintod->h - 1, hilt_bar);
} }
wnoutrefresh(twin); wnoutrefresh(win[TOD].p);
} }

View File

@ -1,4 +1,4 @@
/* $calcurse: utils.c,v 1.36 2007/09/16 15:40:53 culot Exp $ */ /* $calcurse: utils.c,v 1.37 2007/10/21 13:42:34 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -94,25 +94,24 @@ aerror(const char *file, int line, const char *assertion)
void void
status_mesg(char *mesg_line1, char *mesg_line2) status_mesg(char *mesg_line1, char *mesg_line2)
{ {
erase_window_part(swin, 0, 0, col, 2); erase_window_part(win[STA].p, 0, 0, col, 2);
custom_apply_attr(swin, ATTR_HIGHEST); custom_apply_attr(win[STA].p, ATTR_HIGHEST);
mvwprintw(swin, 0, 0, mesg_line1); mvwprintw(win[STA].p, 0, 0, mesg_line1);
mvwprintw(swin, 1, 0, mesg_line2); mvwprintw(win[STA].p, 1, 0, mesg_line2);
custom_remove_attr(swin, ATTR_HIGHEST); custom_remove_attr(win[STA].p, ATTR_HIGHEST);
} }
/* Erase status bar. */ /* Erase status bar. */
void void
erase_status_bar(void) erase_status_bar(void)
{ {
erase_window_part(swin, 0, 0, col, STATUSHEIGHT); erase_window_part(win[STA].p, 0, 0, col, STATUSHEIGHT);
} }
/* /* Erase part of a window. */
* Erase part of a window void
*/ erase_window_part(WINDOW *win, int first_col, int first_row, int last_col,
void erase_window_part(WINDOW *win, int first_col, int first_row, int last_row)
int last_col, int last_row)
{ {
int c, r; int c, r;
@ -148,7 +147,7 @@ WINDOW * popup(int pop_row, int pop_col,
/* prints in middle of a panel */ /* prints in middle of a panel */
void void
print_in_middle(WINDOW * win, int starty, int startx, int width, char *string) print_in_middle(WINDOW *win, int starty, int startx, int width, char *string)
{ {
int length, x, y; int length, x, y;
float temp; float temp;
@ -436,20 +435,23 @@ status_bar(void)
/* Drawing the keybinding with attribute and label without. */ /* Drawing the keybinding with attribute and label without. */
erase_status_bar(); erase_status_bar();
which_pan = wins_slctd(); which_pan = wins_slctd();
start = pos[which_pan] + 2*CMDS_PER_LINE*(status_page - 1); start = pos[which_pan] + 2 * CMDS_PER_LINE * (status_page - 1);
end = MIN(start + 2*CMDS_PER_LINE, pos[which_pan + 1]); end = MIN(start + 2 * CMDS_PER_LINE, pos[which_pan + 1]);
for (i = start; i < end; i += 2) { for (i = start; i < end; i += 2) {
custom_apply_attr(swin, ATTR_HIGHEST); custom_apply_attr(win[STA].p, ATTR_HIGHEST);
mvwprintw(swin, 0, j*cmd_length, binding[i]->key); mvwprintw(win[STA].p, 0, j * cmd_length, binding[i]->key);
if (i + 1 != end) if (i + 1 != end)
mvwprintw(swin, 1, j*cmd_length, binding[i+1]->key); mvwprintw(win[STA].p, 1, j * cmd_length,
custom_remove_attr(swin, ATTR_HIGHEST); binding[i+1]->key);
mvwprintw(swin,0,j*cmd_length+KEY_LENGTH,binding[i]->label); custom_remove_attr(win[STA].p, ATTR_HIGHEST);
mvwprintw(win[STA].p, 0 , j * cmd_length + KEY_LENGTH,
binding[i]->label);
if (i + 1 != end) if (i + 1 != end)
mvwprintw(swin,1,j*cmd_length+KEY_LENGTH,binding[i+1]->label); mvwprintw(win[STA].p, 1, j * cmd_length + KEY_LENGTH,
binding[i+1]->label);
j++; j++;
} }
wnoutrefresh(swin); wnoutrefresh(win[STA].p);
} }
long long
@ -732,7 +734,7 @@ void item_in_popup(char *saved_a_start, char *saved_a_end, char *msg,
saved_a_start, saved_a_end); saved_a_start, saved_a_end);
} }
mvwprintw(pad, 0, margin_left, "%s", msg); mvwprintw(pad, 0, margin_left, "%s", msg);
wmove(swin, 0, 0); wmove(win[STA].p, 0, 0);
pnoutrefresh(pad, 0, 0, margin_top + 2, margin_left, padl, winw); pnoutrefresh(pad, 0, 0, margin_top + 2, margin_left, padl, winw);
doupdate(); doupdate();
wgetch(popup_win); wgetch(popup_win);
@ -780,13 +782,13 @@ void other_status_page(int panel)
char *error = _("FATAL ERROR in other_status_page: unknown panel\n"); char *error = _("FATAL ERROR in other_status_page: unknown panel\n");
switch (panel) { switch (panel) {
case CALENDAR: case CAL:
nb_item = NB_CAL_CMDS; nb_item = NB_CAL_CMDS;
break; break;
case APPOINTMENT: case APP:
nb_item = NB_APP_CMDS; nb_item = NB_APP_CMDS;
break; break;
case TODO: case TOD:
nb_item = NB_TOD_CMDS; nb_item = NB_TOD_CMDS;
break; break;
default: default: