Yet another style for source code. GNU style now used (I am fed up with tabs...)
This commit is contained in:
parent
0c281d2c1e
commit
efd782699b
@ -1,3 +1,7 @@
|
||||
12 Apr 2008:
|
||||
Yet another style for source code. GNU style now used (I am fed up
|
||||
with tabs...)
|
||||
|
||||
09 Apr 2008:
|
||||
Tony's patch concerning date format configuration imported, many
|
||||
thanks to him
|
||||
|
912
src/apoint.c
912
src/apoint.c
File diff suppressed because it is too large
Load Diff
72
src/apoint.h
72
src/apoint.h
@ -1,4 +1,4 @@
|
||||
/* $calcurse: apoint.h,v 1.12 2008/01/20 10:45:38 culot Exp $ */
|
||||
/* $calcurse: apoint.h,v 1.13 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -39,42 +39,46 @@
|
||||
#define APOINT_NOTIFY 0x1 /* Item needs to be notified */
|
||||
#define APOINT_NOTIFIED 0x2 /* Item was already notified */
|
||||
|
||||
typedef struct apoint_llist_node {
|
||||
struct apoint_llist_node *next;
|
||||
long start; /* seconds since 1 jan 1970 */
|
||||
long dur; /* duration of the appointment in seconds */
|
||||
char state; /* 8 bits to store item state */
|
||||
char *mesg;
|
||||
char *note;
|
||||
} apoint_llist_node_t;
|
||||
typedef struct apoint_llist_node
|
||||
{
|
||||
struct apoint_llist_node *next;
|
||||
long start; /* seconds since 1 jan 1970 */
|
||||
long dur; /* duration of the appointment in seconds */
|
||||
char state; /* 8 bits to store item state */
|
||||
char *mesg;
|
||||
char *note;
|
||||
}
|
||||
apoint_llist_node_t;
|
||||
|
||||
typedef struct apoint_llist {
|
||||
apoint_llist_node_t *root;
|
||||
pthread_mutex_t mutex;
|
||||
} apoint_llist_t;
|
||||
typedef struct apoint_llist
|
||||
{
|
||||
apoint_llist_node_t *root;
|
||||
pthread_mutex_t mutex;
|
||||
}
|
||||
apoint_llist_t;
|
||||
|
||||
extern apoint_llist_t *alist_p;
|
||||
|
||||
int apoint_llist_init(void);
|
||||
void apoint_hilt_set(int);
|
||||
void apoint_hilt_decrease(void);
|
||||
void apoint_hilt_increase(void);
|
||||
int apoint_hilt(void);
|
||||
apoint_llist_node_t *apoint_new(char *, char *, long, long, char);
|
||||
void apoint_add(void);
|
||||
void apoint_delete(conf_t *, unsigned *, unsigned *);
|
||||
unsigned apoint_inday(apoint_llist_node_t *, long);
|
||||
void apoint_sec2str(apoint_llist_node_t *, int, long,
|
||||
char *, char *);
|
||||
void apoint_write(apoint_llist_node_t *, FILE *);
|
||||
apoint_llist_node_t *apoint_scan(FILE *, struct tm, struct tm, char, char *);
|
||||
apoint_llist_node_t *apoint_get(long, int);
|
||||
void apoint_delete_bynum(long, unsigned, erase_flag_e);
|
||||
void apoint_scroll_pad_down(int, int);
|
||||
void apoint_scroll_pad_up(int);
|
||||
struct notify_app_s *apoint_check_next(struct notify_app_s *, long);
|
||||
apoint_llist_node_t *apoint_recur_s2apoint_s(recur_apoint_llist_node_t *);
|
||||
void apoint_switch_notify(void);
|
||||
void apoint_update_panel(window_t *, int);
|
||||
int apoint_llist_init (void);
|
||||
void apoint_hilt_set (int);
|
||||
void apoint_hilt_decrease (void);
|
||||
void apoint_hilt_increase (void);
|
||||
int apoint_hilt (void);
|
||||
apoint_llist_node_t *apoint_new (char *, char *, long, long, char);
|
||||
void apoint_add (void);
|
||||
void apoint_delete (conf_t *, unsigned *, unsigned *);
|
||||
unsigned apoint_inday (apoint_llist_node_t *, long);
|
||||
void apoint_sec2str (apoint_llist_node_t *, int, long, char *,
|
||||
char *);
|
||||
void apoint_write (apoint_llist_node_t *, FILE *);
|
||||
apoint_llist_node_t *apoint_scan (FILE *, struct tm, struct tm, char, char *);
|
||||
apoint_llist_node_t *apoint_get (long, int);
|
||||
void apoint_delete_bynum (long, unsigned, erase_flag_e);
|
||||
void apoint_scroll_pad_down (int, int);
|
||||
void apoint_scroll_pad_up (int);
|
||||
struct notify_app_s *apoint_check_next (struct notify_app_s *, long);
|
||||
apoint_llist_node_t *apoint_recur_s2apoint_s (recur_apoint_llist_node_t *);
|
||||
void apoint_switch_notify (void);
|
||||
void apoint_update_panel (window_t *, int);
|
||||
|
||||
#endif /* CALCURSE_APOINT_H */
|
||||
|
967
src/args.c
967
src/args.c
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
/* $calcurse: args.h,v 1.8 2007/07/28 13:11:42 culot Exp $ */
|
||||
/* $calcurse: args.h,v 1.9 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -27,6 +27,6 @@
|
||||
#ifndef CALCURSE_ARGS_H
|
||||
#define CALCURSE_ARGS_H
|
||||
|
||||
int parse_args(int, char **, conf_t *);
|
||||
int parse_args (int, char **, conf_t *);
|
||||
|
||||
#endif /* CALCURSE_ARGS_H */
|
||||
|
842
src/calcurse.c
842
src/calcurse.c
@ -1,4 +1,4 @@
|
||||
/* $calcurse: calcurse.c,v 1.61 2008/04/09 20:38:29 culot Exp $ */
|
||||
/* $calcurse: calcurse.c,v 1.62 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -44,446 +44,466 @@
|
||||
|
||||
|
||||
/*
|
||||
* Calcurse is a text-based personal organizer which helps keeping track
|
||||
* Calcurse is a text-based personal organizer which helps keeping track
|
||||
* of events and everyday tasks. It contains a calendar, a 'todo' list,
|
||||
* and puts your appointments in order. The user interface is configurable,
|
||||
* and one can choose between different color schemes and layouts.
|
||||
* All of the commands are documented within an online help system.
|
||||
*/
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
conf_t conf;
|
||||
day_items_nb_t inday;
|
||||
int ch, background, foreground;
|
||||
int non_interactive;
|
||||
int no_data_file = 1;
|
||||
int sav_hilt_app = 0;
|
||||
int sav_hilt_tod = 0;
|
||||
struct sigaction sigact;
|
||||
bool do_storage = false;
|
||||
bool do_update = true;
|
||||
bool day_changed = false;
|
||||
char *no_color_support =
|
||||
_("Sorry, colors are not supported by your terminal\n"
|
||||
"(Press [ENTER] to continue)");
|
||||
char *quit_message = _("Do you really want to quit ?");
|
||||
char choices[] = "[y/n] ";
|
||||
conf_t conf;
|
||||
day_items_nb_t inday;
|
||||
int ch, background, foreground;
|
||||
int non_interactive;
|
||||
int no_data_file = 1;
|
||||
int sav_hilt_app = 0;
|
||||
int sav_hilt_tod = 0;
|
||||
struct sigaction sigact;
|
||||
bool do_storage = false;
|
||||
bool do_update = true;
|
||||
bool day_changed = false;
|
||||
char *no_color_support =
|
||||
_("Sorry, colors are not supported by your terminal\n"
|
||||
"(Press [ENTER] to continue)");
|
||||
char *quit_message = _("Do you really want to quit ?");
|
||||
char choices[] = "[y/n] ";
|
||||
|
||||
#if ENABLE_NLS
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
#endif /* ENABLE_NLS */
|
||||
|
||||
/* Thread-safe data structure init */
|
||||
apoint_llist_init();
|
||||
recur_apoint_llist_init();
|
||||
|
||||
/*
|
||||
* Begin by parsing and handling command line arguments.
|
||||
* The data path is also initialized here.
|
||||
*/
|
||||
non_interactive = parse_args(argc, argv, &conf);
|
||||
if (non_interactive)
|
||||
return (EXIT_SUCCESS);
|
||||
/* Thread-safe data structure init */
|
||||
apoint_llist_init ();
|
||||
recur_apoint_llist_init ();
|
||||
|
||||
/* Begin of interactive mode with ncurses interface. */
|
||||
sigs_init(&sigact); /* signal handling init */
|
||||
initscr(); /* start the curses mode */
|
||||
cbreak(); /* control chars generate a signal */
|
||||
noecho(); /* controls echoing of typed chars */
|
||||
curs_set(0); /* make cursor invisible */
|
||||
calendar_set_current_date();
|
||||
notify_init_vars();
|
||||
wins_get_config();
|
||||
|
||||
/* Check if terminal supports color. */
|
||||
if (has_colors()) {
|
||||
colorize = true;
|
||||
background = COLOR_BLACK;
|
||||
foreground = COLOR_WHITE;
|
||||
start_color();
|
||||
/*
|
||||
* Begin by parsing and handling command line arguments.
|
||||
* The data path is also initialized here.
|
||||
*/
|
||||
non_interactive = parse_args (argc, argv, &conf);
|
||||
if (non_interactive)
|
||||
return (EXIT_SUCCESS);
|
||||
|
||||
/* Begin of interactive mode with ncurses interface. */
|
||||
sigs_init (&sigact); /* signal handling init */
|
||||
initscr (); /* start the curses mode */
|
||||
cbreak (); /* control chars generate a signal */
|
||||
noecho (); /* controls echoing of typed chars */
|
||||
curs_set (0); /* make cursor invisible */
|
||||
calendar_set_current_date ();
|
||||
notify_init_vars ();
|
||||
wins_get_config ();
|
||||
|
||||
/* Check if terminal supports color. */
|
||||
if (has_colors ())
|
||||
{
|
||||
colorize = true;
|
||||
background = COLOR_BLACK;
|
||||
foreground = COLOR_WHITE;
|
||||
start_color ();
|
||||
|
||||
#ifdef NCURSES_VERSION
|
||||
if (use_default_colors() != ERR) {
|
||||
background = -1;
|
||||
foreground = -1;
|
||||
}
|
||||
if (use_default_colors () != ERR)
|
||||
{
|
||||
background = -1;
|
||||
foreground = -1;
|
||||
}
|
||||
#endif /* NCURSES_VERSION */
|
||||
|
||||
/* Color assignment */
|
||||
init_pair(COLR_RED, COLOR_RED, background);
|
||||
init_pair(COLR_GREEN, COLOR_GREEN, background);
|
||||
init_pair(COLR_YELLOW, COLOR_YELLOW, background);
|
||||
init_pair(COLR_BLUE, COLOR_BLUE, background);
|
||||
init_pair(COLR_MAGENTA, COLOR_MAGENTA, background);
|
||||
init_pair(COLR_CYAN, COLOR_CYAN, background);
|
||||
init_pair(COLR_DEFAULT, foreground, background);
|
||||
init_pair(COLR_HIGH, COLOR_BLACK, COLOR_GREEN);
|
||||
init_pair(COLR_CUSTOM, COLOR_RED, background);
|
||||
/* Color assignment */
|
||||
init_pair (COLR_RED, COLOR_RED, background);
|
||||
init_pair (COLR_GREEN, COLOR_GREEN, background);
|
||||
init_pair (COLR_YELLOW, COLOR_YELLOW, background);
|
||||
init_pair (COLR_BLUE, COLOR_BLUE, background);
|
||||
init_pair (COLR_MAGENTA, COLOR_MAGENTA, background);
|
||||
init_pair (COLR_CYAN, COLOR_CYAN, background);
|
||||
init_pair (COLR_DEFAULT, foreground, background);
|
||||
init_pair (COLR_HIGH, COLOR_BLACK, COLOR_GREEN);
|
||||
init_pair (COLR_CUSTOM, COLOR_RED, background);
|
||||
|
||||
} else {
|
||||
colorize = false;
|
||||
background = COLOR_BLACK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
colorize = false;
|
||||
background = COLOR_BLACK;
|
||||
}
|
||||
|
||||
vars_init(&conf);
|
||||
wins_init();
|
||||
wins_slctd_init();
|
||||
notify_init_bar();
|
||||
reset_status_page();
|
||||
vars_init (&conf);
|
||||
wins_init ();
|
||||
wins_slctd_init ();
|
||||
notify_init_bar ();
|
||||
reset_status_page ();
|
||||
|
||||
/*
|
||||
* Read the data from files : first the user
|
||||
* configuration (the display is then updated), and then
|
||||
* the todo list, appointments and events.
|
||||
*/
|
||||
no_data_file = io_check_data_files();
|
||||
custom_load_conf(&conf, background);
|
||||
erase_status_bar();
|
||||
io_load_todo();
|
||||
io_load_app();
|
||||
wins_reinit();
|
||||
if (notify_bar()) {
|
||||
notify_start_main_thread();
|
||||
notify_check_next_app();
|
||||
}
|
||||
wins_update();
|
||||
io_startup_screen(conf.skip_system_dialogs, no_data_file);
|
||||
inday = *day_process_storage(0, day_changed, &inday);
|
||||
wins_slctd_set(CAL);
|
||||
wins_update();
|
||||
calendar_start_date_thread();
|
||||
/*
|
||||
* Read the data from files : first the user
|
||||
* configuration (the display is then updated), and then
|
||||
* the todo list, appointments and events.
|
||||
*/
|
||||
no_data_file = io_check_data_files ();
|
||||
custom_load_conf (&conf, background);
|
||||
erase_status_bar ();
|
||||
io_load_todo ();
|
||||
io_load_app ();
|
||||
wins_reinit ();
|
||||
if (notify_bar ())
|
||||
{
|
||||
notify_start_main_thread ();
|
||||
notify_check_next_app ();
|
||||
}
|
||||
wins_update ();
|
||||
io_startup_screen (conf.skip_system_dialogs, no_data_file);
|
||||
inday = *day_process_storage (0, day_changed, &inday);
|
||||
wins_slctd_set (CAL);
|
||||
wins_update ();
|
||||
calendar_start_date_thread ();
|
||||
|
||||
/* User input */
|
||||
for (;;) {
|
||||
/* User input */
|
||||
for (;;)
|
||||
{
|
||||
do_update = true;
|
||||
ch = wgetch (win[STA].p);
|
||||
switch (ch)
|
||||
{
|
||||
case ERR:
|
||||
do_update = false;
|
||||
break;
|
||||
|
||||
do_update = true;
|
||||
ch = wgetch(win[STA].p);
|
||||
case CTRL ('R'):
|
||||
case KEY_RESIZE:
|
||||
do_update = false;
|
||||
wins_reset ();
|
||||
break;
|
||||
|
||||
switch (ch) {
|
||||
case 9: /* The TAB key was hit. */
|
||||
reset_status_page ();
|
||||
/* Save previously highlighted event. */
|
||||
switch (wins_slctd ())
|
||||
{
|
||||
case TOD:
|
||||
sav_hilt_tod = todo_hilt ();
|
||||
todo_hilt_set (0);
|
||||
break;
|
||||
case APP:
|
||||
sav_hilt_app = apoint_hilt ();
|
||||
apoint_hilt_set (0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
wins_slctd_next ();
|
||||
|
||||
case ERR:
|
||||
do_update = false;
|
||||
break;
|
||||
/* Select the event to highlight. */
|
||||
switch (wins_slctd ())
|
||||
{
|
||||
case TOD:
|
||||
if ((sav_hilt_tod == 0) && (todo_nb () != 0))
|
||||
todo_hilt_set (1);
|
||||
else
|
||||
todo_hilt_set (sav_hilt_tod);
|
||||
break;
|
||||
case APP:
|
||||
if ((sav_hilt_app == 0)
|
||||
&& ((inday.nb_events + inday.nb_apoints) != 0))
|
||||
apoint_hilt_set (1);
|
||||
else
|
||||
apoint_hilt_set (sav_hilt_app);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case CTRL('R'):
|
||||
case KEY_RESIZE:
|
||||
do_update = false;
|
||||
wins_reset();
|
||||
break;
|
||||
case 'O':
|
||||
case 'o':
|
||||
other_status_page (wins_slctd ());
|
||||
break;
|
||||
|
||||
case 9: /* The TAB key was hit. */
|
||||
reset_status_page();
|
||||
/* Save previously highlighted event. */
|
||||
switch (wins_slctd()) {
|
||||
case TOD:
|
||||
sav_hilt_tod = todo_hilt();
|
||||
todo_hilt_set(0);
|
||||
break;
|
||||
case APP:
|
||||
sav_hilt_app = apoint_hilt();
|
||||
apoint_hilt_set(0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
wins_slctd_next();
|
||||
case 'G':
|
||||
case 'g': /* Goto function */
|
||||
erase_status_bar ();
|
||||
calendar_set_current_date ();
|
||||
calendar_change_day (conf.input_datefmt);
|
||||
do_storage = true;
|
||||
day_changed = true;
|
||||
break;
|
||||
|
||||
/* Select the event to highlight. */
|
||||
switch (wins_slctd()) {
|
||||
case TOD:
|
||||
if ((sav_hilt_tod == 0) && (todo_nb() != 0))
|
||||
todo_hilt_set(1);
|
||||
else
|
||||
todo_hilt_set(sav_hilt_tod);
|
||||
break;
|
||||
case APP:
|
||||
if ((sav_hilt_app == 0) &&
|
||||
((inday.nb_events + inday.nb_apoints) != 0))
|
||||
apoint_hilt_set(1);
|
||||
else
|
||||
apoint_hilt_set(sav_hilt_app);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'O':
|
||||
case 'o':
|
||||
other_status_page(wins_slctd());
|
||||
break;
|
||||
|
||||
case 'G':
|
||||
case 'g': /* Goto function */
|
||||
erase_status_bar();
|
||||
calendar_set_current_date();
|
||||
calendar_change_day(conf.input_datefmt);
|
||||
do_storage = true;
|
||||
day_changed = true;
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
case 'v': /* View function */
|
||||
if ((wins_slctd() == APP) && (apoint_hilt() != 0))
|
||||
day_popup_item();
|
||||
else if ((wins_slctd() == TOD) && (todo_hilt() != 0))
|
||||
item_in_popup(NULL, NULL, todo_saved_mesg(),
|
||||
_("To do :"));
|
||||
break;
|
||||
case 'V':
|
||||
case 'v': /* View function */
|
||||
if ((wins_slctd () == APP) && (apoint_hilt () != 0))
|
||||
day_popup_item ();
|
||||
else if ((wins_slctd () == TOD) && (todo_hilt () != 0))
|
||||
item_in_popup (NULL, NULL, todo_saved_mesg (), _("To do :"));
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
case 'c': /* Configuration menu */
|
||||
erase_status_bar ();
|
||||
config_bar ();
|
||||
while ((ch = wgetch (win[STA].p)) != 'q')
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case 'C':
|
||||
case 'c': /* Configuration menu */
|
||||
erase_status_bar();
|
||||
config_bar();
|
||||
while ((ch = wgetch(win[STA].p)) != 'q') {
|
||||
switch (ch) {
|
||||
case 'C':
|
||||
case 'c':
|
||||
if (has_colors())
|
||||
custom_color_config();
|
||||
else {
|
||||
colorize = false;
|
||||
erase_status_bar();
|
||||
mvwprintw(win[STA].p, 0, 0,
|
||||
_(no_color_support));
|
||||
wgetch(win[STA].p);
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
case 'l':
|
||||
layout_config();
|
||||
break;
|
||||
case 'G':
|
||||
case 'g':
|
||||
custom_general_config(&conf);
|
||||
break;
|
||||
case 'N':
|
||||
case 'n':
|
||||
notify_config_bar();
|
||||
break;
|
||||
}
|
||||
wins_reset();
|
||||
wins_update();
|
||||
do_storage = true;
|
||||
erase_status_bar();
|
||||
config_bar();
|
||||
}
|
||||
wins_update();
|
||||
break;
|
||||
|
||||
case CTRL('A'): /* Add an app, whatever panel selected */
|
||||
apoint_add();
|
||||
do_storage = true;
|
||||
break;
|
||||
|
||||
case CTRL('T'): /* Add a todo, whatever panel selected */
|
||||
todo_new_item();
|
||||
if (todo_hilt() == 0 && todo_nb() == 1)
|
||||
todo_hilt_increase();
|
||||
break;
|
||||
|
||||
case 'A':
|
||||
case 'a': /* Add an item */
|
||||
switch (wins_slctd()) {
|
||||
case APP:
|
||||
apoint_add();
|
||||
do_storage = true;
|
||||
break;
|
||||
case TOD:
|
||||
todo_new_item();
|
||||
if (todo_hilt() == 0 && todo_nb() == 1)
|
||||
todo_hilt_increase();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'E':
|
||||
case 'e': /* Edit an existing item */
|
||||
if (wins_slctd() == APP && apoint_hilt() != 0)
|
||||
day_edit_item(&conf);
|
||||
else if (wins_slctd() == TOD && todo_hilt() != 0)
|
||||
todo_edit_item();
|
||||
do_storage = true;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
case 'd': /* Delete an item */
|
||||
if (wins_slctd() == APP && apoint_hilt() != 0)
|
||||
apoint_delete(&conf, &inday.nb_events,
|
||||
&inday.nb_apoints);
|
||||
else if (wins_slctd() == TOD && todo_hilt() != 0)
|
||||
todo_delete(&conf);
|
||||
do_storage = true;
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
case 'r':
|
||||
if (wins_slctd() == APP && apoint_hilt() != 0)
|
||||
recur_repeat_item(&conf);
|
||||
do_storage = true;
|
||||
break;
|
||||
|
||||
case '!':
|
||||
if (wins_slctd() == APP && apoint_hilt() != 0)
|
||||
apoint_switch_notify();
|
||||
do_storage = true;
|
||||
break;
|
||||
|
||||
case '+':
|
||||
case '-':
|
||||
if (wins_slctd() == TOD && todo_hilt() != 0) {
|
||||
todo_chg_priority(ch);
|
||||
if (todo_hilt_pos() < 0)
|
||||
todo_set_first(todo_hilt());
|
||||
else if (todo_hilt_pos() >= win[TOD].h - 4)
|
||||
todo_set_first(todo_hilt() -
|
||||
win[TOD].h + 5);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
if (has_colors ())
|
||||
custom_color_config ();
|
||||
else
|
||||
{
|
||||
colorize = false;
|
||||
erase_status_bar ();
|
||||
mvwprintw (win[STA].p, 0, 0, _(no_color_support));
|
||||
wgetch (win[STA].p);
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
case 'l':
|
||||
layout_config ();
|
||||
break;
|
||||
case 'G':
|
||||
case 'g':
|
||||
custom_general_config (&conf);
|
||||
break;
|
||||
case 'N':
|
||||
case 'n':
|
||||
/* Attach a note to an item, create it if necessary */
|
||||
if (wins_slctd() == APP && apoint_hilt() != 0)
|
||||
day_edit_note(conf.editor);
|
||||
else if (wins_slctd() == TOD && todo_hilt() != 0)
|
||||
todo_edit_note(conf.editor);
|
||||
do_storage = true;
|
||||
break;
|
||||
|
||||
case '>':
|
||||
/* View a note previously attached to an item */
|
||||
if (wins_slctd() == APP && apoint_hilt() != 0)
|
||||
day_view_note(conf.pager);
|
||||
else if (wins_slctd() == TOD && todo_hilt() != 0)
|
||||
todo_view_note(conf.pager);
|
||||
break;
|
||||
|
||||
case '?': /* Online help system */
|
||||
status_bar();
|
||||
help_screen();
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
case 's': /* Save function */
|
||||
io_save_cal(&conf);
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
case 'x': /* Export function */
|
||||
io_export_data(IO_EXPORT_INTERACTIVE, &conf);
|
||||
break;
|
||||
|
||||
case (261): /* right arrow */
|
||||
case ('L'):
|
||||
case ('l'):
|
||||
case CTRL('L'):
|
||||
if (wins_slctd() == CAL || ch == CTRL('L')) {
|
||||
do_storage = true;
|
||||
day_changed = true;
|
||||
calendar_move(RIGHT);
|
||||
}
|
||||
break;
|
||||
|
||||
case (260): /* left arrow */
|
||||
case ('H'):
|
||||
case ('h'):
|
||||
case CTRL('H'):
|
||||
if (wins_slctd() == CAL || ch == CTRL('H')) {
|
||||
do_storage = true;
|
||||
day_changed = true;
|
||||
calendar_move(LEFT);
|
||||
}
|
||||
break;
|
||||
|
||||
case (259): /* up arrow */
|
||||
case ('K'):
|
||||
case ('k'):
|
||||
case CTRL('K'):
|
||||
if (wins_slctd() == CAL || ch == CTRL('K')) {
|
||||
do_storage = true;
|
||||
day_changed = true;
|
||||
calendar_move(UP);
|
||||
} else {
|
||||
if ((wins_slctd() == APP) &&
|
||||
(apoint_hilt() > 1)) {
|
||||
apoint_hilt_decrease();
|
||||
apoint_scroll_pad_up(inday.nb_events);
|
||||
} else if ((wins_slctd() == TOD) &&
|
||||
(todo_hilt() > 1)) {
|
||||
todo_hilt_decrease();
|
||||
if (todo_hilt_pos() < 0)
|
||||
todo_first_decrease();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case (258): /* down arrow */
|
||||
case ('J'):
|
||||
case ('j'):
|
||||
case CTRL('J'):
|
||||
if (wins_slctd() == CAL || ch == CTRL('J')) {
|
||||
do_storage = true;
|
||||
day_changed = true;
|
||||
calendar_move(DOWN);
|
||||
} else {
|
||||
if ((wins_slctd() == APP) &&
|
||||
(apoint_hilt() < inday.nb_events +
|
||||
inday.nb_apoints)) {
|
||||
apoint_hilt_increase();
|
||||
apoint_scroll_pad_down(inday.nb_events,
|
||||
win[APP].h);
|
||||
}
|
||||
if ((wins_slctd() == TOD) &&
|
||||
(todo_hilt() < todo_nb())) {
|
||||
todo_hilt_increase();
|
||||
if (todo_hilt_pos() == win[TOD].h - 4)
|
||||
todo_first_increase();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ('Q'): /* Quit calcurse :( */
|
||||
case ('q'):
|
||||
if (conf.auto_save)
|
||||
io_save_cal(&conf);
|
||||
|
||||
if (conf.confirm_quit) {
|
||||
status_mesg(_(quit_message), choices);
|
||||
ch = wgetch(win[STA].p);
|
||||
if ( ch == 'y' )
|
||||
exit_calcurse(EXIT_SUCCESS);
|
||||
else {
|
||||
erase_status_bar();
|
||||
break;
|
||||
}
|
||||
} else
|
||||
exit_calcurse(EXIT_SUCCESS);
|
||||
break;
|
||||
|
||||
default:
|
||||
do_update = false;
|
||||
break;
|
||||
case 'n':
|
||||
notify_config_bar ();
|
||||
break;
|
||||
}
|
||||
wins_reset ();
|
||||
wins_update ();
|
||||
do_storage = true;
|
||||
erase_status_bar ();
|
||||
config_bar ();
|
||||
}
|
||||
wins_update ();
|
||||
break;
|
||||
|
||||
if (do_storage) {
|
||||
inday = *day_process_storage(calendar_get_slctd_day(),
|
||||
day_changed, &inday);
|
||||
do_storage = !do_storage;
|
||||
if (day_changed) {
|
||||
sav_hilt_app = 0;
|
||||
day_changed = !day_changed;
|
||||
if ((wins_slctd() == APP) &&
|
||||
(inday.nb_events + inday.nb_apoints != 0))
|
||||
apoint_hilt_set(1);
|
||||
}
|
||||
case CTRL ('A'): /* Add an app, whatever panel selected */
|
||||
apoint_add ();
|
||||
do_storage = true;
|
||||
break;
|
||||
|
||||
case CTRL ('T'): /* Add a todo, whatever panel selected */
|
||||
todo_new_item ();
|
||||
if (todo_hilt () == 0 && todo_nb () == 1)
|
||||
todo_hilt_increase ();
|
||||
break;
|
||||
|
||||
case 'A':
|
||||
case 'a': /* Add an item */
|
||||
switch (wins_slctd ())
|
||||
{
|
||||
case APP:
|
||||
apoint_add ();
|
||||
do_storage = true;
|
||||
break;
|
||||
case TOD:
|
||||
todo_new_item ();
|
||||
if (todo_hilt () == 0 && todo_nb () == 1)
|
||||
todo_hilt_increase ();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'E':
|
||||
case 'e': /* Edit an existing item */
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
day_edit_item (&conf);
|
||||
else if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
todo_edit_item ();
|
||||
do_storage = true;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
case 'd': /* Delete an item */
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
apoint_delete (&conf, &inday.nb_events, &inday.nb_apoints);
|
||||
else if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
todo_delete (&conf);
|
||||
do_storage = true;
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
case 'r':
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
recur_repeat_item (&conf);
|
||||
do_storage = true;
|
||||
break;
|
||||
|
||||
case '!':
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
apoint_switch_notify ();
|
||||
do_storage = true;
|
||||
break;
|
||||
|
||||
case '+':
|
||||
case '-':
|
||||
if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
{
|
||||
todo_chg_priority (ch);
|
||||
if (todo_hilt_pos () < 0)
|
||||
todo_set_first (todo_hilt ());
|
||||
else if (todo_hilt_pos () >= win[TOD].h - 4)
|
||||
todo_set_first (todo_hilt () - win[TOD].h + 5);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
case 'n':
|
||||
/* Attach a note to an item, create it if necessary */
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
day_edit_note (conf.editor);
|
||||
else if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
todo_edit_note (conf.editor);
|
||||
do_storage = true;
|
||||
break;
|
||||
|
||||
case '>':
|
||||
/* View a note previously attached to an item */
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
day_view_note (conf.pager);
|
||||
else if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
todo_view_note (conf.pager);
|
||||
break;
|
||||
|
||||
case '?': /* Online help system */
|
||||
status_bar ();
|
||||
help_screen ();
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
case 's': /* Save function */
|
||||
io_save_cal (&conf);
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
case 'x': /* Export function */
|
||||
io_export_data (IO_EXPORT_INTERACTIVE, &conf);
|
||||
break;
|
||||
|
||||
case (261): /* right arrow */
|
||||
case ('L'):
|
||||
case ('l'):
|
||||
case CTRL ('L'):
|
||||
if (wins_slctd () == CAL || ch == CTRL ('L'))
|
||||
{
|
||||
do_storage = true;
|
||||
day_changed = true;
|
||||
calendar_move (RIGHT);
|
||||
}
|
||||
break;
|
||||
|
||||
case (260): /* left arrow */
|
||||
case ('H'):
|
||||
case ('h'):
|
||||
case CTRL ('H'):
|
||||
if (wins_slctd () == CAL || ch == CTRL ('H'))
|
||||
{
|
||||
do_storage = true;
|
||||
day_changed = true;
|
||||
calendar_move (LEFT);
|
||||
}
|
||||
break;
|
||||
|
||||
case (259): /* up arrow */
|
||||
case ('K'):
|
||||
case ('k'):
|
||||
case CTRL ('K'):
|
||||
if (wins_slctd () == CAL || ch == CTRL ('K'))
|
||||
{
|
||||
do_storage = true;
|
||||
day_changed = true;
|
||||
calendar_move (UP);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((wins_slctd () == APP) && (apoint_hilt () > 1))
|
||||
{
|
||||
apoint_hilt_decrease ();
|
||||
apoint_scroll_pad_up (inday.nb_events);
|
||||
}
|
||||
if (do_update)
|
||||
wins_update();
|
||||
else if ((wins_slctd () == TOD) && (todo_hilt () > 1))
|
||||
{
|
||||
todo_hilt_decrease ();
|
||||
if (todo_hilt_pos () < 0)
|
||||
todo_first_decrease ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case (258): /* down arrow */
|
||||
case ('J'):
|
||||
case ('j'):
|
||||
case CTRL ('J'):
|
||||
if (wins_slctd () == CAL || ch == CTRL ('J'))
|
||||
{
|
||||
do_storage = true;
|
||||
day_changed = true;
|
||||
calendar_move (DOWN);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((wins_slctd () == APP) &&
|
||||
(apoint_hilt () < inday.nb_events + inday.nb_apoints))
|
||||
{
|
||||
apoint_hilt_increase ();
|
||||
apoint_scroll_pad_down (inday.nb_events, win[APP].h);
|
||||
}
|
||||
if ((wins_slctd () == TOD) && (todo_hilt () < todo_nb ()))
|
||||
{
|
||||
todo_hilt_increase ();
|
||||
if (todo_hilt_pos () == win[TOD].h - 4)
|
||||
todo_first_increase ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ('Q'): /* Quit calcurse :( */
|
||||
case ('q'):
|
||||
if (conf.auto_save)
|
||||
io_save_cal (&conf);
|
||||
|
||||
if (conf.confirm_quit)
|
||||
{
|
||||
status_mesg (_(quit_message), choices);
|
||||
ch = wgetch (win[STA].p);
|
||||
if (ch == 'y')
|
||||
exit_calcurse (EXIT_SUCCESS);
|
||||
else
|
||||
{
|
||||
erase_status_bar ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
exit_calcurse (EXIT_SUCCESS);
|
||||
break;
|
||||
|
||||
default:
|
||||
do_update = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (do_storage)
|
||||
{
|
||||
inday = *day_process_storage (calendar_get_slctd_day (),
|
||||
day_changed, &inday);
|
||||
do_storage = !do_storage;
|
||||
if (day_changed)
|
||||
{
|
||||
sav_hilt_app = 0;
|
||||
day_changed = !day_changed;
|
||||
if ((wins_slctd () == APP) &&
|
||||
(inday.nb_events + inday.nb_apoints != 0))
|
||||
apoint_hilt_set (1);
|
||||
}
|
||||
}
|
||||
if (do_update)
|
||||
wins_update ();
|
||||
}
|
||||
}
|
||||
|
716
src/calendar.c
716
src/calendar.c
@ -1,4 +1,4 @@
|
||||
/* $calcurse: calendar.c,v 1.14 2008/04/09 20:38:29 culot Exp $ */
|
||||
/* $calcurse: calendar.c,v 1.15 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -55,273 +55,276 @@
|
||||
|
||||
#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
|
||||
|
||||
static date_t today, slctd_day;
|
||||
static bool week_begins_on_monday;
|
||||
static pthread_mutex_t date_thread_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_t calendar_t_date;
|
||||
static date_t today, slctd_day;
|
||||
static bool week_begins_on_monday;
|
||||
static pthread_mutex_t date_thread_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_t calendar_t_date;
|
||||
|
||||
|
||||
/* Thread needed to update current date in calendar. */
|
||||
static void *
|
||||
calendar_date_thread(void *arg)
|
||||
calendar_date_thread (void *arg)
|
||||
{
|
||||
time_t now, tomorrow;
|
||||
time_t now, tomorrow;
|
||||
|
||||
for (;;) {
|
||||
tomorrow = (time_t)(get_today() + DAYINSEC);
|
||||
for (;;)
|
||||
{
|
||||
tomorrow = (time_t) (get_today () + DAYINSEC);
|
||||
|
||||
while ((now = time(NULL)) < tomorrow) {
|
||||
sleep(tomorrow - now);
|
||||
}
|
||||
|
||||
calendar_set_current_date();
|
||||
calendar_update_panel(win[CAL].p);
|
||||
while ((now = time (NULL)) < tomorrow)
|
||||
{
|
||||
sleep (tomorrow - now);
|
||||
}
|
||||
|
||||
pthread_exit((void*) 0);
|
||||
calendar_set_current_date ();
|
||||
calendar_update_panel (win[CAL].p);
|
||||
}
|
||||
|
||||
pthread_exit ((void *) 0);
|
||||
}
|
||||
|
||||
/* Launch the calendar date thread. */
|
||||
void
|
||||
calendar_start_date_thread(void)
|
||||
void
|
||||
calendar_start_date_thread (void)
|
||||
{
|
||||
pthread_create(&calendar_t_date, NULL, calendar_date_thread, NULL);
|
||||
return;
|
||||
pthread_create (&calendar_t_date, NULL, calendar_date_thread, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Stop the calendar date thread. */
|
||||
void
|
||||
calendar_stop_date_thread(void)
|
||||
void
|
||||
calendar_stop_date_thread (void)
|
||||
{
|
||||
pthread_cancel(calendar_t_date);
|
||||
return;
|
||||
pthread_cancel (calendar_t_date);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set static variable today to current date */
|
||||
void
|
||||
calendar_set_current_date(void)
|
||||
void
|
||||
calendar_set_current_date (void)
|
||||
{
|
||||
time_t timer;
|
||||
struct tm *tm;
|
||||
time_t timer;
|
||||
struct tm *tm;
|
||||
|
||||
timer = time(NULL);
|
||||
tm = localtime(&timer);
|
||||
timer = time (NULL);
|
||||
tm = localtime (&timer);
|
||||
|
||||
pthread_mutex_lock(&date_thread_mutex);
|
||||
today.dd = tm->tm_mday;
|
||||
today.mm = tm->tm_mon + 1;
|
||||
today.yyyy = tm->tm_year + 1900;
|
||||
pthread_mutex_unlock(&date_thread_mutex);
|
||||
pthread_mutex_lock (&date_thread_mutex);
|
||||
today.dd = tm->tm_mday;
|
||||
today.mm = tm->tm_mon + 1;
|
||||
today.yyyy = tm->tm_year + 1900;
|
||||
pthread_mutex_unlock (&date_thread_mutex);
|
||||
}
|
||||
|
||||
/* Needed to display sunday or monday as the first day of week in calendar. */
|
||||
void
|
||||
calendar_set_first_day_of_week(wday_e first_day)
|
||||
calendar_set_first_day_of_week (wday_e first_day)
|
||||
{
|
||||
switch (first_day) {
|
||||
case SUNDAY:
|
||||
week_begins_on_monday = false;
|
||||
break;
|
||||
case MONDAY:
|
||||
week_begins_on_monday = true;
|
||||
break;
|
||||
default:
|
||||
fputs(_("ERROR in calendar_set_first_day_of_week\n"), stderr);
|
||||
week_begins_on_monday = false;
|
||||
/* NOTREACHED */
|
||||
}
|
||||
switch (first_day)
|
||||
{
|
||||
case SUNDAY:
|
||||
week_begins_on_monday = false;
|
||||
break;
|
||||
case MONDAY:
|
||||
week_begins_on_monday = true;
|
||||
break;
|
||||
default:
|
||||
fputs (_("ERROR in calendar_set_first_day_of_week\n"), stderr);
|
||||
week_begins_on_monday = false;
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
|
||||
/* Swap first day of week in calendar. */
|
||||
void
|
||||
calendar_change_first_day_of_week(void)
|
||||
calendar_change_first_day_of_week (void)
|
||||
{
|
||||
week_begins_on_monday = !week_begins_on_monday;
|
||||
week_begins_on_monday = !week_begins_on_monday;
|
||||
}
|
||||
|
||||
/* Return true if week begins on monday, false otherwise. */
|
||||
bool
|
||||
calendar_week_begins_on_monday(void)
|
||||
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. */
|
||||
void
|
||||
calendar_store_current_date(date_t *date)
|
||||
calendar_store_current_date (date_t *date)
|
||||
{
|
||||
pthread_mutex_lock(&date_thread_mutex);
|
||||
*date = today;
|
||||
pthread_mutex_unlock(&date_thread_mutex);
|
||||
pthread_mutex_lock (&date_thread_mutex);
|
||||
*date = today;
|
||||
pthread_mutex_unlock (&date_thread_mutex);
|
||||
}
|
||||
|
||||
/* This is to start at the current date in calendar. */
|
||||
void
|
||||
calendar_init_slctd_day(void)
|
||||
calendar_init_slctd_day (void)
|
||||
{
|
||||
calendar_store_current_date(&slctd_day);
|
||||
calendar_store_current_date (&slctd_day);
|
||||
}
|
||||
|
||||
/* Return the selected day in calendar */
|
||||
date_t *
|
||||
calendar_get_slctd_day(void)
|
||||
calendar_get_slctd_day (void)
|
||||
{
|
||||
return (&slctd_day);
|
||||
return (&slctd_day);
|
||||
}
|
||||
|
||||
/* Returned value represents the selected day in calendar (in seconds) */
|
||||
long
|
||||
calendar_get_slctd_day_sec(void)
|
||||
calendar_get_slctd_day_sec (void)
|
||||
{
|
||||
return (date2sec(slctd_day, 0, 0));
|
||||
return (date2sec (slctd_day, 0, 0));
|
||||
}
|
||||
|
||||
static int
|
||||
isBissextile(unsigned year)
|
||||
static int
|
||||
isBissextile (unsigned year)
|
||||
{
|
||||
return (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0));
|
||||
return (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0));
|
||||
}
|
||||
|
||||
static unsigned
|
||||
months_to_days(unsigned month)
|
||||
static unsigned
|
||||
months_to_days (unsigned month)
|
||||
{
|
||||
return ((month * 3057 - 3007) / 100);
|
||||
return ((month * 3057 - 3007) / 100);
|
||||
}
|
||||
|
||||
|
||||
static long
|
||||
years_to_days(unsigned year)
|
||||
static long
|
||||
years_to_days (unsigned year)
|
||||
{
|
||||
return (year * 365L + year / 4 - year / 100 + year / 400);
|
||||
return (year * 365L + year / 4 - year / 100 + year / 400);
|
||||
}
|
||||
|
||||
static long
|
||||
ymd_to_scalar(unsigned year, unsigned month, unsigned day)
|
||||
static long
|
||||
ymd_to_scalar (unsigned year, unsigned month, unsigned day)
|
||||
{
|
||||
long scalar;
|
||||
long scalar;
|
||||
|
||||
scalar = day + months_to_days(month);
|
||||
if (month > 2)
|
||||
scalar -= isBissextile(year) ? 1 : 2;
|
||||
year--;
|
||||
scalar += years_to_days(year);
|
||||
scalar = day + months_to_days (month);
|
||||
if (month > 2)
|
||||
scalar -= isBissextile (year) ? 1 : 2;
|
||||
year--;
|
||||
scalar += years_to_days (year);
|
||||
|
||||
return (scalar);
|
||||
return (scalar);
|
||||
}
|
||||
|
||||
/* Function used to display the calendar panel. */
|
||||
void
|
||||
calendar_update_panel(WINDOW *cwin)
|
||||
calendar_update_panel (WINDOW *cwin)
|
||||
{
|
||||
date_t current_day, check_day;
|
||||
int c_day, c_day_1, day_1_sav, numdays, j;
|
||||
unsigned yr, mo;
|
||||
int ofs_x, ofs_y;
|
||||
int item_this_day = 0;
|
||||
int title_lines = 3;
|
||||
int sunday_first = 0;
|
||||
date_t current_day, check_day;
|
||||
int c_day, c_day_1, day_1_sav, numdays, j;
|
||||
unsigned yr, mo;
|
||||
int ofs_x, ofs_y;
|
||||
int item_this_day = 0;
|
||||
int title_lines = 3;
|
||||
int sunday_first = 0;
|
||||
|
||||
/* inits */
|
||||
calendar_store_current_date(¤t_day);
|
||||
erase_window_part(cwin, 1, title_lines, CALWIDTH - 2, CALHEIGHT - 2);
|
||||
mo = slctd_day.mm;
|
||||
yr = slctd_day.yyyy;
|
||||
if (!calendar_week_begins_on_monday())
|
||||
sunday_first = 1;
|
||||
|
||||
/* offset for centering calendar in window */
|
||||
ofs_y = 2 + (CALHEIGHT - 9) / 2;
|
||||
ofs_x = (CALWIDTH - 27) / 2;
|
||||
/* inits */
|
||||
calendar_store_current_date (¤t_day);
|
||||
erase_window_part (cwin, 1, title_lines, CALWIDTH - 2, CALHEIGHT - 2);
|
||||
mo = slctd_day.mm;
|
||||
yr = slctd_day.yyyy;
|
||||
if (!calendar_week_begins_on_monday ())
|
||||
sunday_first = 1;
|
||||
|
||||
/* checking the number of days in february */
|
||||
numdays = days[mo - 1];
|
||||
if (2 == mo && isBissextile(yr))
|
||||
++numdays;
|
||||
/* offset for centering calendar in window */
|
||||
ofs_y = 2 + (CALHEIGHT - 9) / 2;
|
||||
ofs_x = (CALWIDTH - 27) / 2;
|
||||
|
||||
/*
|
||||
* the first calendar day will be monday or sunday, depending on
|
||||
* 'week_begins_on_monday' value
|
||||
*/
|
||||
c_day_1 =
|
||||
(int)((ymd_to_scalar(yr, mo, 1 + sunday_first) - (long)1) % 7L);
|
||||
/* checking the number of days in february */
|
||||
numdays = days[mo - 1];
|
||||
if (2 == mo && isBissextile (yr))
|
||||
++numdays;
|
||||
|
||||
/* Write the current month and year on top of the calendar */
|
||||
custom_apply_attr(cwin, ATTR_HIGH);
|
||||
mvwprintw(cwin, ofs_y,
|
||||
(CALWIDTH - (strlen(_(monthnames[mo - 1])) + 5)) / 2,
|
||||
"%s %d", _(monthnames[mo - 1]), slctd_day.yyyy);
|
||||
custom_remove_attr(cwin, ATTR_HIGH);
|
||||
++ofs_y;
|
||||
/*
|
||||
* the first calendar day will be monday or sunday, depending on
|
||||
* 'week_begins_on_monday' value
|
||||
*/
|
||||
c_day_1 = (int) ((ymd_to_scalar (yr, mo, 1 + sunday_first) - (long) 1) % 7L);
|
||||
|
||||
/* print the days, with regards to the first day of the week */
|
||||
custom_apply_attr(cwin, ATTR_HIGH);
|
||||
for (j = 0; j < 7; j++) {
|
||||
mvwprintw(cwin, ofs_y, ofs_x + 4 * j, "%s",
|
||||
_(daynames[1 + j - sunday_first]));
|
||||
/* Write the current month and year on top of the calendar */
|
||||
custom_apply_attr (cwin, ATTR_HIGH);
|
||||
mvwprintw (cwin, ofs_y, (CALWIDTH - (strlen (_(monthnames[mo - 1])) + 5)) / 2,
|
||||
"%s %d", _(monthnames[mo - 1]), slctd_day.yyyy);
|
||||
custom_remove_attr (cwin, ATTR_HIGH);
|
||||
++ofs_y;
|
||||
|
||||
/* print the days, with regards to the first day of the week */
|
||||
custom_apply_attr (cwin, ATTR_HIGH);
|
||||
for (j = 0; j < 7; j++)
|
||||
{
|
||||
mvwprintw (cwin, ofs_y, ofs_x + 4 * j, "%s",
|
||||
_(daynames[1 + j - sunday_first]));
|
||||
}
|
||||
custom_remove_attr (cwin, ATTR_HIGH);
|
||||
|
||||
day_1_sav = (c_day_1 + 1) * 3 + c_day_1 - 7;
|
||||
|
||||
for (c_day = 1; c_day <= numdays; ++c_day, ++c_day_1, c_day_1 %= 7)
|
||||
{
|
||||
check_day.dd = c_day;
|
||||
check_day.mm = slctd_day.mm;
|
||||
check_day.yyyy = slctd_day.yyyy;
|
||||
|
||||
/* check if the day contains an event or an appointment */
|
||||
item_this_day = day_check_if_item (check_day);
|
||||
|
||||
/* Go to next line, the week is over. */
|
||||
if (!c_day_1 && 1 != c_day)
|
||||
{
|
||||
++ofs_y;
|
||||
ofs_x = 2 - day_1_sav - 4 * c_day - 1;
|
||||
}
|
||||
custom_remove_attr(cwin, ATTR_HIGH);
|
||||
|
||||
day_1_sav = (c_day_1 + 1) * 3 + c_day_1 - 7;
|
||||
|
||||
for (c_day = 1; c_day <= numdays; ++c_day, ++c_day_1, c_day_1 %= 7) {
|
||||
check_day.dd = c_day;
|
||||
check_day.mm = slctd_day.mm;
|
||||
check_day.yyyy = slctd_day.yyyy;
|
||||
|
||||
/* check if the day contains an event or an appointment */
|
||||
item_this_day =
|
||||
day_check_if_item(check_day);
|
||||
|
||||
/* Go to next line, the week is over. */
|
||||
if (!c_day_1 && 1 != c_day) {
|
||||
++ofs_y;
|
||||
ofs_x = 2 - day_1_sav - 4 * c_day - 1;
|
||||
}
|
||||
|
||||
/* This is today, so print it in yellow. */
|
||||
if (c_day == current_day.dd && current_day.mm == slctd_day.mm
|
||||
&& current_day.yyyy == slctd_day.yyyy &&
|
||||
current_day.dd != slctd_day.dd) {
|
||||
|
||||
custom_apply_attr(cwin, ATTR_LOWEST);
|
||||
mvwprintw(cwin, ofs_y + 1,
|
||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d", c_day);
|
||||
custom_remove_attr(cwin, ATTR_LOWEST);
|
||||
|
||||
} else if (c_day == slctd_day.dd &&
|
||||
( (current_day.dd != slctd_day.dd) ||
|
||||
(current_day.mm != slctd_day.mm)
|
||||
|| (current_day.yyyy != slctd_day.yyyy))) {
|
||||
|
||||
/* This is the selected day, print it in red. */
|
||||
custom_apply_attr(cwin, ATTR_MIDDLE);
|
||||
mvwprintw(cwin, ofs_y + 1,
|
||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d", c_day);
|
||||
custom_remove_attr(cwin, ATTR_MIDDLE);
|
||||
|
||||
} else if (c_day == slctd_day.dd &&
|
||||
current_day.dd == slctd_day.dd &&
|
||||
current_day.mm == slctd_day.mm &&
|
||||
current_day.yyyy == slctd_day.yyyy) {
|
||||
|
||||
/* today is the selected day */
|
||||
custom_apply_attr(cwin, ATTR_MIDDLE);
|
||||
mvwprintw(cwin, ofs_y + 1,
|
||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d", c_day);
|
||||
custom_remove_attr(cwin, ATTR_MIDDLE);
|
||||
|
||||
} else if (item_this_day) {
|
||||
custom_apply_attr(cwin, ATTR_LOW);
|
||||
mvwprintw(cwin, ofs_y + 1,
|
||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d", c_day);
|
||||
custom_remove_attr(cwin, ATTR_LOW);
|
||||
} else
|
||||
/* otherwise, print normal days in black */
|
||||
mvwprintw(cwin, ofs_y + 1,
|
||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d", c_day);
|
||||
|
||||
/* This is today, so print it in yellow. */
|
||||
if (c_day == current_day.dd && current_day.mm == slctd_day.mm
|
||||
&& current_day.yyyy == slctd_day.yyyy
|
||||
&& current_day.dd != slctd_day.dd)
|
||||
{
|
||||
custom_apply_attr (cwin, ATTR_LOWEST);
|
||||
mvwprintw (cwin, ofs_y + 1,
|
||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d", c_day);
|
||||
custom_remove_attr (cwin, ATTR_LOWEST);
|
||||
}
|
||||
wnoutrefresh(cwin);
|
||||
else if (c_day == slctd_day.dd &&
|
||||
((current_day.dd != slctd_day.dd)
|
||||
|| (current_day.mm != slctd_day.mm)
|
||||
|| (current_day.yyyy != slctd_day.yyyy)))
|
||||
{
|
||||
/* This is the selected day, print it in red. */
|
||||
custom_apply_attr (cwin, ATTR_MIDDLE);
|
||||
mvwprintw (cwin, ofs_y + 1, ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
||||
c_day);
|
||||
custom_remove_attr (cwin, ATTR_MIDDLE);
|
||||
}
|
||||
else if (c_day == slctd_day.dd && current_day.dd == slctd_day.dd
|
||||
&& current_day.mm == slctd_day.mm
|
||||
&& current_day.yyyy == slctd_day.yyyy)
|
||||
{
|
||||
/* today is the selected day */
|
||||
custom_apply_attr (cwin, ATTR_MIDDLE);
|
||||
mvwprintw (cwin, ofs_y + 1, ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
||||
c_day);
|
||||
custom_remove_attr (cwin, ATTR_MIDDLE);
|
||||
}
|
||||
else if (item_this_day)
|
||||
{
|
||||
custom_apply_attr (cwin, ATTR_LOW);
|
||||
mvwprintw (cwin, ofs_y + 1, ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
||||
c_day);
|
||||
custom_remove_attr (cwin, ATTR_LOW);
|
||||
}
|
||||
else
|
||||
/* otherwise, print normal days in black */
|
||||
mvwprintw (cwin, ofs_y + 1, ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
||||
c_day);
|
||||
}
|
||||
wnoutrefresh (cwin);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -332,60 +335,58 @@ calendar_update_panel(WINDOW *cwin)
|
||||
* with the newly selected date.
|
||||
*/
|
||||
void
|
||||
calendar_change_day(int datefmt)
|
||||
calendar_change_day (int datefmt)
|
||||
{
|
||||
#define LDAY 11
|
||||
char selected_day[LDAY] = "";
|
||||
char outstr[BUFSIZ];
|
||||
date_t today;
|
||||
int dday, dmonth, dyear;
|
||||
int wrong_day = 1;
|
||||
char *mesg_line1 =
|
||||
_("The day you entered is not valid (should be between 01/01/1902 and 12/31/2037)");
|
||||
char *mesg_line2 = _("Press [ENTER] to continue");
|
||||
char *request_date =
|
||||
"Enter the day to go to [ENTER for today] : %s";
|
||||
|
||||
while (wrong_day) {
|
||||
snprintf(outstr, BUFSIZ, request_date,
|
||||
DATEFMT_DESC(datefmt));
|
||||
status_mesg(_(outstr), "");
|
||||
if (getstring(win[STA].p, selected_day, LDAY, 0, 1) ==
|
||||
GETSTRING_ESC)
|
||||
return;
|
||||
else {
|
||||
if (strlen(selected_day) == 0) {
|
||||
calendar_store_current_date(&today);
|
||||
|
||||
/* go to today */
|
||||
wrong_day = 0;
|
||||
slctd_day.dd = today.dd;
|
||||
slctd_day.mm = today.mm;
|
||||
slctd_day.yyyy = today.yyyy;
|
||||
|
||||
} else if (strlen(selected_day) != LDAY - 1) {
|
||||
|
||||
wrong_day = 1;
|
||||
|
||||
} else if (parse_date(selected_day, datefmt,
|
||||
&dyear, &dmonth, &dday)) {
|
||||
|
||||
wrong_day = 0;
|
||||
|
||||
/* go to chosen day */
|
||||
slctd_day.dd = dday;
|
||||
slctd_day.mm = dmonth;
|
||||
slctd_day.yyyy = dyear;
|
||||
}
|
||||
|
||||
if (wrong_day) {
|
||||
status_mesg(mesg_line1, mesg_line2);
|
||||
wgetch(win[STA].p);
|
||||
}
|
||||
}
|
||||
}
|
||||
char selected_day[LDAY] = "";
|
||||
char outstr[BUFSIZ];
|
||||
date_t today;
|
||||
int dday, dmonth, dyear;
|
||||
int wrong_day = 1;
|
||||
char *mesg_line1 =
|
||||
_("The day you entered is not valid "
|
||||
"(should be between 01/01/1902 and 12/31/2037)");
|
||||
char *mesg_line2 = _("Press [ENTER] to continue");
|
||||
char *request_date = "Enter the day to go to [ENTER for today] : %s";
|
||||
|
||||
while (wrong_day)
|
||||
{
|
||||
snprintf (outstr, BUFSIZ, request_date, DATEFMT_DESC (datefmt));
|
||||
status_mesg (_(outstr), "");
|
||||
if (getstring (win[STA].p, selected_day, LDAY, 0, 1) == GETSTRING_ESC)
|
||||
return;
|
||||
else
|
||||
{
|
||||
if (strlen (selected_day) == 0)
|
||||
{
|
||||
calendar_store_current_date (&today);
|
||||
/* go to today */
|
||||
wrong_day = 0;
|
||||
slctd_day.dd = today.dd;
|
||||
slctd_day.mm = today.mm;
|
||||
slctd_day.yyyy = today.yyyy;
|
||||
}
|
||||
else if (strlen (selected_day) != LDAY - 1)
|
||||
{
|
||||
wrong_day = 1;
|
||||
}
|
||||
else if (parse_date (selected_day, datefmt, &dyear, &dmonth, &dday))
|
||||
{
|
||||
wrong_day = 0;
|
||||
/* go to chosen day */
|
||||
slctd_day.dd = dday;
|
||||
slctd_day.mm = dmonth;
|
||||
slctd_day.yyyy = dyear;
|
||||
}
|
||||
if (wrong_day)
|
||||
{
|
||||
status_mesg (mesg_line1, mesg_line2);
|
||||
wgetch (win[STA].p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -393,68 +394,70 @@ calendar_change_day(int datefmt)
|
||||
* Returns 0 on success, 1 otherwise.
|
||||
*/
|
||||
int
|
||||
date_change(struct tm *date, int delta_month, int delta_day)
|
||||
{
|
||||
struct tm t;
|
||||
date_change (struct tm *date, int delta_month, int delta_day)
|
||||
{
|
||||
struct tm t;
|
||||
|
||||
t = *date;
|
||||
t.tm_mon += delta_month;
|
||||
t.tm_mday += delta_day;
|
||||
t = *date;
|
||||
t.tm_mon += delta_month;
|
||||
t.tm_mday += delta_day;
|
||||
|
||||
if (mktime(&t) == -1)
|
||||
return (1);
|
||||
else {
|
||||
*date = t;
|
||||
return (0);
|
||||
}
|
||||
if (mktime (&t) == -1)
|
||||
return (1);
|
||||
else
|
||||
{
|
||||
*date = t;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
calendar_move(move_t move)
|
||||
calendar_move (move_t move)
|
||||
{
|
||||
int ret;
|
||||
struct tm t;
|
||||
|
||||
memset(&t, 0, sizeof(struct tm));
|
||||
t.tm_mday = slctd_day.dd;
|
||||
t.tm_mon = slctd_day.mm - 1;
|
||||
t.tm_year = slctd_day.yyyy - 1900;
|
||||
int ret;
|
||||
struct tm t;
|
||||
|
||||
switch (move) {
|
||||
case UP:
|
||||
if ((slctd_day.dd <= 7) && (slctd_day.mm == 1) &&
|
||||
(slctd_day.yyyy == 1902))
|
||||
return;
|
||||
ret = date_change(&t, 0, -WEEKINDAYS);
|
||||
break;
|
||||
case DOWN:
|
||||
if ((slctd_day.dd > days[slctd_day.mm - 1] - 7)
|
||||
&& (slctd_day.mm == 12) && (slctd_day.yyyy == 2037))
|
||||
return;
|
||||
ret = date_change(&t, 0, WEEKINDAYS);
|
||||
break;
|
||||
case LEFT:
|
||||
if ((slctd_day.dd == 1) && (slctd_day.mm == 1) &&
|
||||
(slctd_day.yyyy == 1902))
|
||||
return;
|
||||
ret = date_change(&t, 0, -1);
|
||||
break;
|
||||
case RIGHT:
|
||||
if ((slctd_day.dd == 31) && (slctd_day.mm == 12) &&
|
||||
(slctd_day.yyyy == 2037))
|
||||
return;
|
||||
ret = date_change(&t, 0, 1);
|
||||
break;
|
||||
default:
|
||||
ret = 1;
|
||||
/* NOTREACHED */
|
||||
}
|
||||
memset (&t, 0, sizeof (struct tm));
|
||||
t.tm_mday = slctd_day.dd;
|
||||
t.tm_mon = slctd_day.mm - 1;
|
||||
t.tm_year = slctd_day.yyyy - 1900;
|
||||
|
||||
if (ret == 0) {
|
||||
slctd_day.dd = t.tm_mday;
|
||||
slctd_day.mm = t.tm_mon + 1;
|
||||
slctd_day.yyyy = t.tm_year + 1900;
|
||||
}
|
||||
switch (move)
|
||||
{
|
||||
case UP:
|
||||
if ((slctd_day.dd <= 7) && (slctd_day.mm == 1)
|
||||
&& (slctd_day.yyyy == 1902))
|
||||
return;
|
||||
ret = date_change (&t, 0, -WEEKINDAYS);
|
||||
break;
|
||||
case DOWN:
|
||||
if ((slctd_day.dd > days[slctd_day.mm - 1] - 7)
|
||||
&& (slctd_day.mm == 12) && (slctd_day.yyyy == 2037))
|
||||
return;
|
||||
ret = date_change (&t, 0, WEEKINDAYS);
|
||||
break;
|
||||
case LEFT:
|
||||
if ((slctd_day.dd == 1) && (slctd_day.mm == 1)
|
||||
&& (slctd_day.yyyy == 1902))
|
||||
return;
|
||||
ret = date_change (&t, 0, -1);
|
||||
break;
|
||||
case RIGHT:
|
||||
if ((slctd_day.dd == 31) && (slctd_day.mm == 12)
|
||||
&& (slctd_day.yyyy == 2037))
|
||||
return;
|
||||
ret = date_change (&t, 0, 1);
|
||||
break;
|
||||
default:
|
||||
ret = 1;
|
||||
/* NOTREACHED */
|
||||
}
|
||||
if (ret == 0)
|
||||
{
|
||||
slctd_day.dd = t.tm_mday;
|
||||
slctd_day.mm = t.tm_mon + 1;
|
||||
slctd_day.yyyy = t.tm_year + 1900;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -499,9 +502,9 @@ calendar_move(move_t move)
|
||||
* convert degrees to radians
|
||||
*/
|
||||
static double
|
||||
dtor(double deg)
|
||||
dtor (double deg)
|
||||
{
|
||||
return(deg * M_PI / 180);
|
||||
return (deg * M_PI / 180);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -509,15 +512,15 @@ dtor(double deg)
|
||||
* adjust value so 0 <= deg <= 360
|
||||
*/
|
||||
static void
|
||||
adj360(double *deg)
|
||||
adj360 (double *deg)
|
||||
{
|
||||
for (;;)
|
||||
if (*deg < 0.0)
|
||||
*deg += 360.0;
|
||||
else if (*deg > 360.0)
|
||||
*deg -= 360.0;
|
||||
else
|
||||
break;
|
||||
for (;;)
|
||||
if (*deg < 0.0)
|
||||
*deg += 360.0;
|
||||
else if (*deg > 360.0)
|
||||
*deg -= 360.0;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -525,35 +528,35 @@ adj360(double *deg)
|
||||
* return phase of the moon
|
||||
*/
|
||||
static double
|
||||
potm(double days)
|
||||
potm (double days)
|
||||
{
|
||||
double N, Msol, Ec, LambdaSol, l, Mm, Ev, Ac, A3, Mmprime;
|
||||
double A4, lprime, V, ldprime, D, Nm;
|
||||
double N, Msol, Ec, LambdaSol, l, Mm, Ev, Ac, A3, Mmprime;
|
||||
double A4, lprime, V, ldprime, D, Nm;
|
||||
|
||||
N = 360.0 * days / 365.242191; /* sec 46 #3 */
|
||||
adj360(&N);
|
||||
Msol = N + EPSILONg - RHOg; /* sec 46 #4 */
|
||||
adj360(&Msol);
|
||||
Ec = 360 / M_PI * ECCEN * sin(dtor(Msol)); /* sec 46 #5 */
|
||||
LambdaSol = N + Ec + EPSILONg; /* sec 46 #6 */
|
||||
adj360(&LambdaSol);
|
||||
l = 13.1763966 * days + lzero; /* sec 65 #4 */
|
||||
adj360(&l);
|
||||
Mm = l - (0.1114041 * days) - Pzero; /* sec 65 #5 */
|
||||
adj360(&Mm);
|
||||
Nm = Nzero - (0.0529539 * days); /* sec 65 #6 */
|
||||
adj360(&Nm);
|
||||
Ev = 1.2739 * sin(dtor(2*(l - LambdaSol) - Mm)); /* sec 65 #7 */
|
||||
Ac = 0.1858 * sin(dtor(Msol)); /* sec 65 #8 */
|
||||
A3 = 0.37 * sin(dtor(Msol));
|
||||
Mmprime = Mm + Ev - Ac - A3; /* sec 65 #9 */
|
||||
Ec = 6.2886 * sin(dtor(Mmprime)); /* sec 65 #10 */
|
||||
A4 = 0.214 * sin(dtor(2 * Mmprime)); /* sec 65 #11 */
|
||||
lprime = l + Ev + Ec - Ac + A4; /* sec 65 #12 */
|
||||
V = 0.6583 * sin(dtor(2 * (lprime - LambdaSol))); /* sec 65 #13 */
|
||||
ldprime = lprime + V; /* sec 65 #14 */
|
||||
D = ldprime - LambdaSol; /* sec 67 #2 */
|
||||
return(50.0 * (1 - cos(dtor(D)))); /* sec 67 #3 */
|
||||
N = 360.0 * days / 365.242191; /* sec 46 #3 */
|
||||
adj360 (&N);
|
||||
Msol = N + EPSILONg - RHOg; /* sec 46 #4 */
|
||||
adj360 (&Msol);
|
||||
Ec = 360 / M_PI * ECCEN * sin (dtor (Msol)); /* sec 46 #5 */
|
||||
LambdaSol = N + Ec + EPSILONg; /* sec 46 #6 */
|
||||
adj360 (&LambdaSol);
|
||||
l = 13.1763966 * days + lzero; /* sec 65 #4 */
|
||||
adj360 (&l);
|
||||
Mm = l - (0.1114041 * days) - Pzero; /* sec 65 #5 */
|
||||
adj360 (&Mm);
|
||||
Nm = Nzero - (0.0529539 * days); /* sec 65 #6 */
|
||||
adj360 (&Nm);
|
||||
Ev = 1.2739 * sin (dtor (2 * (l - LambdaSol) - Mm)); /* sec 65 #7 */
|
||||
Ac = 0.1858 * sin (dtor (Msol)); /* sec 65 #8 */
|
||||
A3 = 0.37 * sin (dtor (Msol));
|
||||
Mmprime = Mm + Ev - Ac - A3; /* sec 65 #9 */
|
||||
Ec = 6.2886 * sin (dtor (Mmprime)); /* sec 65 #10 */
|
||||
A4 = 0.214 * sin (dtor (2 * Mmprime)); /* sec 65 #11 */
|
||||
lprime = l + Ev + Ec - Ac + A4; /* sec 65 #12 */
|
||||
V = 0.6583 * sin (dtor (2 * (lprime - LambdaSol))); /* sec 65 #13 */
|
||||
ldprime = lprime + V; /* sec 65 #14 */
|
||||
D = ldprime - LambdaSol; /* sec 67 #2 */
|
||||
return (50.0 * (1 - cos (dtor (D)))); /* sec 67 #3 */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -568,24 +571,24 @@ potm(double days)
|
||||
*
|
||||
*/
|
||||
static double
|
||||
pom(time_t tmpt)
|
||||
pom (time_t tmpt)
|
||||
{
|
||||
struct tm *GMT;
|
||||
double days;
|
||||
int cnt;
|
||||
pom_e pom;
|
||||
struct tm *GMT;
|
||||
double days;
|
||||
int cnt;
|
||||
pom_e pom;
|
||||
|
||||
pom = NO_POM;
|
||||
GMT = gmtime(&tmpt);
|
||||
days = (GMT->tm_yday + 1) + ((GMT->tm_hour +
|
||||
(GMT->tm_min / 60.0) + (GMT->tm_sec / 3600.0)) / 24.0);
|
||||
for (cnt = EPOCH; cnt < GMT->tm_year; ++cnt)
|
||||
days += isleap(cnt + TM_YEAR_BASE) ? 366 : 365;
|
||||
/* Selected time could be before EPOCH */
|
||||
for (cnt = GMT->tm_year; cnt < EPOCH; ++cnt)
|
||||
days -= isleap(cnt + TM_YEAR_BASE) ? 366 : 365;
|
||||
pom = NO_POM;
|
||||
GMT = gmtime (&tmpt);
|
||||
days = (GMT->tm_yday + 1) + ((GMT->tm_hour + (GMT->tm_min / 60.0) +
|
||||
(GMT->tm_sec / 3600.0)) / 24.0);
|
||||
for (cnt = EPOCH; cnt < GMT->tm_year; ++cnt)
|
||||
days += isleap (cnt + TM_YEAR_BASE) ? 366 : 365;
|
||||
/* Selected time could be before EPOCH */
|
||||
for (cnt = GMT->tm_year; cnt < EPOCH; ++cnt)
|
||||
days -= isleap (cnt + TM_YEAR_BASE) ? 366 : 365;
|
||||
|
||||
return (potm(days));
|
||||
return (potm (days));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -594,25 +597,24 @@ pom(time_t tmpt)
|
||||
* the phase of the moon for previous day.
|
||||
*/
|
||||
char *
|
||||
calendar_get_pom(time_t date)
|
||||
calendar_get_pom (time_t date)
|
||||
{
|
||||
char *pom_pict[MOON_PHASES] = {" ", "|) ", "(|)", "(| ", " | "};
|
||||
pom_e phase = NO_POM;
|
||||
double pom_today, relative_pom, pom_yesterday, pom_tomorrow;
|
||||
const double half = 50.0;
|
||||
|
||||
pom_yesterday = pom(date);
|
||||
pom_today = pom(date + DAYINSEC);
|
||||
relative_pom = abs(pom_today - half);
|
||||
pom_tomorrow = pom(date + 2 * DAYINSEC);
|
||||
if (pom_today > pom_yesterday && pom_today > pom_tomorrow)
|
||||
phase = FULL_MOON;
|
||||
else if (pom_today < pom_yesterday && pom_today < pom_tomorrow)
|
||||
phase = NEW_MOON;
|
||||
else if (relative_pom < abs(pom_yesterday - half) &&
|
||||
relative_pom < abs(pom_tomorrow - half))
|
||||
phase = (pom_tomorrow > pom_today) ?
|
||||
FIRST_QUARTER : LAST_QUARTER;
|
||||
char *pom_pict[MOON_PHASES] = { " ", "|) ", "(|)", "(| ", " | " };
|
||||
pom_e phase = NO_POM;
|
||||
double pom_today, relative_pom, pom_yesterday, pom_tomorrow;
|
||||
const double half = 50.0;
|
||||
|
||||
return (pom_pict[phase]);
|
||||
pom_yesterday = pom (date);
|
||||
pom_today = pom (date + DAYINSEC);
|
||||
relative_pom = abs (pom_today - half);
|
||||
pom_tomorrow = pom (date + 2 * DAYINSEC);
|
||||
if (pom_today > pom_yesterday && pom_today > pom_tomorrow)
|
||||
phase = FULL_MOON;
|
||||
else if (pom_today < pom_yesterday && pom_today < pom_tomorrow)
|
||||
phase = NEW_MOON;
|
||||
else if (relative_pom < abs (pom_yesterday - half)
|
||||
&& relative_pom < abs (pom_tomorrow - half))
|
||||
phase = (pom_tomorrow > pom_today) ? FIRST_QUARTER : LAST_QUARTER;
|
||||
|
||||
return (pom_pict[phase]);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $calcurse: calendar.h,v 1.9 2008/04/09 20:38:29 culot Exp $ */
|
||||
/* $calcurse: calendar.h,v 1.10 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -34,53 +34,61 @@
|
||||
#define CALHEIGHT 12
|
||||
#define CALWIDTH 30
|
||||
|
||||
typedef enum { /* days of week */
|
||||
SUNDAY,
|
||||
MONDAY,
|
||||
TUESDAY,
|
||||
WEDNESDAY,
|
||||
THURSDAY,
|
||||
FRIDAY,
|
||||
SATURDAY,
|
||||
WDAYS
|
||||
} wday_e;
|
||||
typedef enum
|
||||
{ /* days of week */
|
||||
SUNDAY,
|
||||
MONDAY,
|
||||
TUESDAY,
|
||||
WEDNESDAY,
|
||||
THURSDAY,
|
||||
FRIDAY,
|
||||
SATURDAY,
|
||||
WDAYS
|
||||
}
|
||||
wday_e;
|
||||
|
||||
typedef struct {
|
||||
unsigned dd;
|
||||
unsigned mm;
|
||||
unsigned yyyy;
|
||||
} date_t;
|
||||
typedef struct
|
||||
{
|
||||
unsigned dd;
|
||||
unsigned mm;
|
||||
unsigned yyyy;
|
||||
}
|
||||
date_t;
|
||||
|
||||
typedef enum {
|
||||
NO_POM,
|
||||
FIRST_QUARTER,
|
||||
FULL_MOON,
|
||||
LAST_QUARTER,
|
||||
NEW_MOON,
|
||||
MOON_PHASES
|
||||
} pom_e;
|
||||
typedef enum
|
||||
{
|
||||
NO_POM,
|
||||
FIRST_QUARTER,
|
||||
FULL_MOON,
|
||||
LAST_QUARTER,
|
||||
NEW_MOON,
|
||||
MOON_PHASES
|
||||
}
|
||||
pom_e;
|
||||
|
||||
typedef enum {
|
||||
UP,
|
||||
DOWN,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
MOVES
|
||||
} move_t;
|
||||
typedef enum
|
||||
{
|
||||
UP,
|
||||
DOWN,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
MOVES
|
||||
}
|
||||
move_t;
|
||||
|
||||
void calendar_start_date_thread(void);
|
||||
void calendar_stop_date_thread(void);
|
||||
void calendar_set_current_date(void);
|
||||
void calendar_set_first_day_of_week(wday_e);
|
||||
void calendar_change_first_day_of_week(void);
|
||||
bool calendar_week_begins_on_monday(void);
|
||||
void calendar_store_current_date(date_t *);
|
||||
void calendar_init_slctd_day(void);
|
||||
date_t *calendar_get_slctd_day(void);
|
||||
long calendar_get_slctd_day_sec(void);
|
||||
void calendar_update_panel(WINDOW *);
|
||||
void calendar_change_day(int datefmt);
|
||||
void calendar_move(move_t);
|
||||
char *calendar_get_pom(time_t);
|
||||
void calendar_start_date_thread (void);
|
||||
void calendar_stop_date_thread (void);
|
||||
void calendar_set_current_date (void);
|
||||
void calendar_set_first_day_of_week (wday_e);
|
||||
void calendar_change_first_day_of_week (void);
|
||||
bool calendar_week_begins_on_monday (void);
|
||||
void calendar_store_current_date (date_t *);
|
||||
void calendar_init_slctd_day (void);
|
||||
date_t *calendar_get_slctd_day (void);
|
||||
long calendar_get_slctd_day_sec (void);
|
||||
void calendar_update_panel (WINDOW *);
|
||||
void calendar_change_day (int);
|
||||
void calendar_move (move_t);
|
||||
char *calendar_get_pom (time_t);
|
||||
|
||||
#endif /* CALCURSE_CALENDAR_H */
|
||||
|
1345
src/custom.c
1345
src/custom.c
File diff suppressed because it is too large
Load Diff
87
src/custom.h
87
src/custom.h
@ -1,4 +1,4 @@
|
||||
/* $calcurse: custom.h,v 1.11 2008/04/09 20:38:29 culot Exp $ */
|
||||
/* $calcurse: custom.h,v 1.12 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -32,52 +32,55 @@
|
||||
|
||||
#define NBUSERCOLORS 6
|
||||
|
||||
enum { /* Color pairs */
|
||||
COLR_RED = 1,
|
||||
COLR_GREEN,
|
||||
COLR_YELLOW,
|
||||
COLR_BLUE,
|
||||
COLR_MAGENTA,
|
||||
COLR_CYAN,
|
||||
COLR_DEFAULT,
|
||||
COLR_HIGH,
|
||||
COLR_CUSTOM
|
||||
enum
|
||||
{ /* Color pairs */
|
||||
COLR_RED = 1,
|
||||
COLR_GREEN,
|
||||
COLR_YELLOW,
|
||||
COLR_BLUE,
|
||||
COLR_MAGENTA,
|
||||
COLR_CYAN,
|
||||
COLR_DEFAULT,
|
||||
COLR_HIGH,
|
||||
COLR_CUSTOM
|
||||
};
|
||||
|
||||
enum { /* Configuration variables */
|
||||
CUSTOM_CONF_NOVARIABLE,
|
||||
CUSTOM_CONF_AUTOSAVE,
|
||||
CUSTOM_CONF_CONFIRMQUIT,
|
||||
CUSTOM_CONF_CONFIRMDELETE,
|
||||
CUSTOM_CONF_SKIPSYSTEMDIALOGS,
|
||||
CUSTOM_CONF_SKIPPROGRESSBAR,
|
||||
CUSTOM_CONF_WEEKBEGINSONMONDAY,
|
||||
CUSTOM_CONF_COLORTHEME,
|
||||
CUSTOM_CONF_LAYOUT,
|
||||
CUSTOM_CONF_NOTIFYBARSHOW,
|
||||
CUSTOM_CONF_NOTIFYBARDATE,
|
||||
CUSTOM_CONF_NOTIFYBARCLOCK,
|
||||
CUSTOM_CONF_NOTIFYBARWARNING,
|
||||
CUSTOM_CONF_NOTIFYBARCOMMAND,
|
||||
CUSTOM_CONF_OUTPUTDATEFMT,
|
||||
CUSTOM_CONF_INPUTDATEFMT,
|
||||
CUSTOM_CONF_VARIABLES
|
||||
enum
|
||||
{ /* Configuration variables */
|
||||
CUSTOM_CONF_NOVARIABLE,
|
||||
CUSTOM_CONF_AUTOSAVE,
|
||||
CUSTOM_CONF_CONFIRMQUIT,
|
||||
CUSTOM_CONF_CONFIRMDELETE,
|
||||
CUSTOM_CONF_SKIPSYSTEMDIALOGS,
|
||||
CUSTOM_CONF_SKIPPROGRESSBAR,
|
||||
CUSTOM_CONF_WEEKBEGINSONMONDAY,
|
||||
CUSTOM_CONF_COLORTHEME,
|
||||
CUSTOM_CONF_LAYOUT,
|
||||
CUSTOM_CONF_NOTIFYBARSHOW,
|
||||
CUSTOM_CONF_NOTIFYBARDATE,
|
||||
CUSTOM_CONF_NOTIFYBARCLOCK,
|
||||
CUSTOM_CONF_NOTIFYBARWARNING,
|
||||
CUSTOM_CONF_NOTIFYBARCOMMAND,
|
||||
CUSTOM_CONF_OUTPUTDATEFMT,
|
||||
CUSTOM_CONF_INPUTDATEFMT,
|
||||
CUSTOM_CONF_VARIABLES
|
||||
};
|
||||
|
||||
struct attribute_s {
|
||||
int color[7];
|
||||
int nocolor[7];
|
||||
struct attribute_s
|
||||
{
|
||||
int color[7];
|
||||
int nocolor[7];
|
||||
};
|
||||
|
||||
void custom_init_attr(void);
|
||||
void custom_apply_attr(WINDOW *, int);
|
||||
void custom_remove_attr(WINDOW *, int);
|
||||
void custom_load_conf(conf_t *, int);
|
||||
void config_bar(void);
|
||||
void layout_config(void);
|
||||
void custom_color_config(void);
|
||||
void custom_color_theme_name(char *);
|
||||
void custom_confwin_init(window_t *, char *);
|
||||
void custom_general_config(conf_t *);
|
||||
void custom_init_attr (void);
|
||||
void custom_apply_attr (WINDOW *, int);
|
||||
void custom_remove_attr (WINDOW *, int);
|
||||
void custom_load_conf (conf_t *, int);
|
||||
void config_bar (void);
|
||||
void layout_config (void);
|
||||
void custom_color_config (void);
|
||||
void custom_color_theme_name (char *);
|
||||
void custom_confwin_init (window_t *, char *);
|
||||
void custom_general_config (conf_t *);
|
||||
|
||||
#endif /* CALCURSE_CUSTOM_H */
|
||||
|
66
src/day.h
66
src/day.h
@ -1,4 +1,4 @@
|
||||
/* $calcurse: day.h,v 1.18 2008/04/09 20:38:29 culot Exp $ */
|
||||
/* $calcurse: day.h,v 1.19 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -38,40 +38,44 @@
|
||||
#define RECUR_APPT 3
|
||||
#define APPT 4
|
||||
|
||||
typedef struct {
|
||||
unsigned nb_events;
|
||||
unsigned nb_apoints;
|
||||
} day_items_nb_t;
|
||||
typedef struct
|
||||
{
|
||||
unsigned nb_events;
|
||||
unsigned nb_apoints;
|
||||
}
|
||||
day_items_nb_t;
|
||||
|
||||
struct day_item_s {
|
||||
struct day_item_s *next;
|
||||
long start; /* seconds since 1 jan 1970 */
|
||||
long appt_dur; /* appointment duration in seconds */
|
||||
int type; /* (recursive or normal) event or appointment */
|
||||
int evnt_id; /* event identifier */
|
||||
int appt_pos; /* real position in recurrent list */
|
||||
char state; /* appointment state */
|
||||
char *mesg; /* item description */
|
||||
char *note; /* note attached to item */
|
||||
struct day_item_s
|
||||
{
|
||||
struct day_item_s *next;
|
||||
long start; /* seconds since 1 jan 1970 */
|
||||
long appt_dur; /* appointment duration in seconds */
|
||||
int type; /* (recursive or normal) event or appointment */
|
||||
int evnt_id; /* event identifier */
|
||||
int appt_pos; /* real position in recurrent list */
|
||||
char state; /* appointment state */
|
||||
char *mesg; /* item description */
|
||||
char *note; /* note attached to item */
|
||||
};
|
||||
|
||||
struct day_saved_item_s {
|
||||
char start[BUFSIZ];
|
||||
char end[BUFSIZ];
|
||||
char state;
|
||||
char type ;
|
||||
char *mesg;
|
||||
struct day_saved_item_s
|
||||
{
|
||||
char start[BUFSIZ];
|
||||
char end[BUFSIZ];
|
||||
char state;
|
||||
char type;
|
||||
char *mesg;
|
||||
};
|
||||
|
||||
day_items_nb_t *day_process_storage(date_t *, bool, day_items_nb_t *);
|
||||
void day_write_pad(long, int, int, int);
|
||||
void day_popup_item(void);
|
||||
int day_check_if_item(date_t);
|
||||
void day_edit_item(conf_t *);
|
||||
int day_erase_item(long, int, erase_flag_e);
|
||||
struct day_item_s *day_get_item(int);
|
||||
int day_item_nb(long, int, int);
|
||||
void day_edit_note(char *);
|
||||
void day_view_note(char *);
|
||||
day_items_nb_t *day_process_storage (date_t *, bool, day_items_nb_t *);
|
||||
void day_write_pad (long, int, int, int);
|
||||
void day_popup_item (void);
|
||||
int day_check_if_item (date_t);
|
||||
void day_edit_item (conf_t *);
|
||||
int day_erase_item (long, int, erase_flag_e);
|
||||
struct day_item_s *day_get_item (int);
|
||||
int day_item_nb (long, int, int);
|
||||
void day_edit_note (char *);
|
||||
void day_view_note (char *);
|
||||
|
||||
#endif /* CALCURSE_DAY_H */
|
||||
|
204
src/event.c
204
src/event.c
@ -1,4 +1,4 @@
|
||||
/* $calcurse: event.c,v 1.6 2008/01/20 10:45:38 culot Exp $ */
|
||||
/* $calcurse: event.c,v 1.7 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -37,132 +37,144 @@ struct event_s *eventlist;
|
||||
|
||||
/* Create a new event */
|
||||
struct event_s *
|
||||
event_new(char *mesg, char *note, long day, int id)
|
||||
event_new (char *mesg, char *note, long day, int id)
|
||||
{
|
||||
struct event_s *o, **i;
|
||||
o = (struct event_s *) malloc(sizeof(struct event_s));
|
||||
o->mesg = (char *) malloc(strlen(mesg) + 1);
|
||||
strncpy(o->mesg, mesg, strlen(mesg) + 1);
|
||||
o->day = day;
|
||||
o->id = id;
|
||||
o->note = (note != NULL) ? strdup(note) : NULL;
|
||||
i = &eventlist;
|
||||
for (;;) {
|
||||
if (*i == 0 || (*i)->day > day) {
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
i = &(*i)->next;
|
||||
struct event_s *o, **i;
|
||||
o = (struct event_s *) malloc (sizeof (struct event_s));
|
||||
o->mesg = (char *) malloc (strlen (mesg) + 1);
|
||||
strncpy (o->mesg, mesg, strlen (mesg) + 1);
|
||||
o->day = day;
|
||||
o->id = id;
|
||||
o->note = (note != NULL) ? strdup (note) : NULL;
|
||||
i = &eventlist;
|
||||
for (;;)
|
||||
{
|
||||
if (*i == 0 || (*i)->day > day)
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
return o;
|
||||
i = &(*i)->next;
|
||||
}
|
||||
return (o);
|
||||
}
|
||||
|
||||
/* Check if the event belongs to the selected day */
|
||||
unsigned
|
||||
event_inday(struct event_s *i, long start)
|
||||
unsigned
|
||||
event_inday (struct event_s *i, long start)
|
||||
{
|
||||
if (i->day <= start + DAYINSEC && i->day > start) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
if (i->day <= start + DAYINSEC && i->day > start)
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Write to file the event in user-friendly format */
|
||||
void
|
||||
event_write(struct event_s *o, FILE * f)
|
||||
void
|
||||
event_write (struct event_s *o, FILE *f)
|
||||
{
|
||||
struct tm *lt;
|
||||
time_t t;
|
||||
struct tm *lt;
|
||||
time_t t;
|
||||
|
||||
t = o->day;
|
||||
lt = localtime(&t);
|
||||
fprintf(f, "%02u/%02u/%04u [%d] ",
|
||||
lt->tm_mon + 1, lt->tm_mday, 1900 + lt->tm_year, o->id);
|
||||
if (o->note != NULL)
|
||||
fprintf(f, ">%s ", o->note);
|
||||
fprintf(f, "%s\n", o->mesg);
|
||||
t = o->day;
|
||||
lt = localtime (&t);
|
||||
fprintf (f, "%02u/%02u/%04u [%d] ", lt->tm_mon + 1, lt->tm_mday,
|
||||
1900 + lt->tm_year, o->id);
|
||||
if (o->note != NULL)
|
||||
fprintf (f, ">%s ", o->note);
|
||||
fprintf (f, "%s\n", o->mesg);
|
||||
}
|
||||
|
||||
/* Load the events from file */
|
||||
struct event_s *
|
||||
event_scan(FILE * f, struct tm start, int id, char *note)
|
||||
event_scan (FILE *f, struct tm start, int id, char *note)
|
||||
{
|
||||
struct tm *lt;
|
||||
char buf[MESG_MAXSIZE], *nl;
|
||||
time_t tstart, t;
|
||||
struct tm *lt;
|
||||
char buf[MESG_MAXSIZE], *nl;
|
||||
time_t tstart, t;
|
||||
|
||||
t = time(NULL);
|
||||
lt = localtime(&t);
|
||||
t = time (NULL);
|
||||
lt = localtime (&t);
|
||||
|
||||
/* Read the event description */
|
||||
fgets(buf, MESG_MAXSIZE, f);
|
||||
nl = strchr(buf, '\n');
|
||||
if (nl) {
|
||||
*nl = '\0';
|
||||
}
|
||||
start.tm_hour = 12;
|
||||
start.tm_min = 0;
|
||||
start.tm_sec = 0;
|
||||
start.tm_isdst = -1;
|
||||
start.tm_year -= 1900;
|
||||
start.tm_mon--;
|
||||
/* Read the event description */
|
||||
fgets (buf, MESG_MAXSIZE, f);
|
||||
nl = strchr (buf, '\n');
|
||||
if (nl)
|
||||
{
|
||||
*nl = '\0';
|
||||
}
|
||||
start.tm_hour = 12;
|
||||
start.tm_min = 0;
|
||||
start.tm_sec = 0;
|
||||
start.tm_isdst = -1;
|
||||
start.tm_year -= 1900;
|
||||
start.tm_mon--;
|
||||
|
||||
tstart = mktime(&start);
|
||||
if (tstart == -1) {
|
||||
fputs(_("FATAL ERROR in event_scan: date error in the event\n"), stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return (event_new(buf, note, tstart, id));
|
||||
tstart = mktime (&start);
|
||||
if (tstart == -1)
|
||||
{
|
||||
fputs (_("FATAL ERROR in event_scan: date error in the event\n"),
|
||||
stderr);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
return (event_new (buf, note, tstart, id));
|
||||
}
|
||||
|
||||
/* Retrieve an event from the list, given the day and item position. */
|
||||
struct event_s *
|
||||
event_get(long day, int pos)
|
||||
event_get (long day, int pos)
|
||||
{
|
||||
struct event_s *o;
|
||||
int n;
|
||||
struct event_s *o;
|
||||
int n;
|
||||
|
||||
n = 0;
|
||||
for (o = eventlist; o; o = o->next) {
|
||||
if (event_inday(o, day)) {
|
||||
if (n == pos)
|
||||
return o;
|
||||
n++;
|
||||
}
|
||||
n = 0;
|
||||
for (o = eventlist; o; o = o->next)
|
||||
{
|
||||
if (event_inday (o, day))
|
||||
{
|
||||
if (n == pos)
|
||||
return o;
|
||||
n++;
|
||||
}
|
||||
/* NOTREACHED */
|
||||
fputs(_("FATAL ERROR in event_get: no such item\n"), stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
fputs (_("FATAL ERROR in event_get: no such item\n"), stderr);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Delete an event from the list. */
|
||||
void
|
||||
event_delete_bynum(long start, unsigned num, erase_flag_e flag)
|
||||
void
|
||||
event_delete_bynum (long start, unsigned num, erase_flag_e flag)
|
||||
{
|
||||
unsigned n;
|
||||
struct event_s *i, **iptr;
|
||||
unsigned n;
|
||||
struct event_s *i, **iptr;
|
||||
|
||||
n = 0;
|
||||
iptr = &eventlist;
|
||||
for (i = eventlist; i != 0; i = i->next) {
|
||||
if (event_inday(i, start)) {
|
||||
if (n == num) {
|
||||
if (flag == ERASE_FORCE_ONLY_NOTE)
|
||||
erase_note(&i->note, flag);
|
||||
else {
|
||||
*iptr = i->next;
|
||||
free(i->mesg);
|
||||
erase_note(&i->note, flag);
|
||||
free(i);
|
||||
}
|
||||
return;
|
||||
}
|
||||
n++;
|
||||
n = 0;
|
||||
iptr = &eventlist;
|
||||
for (i = eventlist; i != 0; i = i->next)
|
||||
{
|
||||
if (event_inday (i, start))
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
if (flag == ERASE_FORCE_ONLY_NOTE)
|
||||
erase_note (&i->note, flag);
|
||||
else
|
||||
{
|
||||
*iptr = i->next;
|
||||
free (i->mesg);
|
||||
erase_note (&i->note, flag);
|
||||
free (i);
|
||||
}
|
||||
iptr = &i->next;
|
||||
return;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
/* NOTREACHED */
|
||||
fputs(_("FATAL ERROR in event_delete_bynum: no such event\n"), stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
iptr = &i->next;
|
||||
}
|
||||
/* NOTREACHED */
|
||||
fputs (_("FATAL ERROR in event_delete_bynum: no such event\n"), stderr);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
27
src/event.h
27
src/event.h
@ -1,4 +1,4 @@
|
||||
/* $calcurse: event.h,v 1.5 2008/01/20 10:45:38 culot Exp $ */
|
||||
/* $calcurse: event.h,v 1.6 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -32,21 +32,22 @@
|
||||
#define HRMIN_SIZE 6
|
||||
#define MESG_MAXSIZE 256
|
||||
|
||||
struct event_s {
|
||||
struct event_s *next;
|
||||
int id; /* event identifier */
|
||||
long day; /* seconds since 1 jan 1970 */
|
||||
char *mesg;
|
||||
char *note;
|
||||
struct event_s
|
||||
{
|
||||
struct event_s *next;
|
||||
int id; /* event identifier */
|
||||
long day; /* seconds since 1 jan 1970 */
|
||||
char *mesg;
|
||||
char *note;
|
||||
};
|
||||
|
||||
extern struct event_s *eventlist;
|
||||
|
||||
struct event_s *event_new(char *, char *, long, int);
|
||||
unsigned event_inday(struct event_s *, long);
|
||||
void event_write(struct event_s *, FILE *);
|
||||
struct event_s *event_scan(FILE *, struct tm, int, char *);
|
||||
struct event_s *event_get(long, int);
|
||||
void event_delete_bynum(long, unsigned, erase_flag_e);
|
||||
struct event_s *event_new (char *, char *, long, int);
|
||||
unsigned event_inday (struct event_s *, long);
|
||||
void event_write (struct event_s *, FILE *);
|
||||
struct event_s *event_scan (FILE *, struct tm, int, char *);
|
||||
struct event_s *event_get (long, int);
|
||||
void event_delete_bynum (long, unsigned, erase_flag_e);
|
||||
|
||||
#endif /* CALCURSE_EVENT_H */
|
||||
|
964
src/help.c
964
src/help.c
File diff suppressed because it is too large
Load Diff
14
src/help.h
14
src/help.h
@ -1,4 +1,4 @@
|
||||
/* $calcurse: help.h,v 1.4 2007/07/28 13:11:42 culot Exp $ */
|
||||
/* $calcurse: help.h,v 1.5 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -27,11 +27,13 @@
|
||||
#ifndef CALCURSE_HELP_H
|
||||
#define CALCURSE_HELP_H
|
||||
|
||||
typedef struct {
|
||||
char *title;
|
||||
char *text;
|
||||
} help_page_t;
|
||||
typedef struct
|
||||
{
|
||||
char *title;
|
||||
char *text;
|
||||
}
|
||||
help_page_t;
|
||||
|
||||
void help_screen(void);
|
||||
void help_screen (void);
|
||||
|
||||
#endif /* CALCURSE_HELP_H */
|
||||
|
34
src/i18n.h
34
src/i18n.h
@ -1,4 +1,4 @@
|
||||
/* $calcurse: i18n.h,v 1.1 2006/07/31 21:00:03 culot Exp $ */
|
||||
/* $calcurse: i18n.h,v 1.2 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -32,23 +32,23 @@
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#if ENABLE_NLS
|
||||
#include <libintl.h>
|
||||
#undef _
|
||||
#define _(String) gettext(String)
|
||||
#ifdef gettext_noop
|
||||
#define N_(String) gettext_noop(String)
|
||||
#else
|
||||
#define N_(String) (String)
|
||||
#endif
|
||||
#include <libintl.h>
|
||||
#undef _
|
||||
#define _(String) gettext(String)
|
||||
#ifdef gettext_noop
|
||||
#define N_(String) gettext_noop(String)
|
||||
#else
|
||||
#define N_(String) (String)
|
||||
#endif
|
||||
#else /* NLS disabled */
|
||||
#define _(String) (String)
|
||||
#define N_(String) (String)
|
||||
#define textdomain(String) (String)
|
||||
#define gettext(String) (String)
|
||||
#define dgettext(String) (String)
|
||||
#define dcgettext(String) (String)
|
||||
#define bindtextdomain(String) (String)
|
||||
#define bind_textdomain_codeset(Domain,Codeset) (Codeset)
|
||||
#define _(String) (String)
|
||||
#define N_(String) (String)
|
||||
#define textdomain(String) (String)
|
||||
#define gettext(String) (String)
|
||||
#define dgettext(String) (String)
|
||||
#define dcgettext(String) (String)
|
||||
#define bindtextdomain(String) (String)
|
||||
#define bind_textdomain_codeset(Domain,Codeset) (Codeset)
|
||||
#endif /* ENABLE_NLS */
|
||||
|
||||
#endif /* CALCURSE_I18N_H */
|
||||
|
32
src/io.h
32
src/io.h
@ -1,8 +1,8 @@
|
||||
/* $calcurse: io.h,v 1.8 2007/08/15 15:36:27 culot Exp $ */
|
||||
/* $calcurse: io.h,v 1.9 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
* Copyright (c) 2004-2007 Frederic Culot
|
||||
* Copyright (c) 2004-2008 Frederic Culot
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -29,19 +29,21 @@
|
||||
|
||||
#include "vars.h"
|
||||
|
||||
typedef enum {
|
||||
IO_EXPORT_NONINTERACTIVE,
|
||||
IO_EXPORT_INTERACTIVE,
|
||||
IO_EXPORT_NBMODES
|
||||
} export_mode_t;
|
||||
typedef enum
|
||||
{
|
||||
IO_EXPORT_NONINTERACTIVE,
|
||||
IO_EXPORT_INTERACTIVE,
|
||||
IO_EXPORT_NBMODES
|
||||
}
|
||||
export_mode_t;
|
||||
|
||||
void io_init(char *);
|
||||
void io_extract_data(char *, const char *, int);
|
||||
void io_save_cal(conf_t *);
|
||||
void io_load_app(void);
|
||||
void io_load_todo(void);
|
||||
int io_check_data_files(void);
|
||||
void io_startup_screen(bool, int);
|
||||
void io_export_data(export_mode_t, conf_t *);
|
||||
void io_init (char *);
|
||||
void io_extract_data (char *, const char *, int);
|
||||
void io_save_cal (conf_t *);
|
||||
void io_load_app (void);
|
||||
void io_load_todo (void);
|
||||
int io_check_data_files (void);
|
||||
void io_startup_screen (bool, int);
|
||||
void io_export_data (export_mode_t, conf_t *);
|
||||
|
||||
#endif /* CALCURSE_IO_H */
|
||||
|
892
src/notify.c
892
src/notify.c
File diff suppressed because it is too large
Load Diff
58
src/notify.h
58
src/notify.h
@ -1,8 +1,8 @@
|
||||
/* $calcurse: notify.h,v 1.12 2007/08/15 15:33:01 culot Exp $ */
|
||||
/* $calcurse: notify.h,v 1.13 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
* Copyright (c) 2004-2007 Frederic Culot
|
||||
* Copyright (c) 2004-2008 Frederic Culot
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -33,35 +33,37 @@
|
||||
|
||||
#define NOTIFY_FIELD_LENGTH 25
|
||||
|
||||
struct notify_vars_s {
|
||||
WINDOW *win;
|
||||
long time_in_sec;
|
||||
char *apts_file;
|
||||
char time[NOTIFY_FIELD_LENGTH];
|
||||
char date[NOTIFY_FIELD_LENGTH];
|
||||
pthread_mutex_t mutex;
|
||||
struct notify_vars_s
|
||||
{
|
||||
WINDOW *win;
|
||||
long time_in_sec;
|
||||
char *apts_file;
|
||||
char time[NOTIFY_FIELD_LENGTH];
|
||||
char date[NOTIFY_FIELD_LENGTH];
|
||||
pthread_mutex_t mutex;
|
||||
};
|
||||
|
||||
struct notify_app_s {
|
||||
long time;
|
||||
int got_app;
|
||||
char *txt;
|
||||
char state;
|
||||
pthread_mutex_t mutex;
|
||||
struct notify_app_s
|
||||
{
|
||||
long time;
|
||||
int got_app;
|
||||
char *txt;
|
||||
char state;
|
||||
pthread_mutex_t mutex;
|
||||
};
|
||||
|
||||
int notify_bar(void);
|
||||
void notify_init_vars(void);
|
||||
void notify_init_bar(void);
|
||||
void notify_start_main_thread(void);
|
||||
void notify_stop_main_thread(void);
|
||||
void notify_reinit_bar(int, int, int, int);
|
||||
void notify_update_bar(void);
|
||||
void notify_check_next_app(void);
|
||||
void notify_check_added(char *, long, char);
|
||||
void notify_check_repeated(recur_apoint_llist_node_t *);
|
||||
int notify_same_item(long);
|
||||
int notify_same_recur_item(recur_apoint_llist_node_t *);
|
||||
void notify_config_bar(void);
|
||||
int notify_bar (void);
|
||||
void notify_init_vars (void);
|
||||
void notify_init_bar (void);
|
||||
void notify_start_main_thread (void);
|
||||
void notify_stop_main_thread (void);
|
||||
void notify_reinit_bar (int, int, int, int);
|
||||
void notify_update_bar (void);
|
||||
void notify_check_next_app (void);
|
||||
void notify_check_added (char *, long, char);
|
||||
void notify_check_repeated (recur_apoint_llist_node_t *);
|
||||
int notify_same_item (long);
|
||||
int notify_same_recur_item (recur_apoint_llist_node_t *);
|
||||
void notify_config_bar (void);
|
||||
|
||||
#endif /* CALCURSE_NOTIFY_H */
|
||||
|
1407
src/recur.c
1407
src/recur.c
File diff suppressed because it is too large
Load Diff
128
src/recur.h
128
src/recur.h
@ -1,4 +1,4 @@
|
||||
/* $calcurse: recur.h,v 1.18 2008/04/09 20:38:29 culot Exp $ */
|
||||
/* $calcurse: recur.h,v 1.19 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -27,75 +27,85 @@
|
||||
#ifndef CALCURSE_RECUR_H
|
||||
#define CALCURSE_RECUR_H
|
||||
|
||||
typedef enum { RECUR_NO,
|
||||
RECUR_DAILY,
|
||||
RECUR_WEEKLY,
|
||||
RECUR_MONTHLY,
|
||||
RECUR_YEARLY,
|
||||
RECUR_TYPES
|
||||
} recur_types_t;
|
||||
typedef enum
|
||||
{ RECUR_NO,
|
||||
RECUR_DAILY,
|
||||
RECUR_WEEKLY,
|
||||
RECUR_MONTHLY,
|
||||
RECUR_YEARLY,
|
||||
RECUR_TYPES
|
||||
}
|
||||
recur_types_t;
|
||||
|
||||
struct days_s {
|
||||
struct days_s *next;
|
||||
long st; /* beggining of the considered day, in seconds */
|
||||
struct days_s
|
||||
{
|
||||
struct days_s *next;
|
||||
long st; /* beggining of the considered day, in seconds */
|
||||
};
|
||||
|
||||
struct rpt_s {
|
||||
int type; /* repetition type, see RECUR_* defines */
|
||||
int freq; /* repetition frequence */
|
||||
long until; /* ending date for repeated event */
|
||||
struct rpt_s
|
||||
{
|
||||
int type; /* repetition type, see RECUR_* defines */
|
||||
int freq; /* repetition frequence */
|
||||
long until; /* ending date for repeated event */
|
||||
};
|
||||
|
||||
typedef struct recur_apoint_llist_node {
|
||||
struct recur_apoint_llist_node *next;
|
||||
struct rpt_s *rpt; /* information about repetition */
|
||||
struct days_s *exc; /* days when the item should not be repeated */
|
||||
long start; /* beggining of the appointment */
|
||||
long dur; /* duration of the appointment */
|
||||
char state; /* 8 bits to store item state */
|
||||
char *mesg; /* appointment description */
|
||||
char *note; /* note attached to appointment */
|
||||
} recur_apoint_llist_node_t;
|
||||
typedef struct recur_apoint_llist_node
|
||||
{
|
||||
struct recur_apoint_llist_node *next;
|
||||
struct rpt_s *rpt; /* information about repetition */
|
||||
struct days_s *exc; /* days when the item should not be repeated */
|
||||
long start; /* beggining of the appointment */
|
||||
long dur; /* duration of the appointment */
|
||||
char state; /* 8 bits to store item state */
|
||||
char *mesg; /* appointment description */
|
||||
char *note; /* note attached to appointment */
|
||||
}
|
||||
recur_apoint_llist_node_t;
|
||||
|
||||
typedef struct recur_apoint_llist {
|
||||
recur_apoint_llist_node_t *root;
|
||||
pthread_mutex_t mutex;
|
||||
} recur_apoint_llist_t;
|
||||
typedef struct recur_apoint_llist
|
||||
{
|
||||
recur_apoint_llist_node_t *root;
|
||||
pthread_mutex_t mutex;
|
||||
}
|
||||
recur_apoint_llist_t;
|
||||
|
||||
struct recur_event_s {
|
||||
struct recur_event_s *next;
|
||||
struct rpt_s *rpt; /* information about repetition */
|
||||
struct days_s *exc; /* days when the item should not be repeated */
|
||||
int id; /* event type */
|
||||
long day; /* day at which event occurs */
|
||||
char *mesg; /* event description */
|
||||
char *note; /* note attached to event */
|
||||
struct recur_event_s
|
||||
{
|
||||
struct recur_event_s *next;
|
||||
struct rpt_s *rpt; /* information about repetition */
|
||||
struct days_s *exc; /* days when the item should not be repeated */
|
||||
int id; /* event type */
|
||||
long day; /* day at which event occurs */
|
||||
char *mesg; /* event description */
|
||||
char *note; /* note attached to event */
|
||||
};
|
||||
|
||||
extern recur_apoint_llist_t *recur_alist_p;
|
||||
extern struct recur_event_s *recur_elist;
|
||||
|
||||
int recur_apoint_llist_init(void);
|
||||
char recur_def2char(recur_types_t);
|
||||
int recur_char2def(char);
|
||||
recur_apoint_llist_node_t *recur_apoint_scan(FILE *, struct tm, struct tm,
|
||||
char, int, struct tm, char *,
|
||||
struct days_s *, char);
|
||||
struct recur_event_s *recur_event_scan(FILE *, struct tm, int, char,
|
||||
int, struct tm, char *, struct days_s *);
|
||||
void recur_save_data(FILE *);
|
||||
unsigned recur_item_inday(long, struct days_s *, int,
|
||||
int, long, long);
|
||||
void recur_event_erase(long, unsigned, unsigned,
|
||||
erase_flag_e);
|
||||
void recur_apoint_erase(long, unsigned, unsigned,
|
||||
erase_flag_e);
|
||||
void recur_repeat_item(conf_t *);
|
||||
struct days_s *recur_exc_scan(FILE *);
|
||||
struct notify_app_s *recur_apoint_check_next(struct notify_app_s *,
|
||||
long, long);
|
||||
recur_apoint_llist_node_t *recur_get_apoint(long, int);
|
||||
struct recur_event_s *recur_get_event(long, int);
|
||||
void recur_apoint_switch_notify(long, int);
|
||||
int recur_apoint_llist_init (void);
|
||||
char recur_def2char (recur_types_t);
|
||||
int recur_char2def (char);
|
||||
recur_apoint_llist_node_t *recur_apoint_scan (FILE *, struct tm, struct tm,
|
||||
char, int, struct tm, char *,
|
||||
struct days_s *, char);
|
||||
struct recur_event_s *recur_event_scan (FILE *, struct tm, int, char,
|
||||
int, struct tm, char *,
|
||||
struct days_s *);
|
||||
void recur_save_data (FILE *);
|
||||
unsigned recur_item_inday (long, struct days_s *, int, int,
|
||||
long, long);
|
||||
void recur_event_erase (long, unsigned, unsigned,
|
||||
erase_flag_e);
|
||||
void recur_apoint_erase (long, unsigned, unsigned,
|
||||
erase_flag_e);
|
||||
void recur_repeat_item (conf_t *);
|
||||
struct days_s *recur_exc_scan (FILE *);
|
||||
struct notify_app_s *recur_apoint_check_next (struct notify_app_s *,
|
||||
long, long);
|
||||
recur_apoint_llist_node_t *recur_get_apoint (long, int);
|
||||
struct recur_event_s *recur_get_event (long, int);
|
||||
void recur_apoint_switch_notify (long, int);
|
||||
|
||||
#endif /* CALCURSE_RECUR_H */
|
||||
|
74
src/sigs.c
74
src/sigs.c
@ -1,8 +1,8 @@
|
||||
/* $calcurse: sigs.c,v 1.5 2008/02/14 20:20:23 culot Exp $ */
|
||||
/* $calcurse: sigs.c,v 1.6 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
* Copyright (c) 2007 Frederic Culot
|
||||
* Copyright (c) 2007-2008 Frederic Culot
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -40,45 +40,49 @@
|
||||
* Also catch CTRL-C (SIGINT), and SIGWINCH to resize screen automatically.
|
||||
*/
|
||||
static void
|
||||
signal_handler(int sig)
|
||||
signal_handler (int sig)
|
||||
{
|
||||
switch (sig) {
|
||||
case SIGCHLD:
|
||||
while (waitpid(WAIT_MYPGRP, NULL, WNOHANG) > 0)
|
||||
;
|
||||
break;
|
||||
case SIGWINCH:
|
||||
clearok(curscr, TRUE);
|
||||
ungetch(KEY_RESIZE);
|
||||
break;
|
||||
}
|
||||
switch (sig)
|
||||
{
|
||||
case SIGCHLD:
|
||||
while (waitpid (WAIT_MYPGRP, NULL, WNOHANG) > 0)
|
||||
;
|
||||
break;
|
||||
case SIGWINCH:
|
||||
clearok (curscr, TRUE);
|
||||
ungetch (KEY_RESIZE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Signal handling init. */
|
||||
void
|
||||
sigs_init(struct sigaction *sa)
|
||||
sigs_init (struct sigaction *sa)
|
||||
{
|
||||
sa->sa_handler = signal_handler;
|
||||
sa->sa_flags = 0;
|
||||
sigemptyset(&sa->sa_mask);
|
||||
if (sigaction(SIGCHLD, sa, NULL) != 0) {
|
||||
perror("sigaction");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
sa->sa_handler = signal_handler;
|
||||
sa->sa_flags = 0;
|
||||
sigemptyset (&sa->sa_mask);
|
||||
if (sigaction (SIGCHLD, sa, NULL) != 0)
|
||||
{
|
||||
perror ("sigaction");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
sa->sa_handler = signal_handler;
|
||||
sa->sa_flags = 0;
|
||||
sigemptyset(&sa->sa_mask);
|
||||
if (sigaction(SIGWINCH, sa, NULL) != 0) {
|
||||
perror("sigaction");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
sa->sa_handler = signal_handler;
|
||||
sa->sa_flags = 0;
|
||||
sigemptyset (&sa->sa_mask);
|
||||
if (sigaction (SIGWINCH, sa, NULL) != 0)
|
||||
{
|
||||
perror ("sigaction");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
sa->sa_handler = SIG_IGN;
|
||||
sa->sa_flags = 0;
|
||||
sigemptyset(&(sa->sa_mask));
|
||||
if (sigaction(SIGINT, sa, NULL) != 0) {
|
||||
perror("sigaction");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
sa->sa_handler = SIG_IGN;
|
||||
sa->sa_flags = 0;
|
||||
sigemptyset (&(sa->sa_mask));
|
||||
if (sigaction (SIGINT, sa, NULL) != 0)
|
||||
{
|
||||
perror ("sigaction");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* $calcurse: sigs.h,v 1.2 2008/02/14 20:20:23 culot Exp $ */
|
||||
/* $calcurse: sigs.h,v 1.3 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
* Copyright (c) 2007 Frederic Culot
|
||||
* Copyright (c) 2007-2008 Frederic Culot
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -27,6 +27,6 @@
|
||||
#ifndef CALCURSE_SIGS_H
|
||||
#define CALCURSE_SIGS_H
|
||||
|
||||
void sigs_init(struct sigaction *);
|
||||
void sigs_init (struct sigaction *);
|
||||
|
||||
#endif /* CALCURSE_SIGS_H */
|
||||
|
627
src/todo.c
627
src/todo.c
@ -1,8 +1,8 @@
|
||||
/* $calcurse: todo.c,v 1.20 2008/04/04 21:31:20 culot Exp $ */
|
||||
/* $calcurse: todo.c,v 1.21 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
* Copyright (c) 2004-2007 Frederic Culot
|
||||
* Copyright (c) 2004-2008 Frederic Culot
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -33,433 +33,458 @@
|
||||
#include "i18n.h"
|
||||
#include "todo.h"
|
||||
|
||||
struct todo_s *todolist;
|
||||
static int hilt = 0;
|
||||
static int todos = 0;
|
||||
static int first = 1;
|
||||
static char *msgsav;
|
||||
struct todo_s *todolist;
|
||||
static int hilt = 0;
|
||||
static int todos = 0;
|
||||
static int first = 1;
|
||||
static char *msgsav;
|
||||
|
||||
/* Returns a structure containing the selected item. */
|
||||
static struct todo_s *
|
||||
todo_get_item(int item_number)
|
||||
todo_get_item (int item_number)
|
||||
{
|
||||
struct todo_s *o;
|
||||
int i;
|
||||
|
||||
o = todolist;
|
||||
for (i = 1; i < item_number; i++) {
|
||||
o = o->next;
|
||||
}
|
||||
return o;
|
||||
struct todo_s *o;
|
||||
int i;
|
||||
|
||||
o = todolist;
|
||||
for (i = 1; i < item_number; i++)
|
||||
{
|
||||
o = o->next;
|
||||
}
|
||||
return (o);
|
||||
}
|
||||
|
||||
/* Sets which todo is highlighted. */
|
||||
void
|
||||
todo_hilt_set(int highlighted)
|
||||
todo_hilt_set (int highlighted)
|
||||
{
|
||||
hilt = highlighted;
|
||||
hilt = highlighted;
|
||||
}
|
||||
|
||||
void
|
||||
todo_hilt_decrease(void)
|
||||
todo_hilt_decrease (void)
|
||||
{
|
||||
hilt--;
|
||||
hilt--;
|
||||
}
|
||||
|
||||
void
|
||||
todo_hilt_increase(void)
|
||||
todo_hilt_increase (void)
|
||||
{
|
||||
hilt++;
|
||||
hilt++;
|
||||
}
|
||||
|
||||
/* Return which todo is highlighted. */
|
||||
int
|
||||
todo_hilt(void)
|
||||
todo_hilt (void)
|
||||
{
|
||||
return (hilt);
|
||||
return (hilt);
|
||||
}
|
||||
|
||||
/* Return the number of todos. */
|
||||
int
|
||||
todo_nb(void)
|
||||
todo_nb (void)
|
||||
{
|
||||
return (todos);
|
||||
return (todos);
|
||||
}
|
||||
|
||||
/* Set the number of todos. */
|
||||
void
|
||||
todo_set_nb(int nb)
|
||||
todo_set_nb (int nb)
|
||||
{
|
||||
todos = nb;
|
||||
todos = nb;
|
||||
}
|
||||
|
||||
/* Set which one is the first todo to be displayed. */
|
||||
void
|
||||
todo_set_first(int nb)
|
||||
todo_set_first (int nb)
|
||||
{
|
||||
first = nb;
|
||||
first = nb;
|
||||
}
|
||||
|
||||
void
|
||||
todo_first_increase(void)
|
||||
todo_first_increase (void)
|
||||
{
|
||||
first++;
|
||||
first++;
|
||||
}
|
||||
|
||||
void
|
||||
todo_first_decrease(void)
|
||||
todo_first_decrease (void)
|
||||
{
|
||||
first--;
|
||||
first--;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the position of the hilghlighted item, relative to the first one
|
||||
* displayed.
|
||||
*/
|
||||
*/
|
||||
int
|
||||
todo_hilt_pos(void)
|
||||
todo_hilt_pos (void)
|
||||
{
|
||||
return (hilt - first);
|
||||
return (hilt - first);
|
||||
}
|
||||
|
||||
/* Return the last visited todo. */
|
||||
char *
|
||||
todo_saved_mesg(void)
|
||||
todo_saved_mesg (void)
|
||||
{
|
||||
return (msgsav);
|
||||
return (msgsav);
|
||||
}
|
||||
|
||||
/* Request user to enter a new todo item. */
|
||||
void
|
||||
todo_new_item(void)
|
||||
void
|
||||
todo_new_item (void)
|
||||
{
|
||||
int ch = 0;
|
||||
char *mesg = _("Enter the new ToDo item : ");
|
||||
char *mesg_id =
|
||||
_("Enter the ToDo priority [1 (highest) - 9 (lowest)] :");
|
||||
char todo_input[BUFSIZ] = "";
|
||||
int ch = 0;
|
||||
char *mesg = _("Enter the new ToDo item : ");
|
||||
char *mesg_id = _("Enter the ToDo priority [1 (highest) - 9 (lowest)] :");
|
||||
char todo_input[BUFSIZ] = "";
|
||||
|
||||
status_mesg(mesg, "");
|
||||
if (getstring(win[STA].p, todo_input, BUFSIZ, 0, 1) ==
|
||||
GETSTRING_VALID) {
|
||||
while ( (ch < '1') || (ch > '9') ) {
|
||||
status_mesg(mesg_id, "");
|
||||
ch = wgetch(win[STA].p);
|
||||
}
|
||||
todo_add(todo_input, ch - '0', NULL);
|
||||
todos++;
|
||||
status_mesg (mesg, "");
|
||||
if (getstring (win[STA].p, todo_input, BUFSIZ, 0, 1) == GETSTRING_VALID)
|
||||
{
|
||||
while ((ch < '1') || (ch > '9'))
|
||||
{
|
||||
status_mesg (mesg_id, "");
|
||||
ch = wgetch (win[STA].p);
|
||||
}
|
||||
todo_add (todo_input, ch - '0', NULL);
|
||||
todos++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add an item in the todo linked list. */
|
||||
struct todo_s *
|
||||
todo_add(char *mesg, int id, char *note)
|
||||
todo_add (char *mesg, int id, char *note)
|
||||
{
|
||||
struct todo_s *o, **i;
|
||||
o = (struct todo_s *) malloc(sizeof(struct todo_s));
|
||||
o->mesg = (char *) malloc(strlen(mesg) + 1);
|
||||
strncpy(o->mesg, mesg, strlen(mesg) + 1);
|
||||
o->id = id;
|
||||
o->note = (note != NULL && note[0] != '\0') ? strdup(note) : NULL;
|
||||
i = &todolist;
|
||||
for (;;) {
|
||||
if (*i == 0 || (*i)->id > id) {
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
i = &(*i)->next;
|
||||
struct todo_s *o, **i;
|
||||
o = (struct todo_s *) malloc (sizeof (struct todo_s));
|
||||
o->mesg = (char *) malloc (strlen (mesg) + 1);
|
||||
strncpy (o->mesg, mesg, strlen (mesg) + 1);
|
||||
o->id = id;
|
||||
o->note = (note != NULL && note[0] != '\0') ? strdup (note) : NULL;
|
||||
i = &todolist;
|
||||
for (;;)
|
||||
{
|
||||
if (*i == 0 || (*i)->id > id)
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
return o;
|
||||
i = &(*i)->next;
|
||||
}
|
||||
return (o);
|
||||
}
|
||||
|
||||
/* Delete a note previously attached to a todo item. */
|
||||
static void
|
||||
todo_delete_note_bynum(unsigned num)
|
||||
static void
|
||||
todo_delete_note_bynum (unsigned num)
|
||||
{
|
||||
unsigned n;
|
||||
struct todo_s *i, **iptr;
|
||||
unsigned n;
|
||||
struct todo_s *i, **iptr;
|
||||
|
||||
n = 0;
|
||||
iptr = &todolist;
|
||||
for (i = todolist; i != 0; i = i->next) {
|
||||
if (n == num) {
|
||||
if (i->note == NULL)
|
||||
ierror(
|
||||
_("FATAL ERROR in todo_delete_note_bynum: "
|
||||
"no note attached\n"), IERROR_FATAL);
|
||||
erase_note(&i->note, ERASE_FORCE_ONLY_NOTE);
|
||||
return;
|
||||
}
|
||||
iptr = &i->next;
|
||||
n++;
|
||||
n = 0;
|
||||
iptr = &todolist;
|
||||
for (i = todolist; i != 0; i = i->next)
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
if (i->note == NULL)
|
||||
ierror (_("FATAL ERROR in todo_delete_note_bynum: "
|
||||
"no note attached\n"), IERROR_FATAL);
|
||||
erase_note (&i->note, ERASE_FORCE_ONLY_NOTE);
|
||||
return;
|
||||
}
|
||||
/* NOTREACHED */
|
||||
ierror(_("FATAL ERROR in todo_delete_note_bynum: no such todo\n"),
|
||||
IERROR_FATAL);
|
||||
exit(EXIT_FAILURE);
|
||||
iptr = &i->next;
|
||||
n++;
|
||||
}
|
||||
/* NOTREACHED */
|
||||
ierror (_("FATAL ERROR in todo_delete_note_bynum: no such todo\n"),
|
||||
IERROR_FATAL);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Delete an item from the todo linked list. */
|
||||
static void
|
||||
todo_delete_bynum(unsigned num, erase_flag_e flag)
|
||||
static void
|
||||
todo_delete_bynum (unsigned num, erase_flag_e flag)
|
||||
{
|
||||
unsigned n;
|
||||
struct todo_s *i, **iptr;
|
||||
unsigned n;
|
||||
struct todo_s *i, **iptr;
|
||||
|
||||
n = 0;
|
||||
iptr = &todolist;
|
||||
for (i = todolist; i != 0; i = i->next) {
|
||||
if (n == num) {
|
||||
*iptr = i->next;
|
||||
free(i->mesg);
|
||||
if (i->note != NULL)
|
||||
erase_note(&i->note, flag);
|
||||
free(i);
|
||||
return;
|
||||
}
|
||||
iptr = &i->next;
|
||||
n++;
|
||||
n = 0;
|
||||
iptr = &todolist;
|
||||
for (i = todolist; i != 0; i = i->next)
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
*iptr = i->next;
|
||||
free (i->mesg);
|
||||
if (i->note != NULL)
|
||||
erase_note (&i->note, flag);
|
||||
free (i);
|
||||
return;
|
||||
}
|
||||
/* NOTREACHED */
|
||||
ierror(_("FATAL ERROR in todo_delete_bynum: no such todo\n"),
|
||||
IERROR_FATAL);
|
||||
exit(EXIT_FAILURE);
|
||||
iptr = &i->next;
|
||||
n++;
|
||||
}
|
||||
/* NOTREACHED */
|
||||
ierror (_("FATAL ERROR in todo_delete_bynum: no such todo\n"),
|
||||
IERROR_FATAL);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Delete an item from the ToDo list. */
|
||||
void
|
||||
todo_delete(conf_t *conf)
|
||||
void
|
||||
todo_delete (conf_t *conf)
|
||||
{
|
||||
char *choices = "[y/n] ";
|
||||
char *del_todo_str = _("Do you really want to delete this task ?");
|
||||
char *erase_warning =
|
||||
_("This item has a note attached to it. "
|
||||
"Delete (t)odo or just its (n)ote ?");
|
||||
char *erase_choice =
|
||||
_("[t/n] ");
|
||||
bool go_for_todo_del = false;
|
||||
int answer = 0, has_note;
|
||||
|
||||
if (conf->confirm_delete) {
|
||||
status_mesg(del_todo_str, choices);
|
||||
answer = wgetch(win[STA].p);
|
||||
if ( (answer == 'y') && (todos > 0) ) {
|
||||
go_for_todo_del = true;
|
||||
} else {
|
||||
erase_status_bar();
|
||||
return;
|
||||
}
|
||||
} else
|
||||
if (todos > 0)
|
||||
go_for_todo_del = true;
|
||||
char *choices = "[y/n] ";
|
||||
char *del_todo_str = _("Do you really want to delete this task ?");
|
||||
char *erase_warning =
|
||||
_("This item has a note attached to it. "
|
||||
"Delete (t)odo or just its (n)ote ?");
|
||||
char *erase_choice = _("[t/n] ");
|
||||
bool go_for_todo_del = false;
|
||||
int answer = 0, has_note;
|
||||
|
||||
if (go_for_todo_del == false) {
|
||||
erase_status_bar();
|
||||
return;
|
||||
if (conf->confirm_delete)
|
||||
{
|
||||
status_mesg (del_todo_str, choices);
|
||||
answer = wgetch (win[STA].p);
|
||||
if ((answer == 'y') && (todos > 0))
|
||||
{
|
||||
go_for_todo_del = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
erase_status_bar ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (todos > 0)
|
||||
go_for_todo_del = true;
|
||||
|
||||
answer = 0;
|
||||
has_note = (todo_get_item(hilt)->note != NULL) ? 1 : 0;
|
||||
if (has_note == 0)
|
||||
answer = 't';
|
||||
|
||||
while (answer != 't' && answer != 'n' && answer != ESCAPE) {
|
||||
status_mesg(erase_warning, erase_choice);
|
||||
answer = wgetch(win[STA].p);
|
||||
}
|
||||
|
||||
switch (answer) {
|
||||
case 't':
|
||||
todo_delete_bynum(hilt - 1, ERASE_FORCE);
|
||||
todos--;
|
||||
if (hilt > 1)
|
||||
hilt--;
|
||||
if (todos == 0)
|
||||
hilt = 0;
|
||||
if (hilt - first < 0)
|
||||
first--;
|
||||
break;
|
||||
case 'n':
|
||||
todo_delete_note_bynum(hilt - 1);
|
||||
break;
|
||||
default:
|
||||
erase_status_bar();
|
||||
return;
|
||||
}
|
||||
if (go_for_todo_del == false)
|
||||
{
|
||||
erase_status_bar ();
|
||||
return;
|
||||
}
|
||||
|
||||
answer = 0;
|
||||
has_note = (todo_get_item (hilt)->note != NULL) ? 1 : 0;
|
||||
if (has_note == 0)
|
||||
answer = 't';
|
||||
|
||||
while (answer != 't' && answer != 'n' && answer != ESCAPE)
|
||||
{
|
||||
status_mesg (erase_warning, erase_choice);
|
||||
answer = wgetch (win[STA].p);
|
||||
}
|
||||
|
||||
switch (answer)
|
||||
{
|
||||
case 't':
|
||||
todo_delete_bynum (hilt - 1, ERASE_FORCE);
|
||||
todos--;
|
||||
if (hilt > 1)
|
||||
hilt--;
|
||||
if (todos == 0)
|
||||
hilt = 0;
|
||||
if (hilt - first < 0)
|
||||
first--;
|
||||
break;
|
||||
case 'n':
|
||||
todo_delete_note_bynum (hilt - 1);
|
||||
break;
|
||||
default:
|
||||
erase_status_bar ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the position into the linked list corresponding to the
|
||||
* given todo_s item.
|
||||
*/
|
||||
static int
|
||||
todo_get_position(struct todo_s *i)
|
||||
static int
|
||||
todo_get_position (struct todo_s *i)
|
||||
{
|
||||
struct todo_s *o;
|
||||
int n = 1, found = 0;
|
||||
|
||||
for (o = todolist; o; o = o->next) {
|
||||
if (o == i) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
n++;
|
||||
struct todo_s *o;
|
||||
int n = 1, found = 0;
|
||||
|
||||
for (o = todolist; o; o = o->next)
|
||||
{
|
||||
if (o == i)
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
if (found) {
|
||||
return n;
|
||||
} else {
|
||||
fputs(_("FATAL ERROR in todo_get_position: todo not found\n"),
|
||||
stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
n++;
|
||||
}
|
||||
if (found)
|
||||
{
|
||||
return (n);
|
||||
}
|
||||
else
|
||||
{
|
||||
fputs (_("FATAL ERROR in todo_get_position: todo not found\n"), stderr);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Change an item priority by pressing '+' or '-' inside TODO panel. */
|
||||
void
|
||||
todo_chg_priority(int action)
|
||||
todo_chg_priority (int action)
|
||||
{
|
||||
struct todo_s *backup;
|
||||
char backup_mesg[BUFSIZ];
|
||||
int backup_id;
|
||||
char backup_note[NOTESIZ + 1];
|
||||
int do_chg = 1;
|
||||
struct todo_s *backup;
|
||||
char backup_mesg[BUFSIZ];
|
||||
int backup_id;
|
||||
char backup_note[NOTESIZ + 1];
|
||||
int do_chg = 1;
|
||||
|
||||
backup = todo_get_item(hilt);
|
||||
strncpy(backup_mesg, backup->mesg, strlen(backup->mesg) + 1);
|
||||
backup_id = backup->id;
|
||||
if (backup->note)
|
||||
strncpy(backup_note, backup->note, NOTESIZ + 1);
|
||||
else
|
||||
backup_note[0] = '\0';
|
||||
if (action == '+') {
|
||||
(backup_id > 1) ? backup_id-- : do_chg--;
|
||||
} else if (action == '-') {
|
||||
(backup_id < 9) ? backup_id++ : do_chg--;
|
||||
} else { /* NOTREACHED */
|
||||
fputs(_("FATAL ERROR in todo_chg_priority: no such action\n"),
|
||||
stderr);
|
||||
}
|
||||
if (do_chg) {
|
||||
todo_delete_bynum(hilt - 1, ERASE_FORCE_KEEP_NOTE);
|
||||
backup = todo_add(backup_mesg, backup_id, backup_note);
|
||||
hilt = todo_get_position(backup);
|
||||
}
|
||||
backup = todo_get_item (hilt);
|
||||
strncpy (backup_mesg, backup->mesg, strlen (backup->mesg) + 1);
|
||||
backup_id = backup->id;
|
||||
if (backup->note)
|
||||
strncpy (backup_note, backup->note, NOTESIZ + 1);
|
||||
else
|
||||
backup_note[0] = '\0';
|
||||
if (action == '+')
|
||||
{
|
||||
(backup_id > 1) ? backup_id-- : do_chg--;
|
||||
}
|
||||
else if (action == '-')
|
||||
{
|
||||
(backup_id < 9) ? backup_id++ : do_chg--;
|
||||
}
|
||||
else
|
||||
{ /* NOTREACHED */
|
||||
fputs (_("FATAL ERROR in todo_chg_priority: no such action\n"), stderr);
|
||||
}
|
||||
if (do_chg)
|
||||
{
|
||||
todo_delete_bynum (hilt - 1, ERASE_FORCE_KEEP_NOTE);
|
||||
backup = todo_add (backup_mesg, backup_id, backup_note);
|
||||
hilt = todo_get_position (backup);
|
||||
}
|
||||
}
|
||||
|
||||
/* Edit the description of an already existing todo item. */
|
||||
void
|
||||
todo_edit_item(void)
|
||||
void
|
||||
todo_edit_item (void)
|
||||
{
|
||||
struct todo_s *i;
|
||||
char *mesg = _("Enter the new ToDo description :");
|
||||
struct todo_s *i;
|
||||
char *mesg = _("Enter the new ToDo description :");
|
||||
|
||||
status_mesg(mesg, "");
|
||||
i = todo_get_item(hilt);
|
||||
updatestring(win[STA].p, &i->mesg, 0, 1);
|
||||
status_mesg (mesg, "");
|
||||
i = todo_get_item (hilt);
|
||||
updatestring (win[STA].p, &i->mesg, 0, 1);
|
||||
}
|
||||
|
||||
/* Display todo items in the corresponding panel. */
|
||||
static void
|
||||
display_todo_item(int incolor, char *msg, int prio, int note, int len, int y,
|
||||
int x)
|
||||
display_todo_item (int incolor, char *msg, int prio, int note, int len, int y,
|
||||
int x)
|
||||
{
|
||||
WINDOW *w;
|
||||
int ch_note;
|
||||
char buf[len];
|
||||
WINDOW *w;
|
||||
int ch_note;
|
||||
char buf[len];
|
||||
|
||||
w = win[TOD].p;
|
||||
ch_note = (note) ? '>' : '.';
|
||||
if (incolor == 0)
|
||||
custom_apply_attr(w, ATTR_HIGHEST);
|
||||
if (strlen(msg) < len)
|
||||
mvwprintw(w, y, x, "%d%c %s", prio, ch_note, msg);
|
||||
else {
|
||||
strncpy(buf, msg, len - 1);
|
||||
buf[len - 1] = '\0';
|
||||
mvwprintw(w, y, x, "%d%c %s...", prio, ch_note, buf);
|
||||
}
|
||||
if (incolor == 0)
|
||||
custom_remove_attr(w, ATTR_HIGHEST);
|
||||
w = win[TOD].p;
|
||||
ch_note = (note) ? '>' : '.';
|
||||
if (incolor == 0)
|
||||
custom_apply_attr (w, ATTR_HIGHEST);
|
||||
if (strlen (msg) < len)
|
||||
mvwprintw (w, y, x, "%d%c %s", prio, ch_note, msg);
|
||||
else
|
||||
{
|
||||
strncpy (buf, msg, len - 1);
|
||||
buf[len - 1] = '\0';
|
||||
mvwprintw (w, y, x, "%d%c %s...", prio, ch_note, buf);
|
||||
}
|
||||
if (incolor == 0)
|
||||
custom_remove_attr (w, ATTR_HIGHEST);
|
||||
}
|
||||
|
||||
/* Updates the ToDo panel. */
|
||||
void
|
||||
todo_update_panel(window_t *wintod, int which_pan)
|
||||
void
|
||||
todo_update_panel (window_t *wintod, int which_pan)
|
||||
{
|
||||
struct todo_s *i;
|
||||
int len = wintod->w - 8;
|
||||
int num_todo = 0;
|
||||
int y_offset = 3, x_offset = 1;
|
||||
int t_realpos = -1;
|
||||
int title_lines = 3;
|
||||
int todo_lines = 1;
|
||||
int max_items = wintod->h - 4;
|
||||
int incolor = -1;
|
||||
struct todo_s *i;
|
||||
int len = wintod->w - 8;
|
||||
int num_todo = 0;
|
||||
int y_offset = 3, x_offset = 1;
|
||||
int t_realpos = -1;
|
||||
int title_lines = 3;
|
||||
int todo_lines = 1;
|
||||
int max_items = wintod->h - 4;
|
||||
int incolor = -1;
|
||||
|
||||
/* Print todo item in the panel. */
|
||||
erase_window_part(win[TOD].p, 1, title_lines, wintod->w - 2,
|
||||
wintod->h - 2);
|
||||
for (i = todolist; i != 0; i = i->next) {
|
||||
num_todo++;
|
||||
t_realpos = num_todo - first;
|
||||
incolor = num_todo - hilt;
|
||||
if (incolor == 0)
|
||||
msgsav = i->mesg;
|
||||
if (t_realpos >= 0 && t_realpos < max_items) {
|
||||
display_todo_item(incolor, i->mesg, i->id,
|
||||
(i->note != NULL) ? 1 : 0, len, y_offset, x_offset);
|
||||
y_offset = y_offset + todo_lines;
|
||||
}
|
||||
/* Print todo item in the panel. */
|
||||
erase_window_part (win[TOD].p, 1, title_lines, wintod->w - 2, wintod->h - 2);
|
||||
for (i = todolist; i != 0; i = i->next)
|
||||
{
|
||||
num_todo++;
|
||||
t_realpos = num_todo - first;
|
||||
incolor = num_todo - hilt;
|
||||
if (incolor == 0)
|
||||
msgsav = i->mesg;
|
||||
if (t_realpos >= 0 && t_realpos < max_items)
|
||||
{
|
||||
display_todo_item (incolor, i->mesg, i->id,
|
||||
(i->note != NULL) ? 1 : 0, len, y_offset,
|
||||
x_offset);
|
||||
y_offset = y_offset + todo_lines;
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw the scrollbar if necessary. */
|
||||
if (todos > max_items){
|
||||
float ratio = ((float) max_items) / ((float) todos);
|
||||
int sbar_length = (int) (ratio * (max_items + 1));
|
||||
int highend = (int) (ratio * first);
|
||||
bool hilt_bar = (which_pan == TOD) ? true : false;
|
||||
int sbar_top = highend + title_lines;
|
||||
|
||||
if ((sbar_top + sbar_length) > wintod->h - 1)
|
||||
sbar_length = wintod->h - 1 - sbar_top;
|
||||
draw_scrollbar(win[TOD].p, sbar_top, wintod->w - 2,
|
||||
sbar_length, title_lines, wintod->h - 1, hilt_bar);
|
||||
}
|
||||
|
||||
wnoutrefresh(win[TOD].p);
|
||||
/* Draw the scrollbar if necessary. */
|
||||
if (todos > max_items)
|
||||
{
|
||||
float ratio = ((float) max_items) / ((float) todos);
|
||||
int sbar_length = (int) (ratio * (max_items + 1));
|
||||
int highend = (int) (ratio * first);
|
||||
bool hilt_bar = (which_pan == TOD) ? true : false;
|
||||
int sbar_top = highend + title_lines;
|
||||
|
||||
if ((sbar_top + sbar_length) > wintod->h - 1)
|
||||
sbar_length = wintod->h - 1 - sbar_top;
|
||||
draw_scrollbar (win[TOD].p, sbar_top, wintod->w - 2,
|
||||
sbar_length, title_lines, wintod->h - 1, hilt_bar);
|
||||
}
|
||||
|
||||
wnoutrefresh (win[TOD].p);
|
||||
}
|
||||
|
||||
/* Attach a note to a todo */
|
||||
void
|
||||
todo_edit_note(char *editor)
|
||||
void
|
||||
todo_edit_note (char *editor)
|
||||
{
|
||||
struct todo_s *i;
|
||||
char fullname[BUFSIZ];
|
||||
char *filename;
|
||||
struct todo_s *i;
|
||||
char fullname[BUFSIZ];
|
||||
char *filename;
|
||||
|
||||
i = todo_get_item(hilt);
|
||||
if (i->note == NULL) {
|
||||
if ((filename = new_tempfile(path_notes, NOTESIZ))
|
||||
!= NULL)
|
||||
i->note = filename;
|
||||
else
|
||||
return;
|
||||
}
|
||||
snprintf(fullname, BUFSIZ, "%s%s", path_notes, i->note);
|
||||
wins_launch_external(fullname, editor);
|
||||
i = todo_get_item (hilt);
|
||||
if (i->note == NULL)
|
||||
{
|
||||
if ((filename = new_tempfile (path_notes, NOTESIZ)) != NULL)
|
||||
i->note = filename;
|
||||
else
|
||||
return;
|
||||
}
|
||||
snprintf (fullname, BUFSIZ, "%s%s", path_notes, i->note);
|
||||
wins_launch_external (fullname, editor);
|
||||
}
|
||||
|
||||
/* View a note previously attached to a todo */
|
||||
void
|
||||
todo_view_note(char *pager)
|
||||
void
|
||||
todo_view_note (char *pager)
|
||||
{
|
||||
struct todo_s *i;
|
||||
char fullname[BUFSIZ];
|
||||
struct todo_s *i;
|
||||
char fullname[BUFSIZ];
|
||||
|
||||
i = todo_get_item(hilt);
|
||||
if (i->note == NULL)
|
||||
return;
|
||||
snprintf(fullname, BUFSIZ, "%s%s", path_notes, i->note);
|
||||
wins_launch_external(fullname, pager);
|
||||
i = todo_get_item (hilt);
|
||||
if (i->note == NULL)
|
||||
return;
|
||||
snprintf (fullname, BUFSIZ, "%s%s", path_notes, i->note);
|
||||
wins_launch_external (fullname, pager);
|
||||
}
|
||||
|
53
src/todo.h
53
src/todo.h
@ -1,8 +1,8 @@
|
||||
/* $calcurse: todo.h,v 1.10 2007/12/30 16:27:59 culot Exp $ */
|
||||
/* $calcurse: todo.h,v 1.11 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
* Copyright (c) 2004-2007 Frederic Culot
|
||||
* Copyright (c) 2004-2008 Frederic Culot
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -29,33 +29,34 @@
|
||||
|
||||
#include "wins.h"
|
||||
|
||||
struct todo_s {
|
||||
struct todo_s *next;
|
||||
char *mesg;
|
||||
int id;
|
||||
char *note;
|
||||
struct todo_s
|
||||
{
|
||||
struct todo_s *next;
|
||||
char *mesg;
|
||||
int id;
|
||||
char *note;
|
||||
};
|
||||
|
||||
extern struct todo_s *todolist;
|
||||
|
||||
void todo_hilt_set(int);
|
||||
void todo_hilt_decrease(void);
|
||||
void todo_hilt_increase(void);
|
||||
int todo_hilt(void);
|
||||
int todo_nb(void);
|
||||
void todo_set_nb(int);
|
||||
void todo_set_first(int);
|
||||
void todo_first_increase(void);
|
||||
void todo_first_decrease(void);
|
||||
int todo_hilt_pos(void);
|
||||
char *todo_saved_mesg(void);
|
||||
void todo_new_item(void);
|
||||
struct todo_s *todo_add(char *, int, char *);
|
||||
void todo_delete(conf_t *);
|
||||
void todo_chg_priority(int);
|
||||
void todo_edit_item(void);
|
||||
void todo_update_panel(window_t *, int);
|
||||
void todo_edit_note(char *);
|
||||
void todo_view_note(char *);
|
||||
void todo_hilt_set (int);
|
||||
void todo_hilt_decrease (void);
|
||||
void todo_hilt_increase (void);
|
||||
int todo_hilt (void);
|
||||
int todo_nb (void);
|
||||
void todo_set_nb (int);
|
||||
void todo_set_first (int);
|
||||
void todo_first_increase (void);
|
||||
void todo_first_decrease (void);
|
||||
int todo_hilt_pos (void);
|
||||
char *todo_saved_mesg (void);
|
||||
void todo_new_item (void);
|
||||
struct todo_s *todo_add (char *, int, char *);
|
||||
void todo_delete (conf_t *);
|
||||
void todo_chg_priority (int);
|
||||
void todo_edit_item (void);
|
||||
void todo_update_panel (window_t *, int);
|
||||
void todo_edit_note (char *);
|
||||
void todo_view_note (char *);
|
||||
|
||||
#endif /* CALCURSE_TODO_H */
|
||||
|
1288
src/utils.c
1288
src/utils.c
File diff suppressed because it is too large
Load Diff
124
src/utils.h
124
src/utils.h
@ -1,4 +1,4 @@
|
||||
/* $calcurse: utils.h,v 1.28 2008/04/09 20:38:29 culot Exp $ */
|
||||
/* $calcurse: utils.h,v 1.29 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -36,70 +36,76 @@
|
||||
((e) ? (void)0 : aerror(__FILE__, __LINE__, #e)); \
|
||||
} while (0)
|
||||
|
||||
#define SPC 32 /* ASCII code for white space */
|
||||
#define SPC 32 /* ASCII code for white space */
|
||||
|
||||
#define NB_CAL_CMDS 16 /* number of commands while in cal view */
|
||||
#define NB_APP_CMDS 23 /* same thing while in appointment view */
|
||||
#define NB_TOD_CMDS 22 /* same thing while in todo view */
|
||||
#define NB_CAL_CMDS 16 /* number of commands while in cal view */
|
||||
#define NB_APP_CMDS 23 /* same thing while in appointment view */
|
||||
#define NB_TOD_CMDS 22 /* same thing while in todo view */
|
||||
#define TOTAL_CMDS NB_CAL_CMDS + NB_APP_CMDS + NB_TOD_CMDS
|
||||
#define NB_PANELS 3 /* 3 panels: CALENDAR, APPOINTMENT, TODO */
|
||||
#define CMDS_PER_LINE 6 /* max number of commands per line */
|
||||
#define KEY_LENGTH 4 /* length of each keybinding + one space */
|
||||
#define LABEL_LENGTH 8 /* length of command description */
|
||||
#define NB_PANELS 3 /* 3 panels: CALENDAR, APPOINTMENT, TODO */
|
||||
#define CMDS_PER_LINE 6 /* max number of commands per line */
|
||||
#define KEY_LENGTH 4 /* length of each keybinding + one space */
|
||||
#define LABEL_LENGTH 8 /* length of command description */
|
||||
|
||||
#define GETSTRING_VALID 0 /* value returned by getstring() if text is valid */
|
||||
#define GETSTRING_ESC 1 /* user pressed escape to cancel editing */
|
||||
#define GETSTRING_RET 2 /* return was pressed without entering any text */
|
||||
#define GETSTRING_VALID 0 /* value returned by getstring() if text is valid */
|
||||
#define GETSTRING_ESC 1 /* user pressed escape to cancel editing */
|
||||
#define GETSTRING_RET 2 /* return was pressed without entering any text */
|
||||
|
||||
typedef struct { /* structure defining a keybinding */
|
||||
char *key;
|
||||
char *label;
|
||||
} binding_t;
|
||||
typedef struct
|
||||
{ /* structure defining a keybinding */
|
||||
char *key;
|
||||
char *label;
|
||||
}
|
||||
binding_t;
|
||||
|
||||
typedef enum {
|
||||
IERROR_FATAL,
|
||||
IERROR_WARN
|
||||
} ierror_sev_e;
|
||||
typedef enum
|
||||
{
|
||||
IERROR_FATAL,
|
||||
IERROR_WARN
|
||||
}
|
||||
ierror_sev_e;
|
||||
|
||||
typedef enum {
|
||||
ERASE_DONT_FORCE,
|
||||
ERASE_FORCE,
|
||||
ERASE_FORCE_KEEP_NOTE,
|
||||
ERASE_FORCE_ONLY_NOTE
|
||||
} erase_flag_e;
|
||||
typedef enum
|
||||
{
|
||||
ERASE_DONT_FORCE,
|
||||
ERASE_FORCE,
|
||||
ERASE_FORCE_KEEP_NOTE,
|
||||
ERASE_FORCE_ONLY_NOTE
|
||||
}
|
||||
erase_flag_e;
|
||||
|
||||
void exit_calcurse(int);
|
||||
void ierror(const char *, ierror_sev_e);
|
||||
void aerror(const char *, int, const char *);
|
||||
void status_mesg(char *, char *);
|
||||
void erase_status_bar(void);
|
||||
void erase_window_part(WINDOW *, int, int, int, int);
|
||||
WINDOW *popup(int, int, int, int, char *);
|
||||
void print_in_middle(WINDOW *, int, int, int, char *);
|
||||
int getstring(WINDOW *, char *, int, int, int);
|
||||
int updatestring(WINDOW *, char **, int, int);
|
||||
int is_all_digit(char *);
|
||||
void status_bar(void);
|
||||
long date2sec(date_t, unsigned, unsigned);
|
||||
char *date_sec2hour_str(long);
|
||||
char *date_sec2date_str(long, char *);
|
||||
void date_sec2ical_date(long, char *);
|
||||
void date_sec2ical_datetime(long, char *);
|
||||
long update_time_in_date(long, unsigned, unsigned);
|
||||
long get_sec_date(date_t);
|
||||
long min2sec(unsigned);
|
||||
int check_time(char *);
|
||||
void draw_scrollbar(WINDOW *, int, int, int, int, int, bool);
|
||||
void item_in_popup(char *, char *, char *, char *);
|
||||
void reset_status_page(void);
|
||||
void other_status_page(int);
|
||||
long get_today(void);
|
||||
long now(void);
|
||||
char *mycpy(const char *);
|
||||
long mystrtol(const char *);
|
||||
void print_option_incolor(WINDOW *, bool, int, int);
|
||||
char *new_tempfile(const char *, int);
|
||||
void erase_note(char **, erase_flag_e);
|
||||
int parse_date(char *, int, int *, int *, int *);
|
||||
void exit_calcurse (int);
|
||||
void ierror (const char *, ierror_sev_e);
|
||||
void aerror (const char *, int, const char *);
|
||||
void status_mesg (char *, char *);
|
||||
void erase_status_bar (void);
|
||||
void erase_window_part (WINDOW *, int, int, int, int);
|
||||
WINDOW *popup (int, int, int, int, char *);
|
||||
void print_in_middle (WINDOW *, int, int, int, char *);
|
||||
int getstring (WINDOW *, char *, int, int, int);
|
||||
int updatestring (WINDOW *, char **, int, int);
|
||||
int is_all_digit (char *);
|
||||
void status_bar (void);
|
||||
long date2sec (date_t, unsigned, unsigned);
|
||||
char *date_sec2hour_str (long);
|
||||
char *date_sec2date_str (long, char *);
|
||||
void date_sec2ical_date (long, char *);
|
||||
void date_sec2ical_datetime (long, char *);
|
||||
long update_time_in_date (long, unsigned, unsigned);
|
||||
long get_sec_date (date_t);
|
||||
long min2sec (unsigned);
|
||||
int check_time (char *);
|
||||
void draw_scrollbar (WINDOW *, int, int, int, int, int, bool);
|
||||
void item_in_popup (char *, char *, char *, char *);
|
||||
void reset_status_page (void);
|
||||
void other_status_page (int);
|
||||
long get_today (void);
|
||||
long now (void);
|
||||
char *mycpy (const char *);
|
||||
long mystrtol (const char *);
|
||||
void print_option_incolor (WINDOW *, bool, int, int);
|
||||
char *new_tempfile (const char *, int);
|
||||
void erase_note (char **, erase_flag_e);
|
||||
int parse_date (char *, int, int *, int *, int *);
|
||||
|
||||
#endif /* CALCURSE_UTILS_H */
|
||||
|
119
src/vars.c
119
src/vars.c
@ -1,4 +1,4 @@
|
||||
/* $calcurse: vars.c,v 1.7 2008/04/09 20:38:29 culot Exp $ */
|
||||
/* $calcurse: vars.c,v 1.8 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -45,29 +45,31 @@ bool colorize = false;
|
||||
* variables to store calendar names
|
||||
*/
|
||||
int days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
char *monthnames[12] =
|
||||
{ N_("January"),
|
||||
N_("February"),
|
||||
N_("March"),
|
||||
N_("April"),
|
||||
N_("May"),
|
||||
N_("June"),
|
||||
N_("July"),
|
||||
N_("August"),
|
||||
N_("September"),
|
||||
N_("October"),
|
||||
N_("November"),
|
||||
N_("December") };
|
||||
char *monthnames[12] = {
|
||||
N_("January"),
|
||||
N_("February"),
|
||||
N_("March"),
|
||||
N_("April"),
|
||||
N_("May"),
|
||||
N_("June"),
|
||||
N_("July"),
|
||||
N_("August"),
|
||||
N_("September"),
|
||||
N_("October"),
|
||||
N_("November"),
|
||||
N_("December")
|
||||
};
|
||||
|
||||
char *daynames[8] =
|
||||
{ N_("Sun"),
|
||||
N_("Mon"),
|
||||
N_("Tue"),
|
||||
N_("Wed"),
|
||||
N_("Thu"),
|
||||
N_("Fri"),
|
||||
N_("Sat"),
|
||||
N_("Sun") };
|
||||
char *daynames[8] = {
|
||||
N_("Sun"),
|
||||
N_("Mon"),
|
||||
N_("Tue"),
|
||||
N_("Wed"),
|
||||
N_("Thu"),
|
||||
N_("Fri"),
|
||||
N_("Sat"),
|
||||
N_("Sun")
|
||||
};
|
||||
|
||||
/*
|
||||
* variables to store data path names, which are initialized in
|
||||
@ -85,51 +87,50 @@ struct pad_s *apad;
|
||||
/* Variable to store notify-bar settings. */
|
||||
struct nbar_s *nbar;
|
||||
|
||||
|
||||
/*
|
||||
* Variables init
|
||||
*/
|
||||
void
|
||||
vars_init(conf_t *conf)
|
||||
void
|
||||
vars_init (conf_t *conf)
|
||||
{
|
||||
char *PATH_VI = "/usr/bin/vi";
|
||||
char *PATH_LESS = "/usr/bin/less";
|
||||
char *ed, *pg;
|
||||
char *PATH_VI = "/usr/bin/vi";
|
||||
char *PATH_LESS = "/usr/bin/less";
|
||||
char *ed, *pg;
|
||||
|
||||
/* Variables for user configuration */
|
||||
conf->confirm_quit = true;
|
||||
conf->confirm_delete = true;
|
||||
conf->auto_save = true;
|
||||
conf->skip_system_dialogs = false;
|
||||
conf->skip_progress_bar = false;
|
||||
strncpy(conf->output_datefmt, "%D", 3);
|
||||
conf->input_datefmt = 1;
|
||||
/* Variables for user configuration */
|
||||
conf->confirm_quit = true;
|
||||
conf->confirm_delete = true;
|
||||
conf->auto_save = true;
|
||||
conf->skip_system_dialogs = false;
|
||||
conf->skip_progress_bar = false;
|
||||
strncpy (conf->output_datefmt, "%D", 3);
|
||||
conf->input_datefmt = 1;
|
||||
|
||||
/* Default external editor and pager */
|
||||
ed = getenv("VISUAL");
|
||||
if (ed == NULL || ed[0] == '\0')
|
||||
ed = getenv("EDITOR");
|
||||
if (ed == NULL || ed[0] == '\0')
|
||||
ed = PATH_VI;
|
||||
conf->editor = ed;
|
||||
/* Default external editor and pager */
|
||||
ed = getenv ("VISUAL");
|
||||
if (ed == NULL || ed[0] == '\0')
|
||||
ed = getenv ("EDITOR");
|
||||
if (ed == NULL || ed[0] == '\0')
|
||||
ed = PATH_VI;
|
||||
conf->editor = ed;
|
||||
|
||||
pg = getenv("PAGER");
|
||||
if (pg == NULL || pg[0] == '\0')
|
||||
pg = PATH_LESS;
|
||||
conf->pager = pg;
|
||||
pg = getenv ("PAGER");
|
||||
if (pg == NULL || pg[0] == '\0')
|
||||
pg = PATH_LESS;
|
||||
conf->pager = pg;
|
||||
|
||||
wins_set_layout(1);
|
||||
wins_set_layout (1);
|
||||
|
||||
calendar_set_first_day_of_week(MONDAY);
|
||||
calendar_set_first_day_of_week (MONDAY);
|
||||
|
||||
/* Pad structure to scroll text inside the appointment panel */
|
||||
apad = (struct pad_s *) malloc(sizeof(struct pad_s));
|
||||
apad->length = 1;
|
||||
apad->first_onscreen = 0;
|
||||
/* Pad structure to scroll text inside the appointment panel */
|
||||
apad = (struct pad_s *) malloc (sizeof (struct pad_s));
|
||||
apad->length = 1;
|
||||
apad->first_onscreen = 0;
|
||||
|
||||
/* Attribute definitions for color and non-color terminals */
|
||||
custom_init_attr();
|
||||
|
||||
/* Start at the current date */
|
||||
calendar_init_slctd_day();
|
||||
/* Attribute definitions for color and non-color terminals */
|
||||
custom_init_attr ();
|
||||
|
||||
/* Start at the current date */
|
||||
calendar_init_slctd_day ();
|
||||
}
|
||||
|
86
src/vars.h
86
src/vars.h
@ -1,4 +1,4 @@
|
||||
/* $calcurse: vars.h,v 1.21 2008/04/09 20:38:29 culot Exp $ */
|
||||
/* $calcurse: vars.h,v 1.22 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -27,7 +27,7 @@
|
||||
#ifndef CALCURSE_VARS_H
|
||||
#define CALCURSE_VARS_H
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <ncurses.h>
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
#define ATTR_HIGH 5
|
||||
#define ATTR_HIGHEST 6
|
||||
|
||||
#define DAYINSEC 86400
|
||||
#define DAYINSEC 86400
|
||||
#define HOURINSEC 3600
|
||||
#define MININSEC 60
|
||||
#define WEEKINDAYS 7
|
||||
@ -61,50 +61,54 @@
|
||||
#define DATEFMT_DESC(datefmt) (datefmt == 1 ? _("mm/dd/yyyy") : \
|
||||
(datefmt == 2 ? _("dd/mm/yyyy") : _("yyyy/mm/dd")))
|
||||
|
||||
struct pad_s {
|
||||
int width;
|
||||
int length;
|
||||
int first_onscreen; /* first line to be displayed inside window */
|
||||
WINDOW *ptrwin; /* pointer to the pad window */
|
||||
struct pad_s
|
||||
{
|
||||
int width;
|
||||
int length;
|
||||
int first_onscreen; /* first line to be displayed inside window */
|
||||
WINDOW *ptrwin; /* pointer to the pad window */
|
||||
};
|
||||
|
||||
struct nbar_s {
|
||||
int show; /* display or hide the notify-bar */
|
||||
int cntdwn; /* warn when time left before next app
|
||||
* becomes lesser than cntdwn */
|
||||
char datefmt[BUFSIZ]; /* format for displaying date */
|
||||
char timefmt[BUFSIZ]; /* format for displaying time */
|
||||
char cmd[BUFSIZ]; /* notification command */
|
||||
char *shell; /* user shell to launch notif. cmd */
|
||||
pthread_mutex_t mutex;
|
||||
struct nbar_s
|
||||
{
|
||||
int show; /* display or hide the notify-bar */
|
||||
int cntdwn; /* warn when time left before next app
|
||||
* becomes lesser than cntdwn */
|
||||
char datefmt[BUFSIZ]; /* format for displaying date */
|
||||
char timefmt[BUFSIZ]; /* format for displaying time */
|
||||
char cmd[BUFSIZ]; /* notification command */
|
||||
char *shell; /* user shell to launch notif. cmd */
|
||||
pthread_mutex_t mutex;
|
||||
};
|
||||
|
||||
/* General configuration variables */
|
||||
typedef struct {
|
||||
bool auto_save;
|
||||
bool confirm_quit;
|
||||
bool confirm_delete;
|
||||
bool skip_system_dialogs;
|
||||
bool skip_progress_bar;
|
||||
char *editor;
|
||||
char *pager;
|
||||
char output_datefmt[BUFSIZ]; /* format for displaying date */
|
||||
int input_datefmt; /* format for reading date */
|
||||
} conf_t;
|
||||
typedef struct
|
||||
{
|
||||
bool auto_save;
|
||||
bool confirm_quit;
|
||||
bool confirm_delete;
|
||||
bool skip_system_dialogs;
|
||||
bool skip_progress_bar;
|
||||
char *editor;
|
||||
char *pager;
|
||||
char output_datefmt[BUFSIZ]; /* format for displaying date */
|
||||
int input_datefmt; /* format for reading date */
|
||||
}
|
||||
conf_t;
|
||||
|
||||
extern int col, row;
|
||||
extern bool colorize;
|
||||
extern int days[12];
|
||||
extern char *monthnames[12];
|
||||
extern char *daynames[8];
|
||||
extern char path_dir[BUFSIZ];
|
||||
extern char path_todo[BUFSIZ];
|
||||
extern char path_apts[BUFSIZ];
|
||||
extern char path_conf[BUFSIZ];
|
||||
extern char path_notes[BUFSIZ];
|
||||
extern struct pad_s *apad;
|
||||
extern struct nbar_s *nbar;
|
||||
extern int col, row;
|
||||
extern bool colorize;
|
||||
extern int days[12];
|
||||
extern char *monthnames[12];
|
||||
extern char *daynames[8];
|
||||
extern char path_dir[BUFSIZ];
|
||||
extern char path_todo[BUFSIZ];
|
||||
extern char path_apts[BUFSIZ];
|
||||
extern char path_conf[BUFSIZ];
|
||||
extern char path_notes[BUFSIZ];
|
||||
extern struct pad_s *apad;
|
||||
extern struct nbar_s *nbar;
|
||||
|
||||
void vars_init(conf_t *conf);
|
||||
void vars_init (conf_t *conf);
|
||||
|
||||
#endif /* CALCURSE_VARS_H */
|
||||
|
543
src/wins.c
543
src/wins.c
@ -1,8 +1,8 @@
|
||||
/* $calcurse: wins.c,v 1.12 2008/02/14 20:20:23 culot Exp $ */
|
||||
/* $calcurse: wins.c,v 1.13 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
* Copyright (c) 2007 Frederic Culot
|
||||
* Copyright (c) 2007-2008 Frederic Culot
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -37,331 +37,344 @@
|
||||
/* Variables to handle calcurse windows. */
|
||||
window_t win[NBWINS];
|
||||
|
||||
static window_e slctd_win;
|
||||
static int layout;
|
||||
static window_e slctd_win;
|
||||
static int layout;
|
||||
|
||||
/* Get the current layout. */
|
||||
int
|
||||
wins_layout(void)
|
||||
wins_layout (void)
|
||||
{
|
||||
return (layout);
|
||||
return (layout);
|
||||
}
|
||||
|
||||
/* Set the current layout. */
|
||||
void
|
||||
wins_set_layout(int nb)
|
||||
wins_set_layout (int nb)
|
||||
{
|
||||
layout = nb;
|
||||
layout = nb;
|
||||
}
|
||||
|
||||
/* Initialize the selected window in calcurse's interface. */
|
||||
void
|
||||
wins_slctd_init(void)
|
||||
wins_slctd_init (void)
|
||||
{
|
||||
wins_slctd_set(CAL);
|
||||
wins_slctd_set (CAL);
|
||||
}
|
||||
|
||||
/* Returns an enum which corresponds to the window which is selected. */
|
||||
window_e
|
||||
wins_slctd(void)
|
||||
wins_slctd (void)
|
||||
{
|
||||
return (slctd_win);
|
||||
return (slctd_win);
|
||||
}
|
||||
|
||||
/* Sets the selected window. */
|
||||
void
|
||||
wins_slctd_set(window_e window)
|
||||
wins_slctd_set (window_e window)
|
||||
{
|
||||
slctd_win = window;
|
||||
slctd_win = window;
|
||||
}
|
||||
|
||||
/* TAB key was hit in the interface, need to select next window. */
|
||||
void
|
||||
wins_slctd_next(void)
|
||||
wins_slctd_next (void)
|
||||
{
|
||||
if (slctd_win == TOD)
|
||||
slctd_win = CAL;
|
||||
else
|
||||
slctd_win++;
|
||||
if (slctd_win == TOD)
|
||||
slctd_win = CAL;
|
||||
else
|
||||
slctd_win++;
|
||||
}
|
||||
|
||||
/* Create all the windows. */
|
||||
void
|
||||
wins_init(void)
|
||||
void
|
||||
wins_init (void)
|
||||
{
|
||||
char label[BUFSIZ];
|
||||
|
||||
/*
|
||||
* Create the three main windows plus the status bar and the pad used to
|
||||
* display appointments and event.
|
||||
*/
|
||||
win[CAL].p = newwin(CALHEIGHT, CALWIDTH, win[CAL].y, win[CAL].x);
|
||||
snprintf(label, BUFSIZ, _("Calendar"));
|
||||
wins_show(win[CAL].p, label);
|
||||
char label[BUFSIZ];
|
||||
|
||||
win[APP].p = newwin(win[APP].h, win[APP].w, win[APP].y, win[APP].x);
|
||||
snprintf(label, BUFSIZ, _("Appointments"));
|
||||
wins_show(win[APP].p, label);
|
||||
apad->width = win[APP].w - 3;
|
||||
apad->ptrwin = newpad(apad->length, apad->width);
|
||||
/*
|
||||
* Create the three main windows plus the status bar and the pad used to
|
||||
* display appointments and event.
|
||||
*/
|
||||
win[CAL].p = newwin (CALHEIGHT, CALWIDTH, win[CAL].y, win[CAL].x);
|
||||
snprintf (label, BUFSIZ, _("Calendar"));
|
||||
wins_show (win[CAL].p, label);
|
||||
|
||||
win[TOD].p = newwin(win[TOD].h, win[TOD].w, win[TOD].y, win[TOD].x);
|
||||
snprintf(label, BUFSIZ, _("ToDo"));
|
||||
wins_show(win[TOD].p, label);
|
||||
win[APP].p = newwin (win[APP].h, win[APP].w, win[APP].y, win[APP].x);
|
||||
snprintf (label, BUFSIZ, _("Appointments"));
|
||||
wins_show (win[APP].p, label);
|
||||
apad->width = win[APP].w - 3;
|
||||
apad->ptrwin = newpad (apad->length, apad->width);
|
||||
|
||||
win[STA].p = newwin(win[STA].h, win[STA].w, win[STA].y, win[STA].x);
|
||||
win[TOD].p = newwin (win[TOD].h, win[TOD].w, win[TOD].y, win[TOD].x);
|
||||
snprintf (label, BUFSIZ, _("ToDo"));
|
||||
wins_show (win[TOD].p, label);
|
||||
|
||||
/* Enable function keys (i.e. arrow keys) in those windows */
|
||||
keypad(win[CAL].p, TRUE);
|
||||
keypad(win[APP].p, TRUE);
|
||||
keypad(win[TOD].p, TRUE);
|
||||
keypad(win[STA].p, TRUE);
|
||||
win[STA].p = newwin (win[STA].h, win[STA].w, win[STA].y, win[STA].x);
|
||||
|
||||
/* Enable function keys (i.e. arrow keys) in those windows */
|
||||
keypad (win[CAL].p, TRUE);
|
||||
keypad (win[APP].p, TRUE);
|
||||
keypad (win[TOD].p, TRUE);
|
||||
keypad (win[STA].p, TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete the existing windows and recreate them with their new
|
||||
* size and placement.
|
||||
*/
|
||||
void
|
||||
wins_reinit(void)
|
||||
void
|
||||
wins_reinit (void)
|
||||
{
|
||||
delwin(win[STA].p);
|
||||
delwin(win[CAL].p);
|
||||
delwin(win[APP].p);
|
||||
delwin(apad->ptrwin);
|
||||
delwin(win[TOD].p);
|
||||
wins_get_config();
|
||||
wins_init();
|
||||
if (notify_bar())
|
||||
notify_reinit_bar(win[NOT].h, win[NOT].w, win[NOT].y,
|
||||
win[NOT].x);
|
||||
delwin (win[STA].p);
|
||||
delwin (win[CAL].p);
|
||||
delwin (win[APP].p);
|
||||
delwin (apad->ptrwin);
|
||||
delwin (win[TOD].p);
|
||||
wins_get_config ();
|
||||
wins_init ();
|
||||
if (notify_bar ())
|
||||
notify_reinit_bar (win[NOT].h, win[NOT].w, win[NOT].y, win[NOT].x);
|
||||
}
|
||||
|
||||
/* Show the window with a border and a label. */
|
||||
void
|
||||
wins_show(WINDOW * win, char *label)
|
||||
void
|
||||
wins_show (WINDOW *win, char *label)
|
||||
{
|
||||
int startx, starty, height, width;
|
||||
int startx, starty, height, width;
|
||||
|
||||
getbegyx(win, starty, startx);
|
||||
getmaxyx(win, height, width);
|
||||
getbegyx (win, starty, startx);
|
||||
getmaxyx (win, height, width);
|
||||
|
||||
box(win, 0, 0);
|
||||
mvwaddch(win, 2, 0, ACS_LTEE);
|
||||
mvwhline(win, 2, 1, ACS_HLINE, width - 2);
|
||||
mvwaddch(win, 2, width - 1, ACS_RTEE);
|
||||
box (win, 0, 0);
|
||||
mvwaddch (win, 2, 0, ACS_LTEE);
|
||||
mvwhline (win, 2, 1, ACS_HLINE, width - 2);
|
||||
mvwaddch (win, 2, width - 1, ACS_RTEE);
|
||||
|
||||
print_in_middle(win, 1, 0, width, label);
|
||||
print_in_middle (win, 1, 0, width, label);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the screen size and recalculate the windows configurations.
|
||||
*/
|
||||
void
|
||||
wins_get_config(void)
|
||||
void
|
||||
wins_get_config (void)
|
||||
{
|
||||
/* Get the screen configuration */
|
||||
getmaxyx(stdscr, row, col);
|
||||
/* Get the screen configuration */
|
||||
getmaxyx (stdscr, row, col);
|
||||
|
||||
/* fixed values for status, notification bars and calendar */
|
||||
win[STA].h = STATUSHEIGHT;
|
||||
win[STA].w = col;
|
||||
win[STA].y = row - win[STA].h;
|
||||
win[STA].x = 0;
|
||||
/* fixed values for status, notification bars and calendar */
|
||||
win[STA].h = STATUSHEIGHT;
|
||||
win[STA].w = col;
|
||||
win[STA].y = row - win[STA].h;
|
||||
win[STA].x = 0;
|
||||
|
||||
if (notify_bar()) {
|
||||
win[NOT].h = 1;
|
||||
win[NOT].w = col;
|
||||
win[NOT].y = win[STA].y - 1;
|
||||
win[NOT].x = 0;
|
||||
} else {
|
||||
win[NOT].h = 0;
|
||||
win[NOT].w = 0;
|
||||
win[NOT].y = 0;
|
||||
win[NOT].x = 0;
|
||||
}
|
||||
if (notify_bar ())
|
||||
{
|
||||
win[NOT].h = 1;
|
||||
win[NOT].w = col;
|
||||
win[NOT].y = win[STA].y - 1;
|
||||
win[NOT].x = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
win[NOT].h = 0;
|
||||
win[NOT].w = 0;
|
||||
win[NOT].y = 0;
|
||||
win[NOT].x = 0;
|
||||
}
|
||||
|
||||
if (layout <= 4) { /* APPOINTMENT is the biggest panel */
|
||||
win[APP].w = col - CALWIDTH;
|
||||
win[APP].h = row - (win[STA].h + win[NOT].h);
|
||||
win[TOD].w = CALWIDTH;
|
||||
win[TOD].h = row - (CALHEIGHT + win[STA].h + win[NOT].h);
|
||||
} else { /* TODO is the biggest panel */
|
||||
win[TOD].w = col - CALWIDTH;
|
||||
win[TOD].h = row - (win[STA].h + win[NOT].h);
|
||||
win[APP].w = CALWIDTH;
|
||||
win[APP].h = row - (CALHEIGHT + win[STA].h + win[NOT].h);
|
||||
}
|
||||
if (layout <= 4)
|
||||
{ /* APPOINTMENT is the biggest panel */
|
||||
win[APP].w = col - CALWIDTH;
|
||||
win[APP].h = row - (win[STA].h + win[NOT].h);
|
||||
win[TOD].w = CALWIDTH;
|
||||
win[TOD].h = row - (CALHEIGHT + win[STA].h + win[NOT].h);
|
||||
}
|
||||
else
|
||||
{ /* TODO is the biggest panel */
|
||||
win[TOD].w = col - CALWIDTH;
|
||||
win[TOD].h = row - (win[STA].h + win[NOT].h);
|
||||
win[APP].w = CALWIDTH;
|
||||
win[APP].h = row - (CALHEIGHT + win[STA].h + win[NOT].h);
|
||||
}
|
||||
|
||||
/* defining the layout */
|
||||
switch (layout) {
|
||||
case 1:
|
||||
win[APP].y = 0;
|
||||
win[APP].x = 0;
|
||||
win[CAL].y = 0;
|
||||
win[TOD].x = win[APP].w;
|
||||
win[TOD].y = CALHEIGHT;
|
||||
win[CAL].x = win[APP].w;
|
||||
break;
|
||||
case 2:
|
||||
win[APP].y = 0;
|
||||
win[APP].x = 0;
|
||||
win[TOD].y = 0;
|
||||
win[TOD].x = win[APP].w;
|
||||
win[CAL].x = win[APP].w;
|
||||
win[CAL].y = win[TOD].h;
|
||||
break;
|
||||
case 3:
|
||||
win[APP].y = 0;
|
||||
win[TOD].x = 0;
|
||||
win[CAL].x = 0;
|
||||
win[CAL].y = 0;
|
||||
win[APP].x = CALWIDTH;
|
||||
win[TOD].y = CALHEIGHT;
|
||||
break;
|
||||
case 4:
|
||||
win[APP].y = 0;
|
||||
win[TOD].x = 0;
|
||||
win[TOD].y = 0;
|
||||
win[CAL].x = 0;
|
||||
win[APP].x = CALWIDTH;
|
||||
win[CAL].y = win[TOD].h;
|
||||
break;
|
||||
case 5:
|
||||
win[TOD].y = 0;
|
||||
win[TOD].x = 0;
|
||||
win[CAL].y = 0;
|
||||
win[APP].y = CALHEIGHT;
|
||||
win[APP].x = win[TOD].w;
|
||||
win[CAL].x = win[TOD].w;
|
||||
break;
|
||||
case 6:
|
||||
win[TOD].y = 0;
|
||||
win[TOD].x = 0;
|
||||
win[APP].y = 0;
|
||||
win[APP].x = win[TOD].w;
|
||||
win[CAL].x = win[TOD].w;
|
||||
win[CAL].y = win[APP].h;
|
||||
break;
|
||||
case 7:
|
||||
win[TOD].y = 0;
|
||||
win[APP].x = 0;
|
||||
win[CAL].x = 0;
|
||||
win[CAL].y = 0;
|
||||
win[TOD].x = CALWIDTH;
|
||||
win[APP].y = CALHEIGHT;
|
||||
break;
|
||||
case 8:
|
||||
win[TOD].y = 0;
|
||||
win[APP].x = 0;
|
||||
win[CAL].x = 0;
|
||||
win[APP].y = 0;
|
||||
win[TOD].x = CALWIDTH;
|
||||
win[CAL].y = win[APP].h;
|
||||
break;
|
||||
}
|
||||
/* defining the layout */
|
||||
switch (layout)
|
||||
{
|
||||
case 1:
|
||||
win[APP].y = 0;
|
||||
win[APP].x = 0;
|
||||
win[CAL].y = 0;
|
||||
win[TOD].x = win[APP].w;
|
||||
win[TOD].y = CALHEIGHT;
|
||||
win[CAL].x = win[APP].w;
|
||||
break;
|
||||
case 2:
|
||||
win[APP].y = 0;
|
||||
win[APP].x = 0;
|
||||
win[TOD].y = 0;
|
||||
win[TOD].x = win[APP].w;
|
||||
win[CAL].x = win[APP].w;
|
||||
win[CAL].y = win[TOD].h;
|
||||
break;
|
||||
case 3:
|
||||
win[APP].y = 0;
|
||||
win[TOD].x = 0;
|
||||
win[CAL].x = 0;
|
||||
win[CAL].y = 0;
|
||||
win[APP].x = CALWIDTH;
|
||||
win[TOD].y = CALHEIGHT;
|
||||
break;
|
||||
case 4:
|
||||
win[APP].y = 0;
|
||||
win[TOD].x = 0;
|
||||
win[TOD].y = 0;
|
||||
win[CAL].x = 0;
|
||||
win[APP].x = CALWIDTH;
|
||||
win[CAL].y = win[TOD].h;
|
||||
break;
|
||||
case 5:
|
||||
win[TOD].y = 0;
|
||||
win[TOD].x = 0;
|
||||
win[CAL].y = 0;
|
||||
win[APP].y = CALHEIGHT;
|
||||
win[APP].x = win[TOD].w;
|
||||
win[CAL].x = win[TOD].w;
|
||||
break;
|
||||
case 6:
|
||||
win[TOD].y = 0;
|
||||
win[TOD].x = 0;
|
||||
win[APP].y = 0;
|
||||
win[APP].x = win[TOD].w;
|
||||
win[CAL].x = win[TOD].w;
|
||||
win[CAL].y = win[APP].h;
|
||||
break;
|
||||
case 7:
|
||||
win[TOD].y = 0;
|
||||
win[APP].x = 0;
|
||||
win[CAL].x = 0;
|
||||
win[CAL].y = 0;
|
||||
win[TOD].x = CALWIDTH;
|
||||
win[APP].y = CALHEIGHT;
|
||||
break;
|
||||
case 8:
|
||||
win[TOD].y = 0;
|
||||
win[APP].x = 0;
|
||||
win[CAL].x = 0;
|
||||
win[APP].y = 0;
|
||||
win[TOD].x = CALWIDTH;
|
||||
win[CAL].y = win[APP].h;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* draw panel border in color */
|
||||
static void
|
||||
border_color(WINDOW *window)
|
||||
static void
|
||||
border_color (WINDOW *window)
|
||||
{
|
||||
int color_attr = A_BOLD;
|
||||
int no_color_attr = A_BOLD;
|
||||
int color_attr = A_BOLD;
|
||||
int no_color_attr = A_BOLD;
|
||||
|
||||
if (colorize) {
|
||||
wattron(window, color_attr | COLOR_PAIR(COLR_CUSTOM));
|
||||
box(window, 0, 0);
|
||||
} else {
|
||||
wattron(window, no_color_attr);
|
||||
box(window, 0, 0);
|
||||
}
|
||||
|
||||
if (colorize) {
|
||||
wattroff(window, color_attr | COLOR_PAIR(COLR_CUSTOM));
|
||||
} else {
|
||||
wattroff(window, no_color_attr);
|
||||
}
|
||||
|
||||
wnoutrefresh(window);
|
||||
if (colorize)
|
||||
{
|
||||
wattron (window, color_attr | COLOR_PAIR (COLR_CUSTOM));
|
||||
box (window, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
wattron (window, no_color_attr);
|
||||
box (window, 0, 0);
|
||||
}
|
||||
if (colorize)
|
||||
{
|
||||
wattroff (window, color_attr | COLOR_PAIR (COLR_CUSTOM));
|
||||
}
|
||||
else
|
||||
{
|
||||
wattroff (window, no_color_attr);
|
||||
}
|
||||
wnoutrefresh (window);
|
||||
}
|
||||
|
||||
/* draw panel border without any color */
|
||||
static void
|
||||
border_nocolor(WINDOW *window)
|
||||
static void
|
||||
border_nocolor (WINDOW *window)
|
||||
{
|
||||
int color_attr = A_BOLD;
|
||||
int no_color_attr = A_DIM;
|
||||
int color_attr = A_BOLD;
|
||||
int no_color_attr = A_DIM;
|
||||
|
||||
if (colorize) {
|
||||
wattron(window, color_attr | COLOR_PAIR(COLR_DEFAULT));
|
||||
} else {
|
||||
wattron(window, no_color_attr);
|
||||
}
|
||||
|
||||
box(window, 0, 0);
|
||||
|
||||
if (colorize) {
|
||||
wattroff(window, color_attr | COLOR_PAIR(COLR_DEFAULT));
|
||||
} else {
|
||||
wattroff(window, no_color_attr);
|
||||
}
|
||||
|
||||
wnoutrefresh(window);
|
||||
if (colorize)
|
||||
{
|
||||
wattron (window, color_attr | COLOR_PAIR (COLR_DEFAULT));
|
||||
}
|
||||
else
|
||||
{
|
||||
wattron (window, no_color_attr);
|
||||
}
|
||||
box (window, 0, 0);
|
||||
if (colorize)
|
||||
{
|
||||
wattroff (window, color_attr | COLOR_PAIR (COLR_DEFAULT));
|
||||
}
|
||||
else
|
||||
{
|
||||
wattroff (window, no_color_attr);
|
||||
}
|
||||
wnoutrefresh (window);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update all of the three windows and put a border around the
|
||||
* selected window.
|
||||
*/
|
||||
void
|
||||
wins_update(void)
|
||||
void
|
||||
wins_update (void)
|
||||
{
|
||||
switch (slctd_win) {
|
||||
switch (slctd_win)
|
||||
{
|
||||
case CAL:
|
||||
border_color (win[CAL].p);
|
||||
border_nocolor (win[APP].p);
|
||||
border_nocolor (win[TOD].p);
|
||||
break;
|
||||
|
||||
case CAL:
|
||||
border_color(win[CAL].p);
|
||||
border_nocolor(win[APP].p);
|
||||
border_nocolor(win[TOD].p);
|
||||
break;
|
||||
case APP:
|
||||
border_color (win[APP].p);
|
||||
border_nocolor (win[CAL].p);
|
||||
border_nocolor (win[TOD].p);
|
||||
break;
|
||||
|
||||
case APP:
|
||||
border_color(win[APP].p);
|
||||
border_nocolor(win[CAL].p);
|
||||
border_nocolor(win[TOD].p);
|
||||
break;
|
||||
case TOD:
|
||||
border_color (win[TOD].p);
|
||||
border_nocolor (win[APP].p);
|
||||
border_nocolor (win[CAL].p);
|
||||
break;
|
||||
|
||||
case TOD:
|
||||
border_color(win[TOD].p);
|
||||
border_nocolor(win[APP].p);
|
||||
border_nocolor(win[CAL].p);
|
||||
break;
|
||||
default:
|
||||
ierror (_("FATAL ERROR in wins_update: no window selected\n"),
|
||||
IERROR_FATAL);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
default:
|
||||
ierror(_("FATAL ERROR in wins_update: no window selected\n"),
|
||||
IERROR_FATAL);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
apoint_update_panel(&win[APP], slctd_win);
|
||||
todo_update_panel(&win[TOD], slctd_win);
|
||||
calendar_update_panel(win[CAL].p);
|
||||
status_bar();
|
||||
if (notify_bar())
|
||||
notify_update_bar();
|
||||
wmove(win[STA].p, 0, 0);
|
||||
doupdate();
|
||||
apoint_update_panel (&win[APP], slctd_win);
|
||||
todo_update_panel (&win[TOD], slctd_win);
|
||||
calendar_update_panel (win[CAL].p);
|
||||
status_bar ();
|
||||
if (notify_bar ())
|
||||
notify_update_bar ();
|
||||
wmove (win[STA].p, 0, 0);
|
||||
doupdate ();
|
||||
}
|
||||
|
||||
/* Reset the screen, needed when resizing terminal for example. */
|
||||
void
|
||||
wins_reset(void)
|
||||
wins_reset (void)
|
||||
{
|
||||
endwin();
|
||||
refresh();
|
||||
curs_set(0);
|
||||
wins_reinit();
|
||||
wins_update();
|
||||
endwin ();
|
||||
refresh ();
|
||||
curs_set (0);
|
||||
wins_reinit ();
|
||||
wins_update ();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -369,30 +382,32 @@ wins_reset(void)
|
||||
* file.
|
||||
*/
|
||||
void
|
||||
wins_launch_external(const char *file, const char *cmd)
|
||||
wins_launch_external (const char *file, const char *cmd)
|
||||
{
|
||||
char *p;
|
||||
int len;
|
||||
char *p;
|
||||
int len;
|
||||
|
||||
len = strlen(file) + strlen(cmd) + 2; /* Beware of space between cmd and
|
||||
file. */
|
||||
p = (char *)malloc(sizeof(char) * len);
|
||||
if (snprintf(p, len, "%s %s", cmd, file) == -1) {
|
||||
free(p);
|
||||
return;
|
||||
}
|
||||
if (notify_bar())
|
||||
notify_stop_main_thread();
|
||||
def_prog_mode();
|
||||
endwin();
|
||||
clear();
|
||||
refresh();
|
||||
system(p);
|
||||
reset_prog_mode();
|
||||
clearok(curscr, TRUE);
|
||||
curs_set(0);
|
||||
refresh();
|
||||
if (notify_bar())
|
||||
notify_start_main_thread();
|
||||
free(p);
|
||||
/* Beware of space between cmd and file. */
|
||||
len = strlen (file) + strlen (cmd) + 2;
|
||||
|
||||
p = (char *) malloc (sizeof (char) * len);
|
||||
if (snprintf (p, len, "%s %s", cmd, file) == -1)
|
||||
{
|
||||
free (p);
|
||||
return;
|
||||
}
|
||||
if (notify_bar ())
|
||||
notify_stop_main_thread ();
|
||||
def_prog_mode ();
|
||||
endwin ();
|
||||
clear ();
|
||||
refresh ();
|
||||
system (p);
|
||||
reset_prog_mode ();
|
||||
clearok (curscr, TRUE);
|
||||
curs_set (0);
|
||||
refresh ();
|
||||
if (notify_bar ())
|
||||
notify_start_main_thread ();
|
||||
free (p);
|
||||
}
|
||||
|
66
src/wins.h
66
src/wins.h
@ -1,8 +1,8 @@
|
||||
/* $calcurse: wins.h,v 1.6 2008/02/14 20:20:23 culot Exp $ */
|
||||
/* $calcurse: wins.h,v 1.7 2008/04/12 21:14:03 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
* Copyright (c) 2007 Frederic Culot
|
||||
* Copyright (c) 2007-2008 Frederic Culot
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -29,38 +29,42 @@
|
||||
|
||||
#include "vars.h"
|
||||
|
||||
typedef enum {
|
||||
CAL,
|
||||
APP,
|
||||
TOD,
|
||||
NOT,
|
||||
STA,
|
||||
NBWINS
|
||||
} window_e;
|
||||
typedef enum
|
||||
{
|
||||
CAL,
|
||||
APP,
|
||||
TOD,
|
||||
NOT,
|
||||
STA,
|
||||
NBWINS
|
||||
}
|
||||
window_e;
|
||||
|
||||
/* Window properties */
|
||||
typedef struct {
|
||||
WINDOW *p; /* pointer to window */
|
||||
unsigned w; /* width */
|
||||
unsigned h; /* height */
|
||||
int x; /* x position */
|
||||
int y; /* y position */
|
||||
} window_t;
|
||||
typedef struct
|
||||
{
|
||||
WINDOW *p; /* pointer to window */
|
||||
unsigned w; /* width */
|
||||
unsigned h; /* height */
|
||||
int x; /* x position */
|
||||
int y; /* y position */
|
||||
}
|
||||
window_t;
|
||||
|
||||
extern window_t win[NBWINS];
|
||||
extern window_t win[NBWINS];
|
||||
|
||||
int wins_layout(void);
|
||||
void wins_set_layout(int);
|
||||
void wins_slctd_init(void);
|
||||
window_e wins_slctd(void);
|
||||
void wins_slctd_set(window_e);
|
||||
void wins_slctd_next(void);
|
||||
void wins_init(void);
|
||||
void wins_reinit(void);
|
||||
void wins_show(WINDOW *, char *);
|
||||
void wins_get_config(void);
|
||||
void wins_update(void);
|
||||
void wins_reset(void);
|
||||
void wins_launch_external(const char *, const char *);
|
||||
int wins_layout (void);
|
||||
void wins_set_layout (int);
|
||||
void wins_slctd_init (void);
|
||||
window_e wins_slctd (void);
|
||||
void wins_slctd_set (window_e);
|
||||
void wins_slctd_next (void);
|
||||
void wins_init (void);
|
||||
void wins_reinit (void);
|
||||
void wins_show (WINDOW *, char *);
|
||||
void wins_get_config (void);
|
||||
void wins_update (void);
|
||||
void wins_reset (void);
|
||||
void wins_launch_external (const char *, const char *);
|
||||
|
||||
#endif /* CALCURSE_WINS_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user