diff --git a/src/builtins/set_color.cpp b/src/builtins/set_color.cpp index 214f35b94..3af941075 100644 --- a/src/builtins/set_color.cpp +++ b/src/builtins/set_color.cpp @@ -38,7 +38,7 @@ static void print_modifiers(outputter_t &outp, bool bold, bool underline, bool i bool reverse, rgb_color_t bg) { if (bold && enter_bold_mode) { // These casts are needed to work with different curses implementations. - writembs_nofail(outp, tparm(const_cast(enter_bold_mode))); + writembs_nofail(outp, fish_tparm(const_cast(enter_bold_mode))); } if (underline && enter_underline_mode) { @@ -59,7 +59,7 @@ static void print_modifiers(outputter_t &outp, bool bold, bool underline, bool i writembs_nofail(outp, enter_standout_mode); } if (!bg.is_none() && bg.is_normal()) { - writembs_nofail(outp, tparm(const_cast(exit_attribute_mode))); + writembs_nofail(outp, fish_tparm(const_cast(exit_attribute_mode))); } } @@ -79,7 +79,7 @@ static void print_colors(io_streams_t &streams, bool bold, bool underline, bool if (!bg.is_none()) { // If we have a background, stop it after the color // or it goes to the end of the line and looks ugly. - writembs_nofail(outp, tparm(const_cast(exit_attribute_mode))); + writembs_nofail(outp, fish_tparm(const_cast(exit_attribute_mode))); } outp.writech(L'\n'); } // conveniently, 'normal' is always the last color so we don't need to reset here @@ -233,12 +233,12 @@ maybe_t builtin_set_color(parser_t &parser, io_streams_t &streams, const wc print_modifiers(outp, bold, underline, italics, dim, reverse, bg); if (bgcolor != nullptr && bg.is_normal()) { - writembs_nofail(outp, tparm(const_cast(exit_attribute_mode))); + writembs_nofail(outp, fish_tparm(const_cast(exit_attribute_mode))); } if (!fg.is_none()) { if (fg.is_normal() || fg.is_reset()) { - writembs_nofail(outp, tparm(const_cast(exit_attribute_mode))); + writembs_nofail(outp, fish_tparm(const_cast(exit_attribute_mode))); } else { if (!outp.write_color(fg, true /* is_fg */)) { // We need to do *something* or the lack of any output messes up diff --git a/src/fallback.cpp b/src/fallback.cpp index d5104daab..d0c1c2e63 100644 --- a/src/fallback.cpp +++ b/src/fallback.cpp @@ -44,16 +44,10 @@ #include "fallback.h" // IWYU pragma: keep #if defined(TPARM_SOLARIS_KLUDGE) -#undef tparm - char *tparm_solaris_kludge(char *str, long p1, long p2, long p3, long p4, long p5, long p6, long p7, long p8, long p9) { return tparm(str, p1, p2, p3, p4, p5, p6, p7, p8, p9); } - -// Re-defining just to make sure nothing breaks further down in this file. -#define tparm tparm_solaris_kludge - #endif int fish_mkstemp_cloexec(char *name_template) { diff --git a/src/fallback.h b/src/fallback.h index cf7981d95..7a212c687 100644 --- a/src/fallback.h +++ b/src/fallback.h @@ -68,9 +68,11 @@ struct winsize { #if defined(TPARM_SOLARIS_KLUDGE) /// Solaris tparm has a set fixed of parameters in its curses implementation, work around this here. -#define tparm tparm_solaris_kludge +#define fish_tparm tparm_solaris_kludge char *tparm_solaris_kludge(char *str, long p1 = 0, long p2 = 0, long p3 = 0, long p4 = 0, long p5 = 0, long p6 = 0, long p7 = 0, long p8 = 0, long p9 = 0); +#else +#define fish_tparm tparm #endif /// These functions are missing from Solaris 10, and only accessible from diff --git a/src/output.cpp b/src/output.cpp index d9bbea5b6..d1a02e61f 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -36,7 +36,7 @@ /// Whether term256 and term24bit are supported. static color_support_t color_support = 0; -/// Returns true if we think tparm can handle outputting a color index +/// Returns true if we think fish_tparm can handle outputting a color index static bool term_supports_color_natively(unsigned int c) { return static_cast(max_colors) >= c + 1; } @@ -54,8 +54,8 @@ unsigned char index_for_color(rgb_color_t c) { static bool write_color_escape(outputter_t &outp, const char *todo, unsigned char idx, bool is_fg) { if (term_supports_color_natively(idx)) { - // Use tparm to emit color escape. - writembs(outp, tparm(const_cast(todo), idx)); + // Use fish_tparm to emit color escape. + writembs(outp, fish_tparm(const_cast(todo), idx)); return true; } @@ -116,7 +116,7 @@ bool outputter_t::write_color(rgb_color_t color, bool is_fg) { return (is_fg ? write_foreground_color : write_background_color)(*this, idx); } - // 24 bit! No tparm here, just ANSI escape sequences. + // 24 bit! No fish_tparm here, just ANSI escape sequences. // Foreground: ^[38;2;;;m // Background: ^[48;2;;;m color24_t rgb = color.to_color24(); @@ -242,7 +242,7 @@ void outputter_t::set_color(rgb_color_t fg, rgb_color_t bg) { // Lastly, we set bold, underline, italics, dim, and reverse modes correctly. if (is_bold && !was_bold && enter_bold_mode && enter_bold_mode[0] != '\0' && !bg_set) { // The unconst cast is for NetBSD's benefit. DO NOT REMOVE! - writembs_nofail(*this, tparm(const_cast(enter_bold_mode))); + writembs_nofail(*this, fish_tparm(const_cast(enter_bold_mode))); was_bold = is_bold; } @@ -304,7 +304,7 @@ int outputter_t::term_puts(const char *str, int affcnt) { scoped_push push(&s_tputs_receiver, this); s_tputs_receiver->begin_buffering(); // On some systems, tputs takes a char*, on others a const char*. - // Like tparm, we just cast it to unconst, that should work everywhere. + // Like fish_tparm, we just cast it to unconst, that should work everywhere. int res = tputs(const_cast(str), affcnt, tputs_writer); s_tputs_receiver->end_buffering(); return res; diff --git a/src/screen.cpp b/src/screen.cpp index bc06f50d3..45fe5bda8 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -228,10 +228,10 @@ static bool is_visual_escape_seq(const wchar_t *code, size_t *resulting_length) for (auto p : esc2) { if (!p) continue; - // Test both padded and unpadded version, just to be safe. Most versions of tparm don't + // Test both padded and unpadded version, just to be safe. Most versions of fish_tparm don't // actually seem to do anything these days. size_t esc_seq_len = - std::max(try_sequence(tparm(const_cast(p)), code), try_sequence(p, code)); + std::max(try_sequence(fish_tparm(const_cast(p)), code), try_sequence(p, code)); if (esc_seq_len) { *resulting_length = esc_seq_len; return true; @@ -599,7 +599,7 @@ void screen_t::move(int new_x, int new_y) { bool use_multi = multi_str != nullptr && multi_str[0] != '\0' && abs(x_steps) * std::strlen(str) > std::strlen(multi_str); if (use_multi && cur_term) { - char *multi_param = tparm(const_cast(multi_str), abs(x_steps)); + char *multi_param = fish_tparm(const_cast(multi_str), abs(x_steps)); writembs(outp, multi_param); } else { for (i = 0; i < abs(x_steps); i++) { @@ -1255,7 +1255,7 @@ void screen_t::reset_abandoning_line(int screen_width) { if (screen_width > non_space_width) { bool justgrey = true; if (cur_term && enter_dim_mode) { - std::string dim = tparm(const_cast(enter_dim_mode)); + std::string dim = fish_tparm(const_cast(enter_dim_mode)); if (!dim.empty()) { // Use dim if they have it, so the color will be based on their actual normal // color and the background of the termianl. @@ -1267,24 +1267,24 @@ void screen_t::reset_abandoning_line(int screen_width) { if (max_colors >= 238) { // draw the string in a particular grey abandon_line_string.append( - str2wcstring(tparm(const_cast(set_a_foreground), 237))); + str2wcstring(fish_tparm(const_cast(set_a_foreground), 237))); } else if (max_colors >= 9) { // bright black (the ninth color, looks grey) abandon_line_string.append( - str2wcstring(tparm(const_cast(set_a_foreground), 8))); + str2wcstring(fish_tparm(const_cast(set_a_foreground), 8))); } else if (max_colors >= 2 && enter_bold_mode) { // we might still get that color by setting black and going bold for bright abandon_line_string.append( - str2wcstring(tparm(const_cast(enter_bold_mode)))); + str2wcstring(fish_tparm(const_cast(enter_bold_mode)))); abandon_line_string.append( - str2wcstring(tparm(const_cast(set_a_foreground), 0))); + str2wcstring(fish_tparm(const_cast(set_a_foreground), 0))); } } abandon_line_string.append(get_omitted_newline_str()); if (cur_term && exit_attribute_mode) { - abandon_line_string.append(str2wcstring(tparm( + abandon_line_string.append(str2wcstring(fish_tparm( const_cast(exit_attribute_mode)))); // normal text ANSI escape sequence }