nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 5ca2fd887a1729f5116d6a403ce0454e06686a82
parent d1e1438ca0348a6f9f1f55623b0a1d546364069f
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed, 29 Apr 2020 12:07:31 +0200

startup: initialize colors only when the terminal is capable of colors

This avoids trying to show colors on a vt100, for example.

Diffstat:
Msrc/color.c | 4----
Msrc/nano.c | 24++++++++++++++----------
Msrc/winio.c | 4++--
3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/color.c b/src/color.c @@ -110,10 +110,6 @@ void prepare_palette(void) bool using_defaults = FALSE; short foreground, background; - /* If the terminal is not capable of colors, forget it. */ - if (!has_colors()) - return; - #ifdef HAVE_USE_DEFAULT_COLORS /* Allow using the default colors, if available. */ using_defaults = (use_default_colors() != ERR); diff --git a/src/nano.c b/src/nano.c @@ -2254,17 +2254,21 @@ int main(int argc, char **argv) started_curses = TRUE; #ifdef ENABLE_COLOR - set_interface_colorpairs(); -#else - interface_color_pair[TITLE_BAR] = hilite_attribute; - interface_color_pair[LINE_NUMBER] = hilite_attribute; - interface_color_pair[GUIDE_STRIPE] = A_REVERSE; - interface_color_pair[SELECTED_TEXT] = hilite_attribute; - interface_color_pair[STATUS_BAR] = hilite_attribute; - interface_color_pair[ERROR_MESSAGE] = hilite_attribute; - interface_color_pair[KEY_COMBO] = hilite_attribute; - interface_color_pair[FUNCTION_TAG] = A_NORMAL; + /* On capable terminals, use colors, otherwise use just reverse or bold.*/ + if (has_colors()) + set_interface_colorpairs(); + else #endif + { + interface_color_pair[TITLE_BAR] = hilite_attribute; + interface_color_pair[LINE_NUMBER] = hilite_attribute; + interface_color_pair[GUIDE_STRIPE] = A_REVERSE; + interface_color_pair[SELECTED_TEXT] = hilite_attribute; + interface_color_pair[STATUS_BAR] = hilite_attribute; + interface_color_pair[ERROR_MESSAGE] = hilite_attribute; + interface_color_pair[KEY_COMBO] = hilite_attribute; + interface_color_pair[FUNCTION_TAG] = A_NORMAL; + } /* Set up the terminal state. */ terminal_init(); diff --git a/src/winio.c b/src/winio.c @@ -3258,8 +3258,8 @@ void edit_refresh(void) int row = 0; #ifdef ENABLE_COLOR - /* When needed, initialize the colors for the current syntax. */ - if (!have_palette) + /* When needed and useful, initialize the colors for the current syntax. */ + if (!have_palette && has_colors()) prepare_palette(); #endif