Improvements for ansi terminal emulators

This commit is contained in:
Markus Gans 2016-11-27 00:41:34 +01:00
parent 33c03cf6fc
commit 4da63ebcac
10 changed files with 32 additions and 15 deletions

View File

@ -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

View File

@ -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 )

View File

@ -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<char*>("linux"), 5) == 0
|| std::strncmp(termtype, const_cast<char*>("con"), 3) == 0 )

View File

@ -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; }

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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();
}

View File

@ -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);

View File

@ -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);

View File

@ -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);