diff --git a/ChangeLog b/ChangeLog index d8d59a26..0d12f313 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2016-01-17 Markus Gans * Moving events into the class fc + * Avoid height and width underflow in adjustSize() + * Fix default color handling on Cygwin and Linux terminals 2016-01-10 Markus Gans * Better default color handling in FOptiAttr diff --git a/src/fapp.cpp b/src/fapp.cpp index 283499b4..87f802d7 100644 --- a/src/fapp.cpp +++ b/src/fapp.cpp @@ -305,7 +305,7 @@ void FApplication::processKeyboardEvent() x11_mouse[3] = '\0'; for (n=len; n < fifo_buf_size; n++) // Remove founded entry - fifo_buf[n-len] = fifo_buf[n]; + fifo_buf[n-len] = fifo_buf[n]; n = fifo_buf_size-len-1; for (; n < fifo_buf_size; n++) // Fill rest with '\0' fifo_buf[n-len] = '\0'; diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index d6630b7b..03fbbdb1 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -214,7 +214,12 @@ void FOptiAttr::change_color (char_data*& term, char_data*& next) } else if ( bg == Default && term->bg_color != Default ) { - char* sgr_49 = const_cast("\033[49m"); + char* sgr_49; + char* op = F_orig_pair.cap; + if ( op && strncmp (op, "\033[39;49;25m", 11) == 0 ) + sgr_49 = const_cast("\033[49;25m"); + else + sgr_49 = const_cast("\033[49m"); append_sequence (sgr_49); term->bg_color = Default; } @@ -231,7 +236,11 @@ void FOptiAttr::change_color (char_data*& term, char_data*& next) return; if ( fake_reverse ) + { std::swap (fg, bg); + if ( fg == Default || bg == Default ) + setTermDefaultColor(term); + } if ( AF && AB ) { @@ -240,17 +249,23 @@ void FOptiAttr::change_color (char_data*& term, char_data*& next) if ( cygwin_terminal ) { + // reset blink and bold mode from colors > 7 char* rst = const_cast("\033[m"); append_sequence (rst); reset(term); - color_str = tparm(AF, ansi_fg); - if ( color_str ) - append_sequence (color_str); - - color_str = tparm(AB, ansi_bg); - if ( color_str ) - append_sequence (color_str); + if ( ansi_fg != Default ) + { + color_str = tparm(AF, ansi_fg); + if ( color_str ) + append_sequence (color_str); + } + if ( ansi_bg != Default ) + { + color_str = tparm(AB, ansi_bg); + if ( color_str ) + append_sequence (color_str); + } } else { @@ -1336,7 +1351,18 @@ char* FOptiAttr::change_attribute (char_data*& term, char_data*& next) setTermPCcharset(term); if ( colorChange(term, next) ) + { change_color (term, next); + if ( cygwin_terminal ) + { + if ( next->bold ) + setTermBold(term); + if ( next->reverse ) + setTermReverse(term); + if ( next->standout ) + setTermStandout(term); + } + } } else { diff --git a/src/fterm.cpp b/src/fterm.cpp index dac0b558..24c56efa 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -999,7 +999,7 @@ void FTerm::init_pc_charset() { bool reinit = false; - // rxvt does not support pc charset + // rxvt does not support pc charset if ( rxvt_terminal || urxvt_terminal ) return; @@ -1148,6 +1148,8 @@ void FTerm::init_termcaps() const_cast("\033[3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;21%;m"); tcap[t_set_a_background].string = \ const_cast("\033[4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m"); + tcap[t_orig_pair].string = \ + const_cast("\033[39;49;25m"); } else if ( rxvt_terminal && ! urxvt_terminal ) { diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 64246e8f..cac6c56f 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -445,6 +445,11 @@ void FWidget::adjustSize() width--; while ( ymin+height-1 > ymax ) height--; + + if ( width < 1 ) + width = 1; + if ( height < 1 ) + height = 1; } adjustWidgetSize.setRect(xpos, ypos, width, height); diff --git a/test/term-attributes.cpp b/test/term-attributes.cpp index 477c12a8..643471ea 100644 --- a/test/term-attributes.cpp +++ b/test/term-attributes.cpp @@ -346,7 +346,7 @@ void AttribDemo::draw() short bg = static_cast(getParent())->bgcolor; print (" Background color:"); if ( bg == fc::Default ) - print (" default"); + print (" default"); else printf ( " %d", bg); gotoxy (xpos + xmin + 14, ypos + ymin + 15);