Skip to content

Commit

Permalink
Improvements for ansi terminal emulators
Browse files Browse the repository at this point in the history
  • Loading branch information
gansm committed Nov 26, 2016
1 parent 33c03cf commit 4da63eb
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 15 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
2016-11-26 Markus Gans <guru.mail@muenster.de>
* Improvements for ansi terminal emulators
* Add the opti-move test program
* Optimized the terminal clear screen

Expand Down
2 changes: 1 addition & 1 deletion src/fapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
8 changes: 8 additions & 0 deletions src/fterm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -3055,6 +3056,7 @@ void FTerm::init()
kterm_terminal = \
gnome_terminal = \
kde_konsole = \
ansi_terminal = \
rxvt_terminal = \
urxvt_terminal = \
mlterm_terminal = \
Expand Down Expand Up @@ -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<char*>("linux"), 5) == 0
|| std::strncmp(termtype, const_cast<char*>("con"), 3) == 0 )
Expand Down
6 changes: 6 additions & 0 deletions src/fterm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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; }
Expand Down
12 changes: 6 additions & 6 deletions src/fvterm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/fvterm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 5 additions & 2 deletions src/fwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -2158,8 +2163,6 @@ void FWidget::init()

foreground_color = wc.term_fg;
background_color = wc.term_bg;
setColor();
clearArea (vdesktop);

accelerator_list = new Accelerators();
}
Expand Down
4 changes: 2 additions & 2 deletions test/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
Expand Down
1 change: 0 additions & 1 deletion test/opti-move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4da63eb

Please sign in to comment.