From 6b5f033b7b96562cb43530a08bce8a6a0c34f87a Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Wed, 5 Apr 2017 00:30:52 +0200 Subject: [PATCH] Replace non-printable chars for Tera Term and Cygwin --- ChangeLog | 5 +++++ src/fbutton.cpp | 2 +- src/fdialog.cpp | 14 ++------------ src/flineedit.cpp | 2 +- src/fmenu.cpp | 4 ---- src/fprogressbar.cpp | 3 +-- src/fradiobutton.cpp | 7 +------ src/fscrollbar.cpp | 12 ++---------- src/fterm.cpp | 41 +++++++++++++++++++++++++++++++++++++++-- src/fterm.h | 2 ++ src/fwidget.cpp | 24 ++++-------------------- test/scrollview.cpp | 6 ------ test/windows.cpp | 17 +++-------------- 13 files changed, 61 insertions(+), 78 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9efdd8d0..eac026bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-04-05 Markus Gans + * 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 * Remap the meta key to left alt key at runtime on the FreeBSD console for the accelerator key access diff --git a/src/fbutton.cpp b/src/fbutton.cpp index e0ed03fe..b6dee224 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -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; diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 15b25d35..73250a06 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -1285,12 +1285,7 @@ void FDialog::drawTitleBar() else { print (' '); - - if ( isCygwinTerminal() ) - print ('v'); - else - print (fc::BlackDownPointingTriangle); // ▼ - + print (fc::BlackDownPointingTriangle); // ▼ print (' '); } } @@ -1313,12 +1308,7 @@ void FDialog::drawTitleBar() else { print (' '); - - if ( isCygwinTerminal() ) - print ('^'); - else - print (fc::BlackUpPointingTriangle); // ▲ - + print (fc::BlackUpPointingTriangle); // ▲ print (' '); } } diff --git a/src/flineedit.cpp b/src/flineedit.cpp index 12b0539b..e964cb00 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -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; diff --git a/src/fmenu.cpp b/src/fmenu.cpp index a64e144c..a756f529 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -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 √ } diff --git a/src/fprogressbar.cpp b/src/fprogressbar.cpp index 3b73877b..187580ca 100644 --- a/src/fprogressbar.cpp +++ b/src/fprogressbar.cpp @@ -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() ) diff --git a/src/fradiobutton.cpp b/src/fradiobutton.cpp index a427722f..afcd031e 100644 --- a/src/fradiobutton.cpp +++ b/src/fradiobutton.cpp @@ -70,12 +70,7 @@ void FRadioButton::drawRadioButton() else { print ('('); - - if ( isCygwinTerminal() ) - print (0x04); - else - print (fc::Bullet); // Bullet ● - + print (fc::Bullet); // Bullet ● print (')'); } } diff --git a/src/fscrollbar.cpp b/src/fscrollbar.cpp index f369d61f..ecbeeea0 100644 --- a/src/fscrollbar.cpp +++ b/src/fscrollbar.cpp @@ -259,17 +259,9 @@ void FScrollbar::drawButtons() if ( bar_orientation == fc::vertical ) { - if ( isCygwinTerminal() ) - print ('^'); - else - print (fc::BlackUpPointingTriangle); // ▲ - + print (fc::BlackUpPointingTriangle); // ▲ setPrintPos (1, length); - - if ( isCygwinTerminal() ) - print ('v'); - else - print (fc::BlackDownPointingTriangle); // ▼ + print (fc::BlackDownPointingTriangle); // ▼ } else // horizontal { diff --git a/src/fterm.cpp b/src/fterm.cpp index a64854c8..d836d280 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -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("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 diff --git a/src/fterm.h b/src/fterm.h index 98bc4d0e..0769fec7 100644 --- a/src/fterm.h +++ b/src/fterm.h @@ -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); diff --git a/src/fwidget.cpp b/src/fwidget.cpp index f0cbf676..f1cdcefb 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -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); // ▄ - } + 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); // ▀ - } + 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; diff --git a/test/scrollview.cpp b/test/scrollview.cpp index e1944b58..1a5fd193 100644 --- a/test/scrollview.cpp +++ b/test/scrollview.cpp @@ -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", diff --git a/test/windows.cpp b/test/windows.cpp index 09f7663e..95738fcd 100644 --- a/test/windows.cpp +++ b/test/windows.cpp @@ -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; - } + arrow_up = fc::BlackUpPointingTriangle; + arrow_down = fc::BlackDownPointingTriangle; left_arrow = new FLabel (arrow_up, this); left_arrow->setForegroundColor (wc.label_inactive_fg); @@ -222,10 +214,7 @@ 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); + drop_down_symbol = wchar_t(fc::BlackDownPointingTriangle); FDialogListMenu* DglList = new FDialogListMenu (drop_down_symbol, Menubar); DglList->setStatusbarMessage ("List of all the active dialogs");