Some code improvements

This commit is contained in:
Markus Gans 2017-09-11 03:06:02 +02:00
parent 1cd1e521c3
commit dc3c5d19e4
94 changed files with 6267 additions and 6137 deletions

View File

@ -1,3 +1,6 @@
2017-09-11 Markus Gans <guru.mail@muenster.de>
* Some code improvements
2017-09-09 Markus Gans <guru.mail@muenster.de> 2017-09-09 Markus Gans <guru.mail@muenster.de>
* Wrong UTF-8 string length fixed when attaching to FString * Wrong UTF-8 string length fixed when attaching to FString

View File

@ -1,6 +1,8 @@
// File: fapplication.cpp // File: fapplication.cpp
// Provides: class FApplication // Provides: class FApplication
#include <string>
#include "fapplication.h" #include "fapplication.h"
#include "fmenu.h" #include "fmenu.h"
#include "fstatusbar.h" #include "fstatusbar.h"
@ -33,7 +35,7 @@ FApplication::eventQueue* FApplication::event_queue = 0;
// constructors and destructor // constructors and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FApplication::FApplication ( int& _argc FApplication::FApplication ( const int& _argc
, char* _argv[] , char* _argv[]
, bool disable_alt_screen ) , bool disable_alt_screen )
: FWidget(0, disable_alt_screen) : FWidget(0, disable_alt_screen)
@ -213,7 +215,9 @@ bool FApplication::sendEvent ( const FObject* receiver
return false; return false;
// For access to a protected base class member // For access to a protected base class member
FApplication* w = const_cast<FApplication*>(static_cast<const FApplication*>(widget)); const FApplication* const_w = static_cast<const FApplication*>(widget);
FApplication* w = const_cast<FApplication*>(const_w);
// Sends event event directly to receiver // Sends event event directly to receiver
return w->event(const_cast<FEvent*>(event)); return w->event(const_cast<FEvent*>(event));
} }
@ -314,7 +318,7 @@ void FApplication::init()
try try
{ {
zero_point = new FPoint(0,0); zero_point = new FPoint (0,0);
event_queue = new eventQueue; event_queue = new eventQueue;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
@ -536,7 +540,7 @@ void FApplication::processKeyboardEvent()
if ( isKeyPressed ) if ( isKeyPressed )
{ {
register ssize_t bytesread; register ssize_t bytesread;
widget->getCurrentTime(time_keypressed); widget->getCurrentTime (&time_keypressed);
x11_mouse[0] = sgr_mouse[0] = urxvt_mouse[0] = '\0'; x11_mouse[0] = sgr_mouse[0] = urxvt_mouse[0] = '\0';
if ( quit_now || app_exit_loop ) if ( quit_now || app_exit_loop )
@ -694,7 +698,6 @@ void FApplication::processKeyboardEvent()
} }
} }
break; break;
} // end of switch } // end of switch
} }
@ -725,7 +728,7 @@ void FApplication::processKeyboardEvent()
#if defined(__linux__) #if defined(__linux__)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FApplication::linuxModifierKeyCorrection (int& key_id) int FApplication::linuxModifierKeyCorrection (const int& key_id)
{ {
// get the current modifier key state // get the current modifier key state
FTerm::modifier_key& m = getLinuxModifierKey(); FTerm::modifier_key& m = getLinuxModifierKey();
@ -1198,7 +1201,7 @@ bool FApplication::parseX11Mouse()
x = uChar(x11_mouse[1] - 0x20); x = uChar(x11_mouse[1] - 0x20);
y = uChar(x11_mouse[2] - 0x20); y = uChar(x11_mouse[2] - 0x20);
new_mouse_position.setPoint(x,y); new_mouse_position.setPoint (x, y);
// fill bit field with 0 // fill bit field with 0
std::memset(&b_state, 0x00, sizeof(b_state)); std::memset(&b_state, 0x00, sizeof(b_state));
@ -1293,7 +1296,7 @@ bool FApplication::parseSGRMouse()
y = uChar(10 * y + (*p - '0')); y = uChar(10 * y + (*p - '0'));
} }
new_mouse_position.setPoint(x,y); new_mouse_position.setPoint (x, y);
// fill bit field with 0 // fill bit field with 0
std::memset(&b_state, 0x00, sizeof(b_state)); std::memset(&b_state, 0x00, sizeof(b_state));
@ -1491,7 +1494,7 @@ bool FApplication::parseUrxvtMouse()
if ( y > getLineNumber() ) if ( y > getLineNumber() )
y = uChar(getLineNumber()); y = uChar(getLineNumber());
new_mouse_position.setPoint(x,y); new_mouse_position.setPoint (x, y);
// fill bit field with 0 // fill bit field with 0
std::memset(&b_state, 0x00, sizeof(b_state)); std::memset(&b_state, 0x00, sizeof(b_state));
@ -1891,8 +1894,7 @@ void FApplication::processMouseEvent()
clicked_widget = 0; clicked_widget = 0;
sendEvent (scroll_over_widget, &wheel_ev); sendEvent (scroll_over_widget, &wheel_ev);
} }
} // end of if ( clicked_widget )
}
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
if ( isGpmMouseEnabled() && gpm_ev.x != -1 ) if ( isGpmMouseEnabled() && gpm_ev.x != -1 )
@ -1920,7 +1922,7 @@ int FApplication::processTimerEvent()
timeval currentTime; timeval currentTime;
int activated = 0; int activated = 0;
getCurrentTime (currentTime); getCurrentTime (&currentTime);
if ( isTimerInUpdating() ) if ( isTimerInUpdating() )
return 0; return 0;

View File

