summaryrefslogtreecommitdiffstats
path: root/src/calcurse.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/calcurse.h')
-rw-r--r--src/calcurse.h266
1 files changed, 163 insertions, 103 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index 091d16a..adb2c1e 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -103,99 +103,111 @@
#define DEFAULT_EDITOR "vi"
#define DEFAULT_PAGER "less"
-#define ATTR_FALSE 0
-#define ATTR_TRUE 1
-#define ATTR_LOWEST 2
-#define ATTR_LOW 3
-#define ATTR_MIDDLE 4
-#define ATTR_HIGH 5
-#define ATTR_HIGHEST 6
-
-#define STATUSHEIGHT 2
-#define NOTESIZ 6
+#define ATTR_FALSE 0
+#define ATTR_TRUE 1
+#define ATTR_LOWEST 2
+#define ATTR_LOW 3
+#define ATTR_MIDDLE 4
+#define ATTR_HIGH 5
+#define ATTR_HIGHEST 6
+
+#define STATUSHEIGHT 2
+#define MAX_NOTESIZ 40
+#define TMPEXTSIZ 6
/* Format for appointment hours is: HH:MM */
#define HRMIN_SIZE 6
/* Maximum number of colors available. */
-#define NBUSERCOLORS 6
+#define NBUSERCOLORS 6
/* Side bar width acceptable boundaries. */
#define SBARMINWIDTH 32
#define SBARMAXWIDTHPERC 50
/* Related to date manipulation. */
-#define DAYINSEC 86400
-#define HOURINSEC 3600
-#define MININSEC 60
-#define YEARINDAYS 365
#define YEARINMONTHS 12
-#define WEEKINDAYS 7
+#define YEARINDAYS 365
#define TM_YEAR_BASE 1900
+#define WEEKINDAYS 7
+#define DAYINHOURS 24
+#define HOURINMIN 60
+#define MININSEC 60
+
+#define WEEKINHOURS (WEEKINDAYS * DAYINHOURS)
+#define WEEKINMIN (WEEKINHOURS * HOURINMIN)
+#define WEEKINSEC (WEEKINMIN * MININSEC)
+#define DAYINMIN (DAYINHOURS * HOURINMIN)
+#define DAYINSEC (DAYINMIN * MININSEC)
+#define HOURINSEC (HOURINMIN * MININSEC)
+
/* Calendar window. */
-#define CALHEIGHT 12
+#define CALHEIGHT 12
/* Key definitions. */
#define CTRLVAL 0x1F
#define CTRL(x) ((x) & CTRLVAL)
-#define ESCAPE 27
-#define TAB 9
+#define ESCAPE 27
+#define TAB 9
#define SPACE 32
-#define KEYS_KEYLEN 3 /* length of each keybinding */
-#define KEYS_LABELEN 8 /* length of command description */
-#define KEYS_CMDS_PER_LINE 6 /* max number of commands per line */
-
-#define ERROR_MSG(...) do { \
- char msg[BUFSIZ]; \
- int len; \
- \
- len = snprintf (msg, BUFSIZ, "%s: %d: ", __FILE__, __LINE__); \
- (void)snprintf (msg + len, BUFSIZ - len, __VA_ARGS__); \
- if (ui_mode == UI_CURSES) \
- fatalbox (msg); \
- else \
- (void)fprintf (stderr, "%s\n", msg); \
+#define KEYS_KEYLEN 3 /* length of each keybinding */
+#define KEYS_LABELEN 8 /* length of command description */
+#define KEYS_CMDS_PER_LINE 6 /* max number of commands per line */
+
+/* Size of the hash table the note garbage collector uses. */
+#define NOTE_GC_HSIZE 1024
+
+#define ERROR_MSG(...) do { \
+ char msg[BUFSIZ]; \
+ int len; \
+ \
+ len = snprintf (msg, BUFSIZ, "%s: %d: ", __FILE__, __LINE__); \
+ snprintf (msg + len, BUFSIZ - len, __VA_ARGS__); \
+ if (ui_mode == UI_CURSES) \
+ fatalbox (msg); \
+ else \
+ fprintf (stderr, "%s\n", msg); \
} while (0)
-#define WARN_MSG(...) do { \
- char msg[BUFSIZ]; \
- \
- (void)snprintf (msg, BUFSIZ, __VA_ARGS__); \
- if (ui_mode == UI_CURSES) \
- warnbox (msg); \
- else \
- (void)fprintf (stderr, "%s\n", msg); \
+#define WARN_MSG(...) do { \
+ char msg[BUFSIZ]; \
+ \
+ snprintf (msg, BUFSIZ, __VA_ARGS__); \
+ if (ui_mode == UI_CURSES) \
+ warnbox (msg); \
+ else \
+ fprintf (stderr, "%s\n", msg); \
} while (0)
-#define EXIT(...) do { \
- ERROR_MSG(__VA_ARGS__); \
- if (ui_mode == UI_CURSES) \
- exit_calcurse (EXIT_FAILURE); \
- else \
- exit (EXIT_FAILURE); \
+#define EXIT(...) do { \
+ ERROR_MSG(__VA_ARGS__); \
+ if (ui_mode == UI_CURSES) \
+ exit_calcurse (EXIT_FAILURE); \
+ else \
+ exit (EXIT_FAILURE); \
} while (0)
-#define EXIT_IF(cond, ...) do { \
- if ((cond)) \
- EXIT(__VA_ARGS__); \
+#define EXIT_IF(cond, ...) do { \
+ if ((cond)) \
+ EXIT(__VA_ARGS__); \
} while (0)
-#define RETURN_IF(cond, ...) do { \
- if ((cond)) \
- { \
- ERROR_MSG(__VA_ARGS__); \
- return; \
- } \
+#define RETURN_IF(cond, ...) do { \
+ if ((cond)) \
+ { \
+ ERROR_MSG(__VA_ARGS__); \
+ return; \
+ } \
} while (0)
-#define RETVAL_IF(cond, val, ...) do { \
- if ((cond)) \
- { \
- ERROR_MSG(__VA_ARGS__); \
- return (val); \
- } \
+#define RETVAL_IF(cond, val, ...) do { \
+ if ((cond)) \
+ { \
+ ERROR_MSG(__VA_ARGS__); \
+ return (val); \
+ } \
} while (0)
#define STRING_BUILD(str) {str, sizeof (str) - 1}
@@ -203,12 +215,22 @@
#define TOSTRING(x) STRINGIFY(x)
#define __FILE_POS__ __FILE__ ":" TOSTRING(__LINE__)
+#define UTF8_MAXLEN 6
+#define UTF8_LENGTH(ch) ((unsigned char)ch >= 0xFC ? 6 : \
+ ((unsigned char)ch >= 0xF8 ? 5 : \
+ ((unsigned char)ch >= 0xF0 ? 4 : \
+ ((unsigned char)ch >= 0xE0 ? 3 : \
+ ((unsigned char)ch >= 0xC0 ? 2 : 1)))))
+#define UTF8_ISCONT(ch) ((unsigned char)ch >= 0x80 && \
+ (unsigned char)ch <= 0xBF)
+
#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
/* General configuration variables. */
struct conf {
unsigned auto_save;
+ unsigned auto_gc;
unsigned periodic_save;
unsigned confirm_quit;
unsigned confirm_delete;
@@ -217,7 +239,7 @@ struct conf {
char *editor;
char *pager;
char output_datefmt[BUFSIZ]; /* format for displaying date */
- int input_datefmt; /* format for reading date */
+ int input_datefmt; /* format for reading date */
};
/* Daemon-related configuration. */
@@ -239,16 +261,13 @@ enum datefmt {
DATE_FORMATS
};
-#define DATEFMT(datefmt) (datefmt == DATEFMT_MMDDYYYY ? "%m/%d/%Y" : \
- (datefmt == DATEFMT_DDMMYYYY ? "%d/%m/%Y" : \
- (datefmt == DATEFMT_YYYYMMDD ? "%Y/%m/%d" : "%Y-%m-%d")))
+#define DATEFMT(datefmt) (datefmt == DATEFMT_MMDDYYYY ? "%m/%d/%Y" : \
+ (datefmt == DATEFMT_DDMMYYYY ? "%d/%m/%Y" : \
+ (datefmt == DATEFMT_YYYYMMDD ? "%Y/%m/%d" : "%Y-%m-%d")))
-#define DATEFMT_DESC(datefmt) (datefmt == DATEFMT_MMDDYYYY ? \
- _("mm/dd/yyyy") : \
- (datefmt == DATEFMT_DDMMYYYY ? \
- _("dd/mm/yyyy") : \
- (datefmt == DATEFMT_YYYYMMDD ? \
- _("yyyy/mm/dd") : _("yyyy-mm-dd"))))
+#define DATEFMT_DESC(datefmt) (datefmt == DATEFMT_MMDDYYYY ? \
+ _("mm/dd/yyyy") : (datefmt == DATEFMT_DDMMYYYY ? _("dd/mm/yyyy") : \
+ (datefmt == DATEFMT_YYYYMMDD ? _("yyyy/mm/dd") : _("yyyy-mm-dd"))))
struct date {
unsigned dd;
@@ -263,8 +282,8 @@ struct apoint
long dur; /* duration of the appointment in seconds */
#define APOINT_NULL 0x0
-#define APOINT_NOTIFY 0x1 /* Item needs to be notified */
-#define APOINT_NOTIFIED 0x2 /* Item was already notified */
+#define APOINT_NOTIFY 0x1 /* Item needs to be notified */
+#define APOINT_NOTIFIED 0x2 /* Item was already notified */
int state;
char *mesg;
@@ -395,6 +414,7 @@ enum key {
KEY_DEL_ITEM,
KEY_EDIT_ITEM,
KEY_VIEW_ITEM,
+ KEY_PIPE_ITEM,
KEY_FLAG_ITEM,
KEY_REPEAT_ITEM,
KEY_EDIT_NOTE,
@@ -421,6 +441,13 @@ enum win {
NBWINS
};
+#define FLAG_CAL (1 << CAL)
+#define FLAG_APP (1 << APP)
+#define FLAG_TOD (1 << TOD)
+#define FLAG_NOT (1 << NOT)
+#define FLAG_STA (1 << STA)
+#define FLAG_ALL ((1 << NBWINS) - 1)
+
enum ui_mode {
UI_CURSES,
UI_CMDLINE,
@@ -455,13 +482,14 @@ struct pad {
/* Notification bar definition. */
struct nbar {
- int show; /* display or hide the notify-bar */
- int cntdwn; /* warn when time left before next app
- becomes lesser than cntdwn */
+ unsigned 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 */
+ char cmd[BUFSIZ]; /* notification command */
+ char *shell; /* user shell to launch notif. cmd */
+ unsigned notify_all; /* notify all appointments */
pthread_mutex_t mutex;
};
@@ -478,7 +506,6 @@ enum item_type {
enum eraseflg {
ERASE_DONT_FORCE,
ERASE_FORCE,
- ERASE_FORCE_KEEP_NOTE,
ERASE_FORCE_ONLY_NOTE,
ERASE_CUT
};
@@ -548,12 +575,12 @@ enum save_display {
/* apoint.c */
extern llist_ts_t alist_p;
-void apoint_free_bkp (enum eraseflg);
+void apoint_free_bkp (void);
void apoint_llist_init (void);
void apoint_llist_free (void);
void apoint_hilt_set (int);
-void apoint_hilt_decrease (void);
-void apoint_hilt_increase (void);
+void apoint_hilt_decrease (int);
+void apoint_hilt_increase (int);
int apoint_hilt (void);
struct apoint *apoint_new (char *, char *, long, long, char);
void apoint_add (void);
@@ -595,7 +622,7 @@ long calendar_get_slctd_day_sec (void);
void calendar_update_panel (struct window *);
void calendar_goto_today (void);
void calendar_change_day (int);
-void calendar_move (enum move);
+void calendar_move (enum move, int);
long calendar_start_of_year (void);
long calendar_end_of_year (void);
char *calendar_get_pom (time_t);
@@ -604,7 +631,7 @@ char *calendar_get_pom (time_t);
void custom_init_attr (void);
void custom_apply_attr (WINDOW *, int);
void custom_remove_attr (WINDOW *, int);
-void custom_load_conf (struct conf *, int);
+void custom_load_conf (struct conf *);
void custom_config_bar (void);
void custom_layout_config (void);
void custom_sidebar_config (void);
@@ -631,6 +658,7 @@ struct day_item *day_get_item (int);
int day_item_nb (long, int, int);
void day_edit_note (char *);
void day_view_note (char *);
+void day_pipe_item (struct conf *);
/* dmon.c */
void dmon_start (int);
@@ -638,7 +666,7 @@ void dmon_stop (void);
/* event.c */
extern llist_t eventlist;
-void event_free_bkp (enum eraseflg);
+void event_free_bkp (void);
void event_llist_init (void);
void event_llist_free (void);
struct event *event_new (char *, char *, long, int);
@@ -653,6 +681,10 @@ void event_paste_item (void);
void help_wins_init (struct scrollwin *, int, int, int, int);
void help_screen (void);
+/* getstring.c */
+enum getstr getstring (WINDOW *, char *, int, int, int);
+int updatestring (WINDOW *, char **, int, int);
+
/* io.c */
unsigned io_fprintln (const char *, const char *, ...);
void io_init (char *, char *);
@@ -683,6 +715,7 @@ void io_set_lock (void);
unsigned io_dump_pid (char *);
unsigned io_get_pid (char *);
int io_file_is_empty (char *);
+int io_file_cp (const char *, const char *);
/* keys.c */
void keys_init (void);
@@ -690,7 +723,7 @@ void keys_free (void);
void keys_dump_defaults (char *);
char *keys_get_label (enum key);
enum key keys_get_action (int);
-enum key keys_getch (WINDOW *win);
+enum key keys_getch (WINDOW *win, int *);
int keys_assign_binding (int, enum key);
void keys_remove_binding (int, enum key);
int keys_str2int (char *);
@@ -738,6 +771,13 @@ void mem_stats (void);
#endif /* CALCURSE_MEMORY_DEBUG */
+/* note.c */
+void edit_note (char **, char *);
+void view_note (char *, char *);
+void erase_note (char **);
+void note_read (char *, FILE *);
+void note_gc (void);
+
/* notify.c */
int notify_time_left (void);
unsigned notify_needs_reminder (void);
@@ -764,8 +804,8 @@ void notify_config_bar (void);
/* recur.c */
extern llist_ts_t recur_alist_p;
extern llist_t recur_elist;
-void recur_event_free_bkp (enum eraseflg);
-void recur_apoint_free_bkp (enum eraseflg);
+void recur_event_free_bkp (void);
+void recur_apoint_free_bkp (void);
void recur_apoint_llist_init (void);
void recur_apoint_llist_free (void);
void recur_event_llist_free (void);
@@ -781,8 +821,17 @@ struct recur_apoint *recur_apoint_scan (FILE *, struct tm, struct tm,
struct recur_event *recur_event_scan (FILE *, struct tm, int, char,
int, struct tm, char *,
llist_t *);
+void recur_apoint_write (struct recur_apoint *, FILE *);
+void recur_event_write (struct recur_event *, FILE *);
void recur_save_data (FILE *);
-unsigned recur_item_inday (long, llist_t *, int, int, long, long);
+unsigned recur_item_find_occurrence (long, long, llist_t *, int,
+ int, long, long, unsigned *);
+unsigned recur_apoint_find_occurrence (struct recur_apoint *,
+ long, unsigned *);
+unsigned recur_event_find_occurrence (struct recur_event *, long,
+ unsigned *);
+unsigned recur_item_inday (long, long, llist_t *, int, int, long,
+ long);
unsigned recur_apoint_inday(struct recur_apoint *, long);
unsigned recur_event_inday(struct recur_event *, long);
void recur_event_erase (long, unsigned, unsigned,
@@ -805,18 +854,19 @@ unsigned sigs_set_hdlr (int, void (*)(int));
/* todo.c */
extern llist_t todolist;
void todo_hilt_set (int);
-void todo_hilt_decrease (void);
-void todo_hilt_increase (void);
+void todo_hilt_decrease (int);
+void todo_hilt_increase (int);
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);
+void todo_first_increase (int);
+void todo_first_decrease (int);
int todo_hilt_pos (void);
char *todo_saved_mesg (void);
void todo_new_item (void);
struct todo *todo_add (char *, int, char *);
+void todo_write (struct todo *, FILE *);
void todo_flag (void);
void todo_delete (struct conf *);
void todo_chg_priority (int);
@@ -824,9 +874,14 @@ void todo_edit_item (void);
void todo_update_panel (int);
void todo_edit_note (char *);
void todo_view_note (char *);
+void todo_pipe_item (void);
void todo_init_list (void);
void todo_free_list (void);
+/* utf8.c */
+int utf8_width (char *);
+int utf8_strwidth (char *);
+
/* utils.c */
void exit_calcurse (int) __attribute__((__noreturn__));
void free_user_data (void);
@@ -836,8 +891,6 @@ void status_mesg (char *, char *);
void erase_window_part (WINDOW *, int, int, int, int);
WINDOW *popup (int, int, int, int, char *, char *, int);
void print_in_middle (WINDOW *, int, int, int, char *);
-enum getstr getstring (WINDOW *, char *, int, int, int);
-int updatestring (WINDOW *, char **, int, int);
int is_all_digit (char *);
long get_item_time (long);
int get_item_hour (long);
@@ -849,7 +902,6 @@ long date_sec_change (long, int, int);
long update_time_in_date (long, unsigned, unsigned);
long get_sec_date (struct date);
long min2sec (unsigned);
-int check_time (char *);
void draw_scrollbar (WINDOW *, int, int, int, int, int, unsigned);
void item_in_popup (char *, char *, char *, char *);
long get_today (void);
@@ -859,17 +911,23 @@ long mystrtol (const char *);
void print_bool_option_incolor (WINDOW *, unsigned, int, int);
const char *get_tempdir (void);
char *new_tempfile (const char *, int);
-void erase_note (char **, enum eraseflg);
-int parse_date (char *, enum datefmt, int *, int *, int *,
+int parse_date (const char *, enum datefmt, int *, int *, int *,
struct date *);
+int parse_time (const char *, unsigned *, unsigned *);
+int parse_duration (const char *, unsigned *);
void str_toupper (char *);
void file_close (FILE *, const char *);
void psleep (unsigned);
+int fork_exec (int *, int *, const char *, char *const *);
+int shell_exec (int *, int *, char *);
+int child_wait (int *, int *, int);
+void press_any_key (void);
/* vars.c */
extern int col, row;
extern int resize;
extern unsigned colorize;
+extern int foreground, background;
extern enum ui_mode ui_mode;
extern int days[12];
extern char *monthnames[12];
@@ -914,11 +972,13 @@ void wins_reinit (void);
void wins_reinit_panels (void);
void wins_show (WINDOW *, char *);
void wins_get_config (void);
-void wins_update_border (void);
-void wins_update_panels (void);
-void wins_update (void);
+void wins_update_border (int);
+void wins_update_panels (int);
+void wins_update (int);
void wins_reset (void);
-void wins_launch_external (const char *, const char *);
+void wins_prepare_external (void);
+void wins_unprepare_external (void);
+void wins_launch_external (char *, char *);
void wins_status_bar (void);
void wins_erase_status_bar (void);
void wins_other_status_page (int);