diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2016-03-13 05:35:23 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2016-03-13 16:44:06 +0100 |
commit | 1c9de9291bd535273af369f63c351da3f1469d50 (patch) | |
tree | b189f73bd09cf7f6173ad95de59fbaa3fa945871 | |
parent | e11ca7cc0021a271709a2a90698bea42378a78af (diff) | |
download | xK-1c9de9291bd535273af369f63c351da3f1469d50.tar.gz xK-1c9de9291bd535273af369f63c351da3f1469d50.tar.xz xK-1c9de9291bd535273af369f63c351da3f1469d50.zip |
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.
-rw-r--r-- | degesch.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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); |