Do not draw shadows on a linux console if not all characters are available

This commit is contained in:
Markus Gans 2016-11-13 22:08:40 +01:00
parent 04a483526f
commit fc8ee51e72
11 changed files with 91 additions and 144 deletions

View File

@ -1,3 +1,7 @@
2016-11-13 Markus Gans <guru.mail@muenster.de>
* Do not draw shadows on a linux console if not
all characters are available
2016-11-12 Markus Gans <guru.mail@muenster.de> 2016-11-12 Markus Gans <guru.mail@muenster.de>
* Better support for Linux terminals with 8 colors * Better support for Linux terminals with 8 colors
* Optimized input cursor positioning for terminals without hidden cursor * Optimized input cursor positioning for terminals without hidden cursor

View File

@ -596,41 +596,20 @@ void FButton::draw()
if ( isMonochron() && (is_Active || is_Focus) ) if ( isMonochron() && (is_Active || is_Focus) )
setReverse(false); setReverse(false);
if ( is_Flat ) if ( margin == 1 )
{ {
if ( margin == 1 ) setColor (getForegroundColor(), button_bg);
{
setColor (getForegroundColor(), button_bg);
for (int y=0; y < getHeight(); y++)
{
setPrintPos (1+d, 1+y);
print (space); // full block █
}
}
if ( ! button_down )
drawFlatBorder();
}
else if ( ! isMonochron() )
{
if ( parent_widget )
setColor (button_bg, parent_widget->getBackgroundColor());
for (int y=0; y < getHeight(); y++) for (int y=0; y < getHeight(); y++)
{ {
setPrintPos (1+d, 1+y); setPrintPos (1+d, 1+y);
print (space); // full block █
// Cygwin terminal use IBM Codepage 850
if ( isCygwinTerminal() )
print (fc::FullBlock); // █
else if ( isTeraTerm() )
print (0xdb);
else
print (fc::RightHalfBlock); // ▐
} }
} }
if ( is_Flat && ! button_down )
drawFlatBorder();
if ( ! button_down if ( ! button_down
&& ! isNewFont() && ! isNewFont()
&& (is_Flat || ! hasShadow() || isMonochron()) ) && (is_Flat || ! hasShadow() || isMonochron()) )

View File

@ -489,7 +489,7 @@ void FFileDialog::init()
FDialog::setText("Open file"); FDialog::setText("Open file");
filename = new FLineEdit(this); filename = new FLineEdit(this);
filename->setLabelText("File&name:"); filename->setLabelText("File&name");
filename->setText(filter_pattern); filename->setText(filter_pattern);
filename->setGeometry(11, 1, 28, 1); filename->setGeometry(11, 1, 28, 1);
filename->setFocus(); filename->setFocus();

View File

@ -664,7 +664,7 @@ void FLineEdit::adjustLabel()
break; break;
case label_left: case label_left:
label->setGeometry(getX()-label_length, getY(), label_length, 1); label->setGeometry(getX()-label_length-1, getY(), label_length, 1);
break; break;
} }
} }
@ -742,12 +742,11 @@ void FLineEdit::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLineEdit::drawInputField() void FLineEdit::drawInputField()
{ {
bool isActiveFocus, isActive, isShadow; bool isActiveFocus, isShadow;
int x; int x;
FString show_text; FString show_text;
int active_focus = fc::active + fc::focus; int active_focus = fc::active + fc::focus;
isActiveFocus = ((flags & active_focus) == active_focus); isActiveFocus = ((flags & active_focus) == active_focus);
isActive = ((flags & fc::active) != 0);
isShadow = ((flags & fc::shadow) != 0 ); isShadow = ((flags & fc::shadow) != 0 );
updateVTerm(false); updateVTerm(false);
@ -763,44 +762,15 @@ void FLineEdit::drawInputField()
else else
setUnderline(true); setUnderline(true);
} }
else if ( isActiveFocus ) else
{ {
setColor (wc.inputfield_active_focus_bg, wc.dialog_bg); setColor();
print (' ');
if ( isCygwinTerminal() ) // IBM Codepage 850
print (fc::FullBlock); // █
else if ( isTeraTerm() )
print (0xdb);
else
print (fc::RightHalfBlock); // ▐
}
else if ( isActive )
{
setColor (wc.inputfield_active_bg, wc.dialog_bg);
if ( isCygwinTerminal() ) // IBM Codepage 850
print (fc::FullBlock); // █
else if ( isTeraTerm() )
print (0xdb);
else
print (fc::RightHalfBlock); // ▐
}
else // isInactive
{
setColor (wc.inputfield_inactive_bg, wc.dialog_bg);
if ( isCygwinTerminal() ) // IBM Codepage 850
print (fc::FullBlock); // █
else if ( isTeraTerm() )
print (0xdb);
else
print (fc::RightHalfBlock); // ▐
} }
if ( isActiveFocus && getMaxColor() < 16 ) if ( isActiveFocus && getMaxColor() < 16 )
setBold(); setBold();
setColor();
show_text = text.mid(uInt(1+text_offset), uInt(getWidth()-2)); show_text = text.mid(uInt(1+text_offset), uInt(getWidth()-2));
if ( isUTF8_linux_terminal() ) if ( isUTF8_linux_terminal() )

