Remove some duplicate code

This commit is contained in:
Markus Gans 2016-10-09 02:06:06 +02:00
parent 8328af4132
commit e14cd1af83
15 changed files with 404 additions and 431 deletions

View File

@ -1,3 +1,6 @@
2016-10-09 Markus Gans <guru.mail@muenster.de>
* Remove some duplicate code
2016-10-08 Markus Gans <guru.mail@muenster.de>
* Add the possibility to scroll text up and down
in a virtual window

View File

@ -64,17 +64,8 @@ FDialog::~FDialog() // destructor
if ( ! is_quit )
switchToPrevWindow();
delWindow(this);
delDialog(this);
if ( ! is_quit )
{
const FRect& t_geometry = getTermGeometryWithShadow();
restoreVTerm (t_geometry);
}
removeArea (vwin);
if ( isModal() )
unsetModal();
}
@ -93,9 +84,7 @@ void FDialog::init()
// initialize geometry values
setGeometry (1, 1, 10, 10, false);
setMinimumSize (15, 4);
createArea (vwin);
addDialog(this);
addWindow(this);
setActiveWindow(this);
setTransparentShadow();
setForegroundColor (wc.dialog_fg);
@ -461,6 +450,12 @@ void FDialog::cb_move (FWidget*, void*)
if ( isResizeable() )
{
if ( isLinuxTerm() )
tooltip->setText ( " Arrow keys: Move\n"
"Shift + Arrow keys: Resize\n"
" Enter: Done\n"
" Esc: Cancel" );
else
tooltip->setText ( " Arrow keys: Move\n"
"Meta + Arrow keys: Resize\n"
" Enter: Done\n"
@ -645,6 +640,7 @@ void FDialog::onKeyPress (FKeyEvent* ev)
break;
case fc::Fmkey_up:
case fc::Fkey_sr:
if ( isResizeable() )
{
setSize (getWidth(), getHeight() - 1);
@ -653,6 +649,7 @@ void FDialog::onKeyPress (FKeyEvent* ev)
break;
case fc::Fmkey_down:
case fc::Fkey_sf:
if ( isResizeable() && getHeight() + getY() <= getMaxHeight() )
{
setSize (getWidth(), getHeight() + 1);
@ -661,6 +658,7 @@ void FDialog::onKeyPress (FKeyEvent* ev)
break;
case fc::Fmkey_left:
case fc::Fkey_sleft:
if ( isResizeable() )
{
setSize (getWidth() - 1, getHeight());
@ -669,6 +667,7 @@ void FDialog::onKeyPress (FKeyEvent* ev)
break;
case fc::Fmkey_right:
case fc::Fkey_sright:
if ( isResizeable() && getWidth() + getX() <= getMaxWidth() )
{
setSize (getWidth() + 1, getHeight());
@ -1486,48 +1485,6 @@ bool FDialog::setModal (bool on)
return on;
}
//----------------------------------------------------------------------
bool FDialog::setTransparentShadow (bool on)
{
if ( on )
{
flags |= fc::shadow;
flags |= fc::trans_shadow;
setShadowSize (2,1);
}
else
{
flags &= ~fc::shadow;
flags &= ~fc::trans_shadow;
setShadowSize (0,0);
}
resizeArea (vwin);
return on;
}
//----------------------------------------------------------------------
bool FDialog::setShadow (bool on)
{
if ( isMonochron() )
return false;
if ( on )
{
flags |= fc::shadow;
flags &= ~fc::trans_shadow;
setShadowSize (1,1);
}
else
{
flags &= ~fc::shadow;
flags &= ~fc::trans_shadow;
setShadowSize (0,0);
}
resizeArea (vwin);
return on;
}
//----------------------------------------------------------------------
bool FDialog::setScrollable (bool on)
@ -1543,16 +1500,12 @@ bool FDialog::setScrollable (bool on)
//----------------------------------------------------------------------
bool FDialog::setResizeable (bool on)
{
FWindow::setResizeable (on);
if ( on )
{
flags |= fc::resizeable;
zoom_item->setEnable();
}
else
{
flags &= ~fc::resizeable;
zoom_item->setDisable();
}
return on;
}

View File

@ -136,22 +136,13 @@ class FDialog : public FWindow
bool setModal();
bool unsetModal();
bool isModal();
bool setResizeable (bool);
// make every setResizeable from FWindow available
using FWindow::setResizeable;
bool setScrollable (bool);
bool setScrollable();
bool unsetScrollable();
bool isScrollable();
bool setResizeable (bool);
bool setResizeable();
bool unsetResizeable();
bool isResizeable();
bool setTransparentShadow (bool);
bool setTransparentShadow();
bool unsetTransparentShadow();
bool hasTransparentShadow();
bool setShadow (bool);
bool setShadow();
bool unsetShadow();
bool hasShadow();
FString getText() const;
void setText (const FString&);
@ -206,42 +197,6 @@ inline bool FDialog::unsetScrollable()
inline bool FDialog::isScrollable()
{ return ((flags & fc::scrollable) != 0); }
//----------------------------------------------------------------------
inline bool FDialog::setResizeable()
{ return setResizeable(true); }
//----------------------------------------------------------------------
inline bool FDialog::unsetResizeable()
{ return setResizeable(false); }
//----------------------------------------------------------------------
inline bool FDialog::isResizeable()
{ return ((flags & fc::resizeable) != 0); }
//----------------------------------------------------------------------
inline bool FDialog::setTransparentShadow()
{ return setTransparentShadow(true); }
//----------------------------------------------------------------------
inline bool FDialog::unsetTransparentShadow()
{ return setTransparentShadow(false); }
//----------------------------------------------------------------------
inline bool FDialog::hasTransparentShadow()
{ return ((flags & fc::trans_shadow) != 0); }
//----------------------------------------------------------------------
inline bool FDialog::setShadow()
{ return setShadow(true); }
//----------------------------------------------------------------------
inline bool FDialog::unsetShadow()
{ return setShadow(false); }
//----------------------------------------------------------------------
inline bool FDialog::hasShadow()
{ return ((flags & fc::shadow) != 0); }
//----------------------------------------------------------------------
inline FString FDialog::getText() const
{ return tb_text; }

View File

@ -73,25 +73,6 @@ FMenu::~FMenu()
if ( ! fapp->isQuit() )
switchToPrevWindow();
delWindow(this);
if ( ! fapp->isQuit() )
{
const FRect& t_geometry = getTermGeometryWithShadow();
restoreVTerm (t_geometry);
}
if ( vwin != 0 )
{
if ( vwin->changes != 0 )
delete[] vwin->changes;
if ( vwin->text != 0 )
delete[] vwin->text;
delete vwin;
}
}
@ -103,11 +84,9 @@ void FMenu::init(FWidget* parent)
setLeftPadding(1);
setBottomPadding(1);
setRightPadding(1);
createArea (vwin);
setMenuWidget();
setGeometry (1, 1, 10, 2, false); // initialize geometry values
setTransparentShadow();
addWindow(this);
setMenuWidget();
hide();
setForegroundColor (wc.menu_active_fg);
@ -1449,17 +1428,6 @@ void FMenu::hide()
}
}
//----------------------------------------------------------------------
void FMenu::setGeometry (int xx, int yy, int ww, int hh, bool adjust)
{
int old_width = getWidth();
int old_height = getHeight();
FWidget::setGeometry (xx, yy, ww, hh, adjust);
if ( vwin && (getWidth() != old_width || getHeight() != old_height) )
resizeArea (vwin);
}
//----------------------------------------------------------------------
void FMenu::setStatusbarMessage(FString msg)
{
@ -1513,23 +1481,3 @@ bool FMenu::setMenuWidget (bool on)
return on;
}
//----------------------------------------------------------------------
bool FMenu::setTransparentShadow (bool on)
{
if ( on )
{
flags |= fc::shadow;
flags |= fc::trans_shadow;
setShadowSize (2,1);
}
else
{
flags &= ~fc::shadow;
flags &= ~fc::trans_shadow;
setShadowSize (0,0);
}
resizeArea (vwin);
return on;
}

View File

@ -106,9 +106,6 @@ class FMenu : public FWindow, public FMenuList
void show();
void hide();
// make every setGeometry from FWidget available
using FWidget::setGeometry;
void setGeometry (int, int, int, int, bool = true);
void setStatusbarMessage (FString);
FMenuItem* getItem() const;
FString getText() const;
@ -126,10 +123,6 @@ class FMenu : public FWindow, public FMenuList
bool hasHotkey() const;
void setMenu (FMenu*);
bool hasMenu() const;
bool setTransparentShadow (bool);
bool setTransparentShadow();
bool unsetTransparentShadow();
bool hasTransparentShadow();
void setText (FString&);
void setText (const std::string&);
void setText (const char*);
@ -232,18 +225,6 @@ inline void FMenu::setMenu (FMenu* m)
inline bool FMenu::hasMenu() const
{ return item->hasMenu(); }
//----------------------------------------------------------------------
inline bool FMenu::setTransparentShadow()
{ return setTransparentShadow(true); }
//----------------------------------------------------------------------
inline bool FMenu::unsetTransparentShadow()
{ return setTransparentShadow(false); }
//----------------------------------------------------------------------
inline bool FMenu::hasTransparentShadow()
{ return ((flags & fc::trans_shadow) != 0); }
//----------------------------------------------------------------------
inline void FMenu::setText (FString& txt)
{ item->setText(txt); }

View File

@ -22,8 +22,6 @@ FMenuBar::FMenuBar(FWidget* parent)
//----------------------------------------------------------------------
FMenuBar::~FMenuBar()
{
delWindow(this);
removeArea (vwin);
setMenuBar(0);
}
@ -36,9 +34,7 @@ void FMenuBar::init()
int w = r->getWidth();
// initialize geometry values
setGeometry (1, 1, w, 1, false);
createArea (vwin);
setAlwaysOnTop();
addWindow(this);
setMenuBar(this);
ignorePadding();

View File

@ -410,7 +410,6 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
//----------------------------------------------------------------------
void FMessageBox::setHeadline (const FString& headline)
{
int old_height = getHeight();
headline_text = headline;
setHeight(getHeight() + 2, true);
@ -421,9 +420,6 @@ void FMessageBox::setHeadline (const FString& headline)
if ( len > max_line_width )
max_line_width = len;
if ( vwin && getHeight() != old_height )
resizeArea (vwin);
}
//----------------------------------------------------------------------

View File

@ -158,8 +158,6 @@ FStatusBar::FStatusBar(FWidget* parent)
//----------------------------------------------------------------------
FStatusBar::~FStatusBar()
{
delWindow(this);
// delete all keys
if ( ! keylist.empty() )
{
@ -174,7 +172,6 @@ FStatusBar::~FStatusBar()
}
}
removeArea (vwin);
setStatusBar(0);
}
@ -188,9 +185,7 @@ void FStatusBar::init()
int h = r->getHeight();
// initialize geometry values
setGeometry (1, h, w, 1, false);
createArea (vwin);
setAlwaysOnTop();
addWindow(this);
setStatusBar(this);
ignorePadding();
mouse_down = false;

View File

@ -47,7 +47,7 @@ bool FTerm::automatic_left_margin;
bool FTerm::automatic_right_margin;
bool FTerm::eat_nl_glitch;
bool FTerm::ansi_default_color;
bool FTerm::xterm;
bool FTerm::xterm_terminal;
bool FTerm::rxvt_terminal;
bool FTerm::urxvt_terminal;
bool FTerm::mlterm_terminal;
@ -1071,6 +1071,7 @@ char* FTerm::parseSecDA (char*& current_termtype)
}
}
}
return new_termtype;
}
@ -1621,7 +1622,7 @@ void FTerm::init_encoding()
utf8_linux_terminal = true;
setUTF8(false);
}
else if ( xterm && utf8_console )
else if ( xterm_terminal && utf8_console )
{
Fputchar = &FTerm::putchar_UTF8; // function pointer
}
@ -1747,10 +1748,11 @@ void FTerm::init()
init_console();
// create virtual terminal
createVTerm();
createVTerm (*term);
// create virtual desktop area
createArea (vdesktop);
FPoint shadow_size(0,0);
createArea (*term, shadow_size, vdesktop);
vdesktop->visible = true;
active_area = vdesktop;
@ -1805,9 +1807,9 @@ void FTerm::init()
// Test if the terminal is a xterm
if ( std::strncmp(termtype, const_cast<char*>("xterm"), 5) == 0
|| std::strncmp(termtype, const_cast<char*>("Eterm"), 4) == 0 )
xterm = true;
xterm_terminal = true;
else
xterm = false;
xterm_terminal = false;
// set the new environment variable TERM
if ( new_termtype )
@ -1920,7 +1922,7 @@ void FTerm::init()
setRawMode();
hideCursor();
if ( (xterm || urxvt_terminal) && ! rxvt_terminal )
if ( (xterm_terminal || urxvt_terminal) && ! rxvt_terminal )
{
setNonBlockingInput();
xterm_font = new FString(getXTermFont());
@ -2004,7 +2006,7 @@ void FTerm::finish()
signal(SIGQUIT, SIG_DFL); // Quit from keyboard (Ctrl-\)
signal(SIGTERM, SIG_DFL); // Termination signal
if ( xterm_title && xterm && ! rxvt_terminal )
if ( xterm_title && xterm_terminal && ! rxvt_terminal )
setXTermTitle (*xterm_title);
showCursor();
@ -2188,7 +2190,17 @@ bool FTerm::charEncodable (uInt c)
}
//----------------------------------------------------------------------
void FTerm::createArea (term_area*& area)
void FTerm::createArea (const FRect& r, const FPoint& p, FTerm::term_area*& area)
{
createArea ( r.getWidth()
, r.getHeight()
, p.getX()
, p.getY()
, area );
}
//----------------------------------------------------------------------
void FTerm::createArea (int width, int height, int rsw, int bsh, term_area*& area)
{
// initialize virtual window
area = new term_area;
@ -2205,35 +2217,30 @@ void FTerm::createArea (term_area*& area)
area->visible = false;
area->widget = static_cast<FWidget*>(this);
resizeArea (area);
resizeArea (width, height, rsw, bsh, area);
}
//----------------------------------------------------------------------
void FTerm::resizeArea (term_area* area)
void FTerm::resizeArea (const FRect& r, const FPoint& p, FTerm::term_area* area)
{
int area_size, width, height, rsw, bsh;
resizeArea ( r.getWidth()
, r.getHeight()
, p.getX()
, p.getY()
, area );
}
//----------------------------------------------------------------------
void FTerm::resizeArea (int width, int height, int rsw, int bsh, term_area* area)
{
int area_size;
FOptiAttr::char_data default_char;
line_changes unchanged;
if ( ! area )
return;
if ( term_object == this )
{
rsw = bsh = 0; // no shadow
width = getColumnNumber();
height = getLineNumber();
area_size = width * height;
}
else
{
FWidget* w = static_cast<FWidget*>(this);
rsw = w->getShadow().getX(); // right shadow width;
bsh = w->getShadow().getY(); // bottom shadow height
width = w->getWidth();
height = w->getHeight();
area_size = (width+rsw) * (height+bsh);
}
if ( area->height + area->bottom_shadow != height + bsh )
{
@ -2355,7 +2362,7 @@ void FTerm::restoreVTerm (int x, int y, int w, int h)
if ( h < 0 )
return;
widget = static_cast<FWidget*>(this);
widget = static_cast<FWidget*>(vterm->widget);
for (register int ty=0; ty < h; ty++)
{
@ -2431,6 +2438,13 @@ void FTerm::restoreVTerm (int x, int y, int w, int h)
}
}
//----------------------------------------------------------------------
FTerm::covered_state FTerm::isCovered ( const FPoint& pos
, FTerm::term_area* area)
{
return isCovered (pos.getX(), pos.getY(), area);
}
//----------------------------------------------------------------------
FTerm::covered_state FTerm::isCovered (int x, int y, FTerm::term_area* area)
{
@ -2719,6 +2733,14 @@ bool FTerm::isInsideArea (int x, int y, FTerm::term_area* area)
return false;
}
//----------------------------------------------------------------------
void FTerm::setAreaCursor ( const FPoint& pos
, bool visible
, FTerm::term_area* area )
{
setAreaCursor (pos.getX(), pos.getY(), visible, area);
}
//----------------------------------------------------------------------
void FTerm::setAreaCursor (int x, int y, bool visible, FTerm::term_area* area)
{
@ -2731,6 +2753,12 @@ void FTerm::setAreaCursor (int x, int y, bool visible, FTerm::term_area* area)
updateVTerm (area);
}
//----------------------------------------------------------------------
void FTerm::getArea (const FPoint& pos, FTerm::term_area* area)
{
return getArea (pos.getX(), pos.getY(), area);
}
//----------------------------------------------------------------------
void FTerm::getArea (int ax, int ay, FTerm::term_area* area)
{
@ -2770,6 +2798,16 @@ void FTerm::getArea (int ax, int ay, FTerm::term_area* area)
}
}
//----------------------------------------------------------------------
void FTerm::getArea (const FRect& box, FTerm::term_area* area)
{
getArea ( box.getX()
, box.getY()
, box.getWidth()
, box.getHeight()
, area );
}
//----------------------------------------------------------------------
void FTerm::getArea (int x, int y, int w, int h, FTerm::term_area* area)
{
@ -3089,6 +3127,14 @@ void FTerm::clearArea (FTerm::term_area* area)
updateVTerm (area);
}
//----------------------------------------------------------------------
FOptiAttr::char_data FTerm::getCharacter ( int type
, const FPoint& pos
, FTerm* obj )
{
return getCharacter (type, pos.getX(), pos.getY(), obj);
}
//----------------------------------------------------------------------
FOptiAttr::char_data FTerm::getCharacter ( int char_type
, int x
@ -3190,6 +3236,36 @@ FOptiAttr::char_data FTerm::getCharacter ( int char_type
return *cc;
}
//----------------------------------------------------------------------
FOptiAttr::char_data FTerm::getCoveredCharacter ( int x
, int y
, FTerm* obj)
{
return getCharacter (covered_character, x, y, obj);
}
//----------------------------------------------------------------------
FOptiAttr::char_data FTerm::getCoveredCharacter ( const FPoint& pos
, FTerm* obj )
{
return getCharacter (covered_character, pos.getX(), pos.getY(), obj);
}
//----------------------------------------------------------------------
FOptiAttr::char_data FTerm::getOverlappedCharacter ( int x
, int y
, FTerm* obj)
{
return getCharacter (overlapped_character, x, y, obj);
}
//----------------------------------------------------------------------
FOptiAttr::char_data FTerm::getOverlappedCharacter ( const FPoint& pos
, FTerm* obj )
{
return getCharacter (overlapped_character, pos.getX(), pos.getY(), obj);
}
// public methods of FTerm
//----------------------------------------------------------------------
@ -3208,7 +3284,7 @@ bool FTerm::setVGAFont()
VGAFont = true;
if ( xterm || screen_terminal || osc_support )
if ( xterm_terminal || screen_terminal || osc_support )
{
// Set font in xterm to vga
oscPrefix();
@ -3219,7 +3295,7 @@ bool FTerm::setVGAFont()
pc_charset_console = true;
Encoding = fc::PC;
if ( xterm && utf8_console )
if ( xterm_terminal && utf8_console )
Fputchar = &FTerm::putchar_UTF8;
else
Fputchar = &FTerm::putchar_ASCII;
@ -3276,7 +3352,7 @@ bool FTerm::setNewFont()
|| mintty_terminal )
return false;
if ( xterm || screen_terminal || urxvt_terminal || osc_support )
if ( xterm_terminal || screen_terminal || urxvt_terminal || osc_support )
{
NewFont = true;
// Set font in xterm to 8x16graph
@ -3287,7 +3363,7 @@ bool FTerm::setNewFont()
pc_charset_console = true;
Encoding = fc::PC;
if ( xterm && utf8_console )
if ( xterm_terminal && utf8_console )
Fputchar = &FTerm::putchar_UTF8;
else
Fputchar = &FTerm::putchar_ASCII;
@ -3342,7 +3418,7 @@ bool FTerm::setOldFont()
NewFont = \
VGAFont = false;
if ( xterm || screen_terminal || urxvt_terminal || osc_support )
if ( xterm_terminal || screen_terminal || urxvt_terminal || osc_support )
{
if ( xterm_font && xterm_font->getLength() > 2 )
{
@ -3445,7 +3521,7 @@ void FTerm::getTermSize()
void FTerm::setTermSize (int term_width, int term_height)
{
// Set xterm size to {term_width} x {term_height}
if ( xterm )
if ( xterm_terminal )
{
putstringf (CSI "8;%d;%dt", term_height, term_width);
std::fflush(stdout);
@ -3453,93 +3529,31 @@ void FTerm::setTermSize (int term_width, int term_height)
}
//----------------------------------------------------------------------
void FTerm::createVTerm()
void FTerm::createVTerm (const FRect& r)
{
// initialize virtual terminal
vterm = new term_area;
vterm->width = -1;
vterm->height = -1;
vterm->right_shadow = 0;
vterm->bottom_shadow = 0;
vterm->input_cursor_x = -1;;
vterm->input_cursor_y = -1;;
vterm->input_cursor_visible = false;
vterm->changes = 0;
vterm->text = 0;
vterm->visible = true;
vterm->widget = static_cast<FWidget*>(this);
resizeVTerm();
const FPoint shadow(0,0);
createArea (r, shadow, vterm);
}
//----------------------------------------------------------------------
void FTerm::resizeVTerm()
void FTerm::createVTerm (int width, int height)
{
FOptiAttr::char_data default_char;
line_changes unchanged;
int term_width, term_height, vterm_size;
term_width = term->getWidth();
term_height = term->getHeight();
vterm_size = term_width * term_height;
if ( vterm->height != term_height )
{
if ( vterm->changes != 0 )
{
delete[] vterm->changes;
vterm->changes = 0;
// initialize virtual terminal
createArea (width, height, 0, 0, vterm);
}
if ( vterm->text != 0 )
//----------------------------------------------------------------------
void FTerm::resizeVTerm (const FRect& r)
{
delete[] vterm->text;
vterm->text = 0;
const FPoint shadow(0,0);
resizeArea (r, shadow, vterm);
}
vterm->changes = new line_changes[term_height];
vterm->text = new FOptiAttr::char_data[vterm_size];
}
else if ( vterm->width != term_width )
//----------------------------------------------------------------------
void FTerm::resizeVTerm (int width, int height)
{
if ( vterm->text != 0 )
{
delete[] vterm->text;
vterm->text = 0;
}
vterm->text = new FOptiAttr::char_data[vterm_size];
}
else
return;
vterm->width = term_width;
vterm->height = term_height;
default_char.code = ' ';
default_char.fg_color = fc::Default;
default_char.bg_color = fc::Default;
default_char.bold = 0;
default_char.dim = 0;
default_char.italic = 0;
default_char.underline = 0;
default_char.blink = 0;
default_char.reverse = 0;
default_char.standout = 0;
default_char.invisible = 0;
default_char.protect = 0;
default_char.crossed_out = 0;
default_char.dbl_underline = 0;
default_char.alt_charset = 0;
default_char.pc_charset = 0;
default_char.transparent = 0;
default_char.trans_shadow = 0;
std::fill_n (vterm->text, vterm_size, default_char);
unchanged.xmin = uInt(term_width);
unchanged.xmax = 0;
unchanged.trans_count = 0;
std::fill_n (vterm->changes, term_height, unchanged);
resizeArea (width, height, 0, 0, vterm);
}
//----------------------------------------------------------------------
@ -3586,8 +3600,8 @@ void FTerm::updateTerminal()
}
vt = vterm;
term_width = term->getWidth() - 1;
term_height = term->getHeight() - 1;
term_width = vt->width - 1;
term_height = vt->height - 1;
for (register uInt y=0; y < uInt(vt->height); y++)
{
@ -3694,7 +3708,7 @@ FString FTerm::getXTermFont()
{
FString font("");
if ( xterm || screen_terminal || osc_support )
if ( xterm_terminal || screen_terminal || osc_support )
{
if ( raw_mode && non_blocking_stdin )
{
@ -3755,7 +3769,7 @@ FString FTerm::getXTermTitle()
void FTerm::setXTermCursorStyle (fc::xtermCursorStyle style)
{
// Set the xterm cursor style
if ( (xterm || mintty_terminal) && ! (gnome_terminal || kde_konsole) )
if ( (xterm_terminal || mintty_terminal) && ! (gnome_terminal || kde_konsole) )
{
putstringf (CSI "%d q", style);
std::fflush(stdout);
@ -3766,7 +3780,7 @@ void FTerm::setXTermCursorStyle (fc::xtermCursorStyle style)
void FTerm::setXTermTitle (const FString& title)
{
// Set the xterm title
if ( xterm || screen_terminal
if ( xterm_terminal || screen_terminal
|| mintty_terminal || putty_terminal
|| osc_support )
{
@ -3781,7 +3795,7 @@ void FTerm::setXTermTitle (const FString& title)
void FTerm::setXTermForeground (const FString& fg)
{
// Set the VT100 text foreground color
if ( xterm || screen_terminal
if ( xterm_terminal || screen_terminal
|| mintty_terminal || mlterm_terminal
|| osc_support )
{
@ -3796,7 +3810,7 @@ void FTerm::setXTermForeground (const FString& fg)
void FTerm::setXTermBackground (const FString& bg)
{
// Set the VT100 text background color
if ( xterm || screen_terminal
if ( xterm_terminal || screen_terminal
|| mintty_terminal || mlterm_terminal
|| osc_support )
{
@ -3811,7 +3825,7 @@ void FTerm::setXTermBackground (const FString& bg)
void FTerm::setXTermCursorColor (const FString& cc)
{
// Set the text cursor color
if ( xterm || screen_terminal
if ( xterm_terminal || screen_terminal
|| mintty_terminal || urxvt_terminal
|| osc_support )
{
@ -3826,7 +3840,7 @@ void FTerm::setXTermCursorColor (const FString& cc)
void FTerm::setXTermMouseForeground (const FString& mfg)
{
// Set the mouse foreground color
if ( xterm || screen_terminal || urxvt_terminal || osc_support )
if ( xterm_terminal || screen_terminal || urxvt_terminal || osc_support )
{
oscPrefix();
putstringf (OSC "13;%s" BEL, mfg.c_str());
@ -3839,7 +3853,7 @@ void FTerm::setXTermMouseForeground (const FString& mfg)
void FTerm::setXTermMouseBackground (const FString& mbg)
{
// Set the mouse background color
if ( xterm || screen_terminal || osc_support )
if ( xterm_terminal || screen_terminal || osc_support )
{
oscPrefix();
putstringf (OSC "14;%s" BEL, mbg.c_str());
@ -3852,7 +3866,7 @@ void FTerm::setXTermMouseBackground (const FString& mbg)
void FTerm::setXTermHighlightBackground (const FString& hbg)
{
// Set the highlight background color
if ( xterm || screen_terminal || urxvt_terminal || osc_support )
if ( xterm_terminal || screen_terminal || urxvt_terminal || osc_support )
{
oscPrefix();
putstringf (OSC "17;%s" BEL, hbg.c_str());
@ -3865,7 +3879,7 @@ void FTerm::setXTermHighlightBackground (const FString& hbg)
void FTerm::resetXTermColors()
{
// Reset the entire color table
if ( xterm || screen_terminal || osc_support )
if ( xterm_terminal || screen_terminal || osc_support )
{
oscPrefix();
putstringf (OSC "104" BEL);
@ -3878,7 +3892,7 @@ void FTerm::resetXTermColors()
void FTerm::resetXTermForeground()
{
// Reset the VT100 text foreground color
if ( xterm || screen_terminal || osc_support )
if ( xterm_terminal || screen_terminal || osc_support )
{
oscPrefix();
putstring (OSC "110" BEL);
@ -3891,7 +3905,7 @@ void FTerm::resetXTermForeground()
void FTerm::resetXTermBackground()
{
// Reset the VT100 text background color
if ( xterm || screen_terminal || osc_support )
if ( xterm_terminal || screen_terminal || osc_support )
{
oscPrefix();
putstring (OSC "111" BEL);
@ -3904,7 +3918,7 @@ void FTerm::resetXTermBackground()
void FTerm::resetXTermCursorColor()
{
// Reset the text cursor color
if ( xterm || screen_terminal || osc_support )
if ( xterm_terminal || screen_terminal || osc_support )
{
oscPrefix();
putstring (OSC "112" BEL);
@ -3917,7 +3931,7 @@ void FTerm::resetXTermCursorColor()
void FTerm::resetXTermMouseForeground()
{
// Reset the mouse foreground color
if ( xterm || screen_terminal || osc_support )
if ( xterm_terminal || screen_terminal || osc_support )
{
oscPrefix();
putstring (OSC "113" BEL);
@ -3930,7 +3944,7 @@ void FTerm::resetXTermMouseForeground()
void FTerm::resetXTermMouseBackground()
{
// Reset the mouse background color
if ( xterm || screen_terminal || osc_support )
if ( xterm_terminal || screen_terminal || osc_support )
{
oscPrefix();
putstring (OSC "114" BEL);
@ -3943,7 +3957,7 @@ void FTerm::resetXTermMouseBackground()
void FTerm::resetXTermHighlightBackground()
{
// Reset the highlight background color
if ( xterm || screen_terminal || urxvt_terminal || osc_support )
if ( xterm_terminal || screen_terminal || urxvt_terminal || osc_support )
{
oscPrefix();
putstringf (OSC "117" BEL);
@ -4251,7 +4265,7 @@ void FTerm::setEncoding (std::string enc)
case fc::VT100:
case fc::PC:
if ( xterm && utf8_console )
if ( xterm_terminal && utf8_console )
Fputchar = &FTerm::putchar_UTF8;
// fall through
case fc::ASCII:
@ -4938,7 +4952,7 @@ inline void FTerm::charsetChanges (FOptiAttr::char_data*& next_char)
{
next_char->pc_charset = true;
if ( xterm && utf8_console && ch < 0x20 ) // Character 0x00..0x1f
if ( xterm_terminal && utf8_console && ch < 0x20 ) // Character 0x00..0x1f
next_char->code = int(charEncode(code, fc::ASCII));
}
}

View File

@ -126,7 +126,7 @@ class FTerm
static bool ascii_console;
static bool color256;
static bool monochron;
static bool xterm;
static bool xterm_terminal;
static bool rxvt_terminal;
static bool urxvt_terminal;
static bool mlterm_terminal;
@ -294,34 +294,36 @@ class FTerm
protected:
static bool charEncodable (uInt);
void createArea (FTerm::term_area*&); // reference to pointer
void resizeArea (FTerm::term_area*);
void removeArea (FTerm::term_area*&); // reference to pointer
void restoreVTerm (const FRect&);
void restoreVTerm (int, int, int, int);
void createArea (const FRect&, const FPoint&, FTerm::term_area*&);
void createArea (int, int, int, int, FTerm::term_area*&);
static void resizeArea (const FRect&, const FPoint&, FTerm::term_area*);
static void resizeArea (int, int, int, int, FTerm::term_area*);
static void removeArea (FTerm::term_area*&);
static void restoreVTerm (const FRect&);
static void restoreVTerm (int, int, int, int);
static FTerm::covered_state isCovered (const FPoint&, FTerm::term_area*);
static FTerm::covered_state isCovered (int, int, FTerm::term_area*);
void updateVTerm (bool);
void updateVTerm (FTerm::term_area*);
static void updateVTerm (bool);
static void updateVTerm (FTerm::term_area*);
static bool updateVTermCursor (FTerm::term_area*);
static bool isInsideArea (int, int, FTerm::term_area*);
void setAreaCursor (const FPoint&, bool, FTerm::term_area*);
void setAreaCursor (int, int, bool, FTerm::term_area*);
void getArea (const FPoint&, FTerm::term_area*);
void getArea (int, int, FTerm::term_area*);
void getArea (const FRect&, FTerm::term_area*);
void getArea (int, int, int, int, FTerm::term_area*);
void putArea (const FPoint&, FTerm::term_area*);
void putArea (int, int, FTerm::term_area*);
static void setAreaCursor (const FPoint&, bool, FTerm::term_area*);
static void setAreaCursor (int, int, bool, FTerm::term_area*);
static void getArea (const FPoint&, FTerm::term_area*);
static void getArea (int, int, FTerm::term_area*);
static void getArea (const FRect&, FTerm::term_area*);
static void getArea (int, int, int, int, FTerm::term_area*);
static void putArea (const FPoint&, FTerm::term_area*);
static void putArea (int, int, FTerm::term_area*);
static void scrollAreaForward (FTerm::term_area*);
static void scrollAreaReverse (FTerm::term_area*);
void clearArea (FTerm::term_area*);
FOptiAttr::char_data getCharacter (int, const FPoint&, FTerm*);
FOptiAttr::char_data getCharacter (int, int, int, FTerm*);
FOptiAttr::char_data getCoveredCharacter (const FPoint&, FTerm*);
FOptiAttr::char_data getCoveredCharacter (int, int, FTerm*);
FOptiAttr::char_data getOverlappedCharacter (const FPoint&, FTerm*);
FOptiAttr::char_data getOverlappedCharacter (int, int, FTerm*);
static void clearArea (FTerm::term_area*);
static FOptiAttr::char_data getCharacter (int, const FPoint&, FTerm*);
static FOptiAttr::char_data getCharacter (int, int, int, FTerm*);
static FOptiAttr::char_data getCoveredCharacter (const FPoint&, FTerm*);
static FOptiAttr::char_data getCoveredCharacter (int, int, FTerm*);
static FOptiAttr::char_data getOverlappedCharacter (const FPoint&, FTerm*);
static FOptiAttr::char_data getOverlappedCharacter (int, int, FTerm*);
public:
// Constructor
@ -346,9 +348,20 @@ class FTerm
static bool hasVT100();
static bool hasASCII();
static bool isMonochron();
static bool isCygwinTerminal();
static bool isTeraTerm();
static bool isXTerminal();
static bool isRxvtTerminal();
static bool isUrxvtTerminal();
static bool isMltermTerminal();
static bool isPuttyTerminal();
static bool isKdeTerminal();
static bool isGnomeTerminal();
static bool isKtermTerminal();
static bool isTeraTerm();
static bool isCygwinTerminal();
static bool isMinttyTerm();
static bool isLinuxTerm();
static bool isScreenTerm();
static bool isTmuxTerm();
static bool setVGAFont();
static bool setNewFont();
static bool isNewFont();
@ -357,8 +370,10 @@ class FTerm
static void setConsoleCursor (fc::consoleCursorStyle);
static void getTermSize();
static void setTermSize (int, int);
void createVTerm();
static void resizeVTerm();
void createVTerm (const FRect&);
void createVTerm (int, int);
static void resizeVTerm (const FRect&);
static void resizeVTerm (int, int);
static void putVTerm();
static void updateTerminal (bool);
static void updateTerminal();
@ -481,51 +496,6 @@ class FTerm
#pragma pack(pop)
// FTerm inline functions
//----------------------------------------------------------------------
inline FTerm::covered_state FTerm::isCovered ( const FPoint& pos
, FTerm::term_area* area)
{ return isCovered (pos.getX(), pos.getY(), area); }
//----------------------------------------------------------------------
inline void FTerm::setAreaCursor ( const FPoint& pos
, bool visible
, FTerm::term_area* area)
{ setAreaCursor (pos.getX(), pos.getY(), visible, area); }
//----------------------------------------------------------------------
inline void FTerm::getArea (const FPoint& pos, FTerm::term_area* area)
{ return getArea (pos.getX(), pos.getY(), area); }
//----------------------------------------------------------------------
inline void FTerm::getArea (const FRect& box, FTerm::term_area* area)
{
getArea ( box.getX()
, box.getY()
, box.getWidth()
, box.getHeight()
, area );
}
//----------------------------------------------------------------------
inline FOptiAttr::char_data FTerm::getCharacter (int type, const FPoint& pos, FTerm* obj)
{ return getCharacter (type, pos.getX(), pos.getY(), obj); }
//----------------------------------------------------------------------
inline FOptiAttr::char_data FTerm::getCoveredCharacter (int x, int y, FTerm* obj)
{ return getCharacter (covered_character, x, y, obj); }
//----------------------------------------------------------------------
inline FOptiAttr::char_data FTerm::getCoveredCharacter (const FPoint& pos, FTerm* obj)
{ return getCharacter (covered_character, pos.getX(), pos.getY(), obj); }
//----------------------------------------------------------------------
inline FOptiAttr::char_data FTerm::getOverlappedCharacter (int x, int y, FTerm* obj)
{ return getCharacter (overlapped_character, x, y, obj); }
//----------------------------------------------------------------------
inline FOptiAttr::char_data FTerm::getOverlappedCharacter (const FPoint& pos, FTerm* obj)
{ return getCharacter (overlapped_character, pos.getX(), pos.getY(), obj); }
//----------------------------------------------------------------------
inline const char* FTerm::getClassName() const
{ return "FTerm"; }
@ -593,16 +563,60 @@ inline bool FTerm::isMonochron()
{ return monochron; }
//----------------------------------------------------------------------
inline bool FTerm::isCygwinTerminal()
{ return cygwin_terminal; }
inline bool FTerm::isXTerminal()
{ return xterm_terminal; }
//----------------------------------------------------------------------
inline bool FTerm::isRxvtTerminal()
{ return rxvt_terminal; }
//----------------------------------------------------------------------
inline bool FTerm::isUrxvtTerminal()
{ return urxvt_terminal; }
//----------------------------------------------------------------------
inline bool FTerm::isMltermTerminal()
{ return mlterm_terminal; }
//----------------------------------------------------------------------
inline bool FTerm::isPuttyTerminal()
{ return putty_terminal; }
//----------------------------------------------------------------------
inline bool FTerm::isKdeTerminal()
{ return kde_konsole; }
//----------------------------------------------------------------------
inline bool FTerm::isGnomeTerminal()
{ return gnome_terminal; }
//----------------------------------------------------------------------
inline bool FTerm::isKtermTerminal()
{ return kterm_terminal; }
//----------------------------------------------------------------------
inline bool FTerm::isTeraTerm()
{ return tera_terminal; }
//----------------------------------------------------------------------
inline bool FTerm::isUrxvtTerminal()
{ return urxvt_terminal; }
inline bool FTerm::isCygwinTerminal()
{ return cygwin_terminal; }
//----------------------------------------------------------------------
inline bool FTerm::isMinttyTerm()
{ return mintty_terminal; }
//----------------------------------------------------------------------
inline bool FTerm::isLinuxTerm()
{ return linux_terminal; }
//----------------------------------------------------------------------
inline bool FTerm::isScreenTerm()
{ return screen_terminal; }
//----------------------------------------------------------------------
inline bool FTerm::isTmuxTerm()
{ return tmux_terminal; }
//----------------------------------------------------------------------
inline bool FTerm::setCursorOptimisation (bool on)

View File

@ -51,16 +51,6 @@ FToolTip::~FToolTip() // destructor
else
switchToPrevWindow();
}
delWindow(this);
if ( ! fapp->isQuit() )
{
const FRect& t_geometry = getTermGeometryWithShadow();
restoreVTerm (t_geometry);
}
removeArea (vwin);
}
@ -73,8 +63,6 @@ void FToolTip::init()
// initialize geometry values
setGeometry (1, 1, 3, 3, false);
setMinimumSize (3, 3);
createArea (vwin);
addWindow(this);
setForegroundColor (wc.tooltip_fg);
setBackgroundColor (wc.tooltip_bg);
calculateDimensions();

View File

@ -53,9 +53,9 @@ FWidget::FWidget (FWidget* parent)
, adjust_wsize_term_shadow()
, offset()
, client_offset()
, wshadow()
, foreground_color()
, background_color()
, wshadow(0,0)
, foreground_color(fc::Default)
, background_color(fc::Default)
, print_area(0)
, statusbar_message()
{
@ -137,7 +137,7 @@ void FWidget::init()
double_flatline_mask.bottom.resize (uLong(getWidth()), false);
double_flatline_mask.left.resize (uLong(getHeight()), false);
// default widget colors
// Initialize default widget colors
setColorTheme();
foreground_color = wc.term_fg;
@ -1323,9 +1323,10 @@ void FWidget::resize()
if ( isRootWidget() && openConsole() == 0 )
{
getTermSize();
const FRect& term_geometry = getGeometry();
closeConsole();
resizeVTerm();
resizeArea (vdesktop);
resizeVTerm (term_geometry);
resizeArea (term_geometry, getShadow(), vdesktop);
adjustSizeGlobal();
}
else
@ -1851,7 +1852,7 @@ void FWidget::getTermSize()
void FWidget::setTermSize (int w, int h)
{
// Set xterm size to w x h
if ( xterm )
if ( xterm_terminal )
{
rootObject->wsize.setRect(1, 1, w, h);
rootObject->adjust_wsize = rootObject->wsize;

View File

@ -491,7 +491,7 @@ class FWidget : public FObject, public FTerm
void setTermSize (int, int);
virtual void setGeometry (const FRect&, bool = true);
virtual void setGeometry (int, int, int, int, bool = true);
void setShadowSize (int, int);
virtual void setShadowSize (int, int);
void setMinimumSize (int, int);
void setMaximumSize (int, int);
void setFixedSize (int, int);

View File

@ -23,16 +23,30 @@ FWindow::FWindow(FWidget* parent)
, normalGeometry()
{
setWindowWidget();
createArea (getGeometry(), getShadow(), vwin);
addWindow (this);
}
//----------------------------------------------------------------------
FWindow::~FWindow() // destructor
{
FApplication* fapp = static_cast<FApplication*>(getRootWidget());
if ( previous_widget == this )
previous_widget = 0;
if ( isAlwaysOnTop() )
deleteFromAlwaysOnTopList (this);
delWindow (this);
if ( ! fapp->isQuit() )
{
const FRect& t_geometry = getTermGeometryWithShadow();
restoreVTerm (t_geometry);
}
removeArea (vwin);
}
@ -211,7 +225,7 @@ void FWindow::setWidth (int w, bool adjust)
FWidget::setWidth (w, adjust);
if ( vwin && getWidth() != old_width )
resizeArea (vwin);
resizeArea (getGeometry(), getShadow(), vwin);
}
//----------------------------------------------------------------------
@ -221,7 +235,7 @@ void FWindow::setHeight (int h, bool adjust)
FWidget::setHeight (h, adjust);
if ( vwin && getHeight() != old_height )
resizeArea (vwin);
resizeArea (getGeometry(), getShadow(), vwin);
}
//----------------------------------------------------------------------
@ -232,7 +246,7 @@ void FWindow::setSize (int w, int h, bool adjust)
FWidget::setSize (w, h, adjust);
if ( vwin && (getWidth() != old_width || getHeight() != old_height) )
resizeArea (vwin);
resizeArea (getGeometry(), getShadow(), vwin);
}
//----------------------------------------------------------------------
@ -243,7 +257,7 @@ void FWindow::setGeometry (int x, int y, int w, int h, bool adjust)
FWidget::setGeometry (x, y, w, h, adjust);
if ( vwin && (getWidth() != old_width || getHeight() != old_height) )
resizeArea (vwin);
resizeArea (getGeometry(), getShadow(), vwin);
}
//----------------------------------------------------------------------
@ -692,6 +706,72 @@ bool FWindow::isHiddenWindow() const
return false;
}
//----------------------------------------------------------------------
bool FWindow::setResizeable (bool on)
{
if ( on )
flags |= fc::resizeable;
else
flags &= ~fc::resizeable;
return on;
}
//----------------------------------------------------------------------
bool FWindow::setTransparentShadow (bool on)
{
if ( on )
{
flags |= fc::shadow;
flags |= fc::trans_shadow;
setShadowSize (2,1);
}
else
{
flags &= ~fc::shadow;
flags &= ~fc::trans_shadow;
setShadowSize (0,0);
}
return on;
}
//----------------------------------------------------------------------
bool FWindow::setShadow (bool on)
{
if ( isMonochron() )
return false;
if ( on )
{
flags |= fc::shadow;
flags &= ~fc::trans_shadow;
setShadowSize (1,1);
}
else
{
flags &= ~fc::shadow;
flags &= ~fc::trans_shadow;
setShadowSize (0,0);
}
return on;
}
//----------------------------------------------------------------------
void FWindow::setShadowSize (int right, int bottom)
{
int old_right, old_bottom, new_right, new_bottom;
old_right = getShadow().getX();
old_bottom = getShadow().getY();
FWidget::setShadowSize (right, bottom);
new_right = getShadow().getX();
new_bottom = getShadow().getY();
if ( vwin && (new_right != old_right || new_bottom != old_bottom) )
resizeArea (getGeometry(), getShadow(), vwin);
}
//----------------------------------------------------------------------
bool FWindow::setAlwaysOnTop (bool on)
{

View File

@ -116,6 +116,19 @@ class FWindow : public FWidget
bool deactivateWindow();
bool isActiveWindow() const;
bool isHiddenWindow() const;
bool setResizeable (bool);
bool setResizeable();
bool unsetResizeable();
bool isResizeable();
bool setTransparentShadow (bool);
bool setTransparentShadow();
bool unsetTransparentShadow();
bool hasTransparentShadow();
bool setShadow (bool);
bool setShadow();
bool unsetShadow();
bool hasShadow();
virtual void setShadowSize (int, int);
bool setAlwaysOnTop (bool);
bool setAlwaysOnTop();
bool unsetAlwaysOnTop();
@ -165,6 +178,42 @@ inline bool FWindow::deactivateWindow()
inline bool FWindow::isActiveWindow() const
{ return window_active; }
//----------------------------------------------------------------------
inline bool FWindow::setResizeable()
{ return setResizeable(true); }
//----------------------------------------------------------------------
inline bool FWindow::unsetResizeable()
{ return setResizeable(false); }
//----------------------------------------------------------------------
inline bool FWindow::isResizeable()
{ return ((flags & fc::resizeable) != 0); }
//----------------------------------------------------------------------
inline bool FWindow::setTransparentShadow()
{ return setTransparentShadow(true); }
//----------------------------------------------------------------------
inline bool FWindow::unsetTransparentShadow()
{ return setTransparentShadow(false); }
//----------------------------------------------------------------------
inline bool FWindow::hasTransparentShadow()
{ return ((flags & fc::trans_shadow) != 0); }
//----------------------------------------------------------------------
inline bool FWindow::setShadow()
{ return setShadow(true); }
//----------------------------------------------------------------------
inline bool FWindow::unsetShadow()
{ return setShadow(false); }
//----------------------------------------------------------------------
inline bool FWindow::hasShadow()
{ return ((flags & fc::shadow) != 0); }
//----------------------------------------------------------------------
inline bool FWindow::setAlwaysOnTop()
{ return setAlwaysOnTop(true); }