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> 2017-04-02 Markus Gans <guru.mail@muenster.de>
* Remap the meta key to left alt key at runtime * Remap the meta key to left alt key at runtime
on the FreeBSD console for the accelerator key access 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) bool FButton::setShadow (bool on)
{ {
if ( on if ( on
&& (Encoding != fc::VT100 || isTeraTerm() ) && Encoding != fc::VT100
&& Encoding != fc::ASCII ) && Encoding != fc::ASCII )
{ {
flags |= fc::shadow; flags |= fc::shadow;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1640,6 +1640,36 @@ void FTerm::initBSDConsoleCharMap()
} }
#endif #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) 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 // 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); FTermcap::no_utf8_acs_chars = bool(tgetnum(const_cast<char*>("U8")) != 0);
if ( isTeraTerm() ) if ( tera_terminal )
FTermcap::eat_nl_glitch = true; FTermcap::eat_nl_glitch = true;
// get termcap numeric // get termcap numeric
@ -3325,7 +3355,8 @@ void FTerm::init_encoding()
if ( linux_terminal if ( linux_terminal
|| cygwin_terminal || cygwin_terminal
|| NewFont || NewFont
|| (putty_terminal && ! utf8_state) ) || (putty_terminal && ! utf8_state)
|| (tera_terminal && ! utf8_state) )
{ {
pc_charset_console = true; pc_charset_console = true;
Encoding = fc::PC; Encoding = fc::PC;
@ -3664,6 +3695,12 @@ void FTerm::init()
if ( kde_konsole ) if ( kde_konsole )
setKDECursor(fc::UnderlineCursor); setKDECursor(fc::UnderlineCursor);
if ( cygwin_terminal )
initCygwinCharMap();
if ( tera_terminal )
initTeraTermCharMap();
if ( FTermcap::max_color >= 16 if ( FTermcap::max_color >= 16
&& ! cygwin_terminal && ! cygwin_terminal
&& ! kde_konsole && ! kde_konsole

View File

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

View File

@ -1353,7 +1353,7 @@ void FWidget::drawShadow()
if ( isMonochron() && ! trans_shadow ) if ( isMonochron() && ! trans_shadow )
return; return;
if ( (Encoding == fc::VT100 && ! (trans_shadow || isTeraTerm()) ) if ( (Encoding == fc::VT100 && ! trans_shadow)
|| (Encoding == fc::ASCII && ! trans_shadow) ) || (Encoding == fc::ASCII && ! trans_shadow) )
{ {
clearShadow(); clearShadow();
@ -1417,16 +1417,8 @@ 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() ) block = fc::FullBlock; // █
{ print (fc::LowerHalfBlock); // ▄
block = 0xdb; // █
print (0xdc); // ▄
}
else
{
block = fc::FullBlock; // █
print (fc::LowerHalfBlock); // ▄
}
if ( isWindowWidget() ) if ( isWindowWidget() )
unsetInheritBackground(); unsetInheritBackground();
@ -1443,12 +1435,7 @@ void FWidget::drawShadow()
setInheritBackground(); setInheritBackground();
for (int i=1; i <= getWidth(); i++) for (int i=1; i <= getWidth(); i++)
{ print (fc::UpperHalfBlock); // ▀
if ( isTeraTerm() )
print (0xdf); // ▀
else
print (fc::UpperHalfBlock); // ▀
}
if ( isWindowWidget() ) if ( isWindowWidget() )
unsetInheritBackground(); unsetInheritBackground();
@ -2412,9 +2399,6 @@ void FWidget::setColorTheme()
if ( isKdeTerminal() ) if ( isKdeTerminal() )
wc.term_bg = fc::SteelBlue3; wc.term_bg = fc::SteelBlue3;
if ( isTeraTerm() )
wc.term_bg = fc::LightBlue;
if ( getMaxColor() < 16 ) // for 8 color mode if ( getMaxColor() < 16 ) // for 8 color mode
{ {
wc.term_fg = fc::Black; 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 = new FButton(wchar_t(fc::BlackUpPointingTriangle) , this);
go_north->setGeometry (1, getScrollHeight() - 2, 5, 1); go_north->setGeometry (1, getScrollHeight() - 2, 5, 1);
if ( isCygwinTerminal() )
{
go_south->setText ('v');
go_north->setText ('^');
}
go_east->addCallback go_east->addCallback
( (
"clicked", "clicked",

View File

@ -60,16 +60,8 @@ smallWindow::smallWindow (FWidget* parent)
{ {
wchar_t arrow_up, arrow_down; wchar_t arrow_up, arrow_down;
if ( isCygwinTerminal() ) arrow_up = fc::BlackUpPointingTriangle;
{ arrow_down = fc::BlackDownPointingTriangle;
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 = new FLabel (arrow_up, this);
left_arrow->setForegroundColor (wc.label_inactive_fg); left_arrow->setForegroundColor (wc.label_inactive_fg);
@ -222,10 +214,7 @@ Window::Window (FWidget* parent)
File->setStatusbarMessage ("File management commands"); File->setStatusbarMessage ("File management commands");
// dialog list menu item // dialog list menu item
if ( isCygwinTerminal() ) drop_down_symbol = wchar_t(fc::BlackDownPointingTriangle);
drop_down_symbol = 'v';
else
drop_down_symbol = wchar_t(fc::BlackDownPointingTriangle);
FDialogListMenu* DglList = new FDialogListMenu (drop_down_symbol, Menubar); FDialogListMenu* DglList = new FDialogListMenu (drop_down_symbol, Menubar);
DglList->setStatusbarMessage ("List of all the active dialogs"); DglList->setStatusbarMessage ("List of all the active dialogs");