@ -38,6 +38,8 @@
#include <getopt.h> #include <getopt.h>
#include <deque> #include <deque>
#include <string>
#include <utility>
#include "fevent.h" #include "fevent.h"
#include "fwidget.h" #include "fwidget.h"
@ -55,7 +57,7 @@ class FApplication : public FWidget
{ {
public: public:
// Constructor // Constructor
FApplication (int&, char*[], bool = false); FApplication (const int&, char*[], bool = false);
// Destructor // Destructor
virtual ~FApplication(); virtual ~FApplication();
@ -130,7 +132,7 @@ class FApplication : public FWidget
ssize_t readKey(); ssize_t readKey();
void processKeyboardEvent(); void processKeyboardEvent();
#if defined(__linux__) #if defined(__linux__)
int linuxModifierKeyCorrection (int& key); int linuxModifierKeyCorrection (const int&);
#endif #endif
bool processDialogSwitchAccelerator(); bool processDialogSwitchAccelerator();
bool processAccelerator (const FWidget*&); bool processAccelerator (const FWidget*&);

View File

@ -664,7 +664,7 @@ void FButton::draw()
if ( is_ActiveFocus && (isMonochron() || getMaxColor() < 16) ) if ( is_ActiveFocus && (isMonochron() || getMaxColor() < 16) )
setBold(); setBold();
for (int z = 0; x < i + length && z < getWidth(); z++,x++) for (int z = 0; x < i + length && z < getWidth(); z++, x++)
{ {
if ( (z == hotkeypos) && is_Active ) if ( (z == hotkeypos) && is_Active )
{ {
@ -760,7 +760,7 @@ void FButton::updateButtonColor()
else else
{ {
button_fg = getForegroundColor(); button_fg = getForegroundColor();
button_bg = getBackgroundColor() ; button_bg = getBackgroundColor();
} }
} }
else // inactive else // inactive

View File

@ -240,7 +240,8 @@ void FButtonGroup::insert (FToggleButton* button)
// setChecked the first FRadioButton // setChecked the first FRadioButton
if ( buttonlist.size() == 1 ) if ( buttonlist.size() == 1 )
{ {
FToggleButton* first_button = static_cast<FToggleButton*>(*buttonlist.begin()); FToggleButton* first_button;
first_button = static_cast<FToggleButton*>(*buttonlist.begin());
if ( isRadioButton(first_button) ) if ( isRadioButton(first_button) )
first_button->setChecked(); first_button->setChecked();
@ -254,8 +255,6 @@ void FButtonGroup::insert (FToggleButton* button)
"toggled", "toggled",
F_METHOD_CALLBACK (this, &FButtonGroup::cb_buttonToggled) F_METHOD_CALLBACK (this, &FButtonGroup::cb_buttonToggled)
); );
//checkScrollSize (button);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -39,7 +39,7 @@ void FCheckMenuItem::init (FWidget* parent)
if ( isMenu(parent) ) // Parent is menu if ( isMenu(parent) ) // Parent is menu
{ {
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent); FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->has_checkable_items = true; menu_ptr->has_checkable_items = true;

View File

@ -1204,7 +1204,7 @@ void FDialog::drawBorder()
void FDialog::drawTitleBar() void FDialog::drawTitleBar()
{ {
static const int menu_btn = 3; static const int menu_btn = 3;
int i,x,length, zoom_btn; int i, x, length, zoom_btn;
// draw the title button // draw the title button
setPrintPos (1, 1); setPrintPos (1, 1);

View File

@ -1,8 +1,11 @@
// File: ffiledialog.cpp // File: ffiledialog.cpp
// Provides: class FFileDialog // Provides: class FFileDialog
#include <vector>
#include "ffiledialog.h" #include "ffiledialog.h"
// non-member functions // non-member functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool sortByName ( const FFileDialog::dir_entry& lhs bool sortByName ( const FFileDialog::dir_entry& lhs
@ -230,7 +233,6 @@ void FFileDialog::onKeyPress (FKeyEvent* ev)
default: default:
break; break;
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -268,7 +270,8 @@ int FFileDialog::readDir()
continue; continue;
} }
if ( dir[0] == '/' && dir[1] == '\0' && std::strcmp(next->d_name, "..") == 0 ) if ( dir[0] == '/' && dir[1] == '\0'
&& std::strcmp(next->d_name, "..") == 0 )
continue; continue;
dir_entry entry; dir_entry entry;
@ -280,7 +283,9 @@ int FFileDialog::readDir()
char resolved_path[MAXPATHLEN] = {}; char resolved_path[MAXPATHLEN] = {};
char symLink[MAXPATHLEN] = {}; char symLink[MAXPATHLEN] = {};
std::strncpy (symLink, dir, sizeof(symLink) - 1); std::strncpy (symLink, dir, sizeof(symLink) - 1);
std::strncat (symLink, next->d_name, sizeof(symLink) - std::strlen(symLink) - 1); std::strncat ( symLink
, next->d_name
, sizeof(symLink) - std::strlen(symLink) - 1);
if ( realpath(symLink, resolved_path) != 0 ) // follow link if ( realpath(symLink, resolved_path) != 0 ) // follow link
{ {
@ -310,7 +315,6 @@ int FFileDialog::readDir()
} }
else else
break; break;
} // end while } // end while
if ( closedir (directory_stream) != 0 ) if ( closedir (directory_stream) != 0 )
@ -326,11 +330,17 @@ int FFileDialog::readDir()
dir_num = numOfDirs(); dir_num = numOfDirs();
// directories first // directories first
std::sort(dir_entries.begin() + start, dir_entries.end(), sortDirFirst); std::sort ( dir_entries.begin() + start
, dir_entries.end()
, sortDirFirst );
// sort directories by name // sort directories by name
std::sort(dir_entries.begin() + start, dir_entries.begin() + dir_num, sortByName); std::sort ( dir_entries.begin() + start
, dir_entries.begin() + dir_num
, sortByName );
// sort files by name // sort files by name
std::sort(dir_entries.begin() + dir_num, dir_entries.end(), sortByName); std::sort ( dir_entries.begin() + dir_num
, dir_entries.end()
, sortByName );
// fill list with directory entries // fill list with directory entries
filebrowser->clear(); filebrowser->clear();
@ -525,9 +535,9 @@ void FFileDialog::init()
cancel->setGeometry(19, 10, 9, 1); cancel->setGeometry(19, 10, 9, 1);
if ( dlg_type == FFileDialog::Save ) if ( dlg_type == FFileDialog::Save )
open = new FButton("&Save",this); open = new FButton("&Save", this);
else else
open = new FButton("&Open",this); open = new FButton("&Open", this);
open->setGeometry(30, 10, 9, 1); open->setGeometry(30, 10, 9, 1);
setGeometry (x, y, getWidth(), getHeight()); setGeometry (x, y, getWidth(), getHeight());
@ -581,19 +591,18 @@ void FFileDialog::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
char* FFileDialog::getHomeDir() char* FFileDialog::getHomeDir()
{ {
struct passwd* pwd; struct passwd pwd;
pwd = getpwuid( geteuid() ); struct passwd* pwd_ptr;
char buf[1024];
if ( ! pwd ) if ( getpwuid_r (geteuid(), &pwd, buf, sizeof(buf), &pwd_ptr) )
return const_cast<char*>(""); return const_cast<char*>("");
else else
{ {
pwd = getpwnam(pwd->pw_name); if ( getpwnam_r (pwd.pw_name, &pwd, buf, sizeof(buf), &pwd_ptr) )
if ( ! pwd )
return const_cast<char*>(""); return const_cast<char*>("");
else else
return pwd->pw_dir; return pwd.pw_dir;
} }
} }
@ -695,7 +704,8 @@ int FFileDialog::changeDir (const FString& dirname)
{ {
int i = 1; int i = 1;
std::vector<dir_entry>::const_iterator iter, end; std::vector<dir_entry>::const_iterator iter, end;
const char* const baseName = basename(const_cast<char*>(lastdir.c_str())); const char* const baseName = \
basename(const_cast<char*>(lastdir.c_str()));
iter = dir_entries.begin(); iter = dir_entries.begin();
end = dir_entries.end(); end = dir_entries.end();

View File

@ -46,6 +46,7 @@
#include <pwd.h> #include <pwd.h>
#include <string> #include <string>
#include <vector>
#include "fbutton.h" #include "fbutton.h"
#include "fcheckbox.h" #include "fcheckbox.h"

View File

@ -3,6 +3,7 @@
#ifndef FKEYMAP_H #ifndef FKEYMAP_H
#define FKEYMAP_H #define FKEYMAP_H
#include <string>
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)

View File

@ -28,6 +28,7 @@
#ifndef FLABEL_H #ifndef FLABEL_H
#define FLABEL_H #define FLABEL_H
#include <vector>
#include "fwidget.h" #include "fwidget.h"

View File

@ -2,6 +2,8 @@
// Provides: class FListBoxItem // Provides: class FListBoxItem
// class FListBox // class FListBox
#include <algorithm>
#include "fapplication.h" #include "fapplication.h"
#include "flistbox.h" #include "flistbox.h"
#include "fscrollbar.h" #include "fscrollbar.h"
@ -38,7 +40,7 @@ FListBoxItem::FListBoxItem (const FString& txt, FWidget::data_ptr data)
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FListBoxItem::~FListBoxItem() FListBoxItem::~FListBoxItem() // destructor
{ } { }
// public methods of FListBoxItem // public methods of FListBoxItem
@ -1306,7 +1308,7 @@ void FListBox::draw()
for (int y = 2; y < getHeight(); y++) for (int y = 2; y < getHeight(); y++)
{ {
setPrintPos (getWidth(),y); setPrintPos (getWidth(), y);
print (' '); // clear right side of the scrollbar print (' '); // clear right side of the scrollbar
} }
} }
@ -1464,7 +1466,8 @@ void FListBox::drawList()
if ( inc_len > 0 ) // incremental search if ( inc_len > 0 ) // incremental search
{ {
serach_mark = true; serach_mark = true;
setCursorPos (2 + b + int(inc_len), 2 + int(y)); // last found character // Place the cursor on the last found character
setCursorPos (2 + b + int(inc_len), 2 + int(y));
} }
else // only highlighted else // only highlighted
setCursorPos (3 + b, 2 + int(y)); // first character setCursorPos (3 + b, 2 + int(y)); // first character

View File

@ -30,6 +30,8 @@
#ifndef FLISTBOX_H #ifndef FLISTBOX_H
#define FLISTBOX_H #define FLISTBOX_H
#include <vector>
#include "fscrollbar.h" #include "fscrollbar.h"
#include "fstring.h" #include "fstring.h"
#include "fwidget.h" #include "fwidget.h"

View File

@ -2,6 +2,8 @@
// Provides: class FListViewItem // Provides: class FListViewItem
// class FListView // class FListView
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "flistview.h" #include "flistview.h"
#include "fscrollbar.h" #include "fscrollbar.h"
@ -109,7 +111,7 @@ FListViewItem::FListViewItem ( const std::vector<FString>& cols
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FListViewItem::~FListViewItem() FListViewItem::~FListViewItem() // destructor
{ } { }
@ -1074,7 +1076,7 @@ void FListView::draw()
for (int y = 2; y < getHeight(); y++) for (int y = 2; y < getHeight(); y++)
{ {
setPrintPos (getWidth(),y); setPrintPos (getWidth(), y);
print (' '); // clear right side of the scrollbar print (' '); // clear right side of the scrollbar
} }
} }

View File

@ -30,6 +30,8 @@
#ifndef FLISTVIEW_H #ifndef FLISTVIEW_H
#define FLISTVIEW_H #define FLISTVIEW_H
#include <vector>
#include "fscrollbar.h" #include "fscrollbar.h"
#include "fstring.h" #include "fstring.h"
#include "ftermbuffer.h" #include "ftermbuffer.h"
@ -48,9 +50,10 @@ class FListView;
class FListViewItem : public FObject class FListViewItem : public FObject
{ {
public: public:
// Constructor
FListViewItem (const FListViewItem&); // copy constructor FListViewItem (const FListViewItem&); // copy constructor
FListViewItem (FListViewItem*); explicit FListViewItem (FListViewItem*);
FListViewItem (FListView*); explicit FListViewItem (FListView*);
FListViewItem ( const std::vector<FString>& FListViewItem ( const std::vector<FString>&
, FWidget::data_ptr = 0 , FWidget::data_ptr = 0
, FListView* = 0 ); , FListView* = 0 );

View File

@ -1,6 +1,8 @@
// File: fmenu.cpp // File: fmenu.cpp
// Provides: class FMenu // Provides: class FMenu
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fdialog.h" #include "fdialog.h"
#include "fmenu.h" #include "fmenu.h"
@ -48,7 +50,7 @@ FMenu::FMenu (const FString& txt, FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMenu::~FMenu() FMenu::~FMenu() // destructor
{ {
FApplication* fapp = static_cast<FApplication*>(getRootWidget()); FApplication* fapp = static_cast<FApplication*>(getRootWidget());
@ -299,7 +301,7 @@ void FMenu::onMouseDown (FMouseEvent* ev)
iter = item_list.begin(); iter = item_list.begin();
end = item_list.end(); end = item_list.end();
mouse_pos = ev->getPos(); mouse_pos = ev->getPos();
mouse_pos -= FPoint(getRightPadding(),getTopPadding()); mouse_pos -= FPoint(getRightPadding(), getTopPadding());
while ( iter != end ) while ( iter != end )
{ {
@ -404,7 +406,7 @@ void FMenu::onMouseUp (FMouseEvent* ev)
iter = item_list.begin(); iter = item_list.begin();
end = item_list.end(); end = item_list.end();
mouse_pos = ev->getPos(); mouse_pos = ev->getPos();
mouse_pos -= FPoint(getRightPadding(),getTopPadding()); mouse_pos -= FPoint(getRightPadding(), getTopPadding());
while ( iter != end ) while ( iter != end )
{ {
@ -492,7 +494,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
iter = item_list.begin(); iter = item_list.begin();
end = item_list.end(); end = item_list.end();
mouse_pos = ev->getPos(); mouse_pos = ev->getPos();
mouse_pos -= FPoint(getRightPadding(),getTopPadding()); mouse_pos -= FPoint(getRightPadding(), getTopPadding());
if ( getTermGeometry().contains(ev->getTermPos()) ) if ( getTermGeometry().contains(ev->getTermPos()) )
mouse_over_menu = true; mouse_over_menu = true;
@ -794,14 +796,14 @@ void FMenu::init(FWidget* parent)
{ {
if ( isMenuBar(parent) ) if ( isMenuBar(parent) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(parent); FMenuBar* mbar = static_cast<FMenuBar*>(parent);
if ( mbar ) if ( mbar )
mbar->calculateDimensions(); mbar->calculateDimensions();
} }
else if ( isMenu(parent) ) else if ( isMenu(parent) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(parent); FMenu* smenu = static_cast<FMenu*>(parent);
if ( smenu ) if ( smenu )
smenu->calculateDimensions(); smenu->calculateDimensions();
@ -994,11 +996,11 @@ bool FMenu::containsMenuStructure (int x, int y)
// Check mouse click position for item, menu and all sub menus // Check mouse click position for item, menu and all sub menus
FMenuItem* si = getSelectedItem(); FMenuItem* si = getSelectedItem();
if ( getTermGeometry().contains(x,y) ) if ( getTermGeometry().contains(x, y) )
return true; return true;
else if ( si && si->hasMenu() && open_sub_menu ) else if ( si && si->hasMenu() && open_sub_menu )
return si->getMenu()->containsMenuStructure(x,y); return si->getMenu()->containsMenuStructure(x, y);
else if ( item && item->getTermGeometry().contains(x,y) ) else if ( item && item->getTermGeometry().contains(x, y) )
return true; return true;
else else
return false; return false;
@ -1008,21 +1010,21 @@ bool FMenu::containsMenuStructure (int x, int y)
FMenu* FMenu::superMenuAt (int x, int y) FMenu* FMenu::superMenuAt (int x, int y)
{ {
// Check mouse click position for super menu // Check mouse click position for super menu
if ( getTermGeometry().contains(x,y) ) if ( getTermGeometry().contains(x, y) )
return 0; return 0;
FWidget* super = getSuperMenu(); FWidget* super = getSuperMenu();
if ( super && isMenu(super) ) if ( super && isMenu(super) )
{ {
if ( super->getTermGeometry().contains(x,y) ) if ( super->getTermGeometry().contains(x, y) )
return dynamic_cast<FMenu*>(super); return static_cast<FMenu*>(super);
else else
{ {
FMenu* smenu = dynamic_cast<FMenu*>(getSuperMenu()); FMenu* smenu = static_cast<FMenu*>(getSuperMenu());
if ( smenu ) if ( smenu )
return smenu->superMenuAt(x,y); return smenu->superMenuAt(x, y);
} }
} }

View File

@ -1,6 +1,8 @@
// File: fmenubar.cpp // File: fmenubar.cpp
// Provides: class FMenuBar // Provides: class FMenuBar
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fmenubar.h" #include "fmenubar.h"
#include "fstatusbar.h" #include "fstatusbar.h"
@ -20,7 +22,7 @@ FMenuBar::FMenuBar(FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMenuBar::~FMenuBar() FMenuBar::~FMenuBar() // destructor
{ {
setMenuBar(0); setMenuBar(0);
} }
@ -428,7 +430,8 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
} }
} }
} }

View File

@ -136,14 +136,14 @@ bool FMenuItem::setFocus (bool on)
if ( isMenuBar(parent) ) if ( isMenuBar(parent) )
{ {
FMenuBar* menubar_ptr = dynamic_cast<FMenuBar*>(parent); FMenuBar* menubar_ptr = static_cast<FMenuBar*>(parent);
if ( menubar_ptr ) if ( menubar_ptr )
menubar_ptr->redraw(); menubar_ptr->redraw();
} }
else if ( isMenu(parent) ) else if ( isMenu(parent) )
{ {
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent); FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->redraw(); menu_ptr->redraw();
@ -215,7 +215,7 @@ void FMenuItem::addAccelerator (int key, FWidget* obj)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* menu_ptr = dynamic_cast<FMenu*>(super_menu); FMenu* menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->calculateDimensions(); menu_ptr->calculateDimensions();
@ -248,7 +248,7 @@ void FMenuItem::delAccelerator (FWidget* obj)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* menu_ptr = dynamic_cast<FMenu*>(super_menu); FMenu* menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->calculateDimensions(); menu_ptr->calculateDimensions();
@ -297,7 +297,7 @@ void FMenuItem::onKeyPress (FKeyEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu ) if ( smenu )
smenu->onKeyPress(ev); smenu->onKeyPress(ev);
@ -305,7 +305,7 @@ void FMenuItem::onKeyPress (FKeyEvent* ev)
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
@ -328,7 +328,7 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu ) if ( smenu )
{ {
@ -336,20 +336,22 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent ( fc::MouseDoubleClick_Event
, p2, t, b );
smenu->onMouseDoubleClick(_ev); smenu->onMouseDoubleClick(_ev);
delete _ev; delete _ev;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
} }
} }
} }
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
@ -357,20 +359,22 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent ( fc::MouseDoubleClick_Event
, p2, t, b );
mbar->onMouseDoubleClick(_ev); mbar->onMouseDoubleClick(_ev);
delete _ev; delete _ev;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
} }
} }
} }
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl ) if ( dgl )
{ {
@ -378,13 +382,15 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent ( fc::MouseDoubleClick_Event
, p2, t, b );
dgl->onMouseDoubleClick(_ev); dgl->onMouseDoubleClick(_ev);
delete _ev; delete _ev;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
} }
} }
} }
@ -401,7 +407,7 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu ) if ( smenu )
{ {
@ -409,20 +415,22 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent ( fc::MouseDown_Event
, p2, t, b );
smenu->onMouseDown(_ev); smenu->onMouseDown(_ev);
delete _ev; delete _ev;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
} }
} }
} }
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
@ -430,20 +438,22 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent ( fc::MouseDown_Event
, p2, t, b );
mbar->onMouseDown(_ev); mbar->onMouseDown(_ev);
delete _ev; delete _ev;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
} }
} }
} }
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl ) if ( dgl )
{ {
@ -451,13 +461,15 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent ( fc::MouseDown_Event
, p2, t, b );
dgl->onMouseDown(_ev); dgl->onMouseDown(_ev);
delete _ev; delete _ev;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
} }
} }
} }
@ -474,7 +486,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu ) if ( smenu )
{ {
@ -487,7 +499,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
@ -500,7 +512,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl ) if ( dgl )
{ {
@ -523,7 +535,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu ) if ( smenu )
{ {
@ -536,7 +548,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
@ -549,7 +561,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl ) if ( dgl )
{ {
@ -573,7 +585,7 @@ void FMenuItem::onAccel (FAccelEvent* ev)
return; return;
} }
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( ! mbar ) if ( ! mbar )
return; return;
@ -639,7 +651,7 @@ void FMenuItem::onFocusOut (FFocusEvent*)
if ( super_menu && isMenuBar(super_menu) ) if ( super_menu && isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
mbar->redraw(); mbar->redraw();
@ -705,14 +717,15 @@ void FMenuItem::init (FWidget* parent)
if ( isMenuBar(parent) ) // Parent is menubar if ( isMenuBar(parent) ) // Parent is menubar
{ {
FMenuBar* menubar_ptr = dynamic_cast<FMenuBar*>(parent); FMenuBar* menubar_ptr = static_cast<FMenuBar*>(parent);
if ( menubar_ptr ) if ( menubar_ptr )
{ {
menubar_ptr->calculateDimensions(); menubar_ptr->calculateDimensions();
if ( hotkey ) // Meta + hotkey if ( hotkey ) // Meta + hotkey
menubar_ptr->addAccelerator (fc::Fmkey_meta + std::tolower(hotkey), this); menubar_ptr->addAccelerator ( fc::Fmkey_meta + std::tolower(hotkey)
, this );
} }
this->addCallback this->addCallback
@ -723,7 +736,7 @@ void FMenuItem::init (FWidget* parent)
} }
else if ( isMenu(parent) ) // Parent is menu else if ( isMenu(parent) ) // Parent is menu
{ {
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent); FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->calculateDimensions(); menu_ptr->calculateDimensions();
@ -781,7 +794,7 @@ void FMenuItem::createDialogList (FMenu* winmenu)
while ( iter != dialog_list->end() && *iter ) while ( iter != dialog_list->end() && *iter )
{ {
FDialog* win = dynamic_cast<FDialog*>(*iter); FDialog* win = static_cast<FDialog*>(*iter);
if ( win ) if ( win )
{ {
@ -797,7 +810,8 @@ void FMenuItem::createDialogList (FMenu* winmenu)
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
return; return;
} }
@ -808,7 +822,7 @@ void FMenuItem::createDialogList (FMenu* winmenu)
( (
"clicked", "clicked",
F_METHOD_CALLBACK (win_item, &FMenuItem::cb_switchToDialog), F_METHOD_CALLBACK (win_item, &FMenuItem::cb_switchToDialog),
dynamic_cast<FWidget::data_ptr>(win) static_cast<FWidget::data_ptr>(win)
); );
win->addCallback win->addCallback

View File

@ -1,6 +1,8 @@
// File: fmenulist.cpp // File: fmenulist.cpp
// Provides: class FMenuList // Provides: class FMenuList
#include <vector>
#include "fmenulist.h" #include "fmenulist.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -19,6 +19,8 @@
#ifndef FMENULIST_H #ifndef FMENULIST_H
#define FMENULIST_H #define FMENULIST_H
#include <vector>
#include "fmenuitem.h" #include "fmenuitem.h"
#include "fwidget.h" #include "fwidget.h"

View File

@ -1,6 +1,8 @@
// File: fmessagebox.cpp // File: fmessagebox.cpp
// Provides: class FMessageBox // Provides: class FMessageBox
#include <algorithm>
#include "fapplication.h" #include "fapplication.h"
#include "fmessagebox.h" #include "fmessagebox.h"
@ -426,7 +428,8 @@ void FMessageBox::draw()
int head_offset = 0; int head_offset = 0;
int center_x = 0; int center_x = 0;
int msg_x = int((getWidth() - int(max_line_width)) / 2); // center the whole block // center the whole block
int msg_x = int((getWidth() - int(max_line_width)) / 2);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);

View File

@ -27,7 +27,6 @@ FObject::FObject (FObject* parent)
if ( parent == 0 ) if ( parent == 0 )
{ {
timer_modify_lock = false; timer_modify_lock = false;
if ( ! timer_list ) if ( ! timer_list )
@ -95,8 +94,6 @@ FObject::~FObject() // destructor
++iter; ++iter;
} }
} }
} }
// public methods of FObject // public methods of FObject
@ -159,27 +156,27 @@ void FObject::delChild (FObject* obj)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FObject::getCurrentTime (timeval &time) void FObject::getCurrentTime (timeval* time)
{ {
gettimeofday(&time, 0); gettimeofday(time, 0);
// NTP fix // NTP fix
while ( time.tv_usec >= 1000000 ) while ( time->tv_usec >= 1000000 )
{ {
time.tv_usec -= 1000000; time->tv_usec -= 1000000;
time.tv_sec++; time->tv_sec++;
} }
while ( time.tv_usec < 0 ) while ( time->tv_usec < 0 )
{ {
if ( time.tv_sec > 0 ) if ( time->tv_sec > 0 )
{ {
time.tv_usec += 1000000; time->tv_usec += 1000000;
time.tv_sec--; time->tv_sec--;
} }
else else
{ {
time.tv_usec = 0; time->tv_usec = 0;
break; break;
} }
} }
@ -232,7 +229,7 @@ int FObject::addTimer (int interval)
time_interval.tv_sec = interval / 1000; time_interval.tv_sec = interval / 1000;
time_interval.tv_usec = (interval % 1000) * 1000; time_interval.tv_usec = (interval % 1000) * 1000;
getCurrentTime (currentTime); getCurrentTime (&currentTime);
timeval timeout = currentTime + time_interval; timeval timeout = currentTime + time_interval;
timer_data t = { id, time_interval, timeout, this }; timer_data t = { id, time_interval, timeout, this };

View File

@ -22,24 +22,6 @@
#include "fevent.h" #include "fevent.h"
#include "ftypes.h" #include "ftypes.h"
#define null NULL
typedef unsigned char uChar;
typedef unsigned int uInt;
typedef unsigned long uLong;
typedef uint8_t uInt8;
typedef uint16_t uInt16;
typedef uint32_t uInt32;
typedef uint64_t uInt64;
typedef signed int sInt;
typedef signed long sLong;
typedef int8_t sInt8;
typedef int16_t sInt16;
typedef int32_t sInt32;
typedef int64_t sInt64;
typedef long double lDouble;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FObject // class FObject
@ -82,7 +64,7 @@ class FObject
void delChild (FObject*); void delChild (FObject*);
// Timer methods // Timer methods
static void getCurrentTime (timeval&); static void getCurrentTime (timeval*);
int addTimer (int); int addTimer (int);
bool delTimer (int); bool delTimer (int);
bool delOwnTimer(); bool delOwnTimer();

View File

@ -11,11 +11,11 @@
#ifndef FOPTIATTR_H #ifndef FOPTIATTR_H
#define FOPTIATTR_H #define FOPTIATTR_H
#include <algorithm> // need for std::swap
#include <assert.h> #include <assert.h>
#include <term.h> // need for tparm #include <term.h> // need for tparm
#include <algorithm> // need for std::swap
#include "fc.h" #include "fc.h"
@ -68,7 +68,6 @@ class FOptiAttr
uChar byte2; uChar byte2;
uChar byte3; uChar byte3;
} attr; } attr;
} char_data; } char_data;
// Constructor // Constructor
@ -82,7 +81,7 @@ class FOptiAttr
friend bool operator != (const char_data&, const char_data&); friend bool operator != (const char_data&, const char_data&);
// Mutators // Mutators
void setMaxColor (int&); void setMaxColor (const int&);
void setNoColorVideo (int); void setNoColorVideo (int);
void setDefaultColorSupport(); void setDefaultColorSupport();
void setCygwinTerminal(); void setCygwinTerminal();
@ -288,7 +287,7 @@ inline bool operator != ( const FOptiAttr::char_data& lhs,
{ return ! ( lhs == rhs ); } { return ! ( lhs == rhs ); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiAttr::setMaxColor (int& c) inline void FOptiAttr::setMaxColor (const int& c)
{ max_color = c; } { max_color = c; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -1,8 +1,10 @@
// File: foptimove.cpp // File: foptimove.cpp
// Provides: class FOptiMove // Provides: class FOptiMove
#include <cstring>
#include "foptimove.h" #include "foptimove.h"
#include "string.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FOptiMove // class FOptiMove
@ -620,24 +622,42 @@ char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::printDurations() void FOptiMove::printDurations()
{ {
std::cout << " speed: " << baudrate << " baud\r\n"; std::cout << " speed: "
std::cout << " char_duration: " << char_duration << " ms\r\n"; << baudrate << " baud\r\n";
std::cout << " cursor_home: " << F_cursor_home.duration << " ms\r\n"; std::cout << " char_duration: "
std::cout << " cursor_to_ll: " << F_cursor_to_ll.duration << " ms\r\n"; << char_duration << " ms\r\n";
std::cout << " carriage_return: " << F_carriage_return.duration << " ms\r\n"; std::cout << " cursor_home: "
std::cout << " tab: " << F_tab.duration << " ms\r\n"; << F_cursor_home.duration << " ms\r\n";
std::cout << " back_tab: " << F_back_tab.duration << " ms\r\n"; std::cout << " cursor_to_ll: "
std::cout << " cursor_up: " << F_cursor_up.duration << " ms\r\n"; << F_cursor_to_ll.duration << " ms\r\n";
std::cout << " cursor_down: " << F_cursor_down.duration << " ms\r\n"; std::cout << " carriage_return: "
std::cout << " cursor_left: " << F_cursor_left.duration << " ms\r\n"; << F_carriage_return.duration << " ms\r\n";
std::cout << " cursor_right: " << F_cursor_right.duration << " ms\r\n"; std::cout << " tab: "
std::cout << " cursor_address: " << F_cursor_address.duration << " ms\r\n"; << F_tab.duration << " ms\r\n";
std::cout << " column_address: " << F_column_address.duration << " ms\r\n"; std::cout << " back_tab: "
std::cout << " row_address: " << F_row_address.duration << " ms\r\n"; << F_back_tab.duration << " ms\r\n";
std::cout << " parm_up_cursor: " << F_parm_up_cursor.duration << " ms\r\n"; std::cout << " cursor_up: "
std::cout << " parm_down_cursor: " << F_parm_down_cursor.duration << " ms\r\n"; << F_cursor_up.duration << " ms\r\n";
std::cout << " parm_left_cursor: " << F_parm_left_cursor.duration << " ms\r\n"; std::cout << " cursor_down: "
std::cout << "parm_right_cursor: " << F_parm_right_cursor.duration << " ms\r\n"; << F_cursor_down.duration << " ms\r\n";
std::cout << " cursor_left: "
<< F_cursor_left.duration << " ms\r\n";
std::cout << " cursor_right: "
<< F_cursor_right.duration << " ms\r\n";
std::cout << " cursor_address: "
<< F_cursor_address.duration << " ms\r\n";
std::cout << " column_address: "
<< F_column_address.duration << " ms\r\n";
std::cout << " row_address: "
<< F_row_address.duration << " ms\r\n";
std::cout << " parm_up_cursor: "
<< F_parm_up_cursor.duration << " ms\r\n";
std::cout << " parm_down_cursor: "
<< F_parm_down_cursor.duration << " ms\r\n";
std::cout << " parm_left_cursor: "
<< F_parm_left_cursor.duration << " ms\r\n";
std::cout << "parm_right_cursor: "
<< F_parm_right_cursor.duration << " ms\r\n";
} }
@ -707,7 +727,7 @@ int FOptiMove::capDurationToLength (int duration)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FOptiMove::repeatedAppend (capability& o, int count, char* dst) int FOptiMove::repeatedAppend (const capability& o, int count, char* dst)
{ {
register std::size_t src_len; register std::size_t src_len;
register std::size_t dst_len; register std::size_t dst_len;
@ -874,7 +894,6 @@ int FOptiMove::relativeMove ( char*& move
std::strncpy (hmove, str, sizeof(move_buf) - 1); std::strncpy (hmove, str, sizeof(move_buf) - 1);
htime = htime_r; htime = htime_r;
} }
} }
} }
else // to_x < from_x else // to_x < from_x
@ -924,7 +943,6 @@ int FOptiMove::relativeMove ( char*& move
std::strncpy (hmove, str, sizeof(move_buf) - 1); std::strncpy (hmove, str, sizeof(move_buf) - 1);
htime = htime_l; htime = htime_l;
} }
} }
} }
@ -947,7 +965,8 @@ int FOptiMove::relativeMove ( char*& move
inline bool FOptiMove::isWideMove ( int xold, int yold inline bool FOptiMove::isWideMove ( int xold, int yold
, int xnew, int ynew ) , int xnew, int ynew )
{ {
return bool ( (xnew > MOVE_LIMIT) return bool ( xnew > MOVE_LIMIT
&& (xnew < screen_width - 1 - MOVE_LIMIT) && xnew < screen_width - 1 - MOVE_LIMIT
&& (std::abs(xnew - xold) + std::abs(ynew - yold) > MOVE_LIMIT) ); && std::abs(xnew - xold) + std::abs(ynew - yold)
> MOVE_LIMIT );
} }

View File

@ -65,8 +65,8 @@ class FOptiMove
int set_repeat_char (char*&); int set_repeat_char (char*&);
int set_clr_bol (char*&); int set_clr_bol (char*&);
int set_clr_eol (char*&); int set_clr_eol (char*&);
void set_auto_left_margin (bool&); void set_auto_left_margin (const bool&);
void set_eat_newline_glitch (bool&); void set_eat_newline_glitch (const bool&);
// Methods // Methods
char* moveCursor (int, int, int, int); char* moveCursor (int, int, int, int);
@ -94,7 +94,7 @@ class FOptiMove
void calculateCharDuration(); void calculateCharDuration();
int capDuration (char*&, int); int capDuration (char*&, int);
int capDurationToLength (int); int capDurationToLength (int);
int repeatedAppend (capability&, int, char*); int repeatedAppend (const capability&, int, char*);
int relativeMove (char*&, int, int, int, int); int relativeMove (char*&, int, int, int, int);
bool isWideMove (int, int, int, int); bool isWideMove (int, int, int, int);
@ -135,11 +135,11 @@ class FOptiMove
// FOptiMove inline functions // FOptiMove inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiMove::set_auto_left_margin (bool& bcap) inline void FOptiMove::set_auto_left_margin (const bool& bcap)
{ automatic_left_margin = bcap; } { automatic_left_margin = bcap; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiMove::set_eat_newline_glitch (bool& bcap) inline void FOptiMove::set_eat_newline_glitch (const bool& bcap)
{ eat_nl_glitch = bcap; } { eat_nl_glitch = bcap; }
#endif // FOPTIMOVE_H #endif // FOPTIMOVE_H

View File

@ -19,7 +19,7 @@ FProgressbar::FProgressbar(FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FProgressbar::~FProgressbar() FProgressbar::~FProgressbar() // destructor
{ } { }

View File

@ -40,7 +40,7 @@ void FRadioMenuItem::init (FWidget* parent)
if ( isMenu(parent) ) // Parent is menu if ( isMenu(parent) ) // Parent is menu
{ {
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent); FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->has_checkable_items = true; menu_ptr->has_checkable_items = true;

View File

@ -1,6 +1,8 @@
// File: frect.cpp // File: frect.cpp
// Provides: class FRect // Provides: class FRect
#include <algorithm>
#include "frect.h" #include "frect.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -20,6 +22,7 @@ FRect::FRect (const FPoint& p1, const FPoint& p2)
FRect::~FRect() // destructor FRect::~FRect() // destructor
{ } { }
// public methods of FRect // public methods of FRect
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FRect::isNull() const bool FRect::isNull() const

View File

@ -159,23 +159,23 @@ inline int FRect::getY() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FPoint FRect::getPos() const inline FPoint FRect::getPos() const
{ return FPoint(X1,Y1); } { return FPoint(X1, Y1); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FPoint FRect::getUpperLeftPos() const inline FPoint FRect::getUpperLeftPos() const
{ return FPoint(X1,Y1); } { return FPoint(X1, Y1); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FPoint FRect::getUpperRightPos() const inline FPoint FRect::getUpperRightPos() const
{ return FPoint(X2,Y1); } { return FPoint(X2, Y1); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FPoint FRect::getLowerLeftPos() const inline FPoint FRect::getLowerLeftPos() const
{ return FPoint(X1,Y2); } { return FPoint(X1, Y2); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FPoint FRect::getLowerRightPos() const inline FPoint FRect::getLowerRightPos() const
{ return FPoint(X2,Y2); } { return FPoint(X2, Y2); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline int FRect::getWidth() const inline int FRect::getWidth() const

View File

@ -1,6 +1,8 @@
// File: fscrollbar.cpp // File: fscrollbar.cpp
// Provides: class FScrollbar // Provides: class FScrollbar
#include <algorithm>
#include "fscrollbar.h" #include "fscrollbar.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -62,7 +64,7 @@ FScrollbar::FScrollbar(int o, FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FScrollbar::~FScrollbar() FScrollbar::~FScrollbar() // destructor
{ {
delOwnTimer(); delOwnTimer();
} }

View File

@ -13,7 +13,7 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FScrollView::FScrollView (FWidget* parent) FScrollView::FScrollView (FWidget* parent)
: FWidget(parent) : FWidget(parent)
, scroll_geometry(1,1,1,1) , scroll_geometry(1, 1, 1, 1)
, viewport_geometry() , viewport_geometry()
, viewport(0) , viewport(0)
, vbar(0) , vbar(0)
@ -96,6 +96,8 @@ void FScrollView::setScrollHeight (int height)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setScrollSize (int width, int height) void FScrollView::setScrollSize (int width, int height)
{ {
int xoffset_end, yoffset_end;
if ( width < getViewportWidth() ) if ( width < getViewportWidth() )
width = getViewportWidth(); width = getViewportWidth();
@ -117,10 +119,12 @@ void FScrollView::setScrollSize (int width, int height)
child_print_area = viewport; child_print_area = viewport;
} }
xoffset_end = getScrollWidth() - getViewportWidth();
yoffset_end = getScrollHeight() - getViewportHeight();
setTopPadding (1 - getScrollY()); setTopPadding (1 - getScrollY());
setLeftPadding (1 - getScrollX()); setLeftPadding (1 - getScrollX());
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - getScrollY())); setBottomPadding (1 - (yoffset_end - getScrollY()));
setRightPadding (1 - (getScrollWidth() - getViewportWidth() - getScrollX()) + nf_offset); setRightPadding (1 - (xoffset_end - getScrollX()) + nf_offset);
hbar->setMaximum (width - getViewportWidth()); hbar->setMaximum (width - getViewportWidth());
hbar->setPageSize (width, getViewportWidth()); hbar->setPageSize (width, getViewportWidth());
@ -335,8 +339,8 @@ void FScrollView::scrollTo (int x, int y)
viewport->has_changes = true; viewport->has_changes = true;
setTopPadding (1 - yoffset); setTopPadding (1 - yoffset);
setLeftPadding (1 - xoffset); setLeftPadding (1 - xoffset);
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - yoffset)); setBottomPadding (1 - (yoffset_end - yoffset));
setRightPadding (1 - (getScrollWidth() - getViewportWidth() - xoffset) + nf_offset); setRightPadding (1 - (xoffset_end - xoffset) + nf_offset);
copy2area(); copy2area();
hbar->setValue (xoffset); hbar->setValue (xoffset);
vbar->setValue (yoffset); vbar->setValue (yoffset);
@ -468,8 +472,8 @@ void FScrollView::onKeyPress (FKeyEvent* ev)
viewport->has_changes = true; viewport->has_changes = true;
setTopPadding (1 - yoffset); setTopPadding (1 - yoffset);
setLeftPadding (1 - xoffset); setLeftPadding (1 - xoffset);
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - yoffset)); setBottomPadding (1 - (yoffset_end - yoffset));
setRightPadding (1 - (getScrollWidth() - getViewportWidth() - xoffset) + nf_offset); setRightPadding (1 - (xoffset_end - xoffset) + nf_offset);
copy2area(); copy2area();
hasChanges = true; hasChanges = true;
vbar->setValue (yoffset); vbar->setValue (yoffset);
@ -489,6 +493,7 @@ void FScrollView::onWheel (FWheelEvent* ev)
bool hasChanges = false; bool hasChanges = false;
short& yoffset = viewport_geometry.y1_ref(); short& yoffset = viewport_geometry.y1_ref();
short yoffset_before = yoffset; short yoffset_before = yoffset;
short yoffset_end = short(getScrollHeight() - getViewportHeight());
int save_height = viewport_geometry.getHeight(); int save_height = viewport_geometry.getHeight();
int wheel = ev->getWheel(); int wheel = ev->getWheel();
@ -507,8 +512,6 @@ void FScrollView::onWheel (FWheelEvent* ev)
case fc::WheelDown: case fc::WheelDown:
{ {
short yoffset_end = short(getScrollHeight() - getViewportHeight());
if ( yoffset_end < 0 ) if ( yoffset_end < 0 )
yoffset_end = 0; yoffset_end = 0;
@ -531,7 +534,7 @@ void FScrollView::onWheel (FWheelEvent* ev)
viewport_geometry.setHeight(save_height); viewport_geometry.setHeight(save_height);
viewport->has_changes = true; viewport->has_changes = true;
setTopPadding (1 - yoffset); setTopPadding (1 - yoffset);
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - yoffset)); setBottomPadding (1 - (yoffset_end - yoffset));
copy2area(); copy2area();
hasChanges = true; hasChanges = true;
vbar->setValue (yoffset); vbar->setValue (yoffset);
@ -756,6 +759,8 @@ inline FPoint FScrollView::getViewportCursorPos()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::init (FWidget* parent) void FScrollView::init (FWidget* parent)
{ {
int xoffset_end, yoffset_end;
assert ( parent != 0 ); assert ( parent != 0 );
assert ( ! parent->isInstanceOf("FScrollView") ); assert ( ! parent->isInstanceOf("FScrollView") );
@ -792,11 +797,13 @@ void FScrollView::init (FWidget* parent)
F_METHOD_CALLBACK (this, &FScrollView::cb_HBarChange) F_METHOD_CALLBACK (this, &FScrollView::cb_HBarChange)
); );
xoffset_end = getScrollWidth() - getViewportWidth();
yoffset_end = getScrollHeight() - getViewportHeight();
nf_offset = isNewFont() ? 1 : 0; nf_offset = isNewFont() ? 1 : 0;
setTopPadding (1 - getScrollY()); setTopPadding (1 - getScrollY());
setLeftPadding (1 - getScrollX()); setLeftPadding (1 - getScrollX());
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - getScrollY())); setBottomPadding (1 - (yoffset_end - getScrollY()));
setRightPadding (1 - (getScrollWidth() - getViewportWidth() - getScrollX()) + nf_offset); setRightPadding (1 - (xoffset_end - getScrollX()) + nf_offset);
FPoint no_shadow(0,0); FPoint no_shadow(0,0);
int w = getViewportWidth(); int w = getViewportWidth();
@ -991,7 +998,7 @@ void FScrollView::cb_VBarChange (FWidget*, data_ptr)
viewport_geometry.setHeight(save_height); viewport_geometry.setHeight(save_height);
viewport->has_changes = true; viewport->has_changes = true;
setTopPadding (1 - yoffset); setTopPadding (1 - yoffset);
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - yoffset)); setBottomPadding (1 - (yoffset_end - yoffset));
copy2area(); copy2area();
hasChanges = true; hasChanges = true;
} }
@ -1096,7 +1103,7 @@ void FScrollView::cb_HBarChange (FWidget*, data_ptr)
viewport_geometry.setWidth(save_width); viewport_geometry.setWidth(save_width);
viewport->has_changes = true; viewport->has_changes = true;
setLeftPadding (1 - xoffset); setLeftPadding (1 - xoffset);
setRightPadding (1 - (getScrollWidth() - getViewportWidth() - xoffset) + nf_offset); setRightPadding (1 - (xoffset_end - xoffset) + nf_offset);
copy2area(); copy2area();
hasChanges = true; hasChanges = true;
} }