View File

@ -185,53 +185,9 @@ void FProgressbar::drawPercentage()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::drawBar() void FProgressbar::drawBar()
{ {
int i = 1; int i = 0;
float length = float(bar_length * percentage) / 100; float length = float(bar_length * percentage) / 100;
setPrintPos (1,1); setPrintPos (1,1);
if ( isMonochron() )
{
if ( round(length) >= 1)
{
setReverse(false);
print (' ');
setReverse(true);
}
else
print (fc::MediumShade); // ▒
}
else if ( getMaxColor() < 16 )
{
setColor ( wc.progressbar_bg
, wc.progressbar_fg );
if ( round(length) >= 1)
print (' ');
else
print (fc::MediumShade);
}
if ( getParentWidget() )
{
if ( round(length) >= 1)
setColor ( wc.progressbar_fg
, getParentWidget()->getBackgroundColor() );
else
setColor ( wc.progressbar_bg
, getParentWidget()->getBackgroundColor() );
}
if ( ! isMonochron() && getMaxColor() >= 16 )
{
// Cygwin terminal use IBM Codepage 850
if ( isCygwinTerminal() )
print (fc::FullBlock); // █
else if ( isTeraTerm() )
print (0xdb);
else
print (fc::RightHalfBlock); // ▐
}
setColor ( wc.progressbar_bg setColor ( wc.progressbar_bg
, wc.progressbar_fg ); , wc.progressbar_fg );
@ -244,7 +200,7 @@ void FProgressbar::drawBar()
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
if ( trunc(length) >= 1 && trunc(length) < bar_length ) if ( percentage > 0.0f && trunc(length) < bar_length )
{ {
if ( round(length) > trunc(length) if ( round(length) > trunc(length)
|| isCygwinTerminal() || isCygwinTerminal()

View File

@ -687,9 +687,15 @@ void FStatusBar::drawKeys()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
setColor (wc.statusbar_active_fg, wc.statusbar_active_bg); if ( no_half_block_character )
print (' ');
else
{
setColor (wc.statusbar_active_fg, wc.statusbar_active_bg);
print (fc::LeftHalfBlock); // ▐
}
x++; x++;
print (fc::LeftHalfBlock); // ▐
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);

View File

@ -58,6 +58,8 @@ bool FTerm::vt100_console;
bool FTerm::ascii_console; bool FTerm::ascii_console;
bool FTerm::NewFont; bool FTerm::NewFont;
bool FTerm::VGAFont; bool FTerm::VGAFont;
bool FTerm::no_shadow_character;
bool FTerm::no_half_block_character;
bool FTerm::cursor_optimisation; bool FTerm::cursor_optimisation;
bool FTerm::xterm_default_colors; bool FTerm::xterm_default_colors;
termios FTerm::term_init; termios FTerm::term_init;
@ -1482,6 +1484,8 @@ int FTerm::UTF8decode(char* utf8)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::init_consoleCharMap() void FTerm::init_consoleCharMap()
{ {
uInt c1, c2, c3, c4, c5;
if ( NewFont || VGAFont ) if ( NewFont || VGAFont )
return; return;
@ -1504,6 +1508,26 @@ void FTerm::init_consoleCharMap()
character[i][fc::PC] = character[i][fc::ASCII]; character[i][fc::PC] = character[i][fc::ASCII];
} }
} }
c1 = fc::UpperHalfBlock;
c2 = fc::LowerHalfBlock;
c3 = fc::FullBlock;
if ( charEncode(c1, fc::PC) == charEncode(c1, fc::ASCII)
|| charEncode(c2, fc::PC) == charEncode(c2, fc::ASCII)
|| charEncode(c3, fc::PC) == charEncode(c3, fc::ASCII) )
{
no_shadow_character = true;
}
c4 = fc::RightHalfBlock;
c5 = fc::LeftHalfBlock;
if ( charEncode(c4, fc::PC) == charEncode(c4, fc::ASCII)
|| charEncode(c5, fc::PC) == charEncode(c5, fc::ASCII) )
{
no_half_block_character = true;
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2948,29 +2972,30 @@ void FTerm::init()
(*encoding_set)["ASCII"] = fc::ASCII; (*encoding_set)["ASCII"] = fc::ASCII;
// Preset to false // Preset to false
utf8_console = \ utf8_console = \
utf8_input = \ utf8_input = \
utf8_state = \ utf8_state = \
utf8_linux_terminal = \ utf8_linux_terminal = \
pc_charset_console = \ pc_charset_console = \
vt100_console = \ vt100_console = \
NewFont = \ NewFont = \
VGAFont = \ VGAFont = \
ascii_console = \ no_shadow_character = \
mouse_support = \ no_half_block_character = \
ascii_console = \
force_vt100 = \ mouse_support = \
tera_terminal = \ force_vt100 = \
kterm_terminal = \ tera_terminal = \
gnome_terminal = \ kterm_terminal = \
kde_konsole = \ gnome_terminal = \
rxvt_terminal = \ kde_konsole = \
urxvt_terminal = \ rxvt_terminal = \
mlterm_terminal = \ urxvt_terminal = \
mintty_terminal = \ mlterm_terminal = \
screen_terminal = \ mintty_terminal = \
tmux_terminal = \ screen_terminal = \
xterm_default_colors = false; tmux_terminal = \
xterm_default_colors = false;
// Preset to true // Preset to true
cursor_optimisation = \ cursor_optimisation = \

View File

@ -250,6 +250,8 @@ class FTerm
static int stdout_no; static int stdout_no;
static bool NewFont; static bool NewFont;
static bool VGAFont; static bool VGAFont;
static bool no_shadow_character;
static bool no_half_block_character;
static bool cursor_optimisation; static bool cursor_optimisation;
static bool xterm_default_colors; static bool xterm_default_colors;
static fc::encoding Encoding; static fc::encoding Encoding;

View File

@ -1092,13 +1092,15 @@ void FWidget::show()
if ( ! visible ) if ( ! visible )
return; return;
// Important: Do not use setNewFont() or setVGAFont() after
// the console character mapping has been initialized
if ( getMainWidget() == this ) if ( getMainWidget() == this )
{ {
// Important: Do not use setNewFont() or setVGAFont() after
// the console character mapping has been initialized
init_consoleCharMap(); init_consoleCharMap();
// set xterm underline cursor // set xterm underline cursor
setXTermCursorStyle(fc::blinking_underline); setXTermCursorStyle(fc::blinking_underline);
// set xterm color settings to defaults // set xterm color settings to defaults
setXTermDefaults(); setXTermDefaults();
} }
@ -1326,6 +1328,10 @@ void FWidget::drawShadow()
{ {
// non-transparent shadow // non-transparent shadow
int block; int block;
if ( no_shadow_character )
return;
setPrintPos (x2+1, y1); setPrintPos (x2+1, y1);
if ( isWindowWidget() ) if ( isWindowWidget() )
@ -1336,7 +1342,6 @@ void FWidget::drawShadow()
else if ( FWidget* p = getParentWidget() ) else if ( FWidget* p = getParentWidget() )
setColor (wc.shadow_fg, p->getBackgroundColor()); setColor (wc.shadow_fg, p->getBackgroundColor());
if ( isTeraTerm() ) if ( isTeraTerm() )
{ {
block = 0xdb; // █ block = 0xdb; // █

View File

@ -58,12 +58,12 @@ int main (int argc, char* argv[])
FLineEdit* st_field = new FLineEdit(&dgl); FLineEdit* st_field = new FLineEdit(&dgl);
FLineEdit* c_field = new FLineEdit(&dgl); FLineEdit* c_field = new FLineEdit(&dgl);
name_field->setLabelText(L"&Name:"); name_field->setLabelText(L"&Name");
email_field->setLabelText(L"&Email:"); email_field->setLabelText(L"&Email");
org_field->setLabelText(L"Or&ganization:"); org_field->setLabelText(L"Or&ganization");
city_field->setLabelText(L"&City:"); city_field->setLabelText(L"&City");
st_field->setLabelText(L"&State:"); st_field->setLabelText(L"&State");
c_field->setLabelText(L"&Country:"); c_field->setLabelText(L"&Country");
name_field->setGeometry(15, 1, 19, 1); name_field->setGeometry(15, 1, 19, 1);
email_field->setGeometry(15, 3, 19, 1); email_field->setGeometry(15, 3, 19, 1);

View File

@ -467,7 +467,7 @@ MyDialog::MyDialog (FWidget* parent)
myLineEdit = new FLineEdit (this); myLineEdit = new FLineEdit (this);
myLineEdit->setGeometry(22, 1, 10, 1); myLineEdit->setGeometry(22, 1, 10, 1);
myLineEdit->setText (FString("EnTry").toLower()); myLineEdit->setText (FString("EnTry").toLower());
myLineEdit->setLabelText (L"&Input:"); myLineEdit->setLabelText (L"&Input");
myLineEdit->setStatusbarMessage ("Press Enter to set the title"); myLineEdit->setStatusbarMessage ("Press Enter to set the title");
// Buttons // Buttons