aboutsummaryrefslogtreecommitdiffstats
path: root/src/wins.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wins.c')
-rw-r--r--src/wins.c135
1 files changed, 73 insertions, 62 deletions
diff --git a/src/wins.c b/src/wins.c
index 7b7384b..0cbe95a 100644
--- a/src/wins.c
+++ b/src/wins.c
@@ -75,7 +75,7 @@ screen_acquire (void)
static void
screen_release (void)
{
- (void)pthread_mutex_unlock (&screen_mutex);
+ pthread_mutex_unlock (&screen_mutex);
}
int
@@ -201,7 +201,7 @@ wins_slctd_init (void)
enum win
wins_slctd (void)
{
- return (slctd_win);
+ return slctd_win;
}
/* Sets the selected window. */
@@ -227,17 +227,17 @@ wins_init_panels (void)
char label[BUFSIZ];
win[CAL].p = newwin (CALHEIGHT, wins_sbar_width (), win[CAL].y, win[CAL].x);
- (void)snprintf (label, BUFSIZ, _("Calendar"));
+ strncpy (label, _("Calendar"), BUFSIZ);
wins_show (win[CAL].p, label);
win[APP].p = newwin (win[APP].h, win[APP].w, win[APP].y, win[APP].x);
- (void)snprintf (label, BUFSIZ, _("Appointments"));
+ strncpy (label, _("Appointments"), BUFSIZ);
wins_show (win[APP].p, label);
apad.width = win[APP].w - 3;
apad.ptrwin = newpad (apad.length, apad.width);
win[TOD].p = newwin (win[TOD].h, win[TOD].w, win[TOD].y, win[TOD].x);
- (void)snprintf (label, BUFSIZ, _("ToDo"));
+ strncpy (label, _("ToDo"), BUFSIZ);
wins_show (win[TOD].p, label);
/* Enable function keys (i.e. arrow keys) in those windows */
@@ -539,37 +539,40 @@ border_nocolor (WINDOW *window)
}
void
-wins_update_border (void)
+wins_update_border (int flags)
{
- switch (slctd_win)
+ if (flags & FLAG_CAL)
{
- 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 TOD:
- border_color (win[TOD].p);
- border_nocolor (win[APP].p);
- border_nocolor (win[CAL].p);
- break;
- default:
- EXIT (_("no window selected"));
- /* NOTREACHED */
+ if (slctd_win == CAL)
+ border_color (win[CAL].p);
+ else
+ border_nocolor (win[CAL].p);
+ }
+ if (flags & FLAG_APP)
+ {
+ if (slctd_win == APP)
+ border_color (win[APP].p);
+ else
+ border_nocolor (win[APP].p);
+ }
+ if (flags & FLAG_TOD)
+ {
+ if (slctd_win == TOD)
+ border_color (win[TOD].p);
+ else
+ border_nocolor (win[TOD].p);
}
}
void
-wins_update_panels (void)
+wins_update_panels (int flags)
{
- apoint_update_panel (slctd_win);
- todo_update_panel (slctd_win);
- calendar_update_panel (&win[CAL]);
+ if (flags & FLAG_APP)
+ apoint_update_panel (slctd_win);
+ if (flags & FLAG_TOD)
+ todo_update_panel (slctd_win);
+ if (flags & FLAG_CAL)
+ calendar_update_panel (&win[CAL]);
}
/*
@@ -577,12 +580,13 @@ wins_update_panels (void)
* selected window.
*/
void
-wins_update (void)
+wins_update (int flags)
{
- wins_update_border ();
- wins_update_panels ();
- wins_status_bar ();
- if (notify_bar ())
+ wins_update_border (flags);
+ wins_update_panels (flags);
+ if (flags & FLAG_STA)
+ wins_status_bar ();
+ if ((flags & FLAG_NOT) && notify_bar ())
notify_update_bar ();
wmove (win[STA].p, 0, 0);
wins_doupdate ();
@@ -596,36 +600,26 @@ wins_reset (void)
wins_refresh ();
curs_set (0);
wins_reinit ();
- wins_update ();
+ wins_update (FLAG_ALL);
}
-/*
- * While inside interactive mode, launch the external command cmd on the given
- * file.
- */
+/* Prepare windows for the execution of an external command. */
void
-wins_launch_external (const char *file, const char *cmd)
+wins_prepare_external (void)
{
- char *p;
- int len;
-
- /* Beware of space between cmd and file. */
- len = strlen (file) + strlen (cmd) + 2;
-
- p = (char *) mem_calloc (len, sizeof (char));
- if (snprintf (p, len, "%s %s", cmd, file) == -1)
- {
- mem_free (p);
- return;
- }
if (notify_bar ())
notify_stop_main_thread ();
def_prog_mode ();
- endwin ();
ui_mode = UI_CMDLINE;
clear ();
wins_refresh ();
- (void)system (p);
+ endwin ();
+}
+
+/* Restore windows when returning from an external command. */
+void
+wins_unprepare_external (void)
+{
reset_prog_mode ();
clearok (curscr, TRUE);
curs_set (0);
@@ -633,12 +627,27 @@ wins_launch_external (const char *file, const char *cmd)
wins_refresh ();
if (notify_bar ())
notify_start_main_thread ();
- mem_free (p);
+}
+
+/*
+ * While inside interactive mode, launch the external command cmd on the given
+ * file.
+ */
+void
+wins_launch_external (char *file, char *cmd)
+{
+ char *arg[] = { cmd, file, NULL };
+ int pid;
+
+ wins_prepare_external ();
+ if ((pid = fork_exec (NULL, NULL, cmd, arg)))
+ child_wait (NULL, NULL, pid);
+ wins_unprepare_external ();
}
#define NB_CAL_CMDS 27 /* number of commands while in cal view */
-#define NB_APP_CMDS 31 /* same thing while in appointment view */
-#define NB_TOD_CMDS 30 /* same thing while in todo view */
+#define NB_APP_CMDS 32 /* same thing while in appointment view */
+#define NB_TOD_CMDS 31 /* same thing while in todo view */
#define TOTAL_CMDS NB_CAL_CMDS + NB_APP_CMDS + NB_TOD_CMDS
#define CMDS_PER_LINE 6 /* max number of commands per line */
@@ -690,6 +699,7 @@ wins_status_bar (void)
struct binding del = {_("Del Item"), KEY_DEL_ITEM};
struct binding edit = {_("Edit Itm"), KEY_EDIT_ITEM};
struct binding view = {_("View"), KEY_VIEW_ITEM};
+ struct binding pipe = {_("Pipe"), KEY_PIPE_ITEM};
struct binding flag = {_("Flag Itm"), KEY_FLAG_ITEM};
struct binding rept = {_("Repeat"), KEY_REPEAT_ITEM};
struct binding enote = {_("EditNote"), KEY_EDIT_NOTE};
@@ -704,13 +714,14 @@ wins_status_bar (void)
&gnday, &gpday, &gnweek, &gpweek, &draw, &othr, &today, &conf, &othr,
/* appointment keys */
&help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view,
- &draw, &othr, &rept, &flag, &enote, &vnote, &up, &down, &gnday, &gpday,
- &gnweek, &gpweek, &togo, &othr, &today, &conf, &appt, &todo, &cut, &paste,
- &othr,
+ &pipe, &othr, &draw, &rept, &flag, &enote, &vnote, &up, &down, &gnday,
+ &gpday, &gnweek, &gpweek, &othr, &togo, &today, &conf, &appt, &todo, &cut,
+ &paste, &othr,
/* todo keys */
&help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view,
- &flag, &othr, &rprio, &lprio, &enote, &vnote, &up, &down, &gnday, &gpday,
- &gnweek, &gpweek, &togo, &othr, &today, &conf, &appt, &todo, &draw, &othr
+ &pipe, &othr, &flag, &rprio, &lprio, &enote, &vnote, &up, &down, &gnday,
+ &gpday, &gnweek, &gpweek, &othr, &togo, &today, &conf, &appt, &todo, &draw,
+ &othr
};
/* Drawing the keybinding with attribute and label without. */