aboutsummaryrefslogtreecommitdiff
path: root/src/sdtui.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-02-27 23:50:32 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2015-02-27 23:50:32 +0100
commit25366d369b01771791d866fdd4abc585096f13c9 (patch)
tree1b2cef6869a4d3c52edc5eed4213c104a15693b4 /src/sdtui.c
parent6fb83a404396f72f8eff6b14b2fff9fd67a7382d (diff)
downloadtdv-25366d369b01771791d866fdd4abc585096f13c9.tar.gz
tdv-25366d369b01771791d866fdd4abc585096f13c9.tar.xz
tdv-25366d369b01771791d866fdd4abc585096f13c9.zip
Refactoring
Diffstat (limited to 'src/sdtui.c')
-rw-r--r--src/sdtui.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/sdtui.c b/src/sdtui.c
index 0823038..156fc67 100644
--- a/src/sdtui.c
+++ b/src/sdtui.c
@@ -1381,6 +1381,28 @@ on_watch_primary_selection (G_GNUC_UNUSED const gchar *option_name,
#endif // WITH_GTK
static void
+log_handler_curses (Application *self, const gchar *message)
+{
+ // Beep, beep, I'm a jeep; let the user know
+ beep ();
+
+ // We certainly don't want to end up in a possibly infinite recursion
+ static gboolean in_processing;
+ if (in_processing)
+ return;
+
+ in_processing = TRUE;
+ SAVE_CURSOR
+
+ attrset (A_REVERSE);
+ mvwhline (stdscr, 0, 0, A_REVERSE, COLS);
+ app_add_utf8_string (self, message, 0, COLS);
+
+ RESTORE_CURSOR
+ in_processing = FALSE;
+}
+
+static void
log_handler (const gchar *domain, GLogLevelFlags level,
const gchar *message, gpointer data)
{
@@ -1409,30 +1431,10 @@ log_handler (const gchar *domain, GLogLevelFlags level,
// If the standard error output isn't redirected, try our best at showing
// the message to the user; it will probably get overdrawn soon
if (isatty (STDERR_FILENO))
- {
- // Beep, beep, I'm a jeep; let the user know
- beep ();
-
- // We certainly don't want to end up in a possibly infinite recursion
- static gboolean in_processing;
- if (in_processing)
- goto out;
-
- in_processing = TRUE;
- SAVE_CURSOR
-
- Application *self = data;
- attrset (A_REVERSE);
- mvwhline (stdscr, 0, 0, A_REVERSE, COLS);
- app_add_utf8_string (self, out, 0, COLS);
-
- RESTORE_CURSOR
- in_processing = FALSE;
- }
+ log_handler_curses (data, out);
else
fprintf (stderr, "%s\n", out);
-out:
g_free (out);
}