calendar.c: Rename to "ui-calendar.c"

This unit belongs to the presentation layer -- rename the file
accordingly.

Also, rename calendar_*() to ui_calendar_*().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2013-02-14 10:52:44 +01:00
parent 971df8d215
commit 806673dd9b
12 changed files with 126 additions and 126 deletions

View File

@ -13,7 +13,6 @@ calcurse_SOURCES = \
sha1.h \ sha1.h \
apoint.c \ apoint.c \
args.c \ args.c \
calendar.c \
config.c \ config.c \
custom.c \ custom.c \
day.c \ day.c \
@ -31,6 +30,7 @@ calcurse_SOURCES = \
sha1.c \ sha1.c \
sigs.c \ sigs.c \
todo.c \ todo.c \
ui-calendar.c \
ui-day.c \ ui-day.c \
ui-todo.c \ ui-todo.c \
utf8.c \ utf8.c \

View File

@ -49,7 +49,7 @@ int count, reg;
*/ */
static struct day_items_nb do_storage(int day_changed) static struct day_items_nb do_storage(int day_changed)
{ {
struct day_items_nb inday = day_process_storage(calendar_get_slctd_day(), struct day_items_nb inday = day_process_storage(ui_calendar_get_slctd_day(),
day_changed); day_changed);
if (day_changed) { if (day_changed) {
@ -92,8 +92,8 @@ static inline void key_generic_other_cmd(void)
static inline void key_generic_goto(void) static inline void key_generic_goto(void)
{ {
wins_erase_status_bar(); wins_erase_status_bar();
calendar_set_current_date(); ui_calendar_set_current_date();
calendar_change_day(conf.input_datefmt); ui_calendar_change_day(conf.input_datefmt);
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP | FLAG_STA); wins_update(FLAG_CAL | FLAG_APP | FLAG_STA);
} }
@ -101,8 +101,8 @@ static inline void key_generic_goto(void)
static inline void key_generic_goto_today(void) static inline void key_generic_goto_today(void)
{ {
wins_erase_status_bar(); wins_erase_status_bar();
calendar_set_current_date(); ui_calendar_set_current_date();
calendar_goto_today(); ui_calendar_goto_today();
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP | FLAG_STA); wins_update(FLAG_CAL | FLAG_APP | FLAG_STA);
} }
@ -287,7 +287,7 @@ static inline void key_generic_import(void)
{ {
wins_erase_status_bar(); wins_erase_status_bar();
io_import_data(IO_IMPORT_ICAL, NULL); io_import_data(IO_IMPORT_ICAL, NULL);
calendar_monthly_view_cache_set_invalid(); ui_calendar_monthly_view_cache_set_invalid();
inday = do_storage(0); inday = do_storage(0);
wins_update(FLAG_ALL); wins_update(FLAG_ALL);
} }
@ -317,7 +317,7 @@ static inline void key_generic_export()
static inline void key_generic_prev_day(void) static inline void key_generic_prev_day(void)
{ {
calendar_move(DAY_PREV, count); ui_calendar_move(DAY_PREV, count);
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} }
@ -330,7 +330,7 @@ static inline void key_move_left(void)
static inline void key_generic_next_day(void) static inline void key_generic_next_day(void)
{ {
calendar_move(DAY_NEXT, count); ui_calendar_move(DAY_NEXT, count);
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} }
@ -343,7 +343,7 @@ static inline void key_move_right(void)
static inline void key_generic_prev_week(void) static inline void key_generic_prev_week(void)
{ {
calendar_move(WEEK_PREV, count); ui_calendar_move(WEEK_PREV, count);
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} }
@ -370,7 +370,7 @@ static inline void key_move_up(void)
static inline void key_generic_next_week(void) static inline void key_generic_next_week(void)
{ {
calendar_move(WEEK_NEXT, count); ui_calendar_move(WEEK_NEXT, count);
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} }
@ -397,28 +397,28 @@ static inline void key_move_down(void)
static inline void key_generic_prev_month(void) static inline void key_generic_prev_month(void)
{ {
calendar_move(MONTH_PREV, count); ui_calendar_move(MONTH_PREV, count);
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} }
static inline void key_generic_next_month(void) static inline void key_generic_next_month(void)
{ {
calendar_move(MONTH_NEXT, count); ui_calendar_move(MONTH_NEXT, count);
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} }
static inline void key_generic_prev_year(void) static inline void key_generic_prev_year(void)
{ {
calendar_move(YEAR_PREV, count); ui_calendar_move(YEAR_PREV, count);
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} }
static inline void key_generic_next_year(void) static inline void key_generic_next_year(void)
{ {
calendar_move(YEAR_NEXT, count); ui_calendar_move(YEAR_NEXT, count);
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} }
@ -426,7 +426,7 @@ static inline void key_generic_next_year(void)
static inline void key_start_of_week(void) static inline void key_start_of_week(void)
{ {
if (wins_slctd() == CAL) { if (wins_slctd() == CAL) {
calendar_move(WEEK_START, count); ui_calendar_move(WEEK_START, count);
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} }
@ -435,7 +435,7 @@ static inline void key_start_of_week(void)
static inline void key_end_of_week(void) static inline void key_end_of_week(void)
{ {
if (wins_slctd() == CAL) { if (wins_slctd() == CAL) {
calendar_move(WEEK_END, count); ui_calendar_move(WEEK_END, count);
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} }
@ -444,7 +444,7 @@ static inline void key_end_of_week(void)
static inline void key_generic_scroll_up(void) static inline void key_generic_scroll_up(void)
{ {
if (wins_slctd() == CAL) { if (wins_slctd() == CAL) {
calendar_view_prev(); ui_calendar_view_prev();
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} }
} }
@ -452,7 +452,7 @@ static inline void key_generic_scroll_up(void)
static inline void key_generic_scroll_down(void) static inline void key_generic_scroll_down(void)
{ {
if (wins_slctd() == CAL) { if (wins_slctd() == CAL) {
calendar_view_next(); ui_calendar_view_next();
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} }
} }
@ -519,7 +519,7 @@ int main(int argc, char **argv)
cbreak(); /* control chars generate a signal */ cbreak(); /* control chars generate a signal */
noecho(); /* controls echoing of typed chars */ noecho(); /* controls echoing of typed chars */
curs_set(0); /* make cursor invisible */ curs_set(0); /* make cursor invisible */
calendar_set_current_date(); ui_calendar_set_current_date();
notify_init_vars(); notify_init_vars();
wins_get_config(); wins_get_config();
@ -586,7 +586,7 @@ int main(int argc, char **argv)
/* Start miscellaneous threads. */ /* Start miscellaneous threads. */
if (notify_bar()) if (notify_bar())
notify_start_main_thread(); notify_start_main_thread();
calendar_start_date_thread(); ui_calendar_start_date_thread();
if (conf.periodic_save > 0) if (conf.periodic_save > 0)
io_start_psave_thread(); io_start_psave_thread();

View File

@ -631,28 +631,28 @@ void apoint_paste_item(struct apoint *, long);
int parse_args(int, char **); int parse_args(int, char **);
/* calendar.c */ /* calendar.c */
void calendar_view_next(void); void ui_calendar_view_next(void);
void calendar_view_prev(void); void ui_calendar_view_prev(void);
void calendar_set_view(int); void ui_calendar_set_view(int);
int calendar_get_view(void); int ui_calendar_get_view(void);
void calendar_start_date_thread(void); void ui_calendar_start_date_thread(void);
void calendar_stop_date_thread(void); void ui_calendar_stop_date_thread(void);
void calendar_set_current_date(void); void ui_calendar_set_current_date(void);
void calendar_set_first_day_of_week(enum wday); void ui_calendar_set_first_day_of_week(enum wday);
void calendar_change_first_day_of_week(void); void ui_calendar_change_first_day_of_week(void);
unsigned calendar_week_begins_on_monday(void); unsigned ui_calendar_week_begins_on_monday(void);
void calendar_store_current_date(struct date *); void ui_calendar_store_current_date(struct date *);
void calendar_init_slctd_day(void); void ui_calendar_init_slctd_day(void);
struct date *calendar_get_slctd_day(void); struct date *ui_calendar_get_slctd_day(void);
long calendar_get_slctd_day_sec(void); long ui_calendar_get_slctd_day_sec(void);
void calendar_monthly_view_cache_set_invalid(void); void ui_calendar_monthly_view_cache_set_invalid(void);
void calendar_update_panel(struct window *); void ui_calendar_update_panel(struct window *);
void calendar_goto_today(void); void ui_calendar_goto_today(void);
void calendar_change_day(int); void ui_calendar_change_day(int);
void calendar_move(enum move, int); void ui_calendar_move(enum move, int);
long calendar_start_of_year(void); long ui_calendar_start_of_year(void);
long calendar_end_of_year(void); long ui_calendar_end_of_year(void);
const char *calendar_get_pom(time_t); const char *ui_calendar_get_pom(time_t);
/* config.c */ /* config.c */

View File

@ -202,9 +202,9 @@ static int config_parse_color_pair(int *dest1, int *dest2, const char *val)
static int config_parse_calendar_view(void *dummy, const char *val) static int config_parse_calendar_view(void *dummy, const char *val)
{ {
if (!strcmp(val, "monthly")) if (!strcmp(val, "monthly"))
calendar_set_view(CAL_MONTH_VIEW); ui_calendar_set_view(CAL_MONTH_VIEW);
else if (!strcmp(val, "weekly")) else if (!strcmp(val, "weekly"))
calendar_set_view(CAL_WEEK_VIEW); ui_calendar_set_view(CAL_WEEK_VIEW);
else else
return 0; return 0;
@ -228,9 +228,9 @@ static int config_parse_default_panel(void *dummy, const char *val)
static int config_parse_first_day_of_week(void *dummy, const char *val) static int config_parse_first_day_of_week(void *dummy, const char *val)
{ {
if (!strcmp(val, "monday")) if (!strcmp(val, "monday"))
calendar_set_first_day_of_week(MONDAY); ui_calendar_set_first_day_of_week(MONDAY);
else if (!strcmp(val, "sunday")) else if (!strcmp(val, "sunday"))
calendar_set_first_day_of_week(SUNDAY); ui_calendar_set_first_day_of_week(SUNDAY);
else else
return 0; return 0;
@ -379,7 +379,7 @@ static void config_color_theme_name(char *theme_name)
static int config_serialize_calendar_view(char *buf, void *dummy) static int config_serialize_calendar_view(char *buf, void *dummy)
{ {
if (calendar_get_view() == CAL_WEEK_VIEW) if (ui_calendar_get_view() == CAL_WEEK_VIEW)
strcpy(buf, "weekly"); strcpy(buf, "weekly");
else else
strcpy(buf, "monthly"); strcpy(buf, "monthly");
@ -401,7 +401,7 @@ static int config_serialize_default_panel(char *buf, void *dummy)
static int config_serialize_first_day_of_week(char *buf, void *dummy) static int config_serialize_first_day_of_week(char *buf, void *dummy)
{ {
if (calendar_week_begins_on_monday()) if (ui_calendar_week_begins_on_monday())
strcpy(buf, "monday"); strcpy(buf, "monday");
else else
strcpy(buf, "sunday"); strcpy(buf, "sunday");

View File

@ -668,7 +668,7 @@ static int print_general_options(WINDOW * win)
mvwprintw(win, y, XPOS, "[8] %s ", opt[FIRST_DAY_OF_WEEK]); mvwprintw(win, y, XPOS, "[8] %s ", opt[FIRST_DAY_OF_WEEK]);
custom_apply_attr(win, ATTR_HIGHEST); custom_apply_attr(win, ATTR_HIGHEST);
mvwaddstr(win, y, XPOS + 4 + strlen(opt[FIRST_DAY_OF_WEEK]), mvwaddstr(win, y, XPOS + 4 + strlen(opt[FIRST_DAY_OF_WEEK]),
calendar_week_begins_on_monday()? _("Monday") : _("Sunday")); ui_calendar_week_begins_on_monday()? _("Monday") : _("Sunday"));
custom_remove_attr(win, ATTR_HIGHEST); custom_remove_attr(win, ATTR_HIGHEST);
mvwaddstr(win, y + 1, XPOS, mvwaddstr(win, y + 1, XPOS,
_("(specifies the first day of week in the calendar view)")); _("(specifies the first day of week in the calendar view)"));
@ -773,7 +773,7 @@ void custom_general_config(void)
conf.progress_bar = !conf.progress_bar; conf.progress_bar = !conf.progress_bar;
break; break;
case '8': case '8':
calendar_change_first_day_of_week(); ui_calendar_change_first_day_of_week();
break; break;
case '9': case '9':
status_mesg(output_datefmt_str, ""); status_mesg(output_datefmt_str, "");

View File

@ -370,7 +370,7 @@ struct day_items_nb day_process_storage(struct date *slctd_date,
if (slctd_date) if (slctd_date)
day = *slctd_date; day = *slctd_date;
else else
calendar_store_current_date(&day); ui_calendar_store_current_date(&day);
date = date2sec(day, 0, 0); date = date2sec(day, 0, 0);
@ -545,7 +545,7 @@ void day_popup_item(struct day_item *day)
struct apoint apt_tmp; struct apoint apt_tmp;
apt_tmp.start = day->start; apt_tmp.start = day->start;
apt_tmp.dur = day_item_get_duration(day); apt_tmp.dur = day_item_get_duration(day);
apoint_sec2str(&apt_tmp, calendar_get_slctd_day_sec(), a_st, a_end); apoint_sec2str(&apt_tmp, ui_calendar_get_slctd_day_sec(), a_st, a_end);
item_in_popup(a_st, a_end, day_item_get_mesg(day), _("Appointment :")); item_in_popup(a_st, a_end, day_item_get_mesg(day), _("Appointment :"));
} else { } else {

View File

@ -101,7 +101,7 @@ static void pcal_export_header(FILE * stream)
fputs("# calcurse pcal export\n", stream); fputs("# calcurse pcal export\n", stream);
fputs("\n# =======\n# options\n# =======\n", stream); fputs("\n# =======\n# options\n# =======\n", stream);
fprintf(stream, "opt -A -K -l -m -F %s\n", fprintf(stream, "opt -A -K -l -m -F %s\n",
calendar_week_begins_on_monday()? "Monday" : "Sunday"); ui_calendar_week_begins_on_monday()? "Monday" : "Sunday");
fputs("# Display week number (i.e. 1-52) on every Monday\n", stream); fputs("# Display week number (i.e. 1-52) on every Monday\n", stream);
fprintf(stream, "all monday in all week %%w\n"); fprintf(stream, "all monday in all week %%w\n");
fputc('\n', stream); fputc('\n', stream);
@ -172,8 +172,8 @@ static void pcal_export_recur_events(FILE * stream)
EXIT(_("incoherent repetition type")); EXIT(_("incoherent repetition type"));
} }
} else { } else {
const long YEAR_START = calendar_start_of_year(); const long YEAR_START = ui_calendar_start_of_year();
const long YEAR_END = calendar_end_of_year(); const long YEAR_END = ui_calendar_end_of_year();
if (rev->day < YEAR_END && rev->day > YEAR_START) if (rev->day < YEAR_END && rev->day > YEAR_START)
foreach_date_dump(YEAR_END, rev->rpt, &rev->exc, rev->day, 0, foreach_date_dump(YEAR_END, rev->rpt, &rev->exc, rev->day, 0,
@ -237,8 +237,8 @@ static void pcal_export_recur_apoints(FILE * stream)
EXIT(_("incoherent repetition type")); EXIT(_("incoherent repetition type"));
} }
} else { } else {
const long YEAR_START = calendar_start_of_year(); const long YEAR_START = ui_calendar_start_of_year();
const long YEAR_END = calendar_end_of_year(); const long YEAR_END = ui_calendar_end_of_year();
if (rapt->start < YEAR_END && rapt->start > YEAR_START) if (rapt->start < YEAR_END && rapt->start > YEAR_START)
foreach_date_dump(YEAR_END, rapt->rpt, &rapt->exc, rapt->start, foreach_date_dump(YEAR_END, rapt->rpt, &rapt->exc, rapt->start,

View File

@ -67,9 +67,9 @@ enum pom {
}; };
static struct date today, slctd_day; static struct date today, slctd_day;
static unsigned calendar_view, week_begins_on_monday; static unsigned ui_calendar_view, week_begins_on_monday;
static pthread_mutex_t date_thread_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t date_thread_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_t calendar_t_date; static pthread_t ui_calendar_t_date;
static void draw_monthly_view(struct window *, struct date *, unsigned); static void draw_monthly_view(struct window *, struct date *, unsigned);
static void draw_weekly_view(struct window *, struct date *, unsigned); static void draw_weekly_view(struct window *, struct date *, unsigned);
@ -82,33 +82,33 @@ static int monthly_view_cache_valid = 0;
static int monthly_view_cache_month = 0; static int monthly_view_cache_month = 0;
/* Switch between calendar views (monthly view is selected by default). */ /* Switch between calendar views (monthly view is selected by default). */
void calendar_view_next(void) void ui_calendar_view_next(void)
{ {
calendar_view++; ui_calendar_view++;
if (calendar_view == CAL_VIEWS) if (ui_calendar_view == CAL_VIEWS)
calendar_view = 0; ui_calendar_view = 0;
} }
void calendar_view_prev(void) void ui_calendar_view_prev(void)
{ {
if (calendar_view == 0) if (ui_calendar_view == 0)
calendar_view = CAL_VIEWS; ui_calendar_view = CAL_VIEWS;
calendar_view--; ui_calendar_view--;
} }
void calendar_set_view(int view) void ui_calendar_set_view(int view)
{ {
calendar_view = (view < 0 || view >= CAL_VIEWS) ? CAL_MONTH_VIEW : view; ui_calendar_view = (view < 0 || view >= CAL_VIEWS) ? CAL_MONTH_VIEW : view;
} }
int calendar_get_view(void) int ui_calendar_get_view(void)
{ {
return (int)calendar_view; return (int)ui_calendar_view;
} }
/* Thread needed to update current date in calendar. */ /* Thread needed to update current date in calendar. */
/* ARGSUSED0 */ /* ARGSUSED0 */
static void *calendar_date_thread(void *arg) static void *ui_calendar_date_thread(void *arg)
{ {
time_t actual, tomorrow; time_t actual, tomorrow;
@ -118,30 +118,30 @@ static void *calendar_date_thread(void *arg)
while ((actual = time(NULL)) < tomorrow) while ((actual = time(NULL)) < tomorrow)
sleep(tomorrow - actual); sleep(tomorrow - actual);
calendar_set_current_date(); ui_calendar_set_current_date();
calendar_update_panel(&win[CAL]); ui_calendar_update_panel(&win[CAL]);
} }
return NULL; return NULL;
} }
/* Launch the calendar date thread. */ /* Launch the calendar date thread. */
void calendar_start_date_thread(void) void ui_calendar_start_date_thread(void)
{ {
pthread_create(&calendar_t_date, NULL, calendar_date_thread, NULL); pthread_create(&ui_calendar_t_date, NULL, ui_calendar_date_thread, NULL);
} }
/* Stop the calendar date thread. */ /* Stop the calendar date thread. */
void calendar_stop_date_thread(void) void ui_calendar_stop_date_thread(void)
{ {
if (calendar_t_date) { if (ui_calendar_t_date) {
pthread_cancel(calendar_t_date); pthread_cancel(ui_calendar_t_date);
pthread_join(calendar_t_date, NULL); pthread_join(ui_calendar_t_date, NULL);
} }
} }
/* Set static variable today to current date */ /* Set static variable today to current date */
void calendar_set_current_date(void) void ui_calendar_set_current_date(void)
{ {
time_t timer; time_t timer;
struct tm tm; struct tm tm;
@ -157,7 +157,7 @@ void calendar_set_current_date(void)
} }
/* Needed to display sunday or monday as the first day of week in calendar. */ /* Needed to display sunday or monday as the first day of week in calendar. */
void calendar_set_first_day_of_week(enum wday first_day) void ui_calendar_set_first_day_of_week(enum wday first_day)
{ {
switch (first_day) { switch (first_day) {
case SUNDAY: case SUNDAY:
@ -174,19 +174,19 @@ void calendar_set_first_day_of_week(enum wday first_day)
} }
/* Swap first day of week in calendar. */ /* Swap first day of week in calendar. */
void calendar_change_first_day_of_week(void) void ui_calendar_change_first_day_of_week(void)
{ {
week_begins_on_monday = !week_begins_on_monday; week_begins_on_monday = !week_begins_on_monday;
} }
/* Return 1 if week begins on monday, 0 otherwise. */ /* Return 1 if week begins on monday, 0 otherwise. */
unsigned calendar_week_begins_on_monday(void) unsigned ui_calendar_week_begins_on_monday(void)
{ {
return week_begins_on_monday; return week_begins_on_monday;
} }
/* Fill in the given variable with the current date. */ /* Fill in the given variable with the current date. */
void calendar_store_current_date(struct date *date) void ui_calendar_store_current_date(struct date *date)
{ {
pthread_mutex_lock(&date_thread_mutex); pthread_mutex_lock(&date_thread_mutex);
*date = today; *date = today;
@ -194,24 +194,24 @@ void calendar_store_current_date(struct date *date)
} }
/* This is to start at the current date in calendar. */ /* This is to start at the current date in calendar. */
void calendar_init_slctd_day(void) void ui_calendar_init_slctd_day(void)
{ {
calendar_store_current_date(&slctd_day); ui_calendar_store_current_date(&slctd_day);
} }
/* Return the selected day in calendar */ /* Return the selected day in calendar */
struct date *calendar_get_slctd_day(void) struct date *ui_calendar_get_slctd_day(void)
{ {
return &slctd_day; return &slctd_day;
} }
/* Returned value represents the selected day in calendar (in seconds) */ /* Returned value represents the selected day in calendar (in seconds) */
long calendar_get_slctd_day_sec(void) long ui_calendar_get_slctd_day_sec(void)
{ {
return date2sec(slctd_day, 0, 0); return date2sec(slctd_day, 0, 0);
} }
static int calendar_get_wday(struct date *date) static int ui_calendar_get_wday(struct date *date)
{ {
struct tm t; struct tm t;
@ -268,7 +268,7 @@ static int date_change(struct tm *date, int delta_month, int delta_day)
} }
} }
void calendar_monthly_view_cache_set_invalid(void) void ui_calendar_monthly_view_cache_set_invalid(void)
{ {
monthly_view_cache_valid = 0; monthly_view_cache_valid = 0;
} }
@ -467,7 +467,7 @@ draw_weekly_view(struct window *cwin, struct date *current_day,
OFFX = (wins_sbar_width() - WCALWIDTH) / 2 + 1; OFFX = (wins_sbar_width() - WCALWIDTH) / 2 + 1;
/* Fill in a tm structure with the first day of the selected week. */ /* Fill in a tm structure with the first day of the selected week. */
c_wday = calendar_get_wday(&slctd_day); c_wday = ui_calendar_get_wday(&slctd_day);
if (sunday_first) if (sunday_first)
days_to_remove = c_wday; days_to_remove = c_wday;
else else
@ -571,12 +571,12 @@ draw_weekly_view(struct window *cwin, struct date *current_day,
} }
/* Function used to display the calendar panel. */ /* Function used to display the calendar panel. */
void calendar_update_panel(struct window *cwin) void ui_calendar_update_panel(struct window *cwin)
{ {
struct date current_day; struct date current_day;
unsigned sunday_first; unsigned sunday_first;
calendar_store_current_date(&current_day); ui_calendar_store_current_date(&current_day);
WINS_CALENDAR_LOCK; WINS_CALENDAR_LOCK;
erase_window_part(cwin->p, 1, conf.compact_panels ? 1 : 3, cwin->w - 2, erase_window_part(cwin->p, 1, conf.compact_panels ? 1 : 3, cwin->w - 2,
@ -585,19 +585,19 @@ void calendar_update_panel(struct window *cwin)
mvwhline(cwin->p, 2, 1, ACS_HLINE, cwin->w - 2); mvwhline(cwin->p, 2, 1, ACS_HLINE, cwin->w - 2);
WINS_CALENDAR_UNLOCK; WINS_CALENDAR_UNLOCK;
sunday_first = calendar_week_begins_on_monday()? 0 : 1; sunday_first = ui_calendar_week_begins_on_monday()? 0 : 1;
draw_calendar[calendar_view] (cwin, &current_day, sunday_first); draw_calendar[ui_calendar_view] (cwin, &current_day, sunday_first);
wnoutrefresh(cwin->p); wnoutrefresh(cwin->p);
} }
/* Set the selected day in calendar to current day. */ /* Set the selected day in calendar to current day. */
void calendar_goto_today(void) void ui_calendar_goto_today(void)
{ {
struct date today; struct date today;
calendar_store_current_date(&today); ui_calendar_store_current_date(&today);
slctd_day.dd = today.dd; slctd_day.dd = today.dd;
slctd_day.mm = today.mm; slctd_day.mm = today.mm;
slctd_day.yyyy = today.yyyy; slctd_day.yyyy = today.yyyy;
@ -609,7 +609,7 @@ void calendar_goto_today(void)
* If the entered date is empty, automatically jump to the current date. * If the entered date is empty, automatically jump to the current date.
* slctd_day is updated with the newly selected date. * slctd_day is updated with the newly selected date.
*/ */
void calendar_change_day(int datefmt) void ui_calendar_change_day(int datefmt)
{ {
#define LDAY 11 #define LDAY 11
char selected_day[LDAY] = ""; char selected_day[LDAY] = "";
@ -630,9 +630,9 @@ void calendar_change_day(int datefmt)
else { else {
if (strlen(selected_day) == 0) { if (strlen(selected_day) == 0) {
wrong_day = 0; wrong_day = 0;
calendar_goto_today(); ui_calendar_goto_today();
} else if (parse_date(selected_day, datefmt, &dyear, &dmonth, &dday, } else if (parse_date(selected_day, datefmt, &dyear, &dmonth, &dday,
calendar_get_slctd_day())) { ui_calendar_get_slctd_day())) {
wrong_day = 0; wrong_day = 0;
/* go to chosen day */ /* go to chosen day */
slctd_day.dd = dday; slctd_day.dd = dday;
@ -649,7 +649,7 @@ void calendar_change_day(int datefmt)
return; return;
} }
void calendar_move(enum move move, int count) void ui_calendar_move(enum move move, int count)
{ {
int ret, days_to_remove, days_to_add; int ret, days_to_remove, days_to_add;
struct tm t; struct tm t;
@ -687,7 +687,7 @@ void calendar_move(enum move move, int count)
case WEEK_START: case WEEK_START:
/* Normalize struct tm to get week day number. */ /* Normalize struct tm to get week day number. */
mktime(&t); mktime(&t);
if (calendar_week_begins_on_monday()) if (ui_calendar_week_begins_on_monday())
days_to_remove = ((t.tm_wday == 0) ? WEEKINDAYS - 1 : t.tm_wday - 1); days_to_remove = ((t.tm_wday == 0) ? WEEKINDAYS - 1 : t.tm_wday - 1);
else else
days_to_remove = ((t.tm_wday == 0) ? 0 : t.tm_wday); days_to_remove = ((t.tm_wday == 0) ? 0 : t.tm_wday);
@ -696,7 +696,7 @@ void calendar_move(enum move move, int count)
break; break;
case WEEK_END: case WEEK_END:
mktime(&t); mktime(&t);
if (calendar_week_begins_on_monday()) if (ui_calendar_week_begins_on_monday())
days_to_add = ((t.tm_wday == 0) ? 0 : WEEKINDAYS - t.tm_wday); days_to_add = ((t.tm_wday == 0) ? 0 : WEEKINDAYS - t.tm_wday);
else else
days_to_add = ((t.tm_wday == 0) ? days_to_add = ((t.tm_wday == 0) ?
@ -727,7 +727,7 @@ void calendar_move(enum move move, int count)
} }
/* Returns the beginning of current year as a long. */ /* Returns the beginning of current year as a long. */
long calendar_start_of_year(void) long ui_calendar_start_of_year(void)
{ {
time_t timer; time_t timer;
struct tm tm; struct tm tm;
@ -744,7 +744,7 @@ long calendar_start_of_year(void)
return (long)timer; return (long)timer;
} }
long calendar_end_of_year(void) long ui_calendar_end_of_year(void)
{ {
time_t timer; time_t timer;
struct tm tm; struct tm tm;
@ -892,7 +892,7 @@ static double pom(time_t tmpt)
* Careful: date is the selected day in calendar at 00:00, so it represents * Careful: date is the selected day in calendar at 00:00, so it represents
* the phase of the moon for previous day. * the phase of the moon for previous day.
*/ */
const char *calendar_get_pom(time_t date) const char *ui_calendar_get_pom(time_t date)
{ {
const char *pom_pict[MOON_PHASES] = { " ", "|) ", "(|)", "(| ", " | " }; const char *pom_pict[MOON_PHASES] = { " ", "|) ", "(|)", "(| ", " | " };
enum pom phase = NO_POM; enum pom phase = NO_POM;

View File

@ -242,7 +242,7 @@ static void update_rept(struct rpt **rpt, const long start)
int newmonth, newday, newyear; int newmonth, newday, newyear;
if (parse_date(timstr, conf.input_datefmt, &newyear, &newmonth, if (parse_date(timstr, conf.input_datefmt, &newyear, &newmonth,
&newday, calendar_get_slctd_day())) { &newday, ui_calendar_get_slctd_day())) {
t = start; t = start;
localtime_r(&t, &lt); localtime_r(&t, &lt);
new_date.dd = newday; new_date.dd = newday;
@ -360,7 +360,7 @@ void ui_day_item_edit(void)
break; break;
} }
calendar_monthly_view_cache_set_invalid(); ui_calendar_monthly_view_cache_set_invalid();
if (need_check_notify) if (need_check_notify)
notify_check_next_app(1); notify_check_next_app(1);
@ -490,18 +490,18 @@ void ui_day_item_add(void)
status_mesg(mesg_3, ""); status_mesg(mesg_3, "");
if (getstring(win[STA].p, item_mesg, BUFSIZ, 0, 1) == GETSTRING_VALID) { if (getstring(win[STA].p, item_mesg, BUFSIZ, 0, 1) == GETSTRING_VALID) {
if (is_appointment) { if (is_appointment) {
apoint_start = date2sec(*calendar_get_slctd_day(), heures, minutes); apoint_start = date2sec(*ui_calendar_get_slctd_day(), heures, minutes);
apoint_new(item_mesg, 0L, apoint_start, min2sec(apoint_duration), 0L); apoint_new(item_mesg, 0L, apoint_start, min2sec(apoint_duration), 0L);
if (notify_bar()) if (notify_bar())
notify_check_added(item_mesg, apoint_start, 0L); notify_check_added(item_mesg, apoint_start, 0L);
} else } else
event_new(item_mesg, 0L, date2sec(*calendar_get_slctd_day(), 0, 0), Id); event_new(item_mesg, 0L, date2sec(*ui_calendar_get_slctd_day(), 0, 0), Id);
if (ui_day_hilt() == 0) if (ui_day_hilt() == 0)
ui_day_hilt_increase(1); ui_day_hilt_increase(1);
} }
calendar_monthly_view_cache_set_invalid(); ui_calendar_monthly_view_cache_set_invalid();
wins_erase_status_bar(); wins_erase_status_bar();
} }
@ -524,7 +524,7 @@ void ui_day_item_delete(unsigned *nb_events, unsigned *nb_apoints,
const char *note_choices = _("[in]"); const char *note_choices = _("[in]");
const int nb_note_choices = 2; const int nb_note_choices = 2;
long date = calendar_get_slctd_day_sec(); long date = ui_calendar_get_slctd_day_sec();
int nb_items = *nb_apoints + *nb_events; int nb_items = *nb_apoints + *nb_events;
int to_be_removed = 0; int to_be_removed = 0;
@ -585,7 +585,7 @@ void ui_day_item_delete(unsigned *nb_events, unsigned *nb_apoints,
/* NOTREACHED */ /* NOTREACHED */
} }
calendar_monthly_view_cache_set_invalid(); ui_calendar_monthly_view_cache_set_invalid();
if (ui_day_hilt() > 1) if (ui_day_hilt() > 1)
ui_day_hilt_decrease(1); ui_day_hilt_decrease(1);
@ -687,7 +687,7 @@ void ui_day_item_repeat(void)
date_entered = 1; date_entered = 1;
} else { } else {
if (parse_date(user_input, conf.input_datefmt, if (parse_date(user_input, conf.input_datefmt,
&year, &month, &day, calendar_get_slctd_day())) { &year, &month, &day, ui_calendar_get_slctd_day())) {
t = p->start; t = p->start;
localtime_r(&t, &lt); localtime_r(&t, &lt);
until_date.dd = day; until_date.dd = day;
@ -713,7 +713,7 @@ void ui_day_item_repeat(void)
return; return;
} }
date = calendar_get_slctd_day_sec(); date = ui_calendar_get_slctd_day_sec();
if (p->type == EVNT) { if (p->type == EVNT) {
struct event *ev = p->item.ev; struct event *ev = p->item.ev;
recur_event_new(ev->mesg, ev->note, ev->day, ev->id, type, freq, until, recur_event_new(ev->mesg, ev->note, ev->day, ev->id, type, freq, until,
@ -734,7 +734,7 @@ void ui_day_item_repeat(void)
day_cut[REG_BLACK_HOLE].type = p->type; day_cut[REG_BLACK_HOLE].type = p->type;
day_cut[REG_BLACK_HOLE].item = p->item; day_cut[REG_BLACK_HOLE].item = p->item;
calendar_monthly_view_cache_set_invalid(); ui_calendar_monthly_view_cache_set_invalid();
} }
/* Free the current cut item, if any. */ /* Free the current cut item, if any. */
@ -783,9 +783,9 @@ void ui_day_item_paste(unsigned *nb_events, unsigned *nb_apoints,
return; return;
day_item_fork(&day_cut[reg], &day); day_item_fork(&day_cut[reg], &day);
item_type = day_paste_item(&day, calendar_get_slctd_day_sec()); item_type = day_paste_item(&day, ui_calendar_get_slctd_day_sec());
calendar_monthly_view_cache_set_invalid(); ui_calendar_monthly_view_cache_set_invalid();
if (item_type == EVNT || item_type == RECUR_EVNT) if (item_type == EVNT || item_type == RECUR_EVNT)
(*nb_events)++; (*nb_events)++;
@ -884,7 +884,7 @@ void ui_day_update_panel(int which_pan)
struct date slctd_date; struct date slctd_date;
/* variable inits */ /* variable inits */
slctd_date = *calendar_get_slctd_day(); slctd_date = *ui_calendar_get_slctd_day();
title_xpos = win[APP].w - (strlen(_(monthnames[slctd_date.mm - 1])) + 16); title_xpos = win[APP].w - (strlen(_(monthnames[slctd_date.mm - 1])) + 16);
if (slctd_date.dd < 10) if (slctd_date.dd < 10)
title_xpos++; title_xpos++;
@ -895,7 +895,7 @@ void ui_day_update_panel(int which_pan)
erase_window_part(win[APP].p, 1, title_lines, win[APP].w - 2, win[APP].h - 2); 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); custom_apply_attr(win[APP].p, ATTR_HIGHEST);
mvwprintw(win[APP].p, title_lines, title_xpos, "%s %s %d, %d", mvwprintw(win[APP].p, title_lines, title_xpos, "%s %s %d, %d",
calendar_get_pom(date), _(monthnames[slctd_date.mm - 1]), ui_calendar_get_pom(date), _(monthnames[slctd_date.mm - 1]),
slctd_date.dd, slctd_date.yyyy); slctd_date.dd, slctd_date.yyyy);
custom_remove_attr(win[APP].p, ATTR_HIGHEST); custom_remove_attr(win[APP].p, ATTR_HIGHEST);

View File

@ -80,7 +80,7 @@ void exit_calcurse(int status)
} else } else
was_interactive = 0; was_interactive = 0;
calendar_stop_date_thread(); ui_calendar_stop_date_thread();
io_stop_psave_thread(); io_stop_psave_thread();
free_user_data(); free_user_data();
keys_free(); keys_free();

View File

@ -161,7 +161,7 @@ void vars_init(void)
wins_set_layout(1); wins_set_layout(1);
calendar_set_first_day_of_week(MONDAY); ui_calendar_set_first_day_of_week(MONDAY);
/* Pad structure to scroll text inside the appointment panel */ /* Pad structure to scroll text inside the appointment panel */
apad.length = 1; apad.length = 1;
@ -171,5 +171,5 @@ void vars_init(void)
custom_init_attr(); custom_init_attr();
/* Start at the current date */ /* Start at the current date */
calendar_init_slctd_day(); ui_calendar_init_slctd_day();
} }

View File

@ -499,7 +499,7 @@ void wins_update_panels(int flags)
if (flags & FLAG_TOD) if (flags & FLAG_TOD)
ui_todo_update_panel(slctd_win); ui_todo_update_panel(slctd_win);
if (flags & FLAG_CAL) if (flags & FLAG_CAL)
calendar_update_panel(&win[CAL]); ui_calendar_update_panel(&win[CAL]);
} }
/* /*