diff --git a/ChangeLog b/ChangeLog index 6be5d107..779920c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ 2016-11-26 Markus Gans + * Improvements for ansi terminal emulators * Add the opti-move test program * Optimized the terminal clear screen diff --git a/src/fapp.cpp b/src/fapp.cpp index e8946542..385a7c52 100644 --- a/src/fapp.cpp +++ b/src/fapp.cpp @@ -371,7 +371,7 @@ void FApplication::cmd_options () + std::string(encoding.c_str()) ); } - if ( std::strcmp(long_options[idx].name, "no-optimize-cursor") == 0 ) + if ( std::strcmp(long_options[idx].name, "no-optimized-cursor") == 0 ) setCursorOptimisation (false); if ( std::strcmp(long_options[idx].name, "vgafont") == 0 ) diff --git a/src/fterm.cpp b/src/fterm.cpp index ab063548..5d3b407b 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -35,6 +35,7 @@ bool FTerm::gpm_mouse_enabled; bool FTerm::color256; bool FTerm::monochron; bool FTerm::xterm_terminal; +bool FTerm::ansi_terminal; bool FTerm::rxvt_terminal; bool FTerm::urxvt_terminal; bool FTerm::mlterm_terminal; @@ -3055,6 +3056,7 @@ void FTerm::init() kterm_terminal = \ gnome_terminal = \ kde_konsole = \ + ansi_terminal = \ rxvt_terminal = \ urxvt_terminal = \ mlterm_terminal = \ @@ -3110,6 +3112,12 @@ void FTerm::init() if ( std::strncmp(termtype, "rxvt-cygwin-native", 18) == 0 ) rxvt_terminal = true; + if ( std::strncmp(termtype, "ansi", 4) == 0 ) + { + terminal_detection = false; + ansi_terminal = true; + } + // Test for Linux console if ( std::strncmp(termtype, const_cast("linux"), 5) == 0 || std::strncmp(termtype, const_cast("con"), 3) == 0 ) diff --git a/src/fterm.h b/src/fterm.h index 160e71dd..eb20ea42 100644 --- a/src/fterm.h +++ b/src/fterm.h @@ -127,6 +127,7 @@ class FTerm static bool hasASCII(); static bool isMonochron(); static bool isXTerminal(); + static bool isAnsiTerminal(); static bool isRxvtTerminal(); static bool isUrxvtTerminal(); static bool isMltermTerminal(); @@ -339,6 +340,7 @@ class FTerm static bool color256; static bool monochron; static bool xterm_terminal; + static bool ansi_terminal; static bool rxvt_terminal; static bool urxvt_terminal; static bool mlterm_terminal; @@ -434,6 +436,10 @@ inline bool FTerm::isMonochron() inline bool FTerm::isXTerminal() { return xterm_terminal; } +//---------------------------------------------------------------------- +inline bool FTerm::isAnsiTerminal() +{ return ansi_terminal; } + //---------------------------------------------------------------------- inline bool FTerm::isRxvtTerminal() { return rxvt_terminal; } diff --git a/src/fvterm.cpp b/src/fvterm.cpp index a47ce1e3..1c4d483f 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -110,9 +110,9 @@ void FVTerm::setTermXY (register int x, register int y) } //---------------------------------------------------------------------- -void FVTerm::clearTerm() +void FVTerm::clearTerm (int fillchar) { - // Clear the physical terminal and put cursor at home + // Clear the real terminal and put cursor at home char*& cl = tcap[fc::t_clear_screen].string; char*& cd = tcap[fc::t_clr_eos].string; char*& cb = tcap[fc::t_clr_eol].string; @@ -121,15 +121,15 @@ void FVTerm::clearTerm() bool normal = isNormal(next); appendAttributes(next); - if ( (! cl && ! cd && ! cb) - || (normal && ! ut ) ) + if ( ! ( (cl || cd || cb) && (normal || ut) ) + || fillchar != ' ' ) { int term_width = getColumnNumber(); for (int i=0; i < getLineNumber(); i++) { setTermXY (0,i); - FString blank_line(term_width, ' '); + FString blank_line(term_width, wchar_t(fillchar)); appendOutputBuffer (blank_line.c_str()); term_pos->setPoint(term_width,i); } @@ -1907,7 +1907,7 @@ void FVTerm::clearArea (term_area* area, int fillchar) if ( area == vdesktop ) { std::fill_n (vterm->text, area_size, nc); - clearTerm(); + clearTerm (fillchar); return; } } diff --git a/src/fvterm.h b/src/fvterm.h index c9d3b9eb..d35488f9 100644 --- a/src/fvterm.h +++ b/src/fvterm.h @@ -93,7 +93,7 @@ class FVTerm : public FObject, public FTerm // Mutators static void setTermXY (register int, register int); - static void clearTerm(); + static void clearTerm (int = ' '); static bool hideCursor (bool); static bool hideCursor(); static bool showCursor(); diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 22341bd4..17a25d0b 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -1103,6 +1103,11 @@ void FWidget::show() // set xterm color settings to defaults setXTermDefaults(); + + // draw the vdesktop + FWidget* r = getRootWidget(); + setColor(r->getForegroundColor(), r->getBackgroundColor()); + clearArea (vdesktop); } if ( ! show_root_widget ) @@ -2158,8 +2163,6 @@ void FWidget::init() foreground_color = wc.term_fg; background_color = wc.term_bg; - setColor(); - clearArea (vdesktop); accelerator_list = new Accelerators(); } diff --git a/test/keyboard.cpp b/test/keyboard.cpp index 165854a1..920836ee 100644 --- a/test/keyboard.cpp +++ b/test/keyboard.cpp @@ -63,8 +63,6 @@ void keyboard::onAccel (FAccelEvent* ev) //---------------------------------------------------------------------- void keyboard::draw() { - setNormal(); - clearArea (vdesktop); setPrintPos (1,1); print ("---------------\n"); print ("Press Q to quit\n"); @@ -78,6 +76,8 @@ void keyboard::draw() int main (int argc, char* argv[]) { FApplication app(argc, argv); + app.setForegroundColor(fc::Default); + app.setBackgroundColor(fc::Default); keyboard key(&app); key.addAccelerator('q'); app.setMainWidget(&key); diff --git a/test/opti-move.cpp b/test/opti-move.cpp index 97aac4be..2f188d3f 100644 --- a/test/opti-move.cpp +++ b/test/opti-move.cpp @@ -149,7 +149,6 @@ int main (int argc, char* argv[]) std::cout << "escape sequence "; std::cout << "Length\r\n"; std::cout << line; - std::cout << "\r\n"; move (5, 12, 0, 0); move (5, ymax, 5, 0); diff --git a/test/timer.cpp b/test/timer.cpp index 0f996194..22bd9d04 100644 --- a/test/timer.cpp +++ b/test/timer.cpp @@ -40,8 +40,6 @@ timer::timer (FWidget* parent) //---------------------------------------------------------------------- void timer::draw() { - setNormal(); - clearArea (vdesktop); setPrintPos (1,1); print ("---------------\n"); print ("Press Q to quit\n"); @@ -86,6 +84,8 @@ void timer::onAccel (FAccelEvent* ev) int main (int argc, char* argv[]) { FApplication app(argc, argv); + app.setForegroundColor(fc::Default); + app.setBackgroundColor(fc::Default); timer t(&app); t.addAccelerator('q'); app.setMainWidget(&t);