From 2f89a8e454405b4fd4856cf541c83e18beee6445 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Wed, 11 Apr 2018 21:41:22 +0200 Subject: [PATCH] Remove Cygwin bold color quirks fix in FOptiAttr --- ChangeLog | 3 +++ include/final/foptiattr.h | 9 +++----- src/foptiattr.cpp | 45 ------------------------------------ src/fterm.cpp | 44 ++++++++++++++++++++++------------- src/fvterm.cpp | 48 +++++++++++++++++++-------------------- 5 files changed, 57 insertions(+), 92 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a56b75f..15cb3194 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2017-04-11 Markus Gans + * Remove Cygwin bold color quirks fix in FOptiAttr + 2017-04-08 Markus Gans * Improved Linux terminal quirks * Improvement in class FOptiAttr diff --git a/include/final/foptiattr.h b/include/final/foptiattr.h index 39a3b314..88e0b9e5 100644 --- a/include/final/foptiattr.h +++ b/include/final/foptiattr.h @@ -128,7 +128,7 @@ class FOptiAttr void setMaxColor (const int&); void setNoColorVideo (int); void setDefaultColorSupport(); - void setCygwinTerminal(); + void unsetDefaultColorSupport(); void set_enter_bold_mode (char[]); void set_exit_bold_mode (char[]); void set_enter_dim_mode (char[]); @@ -273,8 +273,6 @@ class FOptiAttr bool colorChange (char_data*&, char_data*&); void resetColor (char_data*&); void prevent_no_color_video_attributes (char_data*&, bool = false); - void preProcessing_cygwin_quirks (char_data*&); - void postProcessing_cygwin_quirks (char_data*&, char_data*&); void deactivateAttributes (char_data*&, char_data*&); void changeAttributeSGR (char_data*&, char_data*&); void changeAttributeSeparately (char_data*&, char_data*&); @@ -338,7 +336,6 @@ class FOptiAttr bool alt_equal_pc_charset; bool monochron; bool fake_reverse; - bool cygwin_terminal; char attr_buf[8192]; char* attr_ptr; }; @@ -379,7 +376,7 @@ inline void FOptiAttr::setDefaultColorSupport() { ansi_default_color = true; } //---------------------------------------------------------------------- -inline void FOptiAttr::setCygwinTerminal() -{ cygwin_terminal = true; } +inline void FOptiAttr::unsetDefaultColorSupport() +{ ansi_default_color = false; } #endif // FOPTIATTR_H diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index 15969052..2101cdc7 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -75,7 +75,6 @@ FOptiAttr::FOptiAttr() , alt_equal_pc_charset(false) , monochron(true) , fake_reverse(false) - , cygwin_terminal(false) , attr_ptr(attr_buf) { attr_buf[0] = '\0'; @@ -560,8 +559,6 @@ char* FOptiAttr::changeAttribute (char_data*& term, char_data*& next) if ( ! ( switchOn() || switchOff() || colorChange(term, next) ) ) return 0; - preProcessing_cygwin_quirks(term); - if ( hasNoAttribute(next) ) { deactivateAttributes (term, next); @@ -1297,42 +1294,6 @@ inline void FOptiAttr::prevent_no_color_video_attributes ( char_data*& attr } } -//---------------------------------------------------------------------- -inline void FOptiAttr::preProcessing_cygwin_quirks (char_data*& term) -{ - // Cygwin bold color fix pre processing - - if ( ! cygwin_terminal || ! term ) - return; - - if ( term->fg_color > 7 || term->bg_color > 7 ) - { - // Reset blink and bold mode from colors > 7 - char rst[] = CSI "m"; - append_sequence (rst); - reset(term); - } -} - -//---------------------------------------------------------------------- -inline void FOptiAttr::postProcessing_cygwin_quirks ( char_data*& term - , char_data*& next ) -{ - // Cygwin bold color fix post processing - - if ( ! cygwin_terminal ) - return; - - if ( next->attr.bit.bold ) - setTermBold(term); - - if ( next->attr.bit.reverse ) - setTermReverse(term); - - if ( next->attr.bit.standout ) - setTermStandout(term); -} - //---------------------------------------------------------------------- inline void FOptiAttr::deactivateAttributes ( char_data*& term , char_data*& next ) @@ -1398,10 +1359,7 @@ inline void FOptiAttr::changeAttributeSGR ( char_data*& term setTermPCcharset(term); if ( colorChange(term, next) ) - { change_color(term, next); - postProcessing_cygwin_quirks(term, next); - } } //---------------------------------------------------------------------- @@ -1411,10 +1369,7 @@ inline void FOptiAttr::changeAttributeSeparately ( char_data*& term setAttributesOff(term); if ( colorChange(term, next) ) - { change_color (term, next); - postProcessing_cygwin_quirks(term, next); - } detectSwitchOn (term, next); // After reset all attributes setAttributesOn(term); diff --git a/src/fterm.cpp b/src/fterm.cpp index a093273b..5a0e6350 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -3625,18 +3625,16 @@ void FTerm::init_termcaps_cygwin_quirks() TCAP(fc::t_enter_blink_mode) = \ C_STR(CSI "5m"); + // Set enable alternate character set for cygwin terminal + if ( ! TCAP(fc::t_enable_acs) ) + TCAP(fc::t_enable_acs) = \ + C_STR(ESC "(B" ESC ")0"); + // Set background color erase for cygwin terminal FTermcap::background_color_erase = true; // Include the Linux console quirks init_termcaps_linux_quirks(); - - // Avoid underline, blink and dim mode - FTermcap::attr_without_color = 26; - - // Invisible mode is not supported - TCAP(fc::t_enter_secure_mode) = 0; - TCAP(fc::t_exit_secure_mode) = 0; } //---------------------------------------------------------------------- @@ -3648,9 +3646,11 @@ void FTerm::init_termcaps_linux_quirks() if ( FTermcap::max_color > 8 ) { TCAP(fc::t_set_a_foreground) = \ - C_STR(CSI "3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;21%;m"); + C_STR(CSI "3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;22%;m"); TCAP(fc::t_set_a_background) = \ C_STR(CSI "4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m"); + // Avoid underline, blink and dim mode + FTermcap::attr_without_color = 26; } else { @@ -3658,20 +3658,35 @@ void FTerm::init_termcaps_linux_quirks() C_STR(CSI "3%p1%dm"); TCAP(fc::t_set_a_background) = \ C_STR(CSI "4%p1%dm"); + // Avoid underline and dim mode + FTermcap::attr_without_color = 18; } - TCAP(fc::t_orig_pair) = \ - C_STR(CSI "39;49;25m"); + // Set select graphic rendition attributes + TCAP(fc::t_set_attributes) = \ + C_STR(CSI "0" + "%?%p6%|%t;1%;" + "%?%p1%p3%|%t;7%;" + "%?%p4%t;5%;m" + "%?%p9%t\016%e\017%;"); - TCAP(fc::t_exit_reverse_mode) = \ - C_STR(CSI "27m"); + TCAP(fc::t_enter_alt_charset_mode) = C_STR("\016"); + TCAP(fc::t_exit_alt_charset_mode) = C_STR("\017"); + TCAP(fc::t_exit_attribute_mode) = C_STR(CSI "0m\017"); + TCAP(fc::t_exit_bold_mode) = C_STR(CSI "22m"); + TCAP(fc::t_exit_blink_mode) = C_STR(CSI "25m"); + TCAP(fc::t_exit_reverse_mode) = C_STR(CSI "27m"); + TCAP(fc::t_exit_secure_mode) = 0; + TCAP(fc::t_exit_protected_mode) = 0; + TCAP(fc::t_exit_crossed_out_mode) = 0; + TCAP(fc::t_orig_pair) = C_STR(CSI "39;49;25m"); // Avoid underline and dim mode TCAP(fc::t_enter_dim_mode) = 0; TCAP(fc::t_exit_dim_mode) = 0; TCAP(fc::t_enter_underline_mode) = 0; TCAP(fc::t_exit_underline_mode) = 0; - FTermcap::attr_without_color = 18; + } //---------------------------------------------------------------------- @@ -4099,9 +4114,6 @@ void FTerm::init_OptiAttr() if ( FTermcap::ansi_default_color ) opti_attr->setDefaultColorSupport(); - if ( cygwin_terminal ) - opti_attr->setCygwinTerminal(); - opti_attr->initialize(); } diff --git a/src/fvterm.cpp b/src/fvterm.cpp index 815bb0ce..828ad252 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -688,8 +688,6 @@ int FVTerm::print (term_area* area, char_data& term_char) return 1; } -//---------------------------------------------------------------------- - // protected methods of FVTerm //---------------------------------------------------------------------- FVTerm::term_area* FVTerm::getPrintArea() @@ -2910,34 +2908,34 @@ inline void FVTerm::charsetChanges (char_data*& next_char) uInt code = uInt(next_char->code); uInt ch_enc = charEncode(code); - if ( ch_enc != code ) + if ( ch_enc == code ) + return; + + if ( ch_enc == 0 ) { - if ( ch_enc == 0 ) - { - next_char->code = int(charEncode(code, fc::ASCII)); + next_char->code = int(charEncode(code, fc::ASCII)); + return; + } + + next_char->code = int(ch_enc); + + if ( term_encoding == fc::VT100 ) + next_char->attr.bit.alt_charset = true; + else if ( term_encoding == fc::PC ) + { + next_char->attr.bit.pc_charset = true; + + if ( isPuttyTerminal() ) return; - } - next_char->code = int(ch_enc); - - if ( term_encoding == fc::VT100 ) - next_char->attr.bit.alt_charset = true; - else if ( term_encoding == fc::PC ) + if ( isXTerminal() && ch_enc < 0x20 ) // Character 0x00..0x1f { - next_char->attr.bit.pc_charset = true; - - if ( isPuttyTerminal() ) - return; - - if ( isXTerminal() && ch_enc < 0x20 ) // Character 0x00..0x1f + if ( hasUTF8() ) + next_char->code = int(charEncode(code, fc::ASCII)); + else { - if ( hasUTF8() ) - next_char->code = int(charEncode(code, fc::ASCII)); - else - { - next_char->code += 0x5f; - next_char->attr.bit.alt_charset = true; - } + next_char->code += 0x5f; + next_char->attr.bit.alt_charset = true; } } }