Looser coupling between examples and FTerm

This commit is contained in:
Markus Gans 2018-10-29 23:57:35 +01:00
parent 4d42804059
commit c1b304e429
4 changed files with 95 additions and 71 deletions

View File

@ -111,7 +111,7 @@ void move (int xold, int yold, int xnew, int ynew)
<< std::left << std::setw(10) << to
<< " ";
// get the move string
buffer = terminal->getFTerm().moveCursor (xold, yold, xnew, ynew);
buffer = terminal->moveCursor (xold, yold, xnew, ynew);
len = uInt(std::strlen(buffer));
for (uInt i = 0; i < len; i++)
@ -164,7 +164,7 @@ int main (int argc, char* argv[])
TermApp.clearArea();
// Show the determined terminal name and text resolution
std::cout << "Terminal: " << TermApp.getFTerm().getTermType() << "\r\n";
std::cout << "Terminal: " << TermApp.getTermType() << "\r\n";
std::cout << " Columns: 0.." << xmax << "\r\n";
std::cout << " Lines: 0.." << ymax << "\r\n";
@ -197,7 +197,7 @@ int main (int argc, char* argv[])
// Show terminal speed and milliseconds for all cursor movement sequence
std::cout << "\r" << line;
TermApp.getFTerm().printMoveDurations();
TermApp.printMoveDurations();
// Waiting for keypress
keyPressed();

View File

@ -1048,8 +1048,8 @@ int main (int argc, char* argv[])
// Create the application object app
finalcut::FApplication app(argc, argv);
app.getFTerm().redefineDefaultColors(true);
app.getFTerm().setTermTitle (title);
app.redefineDefaultColors(true);
app.setTermTitle (title);
// Force vt100 encoding
//app.getFTerm().setEncoding(finalcut::fc::VT100);

View File