View File

@ -2,6 +2,8 @@
// Provides: class FStatusKey // Provides: class FStatusKey
// class FStatusBar // class FStatusBar
#include <vector>
#include "fstatusbar.h" #include "fstatusbar.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -84,7 +86,7 @@ bool FStatusKey::setMouseFocus(bool on)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusKey::init (FWidget* parent) void FStatusKey::init (FWidget* parent)
{ {
setGeometry (1,1,1,1); setGeometry (1, 1, 1, 1);
if ( parent && parent->isInstanceOf("FStatusBar") ) if ( parent && parent->isInstanceOf("FStatusBar") )
{ {
@ -120,7 +122,7 @@ FStatusBar::FStatusBar(FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FStatusBar::~FStatusBar() FStatusBar::~FStatusBar() // destructor
{ {
// delete all keys // delete all keys
if ( ! key_list.empty() ) if ( ! key_list.empty() )

View File

@ -36,6 +36,8 @@
#ifndef FSTATUSBAR_H #ifndef FSTATUSBAR_H
#define FSTATUSBAR_H #define FSTATUSBAR_H
#include <vector>
#include "fwindow.h" #include "fwindow.h"

View File

@ -1,6 +1,9 @@
// File: fstring.cpp // File: fstring.cpp
// Provides: class FString // Provides: class FString
#include <string>
#include <vector>
#include "fstring.h" #include "fstring.h"
// static class constant // static class constant
@ -500,12 +503,12 @@ uInt FString::getUTF8length() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString& FString::sprintf (const wchar_t* format, ...) FString& FString::sprintf (const wchar_t* format, ...)
{ {
static const int buf_size = 4096; static const int BUFSIZE = 4096;
wchar_t buffer[buf_size]; wchar_t buffer[BUFSIZE];
va_list args; va_list args;
va_start (args, format); va_start (args, format);
std::vswprintf (buffer, buf_size, format, args); std::vswprintf (buffer, BUFSIZE, format, args);
va_end (args); va_end (args);
_assign (buffer); _assign (buffer);
@ -578,7 +581,7 @@ const wchar_t* FString::wc_str() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const char* FString::c_str() const const char* FString::c_str() const
{ {
if ( string ) if ( length > 0 )
return wc_to_c_str (string); return wc_to_c_str (string);
else else
return 0; return 0;
@ -1155,7 +1158,6 @@ FString& FString::setFormatedNumber (uLong num, char separator)
if ( num && ++n % 3 == 0 ) if ( num && ++n % 3 == 0 )
*--s = separator; *--s = separator;
} }
while ( num ); while ( num );

View File

@ -168,11 +168,11 @@ class FString
FString& sprintf (const wchar_t*, ...); FString& sprintf (const wchar_t*, ...);
FString& sprintf (const char*, ...) FString& sprintf (const char*, ...)
#if defined(__clang__) #if defined(__clang__)
__attribute__((__format__ (__printf__, 2, 3))) __attribute__((__format__ (__printf__, 2, 3)))
#elif defined(__GNUC__) #elif defined(__GNUC__)
__attribute__ ((format (printf, 2, 3))) __attribute__ ((format (printf, 2, 3)))
#endif #endif
; ;
FString clear(); FString clear();
@ -204,7 +204,7 @@ class FString
FString mid (uInt, uInt) const; FString mid (uInt, uInt) const;
std::vector<FString> split (const FString&); std::vector<FString> split (const FString&);
std::vector<FString> split (std::wstring&); std::vector<FString> split (const std::wstring&);
std::vector<FString> split (const wchar_t*); std::vector<FString> split (const wchar_t*);
std::vector<FString> split (const std::string&); std::vector<FString> split (const std::string&);
std::vector<FString> split (const char*); std::vector<FString> split (const char*);
@ -363,7 +363,7 @@ inline wchar_t FString::back() const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::vector<FString> FString::split (std::wstring& s) inline std::vector<FString> FString::split (const std::wstring& s)
{ return split(FString(s)); } { return split(FString(s)); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -1,6 +1,11 @@
// File: fterm.cpp // File: fterm.cpp
// Provides: class FTerm // Provides: class FTerm
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include "fterm.h" #include "fterm.h"
#include "fcharmap.h" #include "fcharmap.h"
#include "fkey_map.h" #include "fkey_map.h"
@ -74,15 +79,15 @@ bool FTerm::cursor_optimisation;
bool FTerm::xterm_default_colors; bool FTerm::xterm_default_colors;
bool FTerm::use_alternate_screen = true; bool FTerm::use_alternate_screen = true;
termios FTerm::term_init; termios FTerm::term_init;
char FTerm::termtype[30] = ""; char FTerm::termtype[256] = {};
char FTerm::term_name[256] = {};
#if DEBUG #if DEBUG
char FTerm::termtype_256color[30] = ""; char FTerm::termtype_256color[256] = {};
char FTerm::termtype_Answerback[30] = ""; char FTerm::termtype_Answerback[256] = {};
char FTerm::termtype_SecDA[30] = ""; char FTerm::termtype_SecDA[256] = {};
#endif #endif
char* FTerm::term_name = 0;
char* FTerm::locale_name = 0; char* FTerm::locale_name = 0;
char* FTerm::locale_xterm = 0; char* FTerm::locale_xterm = 0;
FPoint* FTerm::mouse = 0; FPoint* FTerm::mouse = 0;
@ -249,7 +254,7 @@ bool FTerm::isKeyTimeout (timeval* time, register long timeout)
struct timeval now; struct timeval now;
struct timeval diff; struct timeval diff;
FObject::getCurrentTime(now); FObject::getCurrentTime(&now);
diff.tv_sec = now.tv_sec - time->tv_sec; diff.tv_sec = now.tv_sec - time->tv_sec;
diff.tv_usec = now.tv_usec - time->tv_usec; diff.tv_usec = now.tv_usec - time->tv_usec;
@ -309,7 +314,7 @@ void FTerm::setFreeBSDConsoleCursorStyle ( fc::freebsdConsoleCursorStyle style
#endif #endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::setTTY (termios& t) void FTerm::setTTY (const termios& t)
{ {
tcsetattr (stdin_no, TCSADRAIN, &t); tcsetattr (stdin_no, TCSADRAIN, &t);
} }
@ -758,7 +763,6 @@ bool FTerm::setOldFont()
setUnicodeMap (&screen_unicode_map); setUnicodeMap (&screen_unicode_map);
delete[] screen_unicode_map.entries; delete[] screen_unicode_map.entries;
} }
} }
detectTermSize(); detectTermSize();
@ -777,7 +781,7 @@ char* FTerm::moveCursor (int xold, int yold, int xnew, int ynew)
if ( cursor_optimisation ) if ( cursor_optimisation )
return opti_move->moveCursor (xold, yold, xnew, ynew); return opti_move->moveCursor (xold, yold, xnew, ynew);
else else
return tgoto(tcap[fc::t_cursor_address].string, xnew, ynew); return tgoto(TCAP(fc::t_cursor_address), xnew, ynew);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -789,8 +793,8 @@ void FTerm::printMoveDurations()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
char* FTerm::enableCursor() char* FTerm::enableCursor()
{ {
char*& vs = tcap[fc::t_cursor_visible].string; char*& vs = TCAP(fc::t_cursor_visible);
char*& ve = tcap[fc::t_cursor_normal].string; char*& ve = TCAP(fc::t_cursor_normal);
if ( ve ) if ( ve )
return ve; return ve;
@ -803,7 +807,7 @@ char* FTerm::enableCursor()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
char* FTerm::disableCursor() char* FTerm::disableCursor()
{ {
char*& vi = tcap[fc::t_cursor_invisible].string; char*& vi = TCAP(fc::t_cursor_invisible);
if ( vi ) if ( vi )
return vi; return vi;
@ -1277,8 +1281,8 @@ void FTerm::saveColorMap()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::resetColorMap() void FTerm::resetColorMap()
{ {
char*& op = tcap[fc::t_orig_pair].string; char*& op = TCAP(fc::t_orig_pair);
char*& oc = tcap[fc::t_orig_colors].string; char*& oc = TCAP(fc::t_orig_colors);
if ( op ) if ( op )
putstring (op); putstring (op);
@ -1312,8 +1316,8 @@ void FTerm::resetColorMap()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::setPalette (short index, int r, int g, int b) void FTerm::setPalette (short index, int r, int g, int b)
{ {
char*& Ic = tcap[fc::t_initialize_color].string; char*& Ic = TCAP(fc::t_initialize_color);
char*& Ip = tcap[fc::t_initialize_pair].string; char*& Ip = TCAP(fc::t_initialize_pair);
index = FOptiAttr::vga2ansi(index); index = FOptiAttr::vga2ansi(index);
@ -1386,9 +1390,9 @@ void FTerm::resetBeep()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::beep() void FTerm::beep()
{ {
if ( tcap[fc::t_bell].string ) if ( TCAP(fc::t_bell) )
{ {
putstring (tcap[fc::t_bell].string); putstring (TCAP(fc::t_bell));
std::fflush(stdout); std::fflush(stdout);
} }
} }
@ -1442,9 +1446,8 @@ void FTerm::setEncoding (std::string enc)
opti_move->set_tabular (empty); opti_move->set_tabular (empty);
} }
else else
opti_move->set_tabular (tcap[fc::t_tab].string); opti_move->set_tabular (TCAP(fc::t_tab));
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1463,9 +1466,9 @@ std::string FTerm::getEncoding()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTerm::scrollTermForward() bool FTerm::scrollTermForward()
{ {
if ( tcap[fc::t_scroll_forward].string ) if ( TCAP(fc::t_scroll_forward) )
{ {
putstring (tcap[fc::t_scroll_forward].string); putstring (TCAP(fc::t_scroll_forward));
std::fflush(stdout); std::fflush(stdout);
return true; return true;
} }
@ -1476,9 +1479,9 @@ bool FTerm::scrollTermForward()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTerm::scrollTermReverse() bool FTerm::scrollTermReverse()
{ {
if ( tcap[fc::t_scroll_reverse].string ) if ( TCAP(fc::t_scroll_reverse) )
{ {
putstring (tcap[fc::t_scroll_reverse].string); putstring (TCAP(fc::t_scroll_reverse));
std::fflush(stdout); std::fflush(stdout);
return true; return true;
} }
@ -2051,7 +2054,7 @@ int FTerm::openConsole()
if ( fd_tty >= 0 ) // console is already opened if ( fd_tty >= 0 ) // console is already opened
return 0; return 0;
if ( term_name && (fd_tty = open (term_name, O_RDWR, 0)) < 0) if ( *term_name && (fd_tty = open (term_name, O_RDWR, 0)) < 0)
if ( (fd_tty = open("/proc/self/fd/0", O_RDWR, 0)) < 0) if ( (fd_tty = open("/proc/self/fd/0", O_RDWR, 0)) < 0)
if ( (fd_tty = open("/dev/tty", O_RDWR, 0)) < 0) if ( (fd_tty = open("/dev/tty", O_RDWR, 0)) < 0)
if ( (fd_tty = open("/dev/tty0", O_RDWR, 0)) < 0) if ( (fd_tty = open("/dev/tty0", O_RDWR, 0)) < 0)
@ -2088,7 +2091,7 @@ void FTerm::getSystemTermType()
std::strncpy (termtype, term_env, sizeof(termtype) - 1); std::strncpy (termtype, term_env, sizeof(termtype) - 1);
return; return;
} }
else if ( term_name ) // fallback: look into /etc/ttytype or /etc/ttys else if ( *term_name ) // fallback: look into /etc/ttytype or /etc/ttys
{ {
// get term basename // get term basename
const char* term_basename = std::strrchr(term_name, '/'); const char* term_basename = std::strrchr(term_name, '/');
@ -2890,13 +2893,13 @@ void FTerm::init_alt_charset()
{ {
// read the used vt100 pairs // read the used vt100 pairs
if ( tcap[fc::t_acs_chars].string ) if ( TCAP(fc::t_acs_chars) )
{ {
for (int n = 0; tcap[fc::t_acs_chars].string[n]; n += 2) for (int n = 0; TCAP(fc::t_acs_chars)[n]; n += 2)
{ {
// insert the vt100 key/value pairs into a map // insert the vt100 key/value pairs into a map
uChar p1 = uChar(tcap[fc::t_acs_chars].string[n]); uChar p1 = uChar(TCAP(fc::t_acs_chars)[n]);
uChar p2 = uChar(tcap[fc::t_acs_chars].string[n + 1]); uChar p2 = uChar(TCAP(fc::t_acs_chars)[n + 1]);
(*vt100_alt_char)[p1] = p2; (*vt100_alt_char)[p1] = p2;
} }
} }
@ -2942,42 +2945,44 @@ void FTerm::init_pc_charset()
if ( gnome_terminal || linux_terminal ) if ( gnome_terminal || linux_terminal )
{ {
// fallback if tcap "S2" is not found // fallback if tcap "S2" is not found
if ( ! tcap[fc::t_enter_pc_charset_mode].string ) if ( ! TCAP(fc::t_enter_pc_charset_mode) )
{ {
if ( utf8_console ) if ( utf8_console )
{ {
// Select iso8859-1 + null mapping // Select iso8859-1 + null mapping
tcap[fc::t_enter_pc_charset_mode].string = \ TCAP(fc::t_enter_pc_charset_mode) = \
const_cast<char*>(ESC "%@" ESC "(U"); const_cast<char*>(ESC "%@" ESC "(U");
} }
else else
{ {
// Select null mapping // Select null mapping
tcap[fc::t_enter_pc_charset_mode].string = \ TCAP(fc::t_enter_pc_charset_mode) = \
const_cast<char*>(ESC "(U"); const_cast<char*>(ESC "(U");
} }
opti_attr->set_enter_pc_charset_mode (tcap[fc::t_enter_pc_charset_mode].string); opti_attr->set_enter_pc_charset_mode \
(TCAP(fc::t_enter_pc_charset_mode));
reinit = true; reinit = true;
} }
// fallback if tcap "S3" is not found // fallback if tcap "S3" is not found
if ( ! tcap[fc::t_exit_pc_charset_mode].string ) if ( ! TCAP(fc::t_exit_pc_charset_mode) )
{ {
if ( utf8_console ) if ( utf8_console )
{ {
// Select ascii mapping + utf8 // Select ascii mapping + utf8
tcap[fc::t_exit_pc_charset_mode].string = \ TCAP(fc::t_exit_pc_charset_mode) = \
const_cast<char*>(ESC "(B" ESC "%G"); const_cast<char*>(ESC "(B" ESC "%G");
} }
else else
{ {
// Select ascii mapping // Select ascii mapping
tcap[fc::t_enter_pc_charset_mode].string = \ TCAP(fc::t_enter_pc_charset_mode) = \
const_cast<char*>(ESC "(B"); const_cast<char*>(ESC "(B");
} }
opti_attr->set_exit_pc_charset_mode (tcap[fc::t_exit_pc_charset_mode].string); opti_attr->set_exit_pc_charset_mode \
(TCAP(fc::t_exit_pc_charset_mode));
reinit = true; reinit = true;
} }
} }
@ -3132,32 +3137,32 @@ void FTerm::init_termcaps()
tcap[i].string = tgetstr(tcap[i].tname, &buffer); tcap[i].string = tgetstr(tcap[i].tname, &buffer);
// set invisible cursor for cygwin terminal // set invisible cursor for cygwin terminal
if ( cygwin_terminal && ! tcap[fc::t_cursor_invisible].string ) if ( cygwin_terminal && ! TCAP(fc::t_cursor_invisible) )
tcap[fc::t_cursor_invisible].string = \ TCAP(fc::t_cursor_invisible) = \
const_cast<char*>(CSI "?25l"); const_cast<char*>(CSI "?25l");
// set visible cursor for cygwin terminal // set visible cursor for cygwin terminal
if ( cygwin_terminal && ! tcap[fc::t_cursor_visible].string ) if ( cygwin_terminal && ! TCAP(fc::t_cursor_visible) )
tcap[fc::t_cursor_visible].string = \ TCAP(fc::t_cursor_visible) = \
const_cast<char*>(CSI "?25h"); const_cast<char*>(CSI "?25h");
// set ansi blink for cygwin terminal // set ansi blink for cygwin terminal
if ( cygwin_terminal && ! tcap[fc::t_enter_blink_mode].string ) if ( cygwin_terminal && ! TCAP(fc::t_enter_blink_mode) )
tcap[fc::t_enter_blink_mode].string = \ TCAP(fc::t_enter_blink_mode) = \
const_cast<char*>(CSI "5m"); const_cast<char*>(CSI "5m");
// set enter/exit alternative charset mode for rxvt terminal // set enter/exit alternative charset mode for rxvt terminal
if ( rxvt_terminal && std::strncmp(termtype, "rxvt-16color", 12) == 0 ) if ( rxvt_terminal && std::strncmp(termtype, "rxvt-16color", 12) == 0 )
{ {
tcap[fc::t_enter_alt_charset_mode].string = \ TCAP(fc::t_enter_alt_charset_mode) = \
const_cast<char*>(ESC "(0"); const_cast<char*>(ESC "(0");
tcap[fc::t_exit_alt_charset_mode].string = \ TCAP(fc::t_exit_alt_charset_mode) = \
const_cast<char*>(ESC "(B"); const_cast<char*>(ESC "(B");
} }
// set exit underline for gnome terminal // set exit underline for gnome terminal
if ( gnome_terminal ) if ( gnome_terminal )
tcap[fc::t_exit_underline_mode].string = \ TCAP(fc::t_exit_underline_mode) = \
const_cast<char*>(CSI "24m"); const_cast<char*>(CSI "24m");
// set background color erase for cygwin terminal // set background color erase for cygwin terminal
@ -3169,45 +3174,45 @@ void FTerm::init_termcaps()
{ {
if ( FTermcap::max_color > 8 ) if ( FTermcap::max_color > 8 )
{ {
tcap[fc::t_set_a_foreground].string = \ TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;21%;m"); const_cast<char*>(CSI "3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;21%;m");
tcap[fc::t_set_a_background].string = \ TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m"); const_cast<char*>(CSI "4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m");
} }
else else
{ {
tcap[fc::t_set_a_foreground].string = \ TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "3%p1%dm"); const_cast<char*>(CSI "3%p1%dm");
tcap[fc::t_set_a_background].string = \ TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "4%p1%dm"); const_cast<char*>(CSI "4%p1%dm");
} }
tcap[fc::t_orig_pair].string = \ TCAP(fc::t_orig_pair) = \
const_cast<char*>(CSI "39;49;25m"); const_cast<char*>(CSI "39;49;25m");
// avoid dim + underline // avoid dim + underline
tcap[fc::t_enter_dim_mode].string = 0; TCAP(fc::t_enter_dim_mode) = 0;
tcap[fc::t_exit_dim_mode].string = 0; TCAP(fc::t_exit_dim_mode) = 0;
tcap[fc::t_enter_underline_mode].string = 0; TCAP(fc::t_enter_underline_mode) = 0;
tcap[fc::t_exit_underline_mode].string = 0; TCAP(fc::t_exit_underline_mode) = 0;
FTermcap::attr_without_color = 18; FTermcap::attr_without_color = 18;
} }
else if ( rxvt_terminal && ! urxvt_terminal ) else if ( rxvt_terminal && ! urxvt_terminal )
{ {
tcap[fc::t_set_a_foreground].string = \ TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "%?%p1%{8}%<%t%p1%{30}%+%e%p1%'R'%+%;%dm"); const_cast<char*>(CSI "%?%p1%{8}%<%t%p1%{30}%+%e%p1%'R'%+%;%dm");
tcap[fc::t_set_a_background].string = \ TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "%?%p1%{8}%<%t%p1%'('%+%e%p1%{92}%+%;%dm"); const_cast<char*>(CSI "%?%p1%{8}%<%t%p1%'('%+%e%p1%{92}%+%;%dm");
} }
else if ( tera_terminal ) else if ( tera_terminal )
{ {
tcap[fc::t_set_a_foreground].string = \ TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "38;5;%p1%dm"); const_cast<char*>(CSI "38;5;%p1%dm");
tcap[fc::t_set_a_background].string = \ TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "48;5;%p1%dm"); const_cast<char*>(CSI "48;5;%p1%dm");
tcap[fc::t_exit_attribute_mode].string = \ TCAP(fc::t_exit_attribute_mode) = \
const_cast<char*>(CSI "0m" SI); const_cast<char*>(CSI "0m" SI);
tcap[fc::t_orig_pair].string = \ TCAP(fc::t_orig_pair) = \
const_cast<char*>(CSI "39;49m"); const_cast<char*>(CSI "39;49m");
} }
else if ( putty_terminal ) else if ( putty_terminal )
@ -3215,91 +3220,91 @@ void FTerm::init_termcaps()
FTermcap::background_color_erase = true; FTermcap::background_color_erase = true;
FTermcap::osc_support = true; FTermcap::osc_support = true;
tcap[fc::t_set_a_foreground].string = \ TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "%?%p1%{8}%<" const_cast<char*>(CSI "%?%p1%{8}%<"
"%t3%p1%d" "%t3%p1%d"
"%e%p1%{16}%<" "%e%p1%{16}%<"
"%t9%p1%{8}%-%d" "%t9%p1%{8}%-%d"
"%e38;5;%p1%d%;m"); "%e38;5;%p1%d%;m");
tcap[fc::t_set_a_background].string = \ TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "%?%p1%{8}%<" const_cast<char*>(CSI "%?%p1%{8}%<"
"%t4%p1%d" "%t4%p1%d"
"%e%p1%{16}%<" "%e%p1%{16}%<"
"%t10%p1%{8}%-%d" "%t10%p1%{8}%-%d"
"%e48;5;%p1%d%;m"); "%e48;5;%p1%d%;m");
if ( ! tcap[fc::t_clr_bol].string ) if ( ! TCAP(fc::t_clr_bol) )
tcap[fc::t_clr_bol].string = \ TCAP(fc::t_clr_bol) = \
const_cast<char*>(CSI "1K"); const_cast<char*>(CSI "1K");
if ( ! tcap[fc::t_orig_pair].string ) if ( ! TCAP(fc::t_orig_pair) )
tcap[fc::t_orig_pair].string = \ TCAP(fc::t_orig_pair) = \
const_cast<char*>(CSI "39;49m"); const_cast<char*>(CSI "39;49m");
if ( ! tcap[fc::t_orig_colors].string ) if ( ! TCAP(fc::t_orig_colors) )
tcap[fc::t_orig_colors].string = \ TCAP(fc::t_orig_colors) = \
const_cast<char*>(OSC "R"); const_cast<char*>(OSC "R");
if ( ! tcap[fc::t_column_address].string ) if ( ! TCAP(fc::t_column_address) )
tcap[fc::t_column_address].string = \ TCAP(fc::t_column_address) = \
const_cast<char*>(CSI "%i%p1%dG"); const_cast<char*>(CSI "%i%p1%dG");
if ( ! tcap[fc::t_row_address].string ) if ( ! TCAP(fc::t_row_address) )
tcap[fc::t_row_address].string = \ TCAP(fc::t_row_address) = \
const_cast<char*>(CSI "%i%p1%dd"); const_cast<char*>(CSI "%i%p1%dd");
if ( ! tcap[fc::t_enable_acs].string ) if ( ! TCAP(fc::t_enable_acs) )
tcap[fc::t_enable_acs].string = \ TCAP(fc::t_enable_acs) = \
const_cast<char*>(ESC "(B" ESC ")0"); const_cast<char*>(ESC "(B" ESC ")0");
if ( ! tcap[fc::t_set_attributes].string ) if ( ! TCAP(fc::t_set_attributes) )
tcap[fc::t_set_attributes].string = \ TCAP(fc::t_set_attributes) = \
const_cast<char*>(CSI "0%?%p1%p6%|" const_cast<char*>(CSI "0%?%p1%p6%|"
"%t;1%;%?%p2%t;" "%t;1%;%?%p2%t;"
"4%;%?%p1%p3%|" "4%;%?%p1%p3%|"
"%t;7%;%?%p4%t;" "%t;7%;%?%p4%t;"
"5%;m%?%p9%t\016%e\017%;"); "5%;m%?%p9%t\016%e\017%;");
if ( ! tcap[fc::t_enter_am_mode].string ) if ( ! TCAP(fc::t_enter_am_mode) )
tcap[fc::t_enter_am_mode].string = \ TCAP(fc::t_enter_am_mode) = \
const_cast<char*>(CSI "?7h"); const_cast<char*>(CSI "?7h");
if ( ! tcap[fc::t_exit_am_mode].string ) if ( ! TCAP(fc::t_exit_am_mode) )
tcap[fc::t_exit_am_mode].string = \ TCAP(fc::t_exit_am_mode) = \
const_cast<char*>(CSI "?7l"); const_cast<char*>(CSI "?7l");
if ( ! tcap[fc::t_enter_pc_charset_mode].string ) if ( ! TCAP(fc::t_enter_pc_charset_mode) )
tcap[fc::t_enter_pc_charset_mode].string = \ TCAP(fc::t_enter_pc_charset_mode) = \
const_cast<char*>(CSI "11m"); const_cast<char*>(CSI "11m");
if ( ! tcap[fc::t_exit_pc_charset_mode].string ) if ( ! TCAP(fc::t_exit_pc_charset_mode) )
tcap[fc::t_exit_pc_charset_mode].string = \ TCAP(fc::t_exit_pc_charset_mode) = \
const_cast<char*>(CSI "10m"); const_cast<char*>(CSI "10m");
if ( ! tcap[fc::t_key_mouse].string ) if ( ! TCAP(fc::t_key_mouse) )
tcap[fc::t_key_mouse].string = \ TCAP(fc::t_key_mouse) = \
const_cast<char*>(CSI "M"); const_cast<char*>(CSI "M");
} }
// fallback if "AF" is not found // fallback if "AF" is not found
if ( ! tcap[fc::t_set_a_foreground].string ) if ( ! TCAP(fc::t_set_a_foreground) )
tcap[fc::t_set_a_foreground].string = \ TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "3%p1%dm"); const_cast<char*>(CSI "3%p1%dm");
// fallback if "AB" is not found // fallback if "AB" is not found
if ( ! tcap[fc::t_set_a_background].string ) if ( ! TCAP(fc::t_set_a_background) )
tcap[fc::t_set_a_background].string = \ TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "4%p1%dm"); const_cast<char*>(CSI "4%p1%dm");
// fallback if "Ic" is not found // fallback if "Ic" is not found
if ( ! tcap[fc::t_initialize_color].string ) if ( ! TCAP(fc::t_initialize_color) )
{ {
if ( screen_terminal ) if ( screen_terminal )
{ {
if ( tmux_terminal ) if ( tmux_terminal )
{ {
tcap[fc::t_initialize_color].string = \ TCAP(fc::t_initialize_color) = \
const_cast<char*>(ESC "Ptmux;" ESC OSC "4;%p1%d;rgb:" const_cast<char*>(ESC "Ptmux;" ESC OSC "4;%p1%d;rgb:"
"%p2%{255}%*%{1000}%/%2.2X/" "%p2%{255}%*%{1000}%/%2.2X/"
"%p3%{255}%*%{1000}%/%2.2X/" "%p3%{255}%*%{1000}%/%2.2X/"
@ -3307,7 +3312,7 @@ void FTerm::init_termcaps()
} }
else else
{ {
tcap[fc::t_initialize_color].string = \ TCAP(fc::t_initialize_color) = \
const_cast<char*>(ESC "P" OSC "4;%p1%d;rgb:" const_cast<char*>(ESC "P" OSC "4;%p1%d;rgb:"
"%p2%{255}%*%{1000}%/%2.2X/" "%p2%{255}%*%{1000}%/%2.2X/"
"%p3%{255}%*%{1000}%/%2.2X/" "%p3%{255}%*%{1000}%/%2.2X/"
@ -3316,7 +3321,7 @@ void FTerm::init_termcaps()
} }
else if ( xterm_terminal && ! putty_terminal ) else if ( xterm_terminal && ! putty_terminal )
{ {
tcap[fc::t_initialize_color].string = \ TCAP(fc::t_initialize_color) = \
const_cast<char*>(OSC "4;%p1%d;rgb:" const_cast<char*>(OSC "4;%p1%d;rgb:"
"%p2%{255}%*%{1000}%/%2.2X/" "%p2%{255}%*%{1000}%/%2.2X/"
"%p3%{255}%*%{1000}%/%2.2X/" "%p3%{255}%*%{1000}%/%2.2X/"
@ -3324,7 +3329,7 @@ void FTerm::init_termcaps()
} }
else else
{ {
tcap[fc::t_initialize_color].string = \ TCAP(fc::t_initialize_color) = \
const_cast<char*>(OSC "P%p1%x" const_cast<char*>(OSC "P%p1%x"
"%p2%{255}%*%{1000}%/%02x" "%p2%{255}%*%{1000}%/%02x"
"%p3%{255}%*%{1000}%/%02x" "%p3%{255}%*%{1000}%/%02x"
@ -3333,60 +3338,60 @@ void FTerm::init_termcaps()
} }
// fallback if "ti" is not found // fallback if "ti" is not found
if ( ! tcap[fc::t_enter_ca_mode].string ) if ( ! TCAP(fc::t_enter_ca_mode) )
tcap[fc::t_enter_ca_mode].string = \ TCAP(fc::t_enter_ca_mode) = \
const_cast<char*>(ESC "7" CSI "?47h"); const_cast<char*>(ESC "7" CSI "?47h");
// fallback if "te" is not found // fallback if "te" is not found
if ( ! tcap[fc::t_exit_ca_mode].string ) if ( ! TCAP(fc::t_exit_ca_mode) )
tcap[fc::t_exit_ca_mode].string = \ TCAP(fc::t_exit_ca_mode) = \
const_cast<char*>(CSI "?47l" ESC "8" CSI "m"); const_cast<char*>(CSI "?47l" ESC "8" CSI "m");
// set ansi move if "cm" is not found // set ansi move if "cm" is not found
if ( ! tcap[fc::t_cursor_address].string ) if ( ! TCAP(fc::t_cursor_address) )
tcap[fc::t_cursor_address].string = \ TCAP(fc::t_cursor_address) = \
const_cast<char*>(CSI "%i%p1%d;%p2%dH"); const_cast<char*>(CSI "%i%p1%d;%p2%dH");
// test for standard ECMA-48 (ANSI X3.64) terminal // test for standard ECMA-48 (ANSI X3.64) terminal
if ( tcap[fc::t_exit_underline_mode].string if ( TCAP(fc::t_exit_underline_mode)
&& std::strncmp(tcap[fc::t_exit_underline_mode].string, CSI "24m", 5) == 0 ) && std::strncmp(TCAP(fc::t_exit_underline_mode), CSI "24m", 5) == 0 )
{ {
// seems to be a ECMA-48 (ANSI X3.64) compatible terminal // seems to be a ECMA-48 (ANSI X3.64) compatible terminal
tcap[fc::t_enter_dbl_underline_mode].string = \ TCAP(fc::t_enter_dbl_underline_mode) = \
const_cast<char*>(CSI "21m"); // Exit single underline, too const_cast<char*>(CSI "21m"); // Exit single underline, too
tcap[fc::t_exit_dbl_underline_mode].string = \ TCAP(fc::t_exit_dbl_underline_mode) = \
const_cast<char*>(CSI "24m"); const_cast<char*>(CSI "24m");
tcap[fc::t_exit_bold_mode].string = \ TCAP(fc::t_exit_bold_mode) = \
const_cast<char*>(CSI "22m"); // Exit dim, too const_cast<char*>(CSI "22m"); // Exit dim, too
tcap[fc::t_exit_dim_mode].string = \ TCAP(fc::t_exit_dim_mode) = \
const_cast<char*>(CSI "22m"); const_cast<char*>(CSI "22m");
tcap[fc::t_exit_underline_mode].string = \ TCAP(fc::t_exit_underline_mode) = \
const_cast<char*>(CSI "24m"); const_cast<char*>(CSI "24m");
tcap[fc::t_exit_blink_mode].string = \ TCAP(fc::t_exit_blink_mode) = \
const_cast<char*>(CSI "25m"); const_cast<char*>(CSI "25m");
tcap[fc::t_exit_reverse_mode].string = \ TCAP(fc::t_exit_reverse_mode) = \
const_cast<char*>(CSI "27m"); const_cast<char*>(CSI "27m");
tcap[fc::t_exit_secure_mode].string = \ TCAP(fc::t_exit_secure_mode) = \
const_cast<char*>(CSI "28m"); const_cast<char*>(CSI "28m");
tcap[fc::t_enter_crossed_out_mode].string = \ TCAP(fc::t_enter_crossed_out_mode) = \
const_cast<char*>(CSI "9m"); const_cast<char*>(CSI "9m");
tcap[fc::t_exit_crossed_out_mode].string = \ TCAP(fc::t_exit_crossed_out_mode) = \
const_cast<char*>(CSI "29m"); const_cast<char*>(CSI "29m");
} }
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
if ( isFreeBSDConsole() ) if ( isFreeBSDConsole() )
{ {
tcap[fc::t_acs_chars].string = \ TCAP(fc::t_acs_chars) = \
const_cast<char*>("-\036.\0370\333" const_cast<char*>("-\036.\0370\333"
"a\260f\370g\361" "a\260f\370g\361"
"h\261j\331k\277" "h\261j\331k\277"
@ -3394,7 +3399,7 @@ void FTerm::init_termcaps()
"q\304t\303u\264" "q\304t\303u\264"
"v\301w\302x\263" "v\301w\302x\263"
"y\363z\362~\371"); "y\363z\362~\371");
tcap[fc::t_set_attributes].string = \ TCAP(fc::t_set_attributes) = \
const_cast<char*>(CSI "0%?%p1%p6%|" const_cast<char*>(CSI "0%?%p1%p6%|"
"%t;1%;%?%p2%t;" "%t;1%;%?%p2%t;"
"4%;%?%p1%p3%|" "4%;%?%p1%p3%|"
@ -3439,8 +3444,8 @@ void FTerm::init_termcaps()
key_up_string = tgetstr(const_cast<char*>("ku"), &buffer); key_up_string = tgetstr(const_cast<char*>("ku"), &buffer);
if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0)) if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0))
|| ( tcap[fc::t_cursor_up].string || ( TCAP(fc::t_cursor_up)
&& (std::strcmp(tcap[fc::t_cursor_up].string, CSI "A") == 0) ) ) && (std::strcmp(TCAP(fc::t_cursor_up), CSI "A") == 0) ) )
{ {
for (int i = 0; Fkey[i].tname[0] != 0; i++) for (int i = 0; Fkey[i].tname[0] != 0; i++)
{ {
@ -3472,66 +3477,69 @@ void FTerm::init_termcaps()
// duration precalculation of the cursor movement strings // duration precalculation of the cursor movement strings
opti_move->setTabStop(int(FTermcap::tabstop)); opti_move->setTabStop(int(FTermcap::tabstop));
opti_move->set_cursor_home (tcap[fc::t_cursor_home].string); opti_move->set_cursor_home (TCAP(fc::t_cursor_home));
opti_move->set_cursor_to_ll (tcap[fc::t_cursor_to_ll].string); opti_move->set_cursor_to_ll (TCAP(fc::t_cursor_to_ll));
opti_move->set_carriage_return (tcap[fc::t_carriage_return].string); opti_move->set_carriage_return (TCAP(fc::t_carriage_return));
opti_move->set_tabular (tcap[fc::t_tab].string); opti_move->set_tabular (TCAP(fc::t_tab));
opti_move->set_back_tab (tcap[fc::t_back_tab].string); opti_move->set_back_tab (TCAP(fc::t_back_tab));
opti_move->set_cursor_up (tcap[fc::t_cursor_up].string); opti_move->set_cursor_up (TCAP(fc::t_cursor_up));
opti_move->set_cursor_down (tcap[fc::t_cursor_down].string); opti_move->set_cursor_down (TCAP(fc::t_cursor_down));
opti_move->set_cursor_left (tcap[fc::t_cursor_left].string); opti_move->set_cursor_left (TCAP(fc::t_cursor_left));
opti_move->set_cursor_right (tcap[fc::t_cursor_right].string); opti_move->set_cursor_right (TCAP(fc::t_cursor_right));
cursor_addres_lengths = opti_move->set_cursor_address (tcap[fc::t_cursor_address].string); cursor_addres_lengths = \
opti_move->set_column_address (tcap[fc::t_column_address].string); opti_move->set_cursor_address (TCAP(fc::t_cursor_address));
opti_move->set_row_address (tcap[fc::t_row_address].string); opti_move->set_column_address (TCAP(fc::t_column_address));
opti_move->set_parm_up_cursor (tcap[fc::t_parm_up_cursor].string); opti_move->set_row_address (TCAP(fc::t_row_address));
opti_move->set_parm_down_cursor (tcap[fc::t_parm_down_cursor].string); opti_move->set_parm_up_cursor (TCAP(fc::t_parm_up_cursor));
opti_move->set_parm_left_cursor (tcap[fc::t_parm_left_cursor].string); opti_move->set_parm_down_cursor (TCAP(fc::t_parm_down_cursor));
opti_move->set_parm_right_cursor (tcap[fc::t_parm_right_cursor].string); opti_move->set_parm_left_cursor (TCAP(fc::t_parm_left_cursor));
opti_move->set_parm_right_cursor (TCAP(fc::t_parm_right_cursor));
opti_move->set_auto_left_margin (FTermcap::automatic_left_margin); opti_move->set_auto_left_margin (FTermcap::automatic_left_margin);
opti_move->set_eat_newline_glitch (FTermcap::eat_nl_glitch); opti_move->set_eat_newline_glitch (FTermcap::eat_nl_glitch);
erase_ch_length = opti_move->set_erase_chars (tcap[fc::t_erase_chars].string); erase_ch_length = \
repeat_char_length = opti_move->set_repeat_char (tcap[fc::t_repeat_char].string); opti_move->set_erase_chars (TCAP(fc::t_erase_chars));
clr_bol_length = opti_move->set_clr_bol (tcap[fc::t_clr_bol].string); repeat_char_length = \
clr_eol_length = opti_move->set_clr_eol (tcap[fc::t_clr_eol].string); opti_move->set_repeat_char (TCAP(fc::t_repeat_char));
clr_bol_length = opti_move->set_clr_bol (TCAP(fc::t_clr_bol));
clr_eol_length = opti_move->set_clr_eol (TCAP(fc::t_clr_eol));
// attribute settings // attribute settings
opti_attr->setNoColorVideo (int(FTermcap::attr_without_color)); opti_attr->setNoColorVideo (int(FTermcap::attr_without_color));
opti_attr->set_enter_bold_mode (tcap[fc::t_enter_bold_mode].string); opti_attr->set_enter_bold_mode (TCAP(fc::t_enter_bold_mode));
opti_attr->set_exit_bold_mode (tcap[fc::t_exit_bold_mode].string); opti_attr->set_exit_bold_mode (TCAP(fc::t_exit_bold_mode));
opti_attr->set_enter_dim_mode (tcap[fc::t_enter_dim_mode].string); opti_attr->set_enter_dim_mode (TCAP(fc::t_enter_dim_mode));
opti_attr->set_exit_dim_mode (tcap[fc::t_exit_dim_mode].string); opti_attr->set_exit_dim_mode (TCAP(fc::t_exit_dim_mode));
opti_attr->set_enter_italics_mode (tcap[fc::t_enter_italics_mode].string); opti_attr->set_enter_italics_mode (TCAP(fc::t_enter_italics_mode));
opti_attr->set_exit_italics_mode (tcap[fc::t_exit_italics_mode].string); opti_attr->set_exit_italics_mode (TCAP(fc::t_exit_italics_mode));
opti_attr->set_enter_underline_mode (tcap[fc::t_enter_underline_mode].string); opti_attr->set_enter_underline_mode (TCAP(fc::t_enter_underline_mode));
opti_attr->set_exit_underline_mode (tcap[fc::t_exit_underline_mode].string); opti_attr->set_exit_underline_mode (TCAP(fc::t_exit_underline_mode));
opti_attr->set_enter_blink_mode (tcap[fc::t_enter_blink_mode].string); opti_attr->set_enter_blink_mode (TCAP(fc::t_enter_blink_mode));
opti_attr->set_exit_blink_mode (tcap[fc::t_exit_blink_mode].string); opti_attr->set_exit_blink_mode (TCAP(fc::t_exit_blink_mode));
opti_attr->set_enter_reverse_mode (tcap[fc::t_enter_reverse_mode].string); opti_attr->set_enter_reverse_mode (TCAP(fc::t_enter_reverse_mode));
opti_attr->set_exit_reverse_mode (tcap[fc::t_exit_reverse_mode].string); opti_attr->set_exit_reverse_mode (TCAP(fc::t_exit_reverse_mode));
opti_attr->set_enter_standout_mode (tcap[fc::t_enter_standout_mode].string); opti_attr->set_enter_standout_mode (TCAP(fc::t_enter_standout_mode));
opti_attr->set_exit_standout_mode (tcap[fc::t_exit_standout_mode].string); opti_attr->set_exit_standout_mode (TCAP(fc::t_exit_standout_mode));
opti_attr->set_enter_secure_mode (tcap[fc::t_enter_secure_mode].string); opti_attr->set_enter_secure_mode (TCAP(fc::t_enter_secure_mode));
opti_attr->set_exit_secure_mode (tcap[fc::t_exit_secure_mode].string); opti_attr->set_exit_secure_mode (TCAP(fc::t_exit_secure_mode));
opti_attr->set_enter_protected_mode (tcap[fc::t_enter_protected_mode].string); opti_attr->set_enter_protected_mode (TCAP(fc::t_enter_protected_mode));
opti_attr->set_exit_protected_mode (tcap[fc::t_exit_protected_mode].string); opti_attr->set_exit_protected_mode (TCAP(fc::t_exit_protected_mode));
opti_attr->set_enter_crossed_out_mode (tcap[fc::t_enter_crossed_out_mode].string); opti_attr->set_enter_crossed_out_mode (TCAP(fc::t_enter_crossed_out_mode));
opti_attr->set_exit_crossed_out_mode (tcap[fc::t_exit_crossed_out_mode].string); opti_attr->set_exit_crossed_out_mode (TCAP(fc::t_exit_crossed_out_mode));
opti_attr->set_enter_dbl_underline_mode (tcap[fc::t_enter_dbl_underline_mode].string); opti_attr->set_enter_dbl_underline_mode (TCAP(fc::t_enter_dbl_underline_mode));
opti_attr->set_exit_dbl_underline_mode (tcap[fc::t_exit_dbl_underline_mode].string); opti_attr->set_exit_dbl_underline_mode (TCAP(fc::t_exit_dbl_underline_mode));
opti_attr->set_set_attributes (tcap[fc::t_set_attributes].string); opti_attr->set_set_attributes (TCAP(fc::t_set_attributes));
opti_attr->set_exit_attribute_mode (tcap[fc::t_exit_attribute_mode].string); opti_attr->set_exit_attribute_mode (TCAP(fc::t_exit_attribute_mode));
opti_attr->set_enter_alt_charset_mode (tcap[fc::t_enter_alt_charset_mode].string); opti_attr->set_enter_alt_charset_mode (TCAP(fc::t_enter_alt_charset_mode));
opti_attr->set_exit_alt_charset_mode (tcap[fc::t_exit_alt_charset_mode].string); opti_attr->set_exit_alt_charset_mode (TCAP(fc::t_exit_alt_charset_mode));
opti_attr->set_enter_pc_charset_mode (tcap[fc::t_enter_pc_charset_mode].string); opti_attr->set_enter_pc_charset_mode (TCAP(fc::t_enter_pc_charset_mode));
opti_attr->set_exit_pc_charset_mode (tcap[fc::t_exit_pc_charset_mode].string); opti_attr->set_exit_pc_charset_mode (TCAP(fc::t_exit_pc_charset_mode));
opti_attr->set_a_foreground_color (tcap[fc::t_set_a_foreground].string); opti_attr->set_a_foreground_color (TCAP(fc::t_set_a_foreground));
opti_attr->set_a_background_color (tcap[fc::t_set_a_background].string); opti_attr->set_a_background_color (TCAP(fc::t_set_a_background));
opti_attr->set_foreground_color (tcap[fc::t_set_foreground].string); opti_attr->set_foreground_color (TCAP(fc::t_set_foreground));
opti_attr->set_background_color (tcap[fc::t_set_background].string); opti_attr->set_background_color (TCAP(fc::t_set_background));
opti_attr->set_term_color_pair (tcap[fc::t_set_color_pair].string); opti_attr->set_term_color_pair (TCAP(fc::t_set_color_pair));
opti_attr->set_orig_pair (tcap[fc::t_orig_pair].string); opti_attr->set_orig_pair (TCAP(fc::t_orig_pair));
opti_attr->set_orig_orig_colors (tcap[fc::t_orig_colors].string); opti_attr->set_orig_orig_colors (TCAP(fc::t_orig_colors));
opti_attr->setMaxColor (FTermcap::max_color); opti_attr->setMaxColor (FTermcap::max_color);
if ( FTermcap::ansi_default_color ) if ( FTermcap::ansi_default_color )
@ -3560,7 +3568,7 @@ void FTerm::init_encoding()
} }
else if ( isatty(stdout_no) else if ( isatty(stdout_no)
&& (std::strlen(termtype) > 0) && (std::strlen(termtype) > 0)
&& (tcap[fc::t_exit_alt_charset_mode].string != 0) ) && (TCAP(fc::t_exit_alt_charset_mode) != 0) )
{ {
vt100_console = true; vt100_console = true;
Encoding = fc::VT100; Encoding = fc::VT100;
@ -3625,10 +3633,10 @@ void FTerm::init()
{ {
opti_move = new FOptiMove(); opti_move = new FOptiMove();
opti_attr = new FOptiAttr(); opti_attr = new FOptiAttr();
term = new FRect(0,0,0,0); term = new FRect(0, 0, 0, 0);
mouse = new FPoint(0,0); mouse = new FPoint(0, 0);
vt100_alt_char = new std::map<uChar,uChar>; vt100_alt_char = new std::map<uChar, uChar>;
encoding_set = new std::map<std::string,fc::encoding>; encoding_set = new std::map<std::string, fc::encoding>;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -3690,7 +3698,8 @@ void FTerm::init()
if ( stdin_status_flags == -1 ) if ( stdin_status_flags == -1 )
std::abort(); std::abort();
term_name = ttyname(stdout_no); // Get pathname of the terminal device
ttyname_r (stdout_no, term_name, sizeof(term_name));
#if defined(__linux__) #if defined(__linux__)
// initialize Linux console // initialize Linux console
@ -3892,7 +3901,7 @@ void FTerm::init()
#endif #endif
// xterm mouse support // xterm mouse support
if ( tcap[fc::t_key_mouse].string && ! linux_terminal ) if ( TCAP(fc::t_key_mouse) && ! linux_terminal )
{ {
mouse_support = true; mouse_support = true;
enableXTermMouse(); enableXTermMouse();
@ -3903,30 +3912,30 @@ void FTerm::init()
xtermMetaSendsESC(true); xtermMetaSendsESC(true);
// enter 'keyboard_transmit' mode // enter 'keyboard_transmit' mode
if ( tcap[fc::t_keypad_xmit].string ) if ( TCAP(fc::t_keypad_xmit) )
{ {
putstring (tcap[fc::t_keypad_xmit].string); putstring (TCAP(fc::t_keypad_xmit));
std::fflush(stdout); std::fflush(stdout);
} }
// save current cursor position // save current cursor position
if ( use_alternate_screen && tcap[fc::t_save_cursor].string ) if ( use_alternate_screen && TCAP(fc::t_save_cursor) )
{ {
putstring (tcap[fc::t_save_cursor].string); putstring (TCAP(fc::t_save_cursor));
std::fflush(stdout); std::fflush(stdout);
} }
// saves the screen and the cursor position // saves the screen and the cursor position
if ( use_alternate_screen && tcap[fc::t_enter_ca_mode].string ) if ( use_alternate_screen && TCAP(fc::t_enter_ca_mode) )
{ {
putstring (tcap[fc::t_enter_ca_mode].string); putstring (TCAP(fc::t_enter_ca_mode));
std::fflush(stdout); std::fflush(stdout);
} }
// enable alternate charset // enable alternate charset
if ( tcap[fc::t_enable_acs].string ) if ( TCAP(fc::t_enable_acs) )
{ {
putstring (tcap[fc::t_enable_acs].string); putstring (TCAP(fc::t_enable_acs));
std::fflush(stdout); std::fflush(stdout);
} }
@ -4017,16 +4026,16 @@ void FTerm::finish()
restoreTTYsettings(); restoreTTYsettings();
// turn off all attributes // turn off all attributes
if ( tcap[fc::t_exit_attribute_mode].string ) if ( TCAP(fc::t_exit_attribute_mode) )
{ {
putstring (tcap[fc::t_exit_attribute_mode].string); putstring (TCAP(fc::t_exit_attribute_mode));
std::fflush(stdout); std::fflush(stdout);
} }
// turn off pc charset mode // turn off pc charset mode
if ( tcap[fc::t_exit_pc_charset_mode].string ) if ( TCAP(fc::t_exit_pc_charset_mode) )
{ {
putstring (tcap[fc::t_exit_pc_charset_mode].string); putstring (TCAP(fc::t_exit_pc_charset_mode));
std::fflush(stdout); std::fflush(stdout);
} }
@ -4095,23 +4104,23 @@ void FTerm::finish()
#endif #endif
// restores the screen and the cursor position // restores the screen and the cursor position
if ( use_alternate_screen && tcap[fc::t_exit_ca_mode].string ) if ( use_alternate_screen && TCAP(fc::t_exit_ca_mode) )
{ {
putstring (tcap[fc::t_exit_ca_mode].string); putstring (TCAP(fc::t_exit_ca_mode));
std::fflush(stdout); std::fflush(stdout);
} }
// restore cursor to position of last save_cursor // restore cursor to position of last save_cursor
if ( use_alternate_screen && tcap[fc::t_restore_cursor].string ) if ( use_alternate_screen && TCAP(fc::t_restore_cursor) )
{ {
putstring (tcap[fc::t_restore_cursor].string); putstring (TCAP(fc::t_restore_cursor));
std::fflush(stdout); std::fflush(stdout);
} }
// leave 'keyboard_transmit' mode // leave 'keyboard_transmit' mode
if ( tcap[fc::t_keypad_local].string ) if ( TCAP(fc::t_keypad_local) )
{ {
putstring (tcap[fc::t_keypad_local].string); putstring (TCAP(fc::t_keypad_local));
std::fflush(stdout); std::fflush(stdout);
} }

View File

@ -36,7 +36,7 @@
#if defined(__linux__) #if defined(__linux__)
#include <linux/fb.h> // Linux framebuffer console #include <linux/fb.h> // Linux framebuffer console
#include <linux/keyboard.h> // need for gpm keyboard modifiers #include <linux/keyboard.h> // need for gpm keyboard modifiers
#include <sys/io.h> // <asm/io.h> is deprecated, use <sys/io.h> instead #include <sys/io.h> // <asm/io.h> is deprecated
#include <sys/kd.h> #include <sys/kd.h>
#endif #endif
@ -53,7 +53,6 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <langinfo.h> #include <langinfo.h>
#include <term.h> // termcap #include <term.h> // termcap
@ -66,6 +65,7 @@
#include <csignal> #include <csignal>
#include <map> #include <map>
#include <queue> #include <queue>
#include <string>
#include "fc.h" #include "fc.h"
#include "fobject.h" #include "fobject.h"
@ -173,16 +173,16 @@ class FTerm
static void setXTermDefaultColors (bool); static void setXTermDefaultColors (bool);
#if defined(__linux__) #if defined(__linux__)
static void setLinuxConsoleCursorStyle ( fc::linuxConsoleCursorStyle static void setLinuxConsoleCursorStyle \
, bool ); (fc::linuxConsoleCursorStyle, bool);
#endif #endif
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
static void setFreeBSDConsoleCursorStyle ( fc::freebsdConsoleCursorStyle static void setFreeBSDConsoleCursorStyle \
, bool ); (fc::freebsdConsoleCursorStyle, bool);
#endif #endif
static void setTTY (termios&); static void setTTY (const termios&);
static void noHardwareEcho(); static void noHardwareEcho();
static bool setRawMode (bool); static bool setRawMode (bool);
static bool setRawMode(); static bool setRawMode();
@ -249,11 +249,11 @@ class FTerm
static int (*Fputchar)(int); static int (*Fputchar)(int);
static void putstringf (const char* const, ...) static void putstringf (const char* const, ...)
#if defined(__clang__) #if defined(__clang__)
__attribute__((__format__ (__printf__, 1, 2))) __attribute__((__format__ (__printf__, 1, 2)))
#elif defined(__GNUC__) #elif defined(__GNUC__)
__attribute__ ((format (printf, 1, 2))) __attribute__ ((format (printf, 1, 2)))
#endif #endif
; ;
static void putstring (const char* const, int = 1); static void putstring (const char* const, int = 1);
static int putchar_ASCII (register int); static int putchar_ASCII (register int);
@ -261,9 +261,9 @@ class FTerm
static int UTF8decode (const char[]); static int UTF8decode (const char[]);
#if DEBUG #if DEBUG
static char termtype_256color[30]; static char termtype_256color[256];
static char termtype_Answerback[30]; static char termtype_Answerback[256];
static char termtype_SecDA[30]; static char termtype_SecDA[256];
#endif #endif
protected: protected:
@ -370,7 +370,8 @@ class FTerm
#if defined(__linux__) #if defined(__linux__)
static int getScreenFont(); static int getScreenFont();
static int setScreenFont (uChar*, uInt, uInt, uInt, bool = false); static int setScreenFont ( uChar*, uInt, uInt, uInt
, bool = false );
static int setUnicodeMap (struct unimapdesc*); static int setUnicodeMap (struct unimapdesc*);
static int getUnicodeMap (); static int getUnicodeMap ();
static void initLinuxConsole(); static void initLinuxConsole();
@ -445,8 +446,8 @@ class FTerm
static bool openbsd_terminal; static bool openbsd_terminal;
static bool screen_terminal; static bool screen_terminal;
static bool tmux_terminal; static bool tmux_terminal;
static char termtype[30]; static char termtype[256];
static char* term_name; static char term_name[256];
static char* locale_name; static char* locale_name;
static char* locale_xterm; static char* locale_xterm;
static FRect* term; // current terminal geometry static FRect* term; // current terminal geometry

View File

@ -1,6 +1,9 @@
// File: ftermbuffer.cpp // File: ftermbuffer.cpp
// Provides: class FTermBuffer // Provides: class FTermBuffer
#include <string>
#include <vector>
#include "ftermbuffer.h" #include "ftermbuffer.h"
@ -24,12 +27,12 @@ FTermBuffer::~FTermBuffer() // destructor
int FTermBuffer::writef (const wchar_t* format, ...) int FTermBuffer::writef (const wchar_t* format, ...)
{ {
assert ( format != 0 ); assert ( format != 0 );
static const int buf_size = 1024; static const int BufSize = 1024;
wchar_t buffer[buf_size]; wchar_t buffer[BufSize];
va_list args; va_list args;
va_start (args, format); va_start (args, format);
std::vswprintf (buffer, buf_size, format, args); std::vswprintf (buffer, BufSize, format, args);
va_end (args); va_end (args);
FString str(buffer); FString str(buffer);
@ -148,7 +151,8 @@ int FTermBuffer::write (register int c)
// FTermBuffer non-member operators // FTermBuffer non-member operators
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::vector< FTermBuffer::char_data>& operator << ( std::vector<FTermBuffer::char_data>& termString std::vector<FTermBuffer::char_data>& operator << \
( std::vector<FTermBuffer::char_data>& termString
, const FTermBuffer& buf ) , const FTermBuffer& buf )
{ {
if ( ! buf.data.empty() ) if ( ! buf.data.empty() )

View File

@ -12,8 +12,9 @@
#ifndef FTERMBUFFER_H #ifndef FTERMBUFFER_H
#define FTERMBUFFER_H #define FTERMBUFFER_H
#include <vector>
#include <sstream> // std::stringstream #include <sstream> // std::stringstream
#include <string>
#include <vector>
#include "fvterm.h" #include "fvterm.h"
#include "fstring.h" #include "fstring.h"
@ -49,17 +50,17 @@ class FTermBuffer
int getLength() const; int getLength() const;
// Inquiry // Inquiry
bool isEmpty () const; bool isEmpty() const;
// Methods // Methods
void clear(); void clear();
int writef (const wchar_t*, ...); int writef (const wchar_t*, ...);
int writef (const char*, ...) int writef (const char*, ...)
#if defined(__clang__) #if defined(__clang__)
__attribute__((__format__ (__printf__, 2, 3))) __attribute__((__format__ (__printf__, 2, 3)))
#elif defined(__GNUC__) #elif defined(__GNUC__)
__attribute__ ((format (printf, 2, 3))) __attribute__ ((format (printf, 2, 3)))
#endif #endif
; ;
int write (const std::wstring&); int write (const std::wstring&);
int write (const wchar_t*); int write (const wchar_t*);

View File

@ -11,6 +11,10 @@
#ifndef FTERMCAP_H #ifndef FTERMCAP_H
#define FTERMCAP_H #define FTERMCAP_H
// FTermcap string macro
#define TCAP(s) tcap[(s)].string
#include <string>
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FTermcap // class FTermcap

View File

@ -28,6 +28,8 @@
#ifndef FTEXTVIEW_H #ifndef FTEXTVIEW_H
#define FTEXTVIEW_H #define FTEXTVIEW_H
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fscrollbar.h" #include "fscrollbar.h"
#include "fstatusbar.h" #include "fstatusbar.h"

View File

@ -137,7 +137,7 @@ void FToolTip::calculateDimensions()
max_line_width = len; max_line_width = len;
} }
h = int(text_num_lines) + 2 ; h = int(text_num_lines) + 2;
w = int(max_line_width + 4); w = int(max_line_width + 4);
if ( r ) if ( r )

View File

@ -33,6 +33,8 @@
#ifndef FTOOLTIP_H #ifndef FTOOLTIP_H
#define FTOOLTIP_H #define FTOOLTIP_H
#include <vector>
#include "fwindow.h" #include "fwindow.h"

View File

@ -5,6 +5,8 @@
#include <sys/types.h> #include <sys/types.h>
#define null NULL
typedef unsigned char uChar; typedef unsigned char uChar;
typedef unsigned int uInt; typedef unsigned int uInt;
typedef unsigned long uLong; typedef unsigned long uLong;

View File

@ -1,6 +1,10 @@
// File: fvterm.cpp // File: fvterm.cpp
// Provides: class FVTerm // Provides: class FVTerm
#include <queue>
#include <string>
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fvterm.h" #include "fvterm.h"
#include "fwidget.h" #include "fwidget.h"
@ -105,7 +109,7 @@ void FVTerm::setTermXY (register int x, register int y)
appendOutputBuffer(move_str); appendOutputBuffer(move_str);
flush_out(); flush_out();
term_pos->setPoint(x,y); term_pos->setPoint(x, y);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -289,12 +293,12 @@ void FVTerm::delPreprocessingHandler (FVTerm* instance)
int FVTerm::printf (const wchar_t* format, ...) int FVTerm::printf (const wchar_t* format, ...)
{ {
assert ( format != 0 ); assert ( format != 0 );
static const int buf_size = 1024; static const int BufSize = 1024;
wchar_t buffer[buf_size]; wchar_t buffer[BufSize];
va_list args; va_list args;
va_start (args, format); va_start (args, format);
std::vswprintf (buffer, buf_size, format, args); std::vswprintf (buffer, BufSize, format, args);
va_end (args); va_end (args);
FString str(buffer); FString str(buffer);
@ -1248,7 +1252,7 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
, win->width + win->right_shadow , win->width + win->right_shadow
, win->height + win->bottom_shadow ); , win->height + win->bottom_shadow );
if ( found && geometry.contains(x,y) ) if ( found && geometry.contains(x, y) )
{ {
char_data* tmp; char_data* tmp;
int line_len = win->width + win->right_shadow; int line_len = win->width + win->right_shadow;
@ -1500,7 +1504,6 @@ void FVTerm::updateVTerm (term_area* area)
} }
else if ( ! modified ) else if ( ! modified )
line_xmin++; // don't update covered character line_xmin++; // don't update covered character
} }
_xmin = ax + line_xmin - ol; _xmin = ax + line_xmin - ol;
@ -1574,7 +1577,7 @@ bool FVTerm::isInsideArea (int x, int y, term_area* area)
ah = area->height; ah = area->height;
FRect area_geometry(ax, ay, aw, ah); FRect area_geometry(ax, ay, aw, ah);
if ( area_geometry.contains(x,y) ) if ( area_geometry.contains(x, y) )
return true; return true;
else else
return false; return false;
@ -1871,7 +1874,7 @@ void FVTerm::scrollAreaForward (term_area* area)
if ( area == vdesktop ) if ( area == vdesktop )
{ {
if ( tcap[fc::t_scroll_forward].string ) if ( TCAP(fc::t_scroll_forward) )
{ {
setTermXY (0, vdesktop->height); setTermXY (0, vdesktop->height);
scrollTermForward(); scrollTermForward();
@ -1932,7 +1935,7 @@ void FVTerm::scrollAreaReverse (term_area* area)
if ( area == vdesktop ) if ( area == vdesktop )
{ {
if ( tcap[fc::t_scroll_reverse].string ) if ( TCAP(fc::t_scroll_reverse) )
{ {
setTermXY (0, 0); setTermXY (0, 0);
scrollTermReverse(); scrollTermReverse();
@ -2120,7 +2123,7 @@ FVTerm::char_data FVTerm::getCharacter ( character_type char_type
, win->height + win->bottom_shadow ); , win->height + win->bottom_shadow );
// window visible and contains current character // window visible and contains current character
if ( geometry.contains(x,y) ) if ( geometry.contains(x, y) )
{ {
char_data* tmp; char_data* tmp;
int line_len = win->width + win->right_shadow; int line_len = win->width + win->right_shadow;
@ -2257,7 +2260,7 @@ void FVTerm::init()
try try
{ {
term_pos = new FPoint(-1,-1); term_pos = new FPoint(-1, -1);
output_buffer = new std::queue<int>; output_buffer = new std::queue<int>;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
@ -2344,9 +2347,9 @@ void FVTerm::finish()
bool FVTerm::clearTerm (int fillchar) bool FVTerm::clearTerm (int fillchar)
{ {
// Clear the real terminal and put cursor at home // Clear the real terminal and put cursor at home
char*& cl = tcap[fc::t_clear_screen].string; char*& cl = TCAP(fc::t_clear_screen);
char*& cd = tcap[fc::t_clr_eos].string; char*& cd = TCAP(fc::t_clr_eos);
char*& cb = tcap[fc::t_clr_eol].string; char*& cb = TCAP(fc::t_clr_eol);
bool ut = FTermcap::background_color_erase; bool ut = FTermcap::background_color_erase;
char_data* next = &next_attribute; char_data* next = &next_attribute;
bool normal = isNormal(next); bool normal = isNormal(next);
@ -2367,11 +2370,11 @@ bool FVTerm::clearTerm (int fillchar)
{ {
setTermXY (0, 0); setTermXY (0, 0);
appendOutputBuffer (cd); appendOutputBuffer (cd);
term_pos->setPoint(-1,-1); term_pos->setPoint(-1, -1);
} }
else if ( cb ) else if ( cb )
{ {
term_pos->setPoint(-1,-1); term_pos->setPoint(-1, -1);
for (int i = 0; i < getLineNumber(); i++) for (int i = 0; i < getLineNumber(); i++)
{ {
@ -2401,10 +2404,10 @@ void FVTerm::updateTerminalLine (uInt y)
bool is_eol_clean = false; bool is_eol_clean = false;
bool draw_leading_ws = false; bool draw_leading_ws = false;
bool draw_tailing_ws = false; bool draw_tailing_ws = false;
char*& ce = tcap[fc::t_clr_eol].string; char*& ce = TCAP(fc::t_clr_eol);
char*& cb = tcap[fc::t_clr_bol].string; char*& cb = TCAP(fc::t_clr_bol);
char*& ec = tcap[fc::t_erase_chars].string; char*& ec = TCAP(fc::t_erase_chars);
char*& rp = tcap[fc::t_repeat_char].string; char*& rp = TCAP(fc::t_repeat_char);
bool ut = FTermcap::background_color_erase; bool ut = FTermcap::background_color_erase;
char_data* first_char = &vt->text[y * uInt(vt->width)]; char_data* first_char = &vt->text[y * uInt(vt->width)];
char_data* last_char = &vt->text[(y + 1) * uInt(vt->width) - 1]; char_data* last_char = &vt->text[(y + 1) * uInt(vt->width) - 1];
@ -2653,7 +2656,7 @@ void FVTerm::updateTerminalLine (uInt y)
{ {
if ( FTermcap::eat_nl_glitch ) if ( FTermcap::eat_nl_glitch )
{ {
term_pos->setPoint(-1,-1); term_pos->setPoint(-1, -1);
} }
else if ( FTermcap::automatic_right_margin ) else if ( FTermcap::automatic_right_margin )
{ {
@ -2677,7 +2680,7 @@ bool FVTerm::updateTerminalCursor()
if ( isInsideTerminal(x, y) ) if ( isInsideTerminal(x, y) )
{ {
setTermXY (x,y); setTermXY (x, y);
showCursor(); showCursor();
return true; return true;
} }
@ -2694,7 +2697,7 @@ bool FVTerm::isInsideTerminal (int x, int y)
// Check whether the coordinates are within the virtual terminal // Check whether the coordinates are within the virtual terminal
FRect term_geometry (0, 0, getColumnNumber(), getLineNumber()); FRect term_geometry (0, 0, getColumnNumber(), getLineNumber());
if ( term_geometry.contains(x,y) ) if ( term_geometry.contains(x, y) )
return true; return true;
else else
return false; return false;
@ -2782,8 +2785,8 @@ inline void FVTerm::charsetChanges (char_data*& next_char)
else if ( Encoding == fc::PC ) else if ( Encoding == fc::PC )
{ {
next_char->attr.bit.pc_charset = true; next_char->attr.bit.pc_charset = true;
// Character 0x00..0x1f
if ( isXTerminal() && hasUTF8() && ch_enc < 0x20 ) // Character 0x00..0x1f if ( isXTerminal() && hasUTF8() && ch_enc < 0x20 )
next_char->code = int(charEncode(code, fc::ASCII)); next_char->code = int(charEncode(code, fc::ASCII));
} }
} }
@ -2830,8 +2833,8 @@ inline void FVTerm::appendAttributes (char_data*& next_attr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FVTerm::appendLowerRight (char_data*& screen_char) int FVTerm::appendLowerRight (char_data*& screen_char)
{ {
char* SA = tcap[fc::t_enter_am_mode].string; char* SA = TCAP(fc::t_enter_am_mode);
char* RA = tcap[fc::t_exit_am_mode].string; char* RA = TCAP(fc::t_exit_am_mode);
if ( ! FTermcap::automatic_right_margin ) if ( ! FTermcap::automatic_right_margin )
{ {
@ -2846,11 +2849,11 @@ int FVTerm::appendLowerRight (char_data*& screen_char)
else else
{ {
int x, y; int x, y;
char* IC = tcap[fc::t_parm_ich].string; char* IC = TCAP(fc::t_parm_ich);
char* im = tcap[fc::t_enter_insert_mode].string; char* im = TCAP(fc::t_enter_insert_mode);
char* ei = tcap[fc::t_exit_insert_mode].string; char* ei = TCAP(fc::t_exit_insert_mode);
char* ip = tcap[fc::t_insert_padding].string; char* ip = TCAP(fc::t_insert_padding);
char* ic = tcap[fc::t_insert_character].string; char* ic = TCAP(fc::t_insert_character);
x = getColumnNumber() - 2; x = getColumnNumber() - 2;
y = getLineNumber() - 1; y = getLineNumber() - 1;
@ -2890,14 +2893,14 @@ int FVTerm::appendLowerRight (char_data*& screen_char)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::appendOutputBuffer (std::string& s) inline void FVTerm::appendOutputBuffer (const std::string& s)
{ {
const char* const& c_string = s.c_str(); const char* const& c_string = s.c_str();
tputs (c_string, 1, appendOutputBuffer); tputs (c_string, 1, appendOutputBuffer);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::appendOutputBuffer (const char* const& s) inline void FVTerm::appendOutputBuffer (const char*& s)
{ {
tputs (s, 1, appendOutputBuffer); tputs (s, 1, appendOutputBuffer);
} }

View File

@ -400,8 +400,8 @@ class FVTerm : public FObject, public FTerm
static void appendChar (char_data*&); static void appendChar (char_data*&);
static void appendAttributes (char_data*&); static void appendAttributes (char_data*&);
static int appendLowerRight (char_data*&); static int appendLowerRight (char_data*&);
static void appendOutputBuffer (std::string&); static void appendOutputBuffer (const std::string&);
static void appendOutputBuffer (const char* const&); static void appendOutputBuffer (const char*&);
static int appendOutputBuffer (int); static int appendOutputBuffer (int);
// Data Members // Data Members

View File

@ -1,6 +1,8 @@
// File: fwidget.cpp // File: fwidget.cpp
// Provides: class FWidget // Provides: class FWidget
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fmenubar.h" #include "fmenubar.h"
#include "fstatusbar.h" #include "fstatusbar.h"
@ -44,19 +46,19 @@ FWidget::FWidget (FWidget* parent, bool disable_alt_screen)
, focus(false) , focus(false)
, focusable(true) , focusable(true)
, visible_cursor(true) , visible_cursor(true)
, widget_cursor_position(-1,-1) , widget_cursor_position(-1, -1)
, size_hints() , size_hints()
, double_flatline_mask() , double_flatline_mask()
, padding() , padding()
, ignore_padding(false) , ignore_padding(false)
, wsize(1,1,1,1) , wsize(1, 1, 1, 1)
, adjust_wsize(1,1,1,1) , adjust_wsize(1, 1, 1, 1)
, adjust_wsize_term() , adjust_wsize_term()
, adjust_wsize_shadow() , adjust_wsize_shadow()
, adjust_wsize_term_shadow() , adjust_wsize_term_shadow()
, offset() , offset()
, client_offset() , client_offset()
, wshadow(0,0) , wshadow(0, 0)
, foreground_color(fc::Default) , foreground_color(fc::Default)
, background_color(fc::Default) , background_color(fc::Default)
, statusbar_message() , statusbar_message()
@ -263,7 +265,6 @@ FPoint FWidget::getPrintPos()
int cy = cur.getY(); int cy = cur.getY();
return FPoint ( cx - offset.getX1() - getX() + 1 return FPoint ( cx - offset.getX1() - getX() + 1
, cy - offset.getY1() - getY() + 1 ); , cy - offset.getY1() - getY() + 1 );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -450,8 +451,8 @@ void FWidget::setPos (int x, int y, bool adjust)
y = 1; y = 1;
} }
wsize.setPos(x,y); wsize.setPos(x, y);
adjust_wsize.setPos(x,y); adjust_wsize.setPos(x, y);
if ( adjust ) if ( adjust )
adjustSize(); adjustSize();
@ -710,7 +711,7 @@ bool FWidget::setCursorPos (register int x, register int y)
{ {
// sets the input cursor position // sets the input cursor position
widget_cursor_position.setPoint(x,y); widget_cursor_position.setPoint(x, y);
if ( (flags & fc::focus) == 0 || isWindowWidget() ) if ( (flags & fc::focus) == 0 || isWindowWidget() )
return false; return false;
@ -857,7 +858,7 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
if ( widget->isEnabled() if ( widget->isEnabled()
&& widget->isVisible() && widget->isVisible()
&& ! widget->isWindowWidget() && ! widget->isWindowWidget()
&& widget->getTermGeometry().contains(x,y) ) && widget->getTermGeometry().contains(x, y) )
{ {
FWidget* child = childWidgetAt(widget, x, y); FWidget* child = childWidgetAt(widget, x, y);
return (child != 0) ? child : widget; return (child != 0) ? child : widget;
@ -1405,8 +1406,8 @@ void FWidget::detectTermSize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::move (int dx, int dy) void FWidget::move (int dx, int dy)
{ {
wsize.move(dx,dy); wsize.move(dx, dy);
adjust_wsize.move(dx,dy); adjust_wsize.move(dx, dy);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1572,9 +1573,11 @@ void FWidget::drawFlatBorder()
setPrintPos (x1 - 1, y1 + y + 1); setPrintPos (x1 - 1, y1 + y + 1);
if ( double_flatline_mask.left[uLong(y)] ) if ( double_flatline_mask.left[uLong(y)] )
print (fc::NF_rev_border_line_right_and_left); // left+right line (on left side) // left+right line (on left side)
print (fc::NF_rev_border_line_right_and_left);
else else
print (fc::NF_rev_border_line_right); // right line (on left side) // right line (on left side)
print (fc::NF_rev_border_line_right);
} }
setPrintPos (x2, y1 + 1); setPrintPos (x2, y1 + 1);
@ -1582,9 +1585,11 @@ void FWidget::drawFlatBorder()
for (int y = 0; y < getHeight(); y++) for (int y = 0; y < getHeight(); y++)
{ {
if ( double_flatline_mask.right[uLong(y)] ) if ( double_flatline_mask.right[uLong(y)] )
print (fc::NF_rev_border_line_right_and_left); // left+right line (on right side) // left+right line (on right side)
print (fc::NF_rev_border_line_right_and_left);
else else
print (fc::NF_border_line_left); // left line (on right side) // left line (on right side)
print (fc::NF_border_line_left);
setPrintPos (x2, y1 + y + 2); setPrintPos (x2, y1 + y + 2);
} }
@ -1594,9 +1599,11 @@ void FWidget::drawFlatBorder()
for (int x = 0; x < getWidth(); x++) for (int x = 0; x < getWidth(); x++)
{ {
if ( double_flatline_mask.top[uLong(x)] ) if ( double_flatline_mask.top[uLong(x)] )
print (fc::NF_border_line_up_and_down); // top+bottom line (at top) // top+bottom line (at top)
print (fc::NF_border_line_up_and_down);
else else
print (fc::NF_border_line_bottom); // bottom line (at top) // bottom line (at top)
print (fc::NF_border_line_bottom);
} }
setPrintPos (x1, y2); setPrintPos (x1, y2);
@ -1604,9 +1611,11 @@ void FWidget::drawFlatBorder()
for (int x = 0; x < getWidth(); x++) for (int x = 0; x < getWidth(); x++)
{ {
if ( double_flatline_mask.bottom[uLong(x)] ) if ( double_flatline_mask.bottom[uLong(x)] )
print (fc::NF_border_line_up_and_down); // top+bottom line (at bottom) // top+bottom line (at bottom)
print (fc::NF_border_line_up_and_down);
else else
print (fc::NF_border_line_upper); // top line (at bottom) // top line (at bottom)
print (fc::NF_border_line_upper);
} }
} }

View File

@ -71,6 +71,8 @@
#ifndef FWIDGET_H #ifndef FWIDGET_H
#define FWIDGET_H #define FWIDGET_H
#include <vector>
#include "fvterm.h" #include "fvterm.h"
@ -804,7 +806,7 @@ inline bool FWidget::setCursorPos (const FPoint& pos)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::unsetCursorPos() inline void FWidget::unsetCursorPos()
{ setCursorPos(-1,-1); } { setCursorPos(-1, -1); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::setPrintPos (const FPoint& pos) inline void FWidget::setPrintPos (const FPoint& pos)

View File

@ -25,7 +25,7 @@ FWindow::FWindow(FWidget* parent)
{ {
setWindowWidget(); setWindowWidget();
FRect geometry = getTermGeometry(); FRect geometry = getTermGeometry();
geometry.move(-1,-1); geometry.move(-1, -1);
createArea (geometry, getShadow(), vwin); createArea (geometry, getShadow(), vwin);
addWindow (this); addWindow (this);
} }
@ -358,7 +358,7 @@ void FWindow::setWidth (int w, bool adjust)
if ( isVirtualWindow() && getWidth() != old_width ) if ( isVirtualWindow() && getWidth() != old_width )
{ {
FRect geometry = getTermGeometry(); FRect geometry = getTermGeometry();
geometry.move(-1,-1); geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin); resizeArea (geometry, getShadow(), vwin);
} }
} }
@ -372,7 +372,7 @@ void FWindow::setHeight (int h, bool adjust)
if ( isVirtualWindow() && getHeight() != old_height ) if ( isVirtualWindow() && getHeight() != old_height )
{ {
FRect geometry = getTermGeometry(); FRect geometry = getTermGeometry();
geometry.move(-1,-1); geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin); resizeArea (geometry, getShadow(), vwin);
} }
} }
@ -384,10 +384,11 @@ void FWindow::setSize (int w, int h, bool adjust)
int old_height = getHeight(); int old_height = getHeight();
FWidget::setSize (w, h, adjust); FWidget::setSize (w, h, adjust);
if ( isVirtualWindow() && (getWidth() != old_width || getHeight() != old_height) ) if ( isVirtualWindow()
&& (getWidth() != old_width || getHeight() != old_height) )
{ {
FRect geometry = getTermGeometry(); FRect geometry = getTermGeometry();
geometry.move(-1,-1); geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin); resizeArea (geometry, getShadow(), vwin);
} }
} }
@ -413,7 +414,7 @@ void FWindow::setGeometry (int x, int y, int w, int h, bool adjust)
if ( getWidth() != old_width || getHeight() != old_height ) if ( getWidth() != old_width || getHeight() != old_height )
{ {
FRect geometry = getTermGeometry(); FRect geometry = getTermGeometry();
geometry.move(-1,-1); geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin); resizeArea (geometry, getShadow(), vwin);
} }
else else
@ -429,7 +430,7 @@ void FWindow::setGeometry (int x, int y, int w, int h, bool adjust)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWindow::move (int dx, int dy) void FWindow::move (int dx, int dy)
{ {
FWidget::move (dx,dy); FWidget::move (dx, dy);
if ( isVirtualWindow() ) if ( isVirtualWindow() )
{ {
@ -456,12 +457,11 @@ FWindow* FWindow::getWindowWidgetAt (int x, int y)
FWindow* w = static_cast<FWindow*>(*iter); FWindow* w = static_cast<FWindow*>(*iter);
if ( ! w->isWindowHidden() if ( ! w->isWindowHidden()
&& w->getTermGeometry().contains(x,y) ) && w->getTermGeometry().contains(x, y) )
return w; return w;
} }
} }
while ( iter != begin ); while ( iter != begin );
} }
return 0; return 0;
@ -779,10 +779,11 @@ void FWindow::setShadowSize (int right, int bottom)
new_right = getShadow().getX(); new_right = getShadow().getX();
new_bottom = getShadow().getY(); new_bottom = getShadow().getY();
if ( isVirtualWindow() && (new_right != old_right || new_bottom != old_bottom) ) if ( isVirtualWindow()
&& (new_right != old_right || new_bottom != old_bottom) )
{ {
FRect geometry = getTermGeometry(); FRect geometry = getTermGeometry();
geometry.move(-1,-1); geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin); resizeArea (geometry, getShadow(), vwin);
} }
} }

View File

@ -8,6 +8,7 @@
#include <cmath> #include <cmath>
#include <cstdlib> #include <cstdlib>
#include <limits> #include <limits>
#include <map>
#include <stack> #include <stack>
#include "fapplication.h" #include "fapplication.h"
@ -277,7 +278,6 @@ Calc::Calc (FWidget* parent)
); );
calculator_buttons[button(key)] = btn; calculator_buttons[button(key)] = btn;
} }
calculator_buttons[On]->addAccelerator(fc::Fkey_dc); // del key calculator_buttons[On]->addAccelerator(fc::Fkey_dc); // del key
@ -329,7 +329,7 @@ void Calc::drawDispay()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
setPrintPos (3,3); setPrintPos (3, 3);
print(display); print(display);
print(L' '); print(L' ');
setColor(wc.dialog_fg, wc.dialog_bg); setColor(wc.dialog_fg, wc.dialog_bg);
@ -339,16 +339,16 @@ void Calc::drawDispay()
if ( isNewFont() ) if ( isNewFont() )
{ {
FString bottom_line(33, wchar_t(fc::NF_border_line_bottom)); FString bottom_line (33, wchar_t(fc::NF_border_line_bottom));
setPrintPos (3,2); setPrintPos (3, 2);
print (bottom_line); print (bottom_line);
setPrintPos (2,3); setPrintPos (2, 3);
print (wchar_t(fc::NF_rev_border_line_right)); print (wchar_t(fc::NF_rev_border_line_right));
setPrintPos (36,3); setPrintPos (36, 3);
print (wchar_t(fc::NF_border_line_left)); print (wchar_t(fc::NF_border_line_left));
FString top_bottom_line_5(5, wchar_t(fc::NF_border_line_up_and_down)); FString top_bottom_line_5 (5, wchar_t(fc::NF_border_line_up_and_down));
FString top_line_2(2, wchar_t(fc::NF_border_line_upper)); FString top_line_2 (2, wchar_t(fc::NF_border_line_upper));
setPrintPos (3,4); setPrintPos (3, 4);
print ( top_bottom_line_5 + top_line_2 print ( top_bottom_line_5 + top_line_2
+ top_bottom_line_5 + top_line_2 + top_bottom_line_5 + top_line_2
+ top_bottom_line_5 + top_line_2 + top_bottom_line_5 + top_line_2
@ -360,7 +360,7 @@ void Calc::drawDispay()
FString separator = FString(wchar_t(fc::BoxDrawingsVerticalAndRight)) FString separator = FString(wchar_t(fc::BoxDrawingsVerticalAndRight))
+ FString(35, wchar_t(fc::BoxDrawingsHorizontal)) + FString(35, wchar_t(fc::BoxDrawingsHorizontal))
+ FString(wchar_t(fc::BoxDrawingsVerticalAndLeft)); + FString(wchar_t(fc::BoxDrawingsVerticalAndLeft));
setPrintPos (1,4); setPrintPos (1, 4);
print(separator); print(separator);
} }
} }
@ -449,8 +449,6 @@ inline void Calc::clearInfixOperator()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Calc::calcInfixOperator() void Calc::calcInfixOperator()
{ {
using namespace std;
switch ( infix_operator ) switch ( infix_operator )
{ {
case '*': case '*':
@ -576,8 +574,6 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
lDouble* x; lDouble* x;
lDouble infinity = std::numeric_limits<lDouble>::infinity(); lDouble infinity = std::numeric_limits<lDouble>::infinity();
using namespace std;
if ( infix_operator ) if ( infix_operator )
x = &b; x = &b;
else else
@ -597,7 +593,7 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
if ( errno == EDOM || errno == ERANGE ) if ( errno == EDOM || errno == ERANGE )
error = true; error = true;
if ( fabs(*x - infinity) < LDBL_EPSILON ) // x = ∞ if ( std::fabs(*x - infinity) < LDBL_EPSILON ) // x = ∞
error = true; error = true;
} }
else else
@ -633,7 +629,7 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
if ( errno == EDOM || errno == ERANGE ) if ( errno == EDOM || errno == ERANGE )
error = true; error = true;
if ( fabs(*x - infinity) < LDBL_EPSILON ) // x = ∞ if ( std::fabs(*x - infinity) < LDBL_EPSILON ) // x = ∞
error = true; error = true;
} }
else else
@ -775,7 +771,7 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
break; break;
case Powers_of_ten: // 10ˣ case Powers_of_ten: // 10ˣ
*x = std::pow(10,*x); *x = std::pow(10, *x);
if ( errno == EDOM || errno == ERANGE ) if ( errno == EDOM || errno == ERANGE )
error = true; error = true;

View File

@ -26,7 +26,7 @@ void cb_quit (FWidget*, FWidget::data_ptr data)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
int x,y,w,h; int x, y, w, h;
FString label_text = "no OS"; FString label_text = "no OS";
// Create the application object // Create the application object

View File

@ -58,7 +58,7 @@ void keyboard::onAccel (FAccelEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void keyboard::draw() void keyboard::draw()
{ {
setPrintPos (1,1); setPrintPos (1, 1);
print() << "---------------\n" print() << "---------------\n"
<< "Press Q to quit\n" << "Press Q to quit\n"
<< "---------------\n"; << "---------------\n";

View File

@ -1,6 +1,8 @@
// File: listbox.cpp // File: listbox.cpp
#include <iostream> #include <iostream>
#include <list>
#include <map>
#include <fstream> #include <fstream>
#include "fapplication.h" #include "fapplication.h"
@ -134,7 +136,7 @@ Listbox::Listbox (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
Listbox::~Listbox() Listbox::~Listbox() // destructor
{ {
delete temp_str; delete temp_str;
delete double_list; delete double_list;

View File

@ -2,6 +2,8 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <string>
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fdialog.h" #include "fdialog.h"
@ -133,7 +135,7 @@ Listview::Listview (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
Listview::~Listview() Listview::~Listview() // destructor
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -100,7 +100,8 @@ Menu::Menu (FWidget* parent)
FMenuItem* Line3 = new FMenuItem (Edit); FMenuItem* Line3 = new FMenuItem (Edit);
Line3->setSeparator(); Line3->setSeparator();
FMenuItem* Cut = new FMenuItem (fc::Fckey_x, "Cu&t", Edit); FMenuItem* Cut = new FMenuItem (fc::Fckey_x, "Cu&t", Edit);
Cut->setStatusbarMessage ("Remove the input text and put it in the clipboard"); Cut->setStatusbarMessage ( "Remove the input text "
"and put it in the clipboard" );
FMenuItem* Copy = new FMenuItem (fc::Fckey_c, "&Copy", Edit); FMenuItem* Copy = new FMenuItem (fc::Fckey_c, "&Copy", Edit);
Copy->setStatusbarMessage ("Copy the input text into the clipboad"); Copy->setStatusbarMessage ("Copy the input text into the clipboad");
FMenuItem* Paste = new FMenuItem (fc::Fckey_v, "&Paste", Edit); FMenuItem* Paste = new FMenuItem (fc::Fckey_v, "&Paste", Edit);
@ -184,19 +185,19 @@ Menu::Menu (FWidget* parent)
// Headline labels // Headline labels
FLabel* Headline1 = new FLabel(" Key ", this); FLabel* Headline1 = new FLabel(" Key ", this);
Headline1->ignorePadding(); Headline1->ignorePadding();
Headline1->setGeometry(3,2,5,1); Headline1->setGeometry(3, 2, 5, 1);
Headline1->setEmphasis(); Headline1->setEmphasis();
FLabel* Headline2 = new FLabel(" Function ", this); FLabel* Headline2 = new FLabel(" Function ", this);
Headline2->ignorePadding(); Headline2->ignorePadding();
Headline2->setGeometry(19,2,10,1); Headline2->setGeometry(19, 2, 10, 1);
Headline2->setEmphasis(); Headline2->setEmphasis();
// Info label // Info label
FLabel* Info = new FLabel("<F10> Activate menu bar\n" FLabel* Info = new FLabel("<F10> Activate menu bar\n"
"<Ctrl>+<Space> Activate menu bar\n" "<Ctrl>+<Space> Activate menu bar\n"
"<Meta>+<X> Exit", this); "<Meta>+<X> Exit", this);
Info->setGeometry(2,1,36,3); Info->setGeometry(2, 1, 36, 3);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -337,7 +337,7 @@ MouseDraw::MouseDraw (FWidget* parent)
{ {
setText ("Drawing with the mouse"); setText ("Drawing with the mouse");
c_chooser = new ColorChooser(this); c_chooser = new ColorChooser(this);
c_chooser->setPos (1,1); c_chooser->setPos (1, 1);
c_chooser->addCallback c_chooser->addCallback
( (
"clicked", "clicked",
@ -345,7 +345,7 @@ MouseDraw::MouseDraw (FWidget* parent)
); );
brush = new Brushes(this); brush = new Brushes(this);
brush->setPos (1,12); brush->setPos (1, 12);
FPoint no_shadow(0,0); FPoint no_shadow(0,0);
FRect scroll_geometry(0, 0, 1, 1); FRect scroll_geometry(0, 0, 1, 1);

View File

@ -1,6 +1,8 @@
// File: opti-move.cpp // File: opti-move.cpp
#include <iomanip> #include <iomanip>
#include <string>
#include "fapplication.h" #include "fapplication.h"
#include "fvterm.h" #include "fvterm.h"

View File

@ -1,12 +1,14 @@
// File: string-operations.cpp // File: string-operations.cpp
#include <clocale>
#include <iomanip>
#include <langinfo.h> #include <langinfo.h>
#include <term.h> #include <term.h>
#include <unistd.h> #include <unistd.h>
#include <clocale>
#include <iomanip>
#include <string>
#include <vector>
#include "fstring.h" #include "fstring.h"
@ -70,19 +72,23 @@ int main (int, char**)
std::cout << " add: " << add1 << std::endl; std::cout << " add: " << add1 << std::endl;
// Test: concatenate a FString and a c++ wide string (operator +) // Test: concatenate a FString and a c++ wide string (operator +)
const FString& add2 = FString("FString + ") + std::wstring(L"std::wstring"); const FString& add2 = FString("FString + ")
+ std::wstring(L"std::wstring");
std::cout << " add: " << add2 << std::endl; std::cout << " add: " << add2 << std::endl;
// Test: concatenate a FString and a wide string (operator +) // Test: concatenate a FString and a wide string (operator +)
const FString& add3 = FString("FString + ") + const_cast<wchar_t*>(L"wchar_t*"); const FString& add3 = FString("FString + ")
+ const_cast<wchar_t*>(L"wchar_t*");
std::cout << " add: " << add3 << std::endl; std::cout << " add: " << add3 << std::endl;
// Test: concatenate a FString and a c++ string (operator +) // Test: concatenate a FString and a c++ string (operator +)
const FString& add4 = FString("FString + ") + std::string("std::string"); const FString& add4 = FString("FString + ")
+ std::string("std::string");
std::cout << " add: " << add4 << std::endl; std::cout << " add: " << add4 << std::endl;
// Test: concatenate a FString and a c-string (operator +) // Test: concatenate a FString and a c-string (operator +)
const FString& add5 = FString("FString + ") + const_cast<char*>("char*"); const FString& add5 = FString("FString + ")
+ const_cast<char*>("char*");
std::cout << " add: " << add5 << std::endl; std::cout << " add: " << add5 << std::endl;
// Test: concatenate a FString and a wide character (operator +) // Test: concatenate a FString and a wide character (operator +)
@ -102,19 +108,23 @@ int main (int, char**)
std::cout << " add: " << add9 << std::endl; std::cout << " add: " << add9 << std::endl;
// Test: concatenate a c-string and a FString (operator +) // Test: concatenate a c-string and a FString (operator +)
const FString& add10 = const_cast<char*>("char*") + FString(" + FString"); const FString& add10 = const_cast<char*>("char*")
+ FString(" + FString");
std::cout << " add: " << add10 << std::endl; std::cout << " add: " << add10 << std::endl;
// Test: concatenate a c++ string and a FString (operator +) // Test: concatenate a c++ string and a FString (operator +)
const FString& add11 = std::string("std::string") + FString(" + FString"); const FString& add11 = std::string("std::string")
+ FString(" + FString");
std::cout << " add: " << add11 << std::endl; std::cout << " add: " << add11 << std::endl;
// Test: concatenate a wide string and a FString (operator +) // Test: concatenate a wide string and a FString (operator +)
const FString& add12 = const_cast<wchar_t*>(L"wchar_t*") + FString(" + FString"); const FString& add12 = const_cast<wchar_t*>(L"wchar_t*")
+ FString(" + FString");
std::cout << " add: " << add12 << std::endl; std::cout << " add: " << add12 << std::endl;
// Test: concatenate a c++ wide string and a FString (operator +) // Test: concatenate a c++ wide string and a FString (operator +)
const FString& add13 = std::wstring(L"std::wstring") + FString(" + FString"); const FString& add13 = std::wstring(L"std::wstring")
+ FString(" + FString");
std::cout << " add: " << add13 << std::endl; std::cout << " add: " << add13 << std::endl;
// Test: compare operators ==, <=, <, >=, >, != // Test: compare operators ==, <=, <, >=, >, !=
@ -268,7 +278,7 @@ int main (int, char**)
// Test: extract a substring of 27 characters from position 12 // Test: extract a substring of 27 characters from position 12
std::cout << " mid: \"" std::cout << " mid: \""
<< alphabet.mid(13,27) << "\"" << std::endl; << alphabet.mid(13, 27) << "\"" << std::endl;
// Test: 11 characters from the right of the string // Test: 11 characters from the right of the string
std::cout << " right: \"" std::cout << " right: \""
@ -327,7 +337,7 @@ int main (int, char**)
// Test: remove 2 characters at position 7 // Test: remove 2 characters at position 7
FString remove_std = "A fast remove"; FString remove_std = "A fast remove";
std::cout << " remove: " std::cout << " remove: "
<< remove_std.remove(7,2) << std::endl; << remove_std.remove(7, 2) << std::endl;
// Test: includes a substring (positive test) // Test: includes a substring (positive test)
FString include_std = "string"; FString include_std = "string";

View File

@ -45,7 +45,6 @@ class AttribDlg : public FDialog
// Data Members // Data Members
FButton* next_button; FButton* next_button;
FButton* back_button; FButton* back_button;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -187,7 +186,7 @@ class AttribDemo : public FWidget
// Event handler // Event handler
void onWheel (FWheelEvent* ev) void onWheel (FWheelEvent* ev)
{ {
AttribDlg* p = dynamic_cast<AttribDlg*>(getParentWidget()); AttribDlg* p = static_cast<AttribDlg*>(getParentWidget());
if ( p ) if ( p )
p->onWheel(ev); p->onWheel(ev);
@ -402,7 +401,7 @@ int main (int argc, char* argv[])
dialog->setShadow(); dialog->setShadow();
AttribDemo* demo = new AttribDemo(dialog); AttribDemo* demo = new AttribDemo(dialog);
demo->setGeometry (1,1,67,19); demo->setGeometry (1, 1, 67, 19);
app.setMainWidget(dialog); app.setMainWidget(dialog);
dialog->show(); dialog->show();

View File

@ -1,7 +1,9 @@
// File: opti-move.cpp // File: termcap.cpp
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <string>
#include "fapplication.h" #include "fapplication.h"
#include "ftermcap.h" #include "ftermcap.h"
#include "fvterm.h" #include "fvterm.h"

View File

@ -218,9 +218,9 @@ void MainWindow::draw()
setReverse(true); setReverse(true);
setColor(); setColor();
setPrintPos (2,4); setPrintPos (2, 4);
print(line1); print(line1);
setPrintPos (2,5); setPrintPos (2, 5);
print(line2); print(line2);
if ( isMonochron() ) if ( isMonochron() )

View File

@ -2,6 +2,8 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <string>
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fdialog.h" #include "fdialog.h"
@ -92,7 +94,7 @@ Treeview::Treeview (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
Treeview::~Treeview() Treeview::~Treeview() // destructor
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -1,7 +1,8 @@
// File: ui.cpp // File: ui.cpp
#include <iostream>
#include <fstream> #include <fstream>
#include <iostream>
#include <string>
#include "final.h" #include "final.h"
@ -97,7 +98,7 @@ ProgressDialog::ProgressDialog (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
ProgressDialog::~ProgressDialog() ProgressDialog::~ProgressDialog() // destructor
{ {
delOwnTimer(); delOwnTimer();
delCallback(quit); delCallback(quit);
@ -212,7 +213,7 @@ TextWindow::TextWindow (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
TextWindow::~TextWindow() TextWindow::~TextWindow() // destructor
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -332,7 +333,8 @@ MyDialog::MyDialog (FWidget* parent)
FMenuItem* Line2 = new FMenuItem (Edit); FMenuItem* Line2 = new FMenuItem (Edit);
Line2->setSeparator(); Line2->setSeparator();
FMenuItem* Cut = new FMenuItem (fc::Fckey_x, "Cu&t", Edit); FMenuItem* Cut = new FMenuItem (fc::Fckey_x, "Cu&t", Edit);
Cut->setStatusbarMessage ("Remove the input text and put it in the clipboard"); Cut->setStatusbarMessage ( "Remove the input text"
" and put it in the clipboard" );
FMenuItem* Copy = new FMenuItem (fc::Fckey_c, "&Copy", Edit); FMenuItem* Copy = new FMenuItem (fc::Fckey_c, "&Copy", Edit);
Copy->setStatusbarMessage ("Copy the input text into the clipboad"); Copy->setStatusbarMessage ("Copy the input text into the clipboad");
FMenuItem* Paste = new FMenuItem (fc::Fckey_v, "&Paste", Edit); FMenuItem* Paste = new FMenuItem (fc::Fckey_v, "&Paste", Edit);
@ -405,21 +407,21 @@ MyDialog::MyDialog (FWidget* parent)
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view), F_METHOD_CALLBACK (this, &MyDialog::cb_view),
dynamic_cast<FWidget::data_ptr>(File1) static_cast<FWidget::data_ptr>(File1)
); );
File2->addCallback File2->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view), F_METHOD_CALLBACK (this, &MyDialog::cb_view),
dynamic_cast<FWidget::data_ptr>(File2) static_cast<FWidget::data_ptr>(File2)
); );
File3->addCallback File3->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view), F_METHOD_CALLBACK (this, &MyDialog::cb_view),
dynamic_cast<FWidget::data_ptr>(File3) static_cast<FWidget::data_ptr>(File3)
); );
// Buttons // Buttons
@ -563,7 +565,7 @@ MyDialog::MyDialog (FWidget* parent)
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_input2buttonText), F_METHOD_CALLBACK (this, &MyDialog::cb_input2buttonText),
dynamic_cast<FWidget::data_ptr>(myLineEdit) static_cast<FWidget::data_ptr>(myLineEdit)
); );
MyButton5->addCallback MyButton5->addCallback
@ -588,21 +590,21 @@ MyDialog::MyDialog (FWidget* parent)
( (
"toggled", "toggled",
F_METHOD_CALLBACK (this, &MyDialog::cb_activateButton), F_METHOD_CALLBACK (this, &MyDialog::cb_activateButton),
dynamic_cast<FWidget::data_ptr>(MyButton5) static_cast<FWidget::data_ptr>(MyButton5)
); );
myList->addCallback myList->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_setInput), F_METHOD_CALLBACK (this, &MyDialog::cb_setInput),
dynamic_cast<FWidget::data_ptr>(myLineEdit) static_cast<FWidget::data_ptr>(myLineEdit)
); );
myList->addCallback myList->addCallback
( (
"row-selected", "row-selected",
F_METHOD_CALLBACK (this, &MyDialog::cb_updateNumber), F_METHOD_CALLBACK (this, &MyDialog::cb_updateNumber),
dynamic_cast<FWidget::data_ptr>(tagged_count) static_cast<FWidget::data_ptr>(tagged_count)
); );
key_F1->addCallback key_F1->addCallback
@ -625,7 +627,7 @@ MyDialog::MyDialog (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
MyDialog::~MyDialog() MyDialog::~MyDialog() // destructor
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -119,16 +119,16 @@ watch::~watch()
void watch::printTime() void watch::printTime()
{ {
FString str; FString str;
std::tm* now; std::tm now;
std::time_t t; std::time_t t;
t = std::time(0); // get current time t = std::time(0); // get current time
now = std::localtime(&t); localtime_r(&t, &now);
if ( sec ) if ( sec )
str.sprintf("%02d:%02d:%02d", now->tm_hour, now->tm_min, now->tm_sec); str.sprintf("%02d:%02d:%02d", now.tm_hour, now.tm_min, now.tm_sec);
else else
str.sprintf("%02d:%02d ", now->tm_hour, now->tm_min); str.sprintf("%02d:%02d ", now.tm_hour, now.tm_min);
time_str->setText(str); time_str->setText(str);
time_str->redraw(); time_str->redraw();

View File

@ -1,5 +1,7 @@
// File: windows.cpp // File: windows.cpp
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fdialog.h" #include "fdialog.h"
#include "fdialoglistmenu.h" #include "fdialoglistmenu.h"
@ -353,7 +355,7 @@ void Window::activateWindow (FDialog* win)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::adjustSize() void Window::adjustSize()
{ {
int w,h,X,Y,dx,dy; int w, h, X, Y, dx, dy;
std::vector<win_data*>::const_iterator iter, begin; std::vector<win_data*>::const_iterator iter, begin;
w = getRootWidget()->getWidth(); w = getRootWidget()->getWidth();
h = getRootWidget()->getHeight(); h = getRootWidget()->getHeight();
@ -372,7 +374,7 @@ void Window::adjustSize()
{ {
if ( (*iter)->is_open ) if ( (*iter)->is_open )
{ {
int x,y,n; int x, y, n;
n = int(std::distance(begin, iter)); n = int(std::distance(begin, iter));
x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3; x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3;
y = dy + 11 + int(n / 3) * 3; y = dy + 11 + int(n / 3) * 3;
@ -405,7 +407,7 @@ void Window::onClose (FCloseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::cb_createWindows (FWidget*, data_ptr) void Window::cb_createWindows (FWidget*, data_ptr)
{ {
int w,h,dx,dy; int w, h, dx, dy;
std::vector<win_data*>::const_iterator iter, begin; std::vector<win_data*>::const_iterator iter, begin;
iter = begin = windows.begin(); iter = begin = windows.begin();
w = getRootWidget()->getWidth(); w = getRootWidget()->getWidth();