Replace non-printable chars for Tera Term and Cygwin

This commit is contained in:
Markus Gans 2017-04-05 00:30:52 +02:00
parent 8de22dc903
commit 6b5f033b7b
13 changed files with 61 additions and 78 deletions

View File

@ -1,3 +1,8 @@
2017-04-05 Markus Gans <guru.mail@muenster.de>
* Replace non-printable characters for Tera Term and
Cygwin terminal directly at start-up. Special cases
in the code are no longer necessary.
2017-04-02 Markus Gans <guru.mail@muenster.de>
* Remap the meta key to left alt key at runtime
on the FreeBSD console for the accelerator key access

View File

@ -197,7 +197,7 @@ bool FButton::setFlat (bool on)
bool FButton::setShadow (bool on)
{
if ( on
&& (Encoding != fc::VT100 || isTeraTerm() )
&& Encoding != fc::VT100
&& Encoding != fc::ASCII )
{
flags |= fc::shadow;

View File

@ -1285,12 +1285,7 @@ void FDialog::drawTitleBar()
else
{
print (' ');
if ( isCygwinTerminal() )
print ('v');
else
print (fc::BlackDownPointingTriangle); // ▼
print (' ');
}
}
@ -1313,12 +1308,7 @@ void FDialog::drawTitleBar()
else
{
print (' ');
if ( isCygwinTerminal() )
print ('^');
else
print (fc::BlackUpPointingTriangle); // ▲
print (' ');
}
}

View File

