Avoid height and width underflow in adjustSize

This commit is contained in:
Markus Gans 2016-01-17 23:37:52 +01:00
parent b21fe6a405
commit e35340114b
6 changed files with 46 additions and 11 deletions

View File

@ -1,5 +1,7 @@
2016-01-17 Markus Gans <guru.mail@muenster.de> 2016-01-17 Markus Gans <guru.mail@muenster.de>
* Moving events into the class fc * 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 <guru.mail@muenster.de> 2016-01-10 Markus Gans <guru.mail@muenster.de>
* Better default color handling in FOptiAttr * Better default color handling in FOptiAttr

View File

@ -305,7 +305,7 @@ void FApplication::processKeyboardEvent()
x11_mouse[3] = '\0'; x11_mouse[3] = '\0';
for (n=len; n < fifo_buf_size; n++) // Remove founded entry 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; n = fifo_buf_size-len-1;
for (; n < fifo_buf_size; n++) // Fill rest with '\0' for (; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n-len] = '\0'; fifo_buf[n-len] = '\0';

View File

@ -214,7 +214,12 @@ void FOptiAttr::change_color (char_data*& term, char_data*& next)
} }
else if ( bg == Default && term->bg_color != Default ) else if ( bg == Default && term->bg_color != Default )
{ {
char* sgr_49 = const_cast<char*>("\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<char*>("\033[49;25m");
else
sgr_49 = const_cast<char*>("\033[49m");
append_sequence (sgr_49); append_sequence (sgr_49);
term->bg_color = Default; term->bg_color = Default;
} }
@ -231,7 +236,11 @@ void FOptiAttr::change_color (char_data*& term, char_data*& next)
return; return;
if ( fake_reverse ) if ( fake_reverse )
{
std::swap (fg, bg); std::swap (fg, bg);
if ( fg == Default || bg == Default )
setTermDefaultColor(term);
}
if ( AF && AB ) if ( AF && AB )
{ {
@ -240,17 +249,23 @@ void FOptiAttr::change_color (char_data*& term, char_data*& next)
if ( cygwin_terminal ) if ( cygwin_terminal )
{ {
// reset blink and bold mode from colors > 7
char* rst = const_cast<char*>("\033[m"); char* rst = const_cast<char*>("\033[m");
append_sequence (rst); append_sequence (rst);
reset(term); reset(term);
color_str = tparm(AF, ansi_fg); if ( ansi_fg != Default )
if ( color_str ) {
append_sequence (color_str); color_str = tparm(AF, ansi_fg);
if ( color_str )
color_str = tparm(AB, ansi_bg); append_sequence (color_str);
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 else
{ {
@ -1336,7 +1351,18 @@ char* FOptiAttr::change_attribute (char_data*& term, char_data*& next)
setTermPCcharset(term); setTermPCcharset(term);
if ( colorChange(term, next) ) if ( colorChange(term, next) )
{
change_color (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 else
{ {

View File

@ -999,7 +999,7 @@ void FTerm::init_pc_charset()
{ {
bool reinit = false; bool reinit = false;
// rxvt does not support pc charset // rxvt does not support pc charset
if ( rxvt_terminal || urxvt_terminal ) if ( rxvt_terminal || urxvt_terminal )
return; return;
@ -1148,6 +1148,8 @@ void FTerm::init_termcaps()
const_cast<char*>("\033[3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;21%;m"); const_cast<char*>("\033[3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;21%;m");
tcap[t_set_a_background].string = \ tcap[t_set_a_background].string = \
const_cast<char*>("\033[4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m"); const_cast<char*>("\033[4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m");
tcap[t_orig_pair].string = \
const_cast<char*>("\033[39;49;25m");
} }
else if ( rxvt_terminal && ! urxvt_terminal ) else if ( rxvt_terminal && ! urxvt_terminal )
{ {

View File

@ -445,6 +445,11 @@ void FWidget::adjustSize()
width--; width--;
while ( ymin+height-1 > ymax ) while ( ymin+height-1 > ymax )
height--; height--;
if ( width < 1 )
width = 1;
if ( height < 1 )
height = 1;
} }
adjustWidgetSize.setRect(xpos, ypos, width, height); adjustWidgetSize.setRect(xpos, ypos, width, height);

View File

@ -346,7 +346,7 @@ void AttribDemo::draw()
short bg = static_cast<AttribDlg*>(getParent())->bgcolor; short bg = static_cast<AttribDlg*>(getParent())->bgcolor;
print (" Background color:"); print (" Background color:");
if ( bg == fc::Default ) if ( bg == fc::Default )
print (" default"); print (" default");
else else
printf ( " %d", bg); printf ( " %d", bg);
gotoxy (xpos + xmin + 14, ypos + ymin + 15); gotoxy (xpos + xmin + 14, ypos + ymin + 15);