# HG changeset patch # User Sadrul Habib Chowdhury # Date 1183452874 0 # Node ID e16d097c5739a60725573c8f239a94c1335d817f # Parent e2b8b17fc62cfa6961389ac7dace84f17a55840e Allow executing another application (eg. PAGER) that will use the same console. diff -r e2b8b17fc62c -r e16d097c5739 finch/libgnt/gnt.h --- a/finch/libgnt/gnt.h Tue Jul 03 04:47:24 2007 +0000 +++ b/finch/libgnt/gnt.h Tue Jul 03 08:54:34 2007 +0000 @@ -112,7 +112,7 @@ /** * * @param label - * @param callback)() + * @param callback */ void gnt_register_action(const char *label, void (*callback)()); @@ -149,3 +149,11 @@ */ void gnt_set_clipboard_string(gchar *string); +/** + * Spawn a different application that will consume the console. + */ +gboolean gnt_giveup_console(const char *wd, char **argv, char **envp, + gint *stin, gint *stout, gint *sterr); + +gboolean gnt_is_refugee(void); + diff -r e2b8b17fc62c -r e16d097c5739 finch/libgnt/gntmain.c --- a/finch/libgnt/gntmain.c Tue Jul 03 04:47:24 2007 +0000 +++ b/finch/libgnt/gntmain.c Tue Jul 03 08:54:34 2007 +0000 @@ -220,8 +220,13 @@ io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) { char keys[256]; - int rd = read(STDIN_FILENO, keys + HOLDING_ESCAPE, sizeof(keys) - 1 - HOLDING_ESCAPE); + int rd; char *k; + + if (wm->mode == GNT_KP_MODE_WAIT_ON_CHILD) + return FALSE; + + rd = read(STDIN_FILENO, keys + HOLDING_ESCAPE, sizeof(keys) - 1 - HOLDING_ESCAPE); if (rd < 0) { int ch = getch(); /* This should return ERR, but let's see what it really returns */ @@ -622,7 +627,50 @@ { return clipboard; } + gchar *gnt_get_clipboard_string() { return gnt_clipboard_get_string(clipboard); } + +#if GLIB_CHECK_VERSION(2,4,0) +static void +reap_child(GPid pid, gint status, gpointer data) +{ + wm->mode = GNT_KP_MODE_NORMAL; + clear(); + setup_io(); + refresh_screen(); +} +#endif + +gboolean gnt_giveup_console(const char *wd, char **argv, char **envp, + gint *stin, gint *stout, gint *sterr) +{ +#if GLIB_CHECK_VERSION(2,4,0) + GPid pid = 0; + + if (!g_spawn_async_with_pipes(wd, argv, envp, + G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, + (GSpawnChildSetupFunc)endwin, NULL, + &pid, stin, stout, sterr, NULL)) + return FALSE; + + wm->mode = GNT_KP_MODE_WAIT_ON_CHILD; + g_child_watch_add(pid, reap_child, NULL); + + return TRUE; +#else + return FALSE; +#endif +} + +gboolean gnt_is_refugee() +{ +#if GLIB_CHECK_VERSION(2,4,0) + return (wm && wm->mode == GNT_KP_MODE_WAIT_ON_CHILD); +#else + return FALSE; +#endif +} + diff -r e2b8b17fc62c -r e16d097c5739 finch/libgnt/gntwm.c --- a/finch/libgnt/gntwm.c Tue Jul 03 04:47:24 2007 +0000 +++ b/finch/libgnt/gntwm.c Tue Jul 03 08:54:34 2007 +0000 @@ -204,6 +204,9 @@ static gboolean update_screen(GntWM *wm) { + if (wm->mode == GNT_KP_MODE_WAIT_ON_CHILD) + return TRUE; + if (wm->menu) { GntMenu *top = wm->menu; while (top) { diff -r e2b8b17fc62c -r e16d097c5739 finch/libgnt/gntwm.h --- a/finch/libgnt/gntwm.h Tue Jul 03 04:47:24 2007 +0000 +++ b/finch/libgnt/gntwm.h Tue Jul 03 08:54:34 2007 +0000 @@ -46,6 +46,7 @@ GNT_KP_MODE_NORMAL, GNT_KP_MODE_RESIZE, GNT_KP_MODE_MOVE, + GNT_KP_MODE_WAIT_ON_CHILD } GntKeyPressMode; typedef struct diff -r e2b8b17fc62c -r e16d097c5739 finch/libgnt/gntws.c --- a/finch/libgnt/gntws.c Tue Jul 03 04:47:24 2007 +0000 +++ b/finch/libgnt/gntws.c Tue Jul 03 08:54:34 2007 +0000 @@ -35,6 +35,9 @@ int n, width = 0; int i; + if (gnt_is_refugee()) + return; + if (taskbar == NULL) { taskbar = newwin(1, getmaxx(stdscr), getmaxy(stdscr) - 1, 0); } else if (reposition) {