From 73e697ac8fbe37096be960b87b684d20d4bad0eb Mon Sep 17 00:00:00 2001 From: Joshua Judson Rosen Date: Sun, 19 Mar 2017 15:28:00 -0400 Subject: ui-cmdwin: redirect all stdio into the embedded terminal Users should no longer need to run from an xterm to see to see things like final energy/score/odometry stats, map-file path, copyright, load-messages, etc. Note that this also means we no longer need to redirect readline, since we're just redirecting *everything*. --- src/ui-cmdwin.c | 11 +++++------ src/ui-window.c | 3 +++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ui-cmdwin.c b/src/ui-cmdwin.c index c96388e..ce2c9ee 100644 --- a/src/ui-cmdwin.c +++ b/src/ui-cmdwin.c @@ -43,7 +43,6 @@ GtkWidget *ui_cmdwin_new(void) static void ui_cmdwin_init(UICmdWin *cmdwin) { int master_pty, slave_pty; - FILE *in, *out; cmdwin->priv = UI_CMDWIN_GET_PRIVATE(cmdwin); @@ -54,12 +53,12 @@ static void ui_cmdwin_init(UICmdWin *cmdwin) gtk_widget_set_size_request(GTK_WIDGET(cmdwin), -1, 200); g_assert(openpty(&master_pty, &slave_pty, NULL, NULL, NULL) >= 0); - vte_terminal_set_pty(VTE_TERMINAL(cmdwin->priv->vte), master_pty); - in = fdopen(slave_pty, "r"); - out = fdopen(slave_pty, "w"); - rl_instream = in; - rl_outstream = out; + dup2(slave_pty, 0); + dup2(slave_pty, 1); + dup2(slave_pty, 2); + + vte_terminal_set_pty(VTE_TERMINAL(cmdwin->priv->vte), master_pty); gtk_widget_show(cmdwin->priv->vte); } diff --git a/src/ui-window.c b/src/ui-window.c index e923c24..8034138 100644 --- a/src/ui-window.c +++ b/src/ui-window.c @@ -57,7 +57,10 @@ static void ui_window_init(UIWindow *window) gtk_window_set_title(GTK_WINDOW(window), "GNU Robots"); gtk_window_set_resizable(GTK_WINDOW(window), FALSE); + /* stdio is redirected in here...: */ window->priv->cmdwin = ui_cmdwin_new(); + /* ^so that's needed before guile can start... */ + window->priv->arena = ui_arena_new(); } -- cgit v1.1