@ -129,7 +129,7 @@ void FVTerm::setTermXY (int x, int y)
term_x = term_pos->getX();
term_y = term_pos->getY();
move_str = fterm->moveCursor (term_x, term_y, x, y);
move_str = FTerm::moveCursor (term_x, term_y, x, y);
if ( move_str )
appendOutputBuffer(move_str);
@ -143,7 +143,7 @@ void FVTerm::hideCursor (bool on)
{
// Hides or shows the input cursor on the terminal
char* visibility_str = fterm->cursorsVisibility (on);
char* visibility_str = FTerm::cursorsVisibility (on);
if ( visibility_str )
appendOutputBuffer(visibility_str);
@ -1578,7 +1578,7 @@ void FVTerm::scrollAreaForward (term_area* area)
if ( TCAP(fc::t_scroll_forward) )
{
setTermXY (0, vdesktop->height);
fterm->scrollTermForward();
FTerm::scrollTermForward();
putArea (1, 1, vdesktop);
// avoid update lines from 0 to (y_max - 1)
@ -1639,7 +1639,7 @@ void FVTerm::scrollAreaReverse (term_area* area)
if ( TCAP(fc::t_scroll_reverse) )
{
setTermXY (0, 0);
fterm->scrollTermReverse();
FTerm::scrollTermReverse();
putArea (1, 1, vdesktop);
// avoid update lines from 1 to y_max
@ -1951,9 +1951,7 @@ void FVTerm::flush_out()
{
while ( ! output_buffer->empty() )
{
if ( fterm )
fterm->Fputchar(output_buffer->front());
FTerm::Fputchar(output_buffer->front());
output_buffer->pop();
}
@ -2011,13 +2009,13 @@ void FVTerm::init (bool disable_alt_screen)
active_area = vdesktop;
// Initialize keyboard
keyboard = fterm->getKeyboard();
keyboard = FTerm::getKeyboard();
// Hide the input cursor
hideCursor();
// Initialize character lengths
init_characterLengths (fterm->getFOptiMove());
init_characterLengths (FTerm::getFOptiMove());
}
//----------------------------------------------------------------------
@ -2050,7 +2048,7 @@ void FVTerm::finish()
// Clear the terminal
setNormal();
if ( fterm->hasAlternateScreen() )
if ( FTerm::hasAlternateScreen() )
clearTerm();
flush_out();
@ -2170,7 +2168,7 @@ bool FVTerm::clearTerm (int fillchar)
char*& cb = TCAP(fc::t_clr_eol);
bool ut = FTermcap::background_color_erase;
charData* next = &next_attribute;
bool normal = fterm->isNormal(next);
bool normal = FTerm::isNormal(next);
appendAttributes(next);
if ( ! ( (cl || cd || cb) && (normal || ut) )
@ -2275,7 +2273,7 @@ bool FVTerm::canClearToEOL (uInt xmin, uInt y)
if ( ce && min_char->code == ' ' )
{
uInt beginning_whitespace = 1;
bool normal = fterm->isNormal(min_char);
bool normal = FTerm::isNormal(min_char);
bool& ut = FTermcap::background_color_erase;
for (uInt x = xmin + 1; x < uInt(vt->width); x++)
@ -2310,7 +2308,7 @@ bool FVTerm::canClearLeadingWS (uInt& xmin, uInt y)
if ( cb && first_char->code == ' ' )
{
uInt leading_whitespace = 1;
bool normal = fterm->isNormal(first_char);
bool normal = FTerm::isNormal(first_char);
bool& ut = FTermcap::background_color_erase;
for (uInt x = 1; x < uInt(vt->width); x++)
@ -2348,7 +2346,7 @@ bool FVTerm::canClearTrailingWS (uInt& xmax, uInt y)
if ( ce && last_char->code == ' ' )
{
uInt trailing_whitespace = 1;
bool normal = fterm->isNormal(last_char);
bool normal = FTerm::isNormal(last_char);
bool& ut = FTermcap::background_color_erase;
for (uInt x = uInt(vt->width) - 1; x > 0 ; x--)
@ -2459,7 +2457,7 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
return not_used;
uInt whitespace = 1;
bool normal = fterm->isNormal(print_char);
bool normal = FTerm::isNormal(print_char);
for (uInt i = x + 1; i <= xmax; i++)
{
@ -2783,14 +2781,14 @@ inline void FVTerm::charsetChanges (charData*& next_char)
return;
uInt code = uInt(next_char->code);
uInt ch_enc = fterm->charEncode(code);
uInt ch_enc = FTerm::charEncode(code);
if ( ch_enc == code )
return;
if ( ch_enc == 0 )
{
next_char->code = int(fterm->charEncode(code, fc::ASCII));
next_char->code = int(FTerm::charEncode(code, fc::ASCII));
return;
}
@ -2808,7 +2806,7 @@ inline void FVTerm::charsetChanges (charData*& next_char)
if ( isXTerminal() && ch_enc < 0x20 ) // Character 0x00..0x1f
{
if ( hasUTF8() )
next_char->code = int(fterm->charEncode(code, fc::ASCII));
next_char->code = int(FTerm::charEncode(code, fc::ASCII));
else
{
next_char->code += 0x5f;
@ -2850,7 +2848,7 @@ inline void FVTerm::appendAttributes (charData*& next_attr)
charData* term_attr = &term_attribute;
// generate attribute string for the next character
attr_str = fterm->changeAttribute (term_attr, next_attr);
attr_str = FTerm::changeAttribute (term_attr, next_attr);
if ( attr_str )
appendOutputBuffer (attr_str);

View File

@ -139,6 +139,7 @@ class FVTerm
static fc::encoding getEncoding();
static std::string getEncodingString();
static const FString getKeyName (int);
static char* getTermType();
FTerm& getFTerm();
// Mutators
@ -215,6 +216,8 @@ class FVTerm
static bool setInheritBackground();
static bool unsetInheritBackground();
static void setTermTitle (const FString&);
// Inquiries
static bool isBold();
static bool isDim();
@ -281,6 +284,9 @@ class FVTerm
int print (term_area*, charData&);
FVTerm& print();
static void beep();
static void redefineDefaultColors (bool);
static char* moveCursor (int, int, int, int);
static void printMoveDurations();
protected:
// Enumeration
@ -607,23 +613,27 @@ inline FVTerm::charData FVTerm::getAttribute()
//----------------------------------------------------------------------
inline int FVTerm::getMaxColor()
{ return fterm->getMaxColor(); }
{ return FTerm::getMaxColor(); }
//----------------------------------------------------------------------
inline int FVTerm::getTabstop()
{ return fterm->getTabstop(); }
{ return FTerm::getTabstop(); }
//----------------------------------------------------------------------
inline fc::encoding FVTerm::getEncoding()
{ return fterm->getEncoding(); }
{ return FTerm::getEncoding(); }
//----------------------------------------------------------------------
inline std::string FVTerm::getEncodingString()
{ return fterm->getEncodingString(); }
{ return FTerm::getEncodingString(); }
//----------------------------------------------------------------------
inline const FString FVTerm::getKeyName (int keynum)
{ return fterm->getKeyName(keynum); }
{ return FTerm::getKeyName(keynum); }
//----------------------------------------------------------------------
inline char* FVTerm::getTermType()
{ return FTerm::getTermType(); }
//----------------------------------------------------------------------
inline FTerm& FVTerm::getFTerm()
@ -852,6 +862,10 @@ inline bool FVTerm::setInheritBackground()
inline bool FVTerm::unsetInheritBackground()
{ return setInheritBackground(false); }
//----------------------------------------------------------------------
inline void FVTerm::setTermTitle (const FString& title)
{ FTerm::setTermTitle(title); }
//----------------------------------------------------------------------
inline bool FVTerm::isBold()
{ return next_attribute.attr.bit.bold; }
@ -918,99 +932,99 @@ inline bool FVTerm::isInheritBackground()
//----------------------------------------------------------------------
inline bool FVTerm::isMonochron()
{ return fterm->isMonochron(); }
{ return FTerm::isMonochron(); }
//----------------------------------------------------------------------
inline bool FVTerm::isXTerminal()
{ return fterm->isXTerminal(); }
{ return FTerm::isXTerminal(); }
//----------------------------------------------------------------------
inline bool FVTerm::isAnsiTerminal()
{ return fterm->isAnsiTerminal(); }
{ return FTerm::isAnsiTerminal(); }
//----------------------------------------------------------------------
inline bool FVTerm::isRxvtTerminal()
{ return fterm->isRxvtTerminal(); }
{ return FTerm::isRxvtTerminal(); }
//----------------------------------------------------------------------
inline bool FVTerm::isUrxvtTerminal()
{ return fterm->isUrxvtTerminal(); }
{ return FTerm::isUrxvtTerminal(); }
//----------------------------------------------------------------------
inline bool FVTerm::isMltermTerminal()
{ return fterm->isMltermTerminal(); }
{ return FTerm::isMltermTerminal(); }
//----------------------------------------------------------------------
inline bool FVTerm::isPuttyTerminal()
{ return fterm->isPuttyTerminal(); }
{ return FTerm::isPuttyTerminal(); }
//----------------------------------------------------------------------
inline bool FVTerm::isKdeTerminal()
{ return fterm->isKdeTerminal(); }
{ return FTerm::isKdeTerminal(); }
//----------------------------------------------------------------------
inline bool FVTerm::isGnomeTerminal()
{ return fterm->isGnomeTerminal(); }
{ return FTerm::isGnomeTerminal(); }
//----------------------------------------------------------------------
inline bool FVTerm::isKtermTerminal()
{ return fterm->isKtermTerminal(); }
{ return FTerm::isKtermTerminal(); }
//----------------------------------------------------------------------
inline bool FVTerm::isTeraTerm()
{ return fterm->isTeraTerm(); }
{ return FTerm::isTeraTerm(); }
//----------------------------------------------------------------------
inline bool FVTerm::isSunTerminal()
{ return fterm->isSunTerminal(); }
{ return FTerm::isSunTerminal(); }
//----------------------------------------------------------------------
inline bool FVTerm::isCygwinTerminal()
{ return fterm->isCygwinTerminal(); }
{ return FTerm::isCygwinTerminal(); }
//----------------------------------------------------------------------
inline bool FVTerm::isMinttyTerm()
{ return fterm->isMinttyTerm(); }
{ return FTerm::isMinttyTerm(); }
//----------------------------------------------------------------------
inline bool FVTerm::isLinuxTerm()
{ return fterm->isLinuxTerm(); }
{ return FTerm::isLinuxTerm(); }
//----------------------------------------------------------------------
inline bool FVTerm::isFreeBSDTerm()
{ return fterm->isFreeBSDTerm(); }
{ return FTerm::isFreeBSDTerm(); }
//----------------------------------------------------------------------
inline bool FVTerm::isNetBSDTerm()
{ return fterm->isNetBSDTerm(); }
{ return FTerm::isNetBSDTerm(); }
//----------------------------------------------------------------------
inline bool FVTerm::isOpenBSDTerm()
{ return fterm->isOpenBSDTerm(); }
{ return FTerm::isOpenBSDTerm(); }
//----------------------------------------------------------------------
inline bool FVTerm::isScreenTerm()
{ return fterm->isScreenTerm(); }
{ return FTerm::isScreenTerm(); }
//----------------------------------------------------------------------
inline bool FVTerm::isTmuxTerm()
{ return fterm->isTmuxTerm(); }
{ return FTerm::isTmuxTerm(); }
//----------------------------------------------------------------------
inline bool FVTerm::isNewFont()
{ return fterm->isNewFont(); }
{ return FTerm::isNewFont(); }
//----------------------------------------------------------------------
inline bool FVTerm::isCursorHideable()
{ return fterm->isCursorHideable(); }
{ return FTerm::isCursorHideable(); }
//----------------------------------------------------------------------
inline bool FVTerm::hasChangedTermSize()
{ return fterm->hasChangedTermSize(); }
{ return FTerm::hasChangedTermSize(); }
//----------------------------------------------------------------------
inline bool FVTerm::hasUTF8()
{ return fterm->hasUTF8(); }
{ return FTerm::hasUTF8(); }
//----------------------------------------------------------------------
inline FVTerm& FVTerm::print()
@ -1018,55 +1032,67 @@ inline FVTerm& FVTerm::print()
//----------------------------------------------------------------------
inline void FVTerm::beep()
{ return fterm->beep(); }
{ FTerm::beep(); }
//----------------------------------------------------------------------
inline void FVTerm::redefineDefaultColors (bool on)
{ FTerm::redefineDefaultColors(on); }
//----------------------------------------------------------------------
inline char* FVTerm::moveCursor (int xold, int yold, int xnew, int ynew)
{ return FTerm::moveCursor (xold, yold, xnew, ynew); }
//----------------------------------------------------------------------
inline void FVTerm::printMoveDurations()
{ return FTerm::printMoveDurations(); }
//----------------------------------------------------------------------
inline std::size_t FVTerm::getLineNumber()
{ return fterm->getLineNumber(); }
{ return FTerm::getLineNumber(); }
//----------------------------------------------------------------------
inline std::size_t FVTerm::getColumnNumber()
{ return fterm->getColumnNumber(); }
{ return FTerm::getColumnNumber(); }
//----------------------------------------------------------------------
inline bool FVTerm::charEncodable (uInt c)
{ return fterm->charEncodable(c); }
{ return FTerm::charEncodable(c); }
//----------------------------------------------------------------------
inline FKeyboard* FVTerm::getKeyboard()
{ return fterm->getKeyboard(); }
{ return FTerm::getKeyboard(); }
//----------------------------------------------------------------------
inline FMouseControl* FVTerm::getMouseControl()
{ return fterm->getMouseControl(); }
{ return FTerm::getMouseControl(); }
//----------------------------------------------------------------------
inline FTerm::initializationValues& FVTerm::getInitValues()
{ return fterm->getInitValues(); }
{ return getFTerm().getInitValues(); }
//----------------------------------------------------------------------
inline void FVTerm::setInsertCursor (bool on)
{ return fterm->setInsertCursor(on); }
{ return FTerm::setInsertCursor(on); }
//----------------------------------------------------------------------
inline void FVTerm::setInsertCursor()
{ return fterm->setInsertCursor(true); }
{ return FTerm::setInsertCursor(true); }
//----------------------------------------------------------------------
inline void FVTerm::unsetInsertCursor()
{ return fterm->setInsertCursor(false); }
{ return FTerm::setInsertCursor(false); }
//----------------------------------------------------------------------
inline bool FVTerm::setUTF8 (bool on)
{ return fterm->setUTF8(on); }
{ return FTerm::setUTF8(on); }
//----------------------------------------------------------------------
inline bool FVTerm::setUTF8()
{ return fterm->setUTF8(true); }
{ return FTerm::setUTF8(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetUTF8()
{ return fterm->setUTF8(false); }
{ return FTerm::setUTF8(false); }
//----------------------------------------------------------------------
inline bool FVTerm::hasPrintArea() const
@ -1082,23 +1108,23 @@ inline bool FVTerm::isVirtualWindow() const
//----------------------------------------------------------------------
inline bool FVTerm::hasHalfBlockCharacter()
{ return fterm->hasHalfBlockCharacter(); }
{ return FTerm::hasHalfBlockCharacter(); }
//----------------------------------------------------------------------
inline bool FVTerm::hasShadowCharacter()
{ return fterm->hasShadowCharacter(); }
{ return FTerm::hasShadowCharacter(); }
//----------------------------------------------------------------------
inline void FVTerm::initScreenSettings()
{ fterm->initScreenSettings(); }
{ FTerm::initScreenSettings(); }
//----------------------------------------------------------------------
inline void FVTerm::changeTermSizeFinished()
{ fterm->changeTermSizeFinished(); }
{ FTerm::changeTermSizeFinished(); }
//----------------------------------------------------------------------
inline void FVTerm::exitWithMessage (const FString& message)
{ fterm->exitWithMessage(message); }
{ FTerm::exitWithMessage(message); }
//----------------------------------------------------------------------
inline void FVTerm::setPrintArea (term_area* area)