From 1c9de9291bd535273af369f63c351da3f1469d50 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Sun, 13 Mar 2016 05:35:23 +0100 Subject: degesch: cleanup, fix no-tty mode FWIW Removed the no color mode that couldn't even be enabled. Not sure why we still support running without a proper terminal but let's at least not make it crash for now. --- degesch.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/degesch.c b/degesch.c index 4befc02..dcad0b2 100644 --- a/degesch.c +++ b/degesch.c @@ -1927,7 +1927,6 @@ struct completion_hook_vtable struct app_context { - bool no_colors; ///< Disable attribute printing char *attrs_defaults[ATTR_COUNT]; ///< Default terminal attributes // Configuration: @@ -2620,16 +2619,17 @@ init_colors (struct app_context *ctx) INIT_ATTR (JOIN, g_terminal.color_set_fg[COLOR_GREEN]); INIT_ATTR (PART, g_terminal.color_set_fg[COLOR_RED]); - char *highlight = xstrdup_printf ("%s%s%s", + char *highlight = have_ti ? xstrdup_printf ("%s%s%s", g_terminal.color_set_fg[COLOR_YELLOW], g_terminal.color_set_bg[COLOR_MAGENTA], - enter_bold_mode); + enter_bold_mode) : NULL; INIT_ATTR (HIGHLIGHT, highlight); free (highlight); #undef INIT_ATTR - if (ctx->no_colors) + // This prevents formatters from obtaining an attribute printer function + if (!have_ti) { g_terminal.stdout_is_tty = false; g_terminal.stderr_is_tty = false; @@ -3749,7 +3749,7 @@ buffer_print_backlog (struct app_context *ctx, struct buffer *buffer) int display_limit = MAX (10, g_terminal.lines - 1); // Simulate curses-like fullscreen buffers if the terminal allows it - if (clear_screen) + if (g_terminal.initialized && clear_screen) { terminal_printer_fn printer = get_attribute_printer (stdout); tputs (clear_screen, 1, printer); -- cgit v1.2.3-70-g09d2