aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--configure.ac1
-rw-r--r--src/interface-curses.cpp65
-rw-r--r--src/interface-curses.h2
3 files changed, 65 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index fe06358..4e85cc5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -146,6 +146,7 @@ case $INTERFACE in
AC_CHECK_LIB(ncurses, initscr, , [
AC_MSG_ERROR([libncurses missing!])
])
+ AC_CHECK_FUNCS([tigetstr])
;;
pdcurses)
AC_CHECK_LIB(pdcurses, initscr, , [
diff --git a/src/interface-curses.cpp b/src/interface-curses.cpp
index 008b2db..e331a92 100644
--- a/src/interface-curses.cpp
+++ b/src/interface-curses.cpp
@@ -268,6 +268,57 @@ InterfaceCurses::show_view_impl(ViewCurses *view)
lines - 3, cols);
}
+#if PDCURSES
+
+void
+InterfaceCurses::set_window_title(const gchar *title)
+{
+ PDC_set_title(title);
+}
+
+#elif defined(HAVE_TIGETSTR)
+
+void
+InterfaceCurses::set_window_title(const gchar *title)
+{
+ /*
+ * NOTE: terminfo variables in term.h interfere with
+ * the rest of our code
+ */
+ const char *tsl = tigetstr("tsl");
+ const char *fsl = tigetstr("fsl");
+
+ if (!tsl || !fsl)
+ return;
+
+ /*
+ * Modern terminal emulators map the window title to
+ * the historic status line.
+ * This feature is not standardized in ncurses,
+ * so we query the terminfo database.
+ * NOTE: The terminfo manpage advises us to use putp(),
+ * but I don't feel comfortable with writing to stdout.
+ * NOTE: This leaves the title set after we quit.
+ * xterm has escape sequences to save/restore a window title,
+ * but there do not seem to be terminfo capabilities for that.
+ * NOTE: Resetting the title does not always work ;-)
+ */
+ fputs(tsl, screen_tty);
+ fputs(info_current, screen_tty);
+ fputs(fsl, screen_tty);
+ fflush(screen_tty);
+}
+
+#else
+
+void
+InterfaceCurses::set_window_title(const gchar *title)
+{
+ /* no way to set window title */
+}
+
+#endif
+
void
InterfaceCurses::draw_info(void)
{
@@ -279,9 +330,7 @@ InterfaceCurses::draw_info(void)
waddstr(info_window, info_current);
wclrtoeol(info_window);
-#if PDCURSES
- PDC_set_title(info_current);
-#endif
+ set_window_title(info_current);
}
void
@@ -696,7 +745,17 @@ InterfaceCurses::event_loop_impl(void)
}
/*
+ * Set window title to a reasonable default,
+ * in case it is not reset immediately by the
+ * shell.
+ */
+#if !PDCURSES && defined(HAVE_TIGETSTR)
+ set_window_title(g_getenv("TERM") ? : "");
+#endif
+
+ /*
* Restore ordinary terminal behaviour
+ * (i.e. return to batch mode)
*/
endwin();
#endif
diff --git a/src/interface-curses.h b/src/interface-curses.h
index 5da7e56..50f4157 100644
--- a/src/interface-curses.h
+++ b/src/interface-curses.h
@@ -151,6 +151,8 @@ private:
void init_interactive(void);
void resize_all_windows(void);
+
+ void set_window_title(const gchar *title);
void draw_info(void);
void format_chr(chtype *&target, gchar chr,