@ -137,7 +137,7 @@ bool FLineEdit::setFocus (bool on)
bool FLineEdit::setShadow (bool on)
{
if ( on
&& (Encoding != fc::VT100 || isTeraTerm() )
&& Encoding != fc::VT100
&& Encoding != fc::ASCII )
{
flags |= fc::shadow;

View File

@ -1278,8 +1278,6 @@ void FMenu::drawItems()
{
if ( isNewFont() )
print (fc::NF_Bullet); // NF_Bullet ●
else if ( isCygwinTerminal() )
print (0x04);
else
print (fc::Bullet); // Bullet ●
}
@ -1287,8 +1285,6 @@ void FMenu::drawItems()
{
if ( isNewFont() )
print (fc::NF_check_mark); // NF_check_mark ✓
else if ( isCygwinTerminal() )
print (fc::Times); // Times ×
else
print (fc::SquareRoot); // SquareRoot √
}

View File

@ -70,7 +70,7 @@ bool FProgressbar::setEnable (bool on)
bool FProgressbar::setShadow (bool on)
{
if ( on
&& (Encoding != fc::VT100 || isTeraTerm() )
&& Encoding != fc::VT100
&& Encoding != fc::ASCII )
{
flags |= fc::shadow;
@ -202,7 +202,6 @@ void FProgressbar::drawBar()
if ( percentage > 0.0f && trunc(length) < bar_length )
{
if ( round(length) > trunc(length)
|| isCygwinTerminal()
|| getMaxColor() < 16 )
{
if ( isMonochron() )

View File

@ -70,12 +70,7 @@ void FRadioButton::drawRadioButton()
else
{
print ('(');
if ( isCygwinTerminal() )
print (0x04);
else
print (fc::Bullet); // Bullet ●
print (')');
}
}

View File

@ -259,16 +259,8 @@ void FScrollbar::drawButtons()
if ( bar_orientation == fc::vertical )
{
if ( isCygwinTerminal() )
print ('^');
else
print (fc::BlackUpPointingTriangle); // ▲
setPrintPos (1, length);
if ( isCygwinTerminal() )
print ('v');
else
print (fc::BlackDownPointingTriangle); // ▼
}
else // horizontal

View File

@ -1640,6 +1640,36 @@ void FTerm::initBSDConsoleCharMap()
}
#endif
//----------------------------------------------------------------------
void FTerm::initCygwinCharMap()
{
// Replace don't printable characters in a Cygwin terminal
if ( ! cygwin_terminal )
return;
for (int i=0; i <= lastCharItem; i++ )
{
if ( character[i][fc::UTF8] == fc::BlackUpPointingTriangle // ▲
|| character[i][fc::UTF8] == fc::BlackDownPointingTriangle // ▼
|| character[i][fc::UTF8] == fc::SquareRoot ) // SquareRoot √
character[i][fc::PC] = character[i][fc::ASCII];
}
}
//----------------------------------------------------------------------
void FTerm::initTeraTermCharMap()
{
// Tera Term can't print ascii characters < 0x20
if ( ! tera_terminal )
return;
for (int i=0; i <= lastCharItem; i++ )
if ( character[i][fc::PC] < 0x20 )
character[i][fc::PC] = character[i][fc::ASCII];
}
//----------------------------------------------------------------------
bool FTerm::charEncodable (uInt c)
{
@ -2833,7 +2863,7 @@ void FTerm::init_termcaps()
// U8 is nonzero for terminals with no VT100 line-drawing in UTF-8 mode
FTermcap::no_utf8_acs_chars = bool(tgetnum(const_cast<char*>("U8")) != 0);
if ( isTeraTerm() )
if ( tera_terminal )
FTermcap::eat_nl_glitch = true;
// get termcap numeric
@ -3325,7 +3355,8 @@ void FTerm::init_encoding()
if ( linux_terminal
|| cygwin_terminal
|| NewFont
|| (putty_terminal && ! utf8_state) )
|| (putty_terminal && ! utf8_state)
|| (tera_terminal && ! utf8_state) )
{
pc_charset_console = true;
Encoding = fc::PC;
@ -3664,6 +3695,12 @@ void FTerm::init()
if ( kde_konsole )
setKDECursor(fc::UnderlineCursor);
if ( cygwin_terminal )
initCygwinCharMap();
if ( tera_terminal )
initTeraTermCharMap();
if ( FTermcap::max_color >= 16
&& ! cygwin_terminal
&& ! kde_konsole

View File

@ -260,6 +260,8 @@ class FTerm
#if defined(BSD)
static void initBSDConsoleCharMap();
#endif
static void initCygwinCharMap();
static void initTeraTermCharMap();
static bool charEncodable (uInt);
static uInt charEncode (uInt);

View File

@ -1353,7 +1353,7 @@ void FWidget::drawShadow()
if ( isMonochron() && ! trans_shadow )
return;
if ( (Encoding == fc::VT100 && ! (trans_shadow || isTeraTerm()) )
if ( (Encoding == fc::VT100 && ! trans_shadow)
|| (Encoding == fc::ASCII && ! trans_shadow) )
{
clearShadow();
@ -1417,16 +1417,8 @@ void FWidget::drawShadow()
else if ( FWidget* p = getParentWidget() )
setColor (wc.shadow_fg, p->getBackgroundColor());
if ( isTeraTerm() )
{
block = 0xdb; // █
print (0xdc); // ▄
}
else
{
block = fc::FullBlock; // █
print (fc::LowerHalfBlock); // ▄
}
if ( isWindowWidget() )
unsetInheritBackground();
@ -1443,12 +1435,7 @@ void FWidget::drawShadow()
setInheritBackground();
for (int i=1; i <= getWidth(); i++)
{
if ( isTeraTerm() )
print (0xdf); // ▀
else
print (fc::UpperHalfBlock); // ▀
}
if ( isWindowWidget() )
unsetInheritBackground();
@ -2412,9 +2399,6 @@ void FWidget::setColorTheme()
if ( isKdeTerminal() )
wc.term_bg = fc::SteelBlue3;
if ( isTeraTerm() )
wc.term_bg = fc::LightBlue;
if ( getMaxColor() < 16 ) // for 8 color mode
{
wc.term_fg = fc::Black;

View File

@ -69,12 +69,6 @@ scrollview::scrollview (FWidget* parent)
go_north = new FButton(wchar_t(fc::BlackUpPointingTriangle) , this);
go_north->setGeometry (1, getScrollHeight() - 2, 5, 1);
if ( isCygwinTerminal() )
{
go_south->setText ('v');
go_north->setText ('^');
}
go_east->addCallback
(
"clicked",

View File

@ -60,16 +60,8 @@ smallWindow::smallWindow (FWidget* parent)
{
wchar_t arrow_up, arrow_down;
if ( isCygwinTerminal() )
{
arrow_up = L'^';
arrow_down = L'v';
}
else
{
arrow_up = fc::BlackUpPointingTriangle;
arrow_down = fc::BlackDownPointingTriangle;
}
left_arrow = new FLabel (arrow_up, this);
left_arrow->setForegroundColor (wc.label_inactive_fg);
@ -222,9 +214,6 @@ Window::Window (FWidget* parent)
File->setStatusbarMessage ("File management commands");
// dialog list menu item
if ( isCygwinTerminal() )
drop_down_symbol = 'v';
else
drop_down_symbol = wchar_t(fc::BlackDownPointingTriangle);
FDialogListMenu* DglList = new FDialogListMenu (drop_down_symbol, Menubar);