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>
* Wrong UTF-8 string length fixed when attaching to FString

View File

@ -1,6 +1,8 @@
// File: fapplication.cpp
// Provides: class FApplication
#include <string>
#include "fapplication.h"
#include "fmenu.h"
#include "fstatusbar.h"
@ -33,7 +35,7 @@ FApplication::eventQueue* FApplication::event_queue = 0;
// constructors and destructor
//----------------------------------------------------------------------
FApplication::FApplication ( int& _argc
FApplication::FApplication ( const int& _argc
, char* _argv[]
, bool disable_alt_screen )
: FWidget(0, disable_alt_screen)
@ -213,7 +215,9 @@ bool FApplication::sendEvent ( const FObject* receiver
return false;
// 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
return w->event(const_cast<FEvent*>(event));
}
@ -536,7 +540,7 @@ void FApplication::processKeyboardEvent()
if ( isKeyPressed )
{
register ssize_t bytesread;
widget->getCurrentTime(time_keypressed);
widget->getCurrentTime (&time_keypressed);
x11_mouse[0] = sgr_mouse[0] = urxvt_mouse[0] = '\0';
if ( quit_now || app_exit_loop )
@ -694,7 +698,6 @@ void FApplication::processKeyboardEvent()
}
}
break;
} // end of switch
}
@ -725,7 +728,7 @@ void FApplication::processKeyboardEvent()
#if defined(__linux__)
//----------------------------------------------------------------------
int FApplication::linuxModifierKeyCorrection (int& key_id)
int FApplication::linuxModifierKeyCorrection (const int& key_id)
{
// get the current modifier key state
FTerm::modifier_key& m = getLinuxModifierKey();
@ -1891,8 +1894,7 @@ void FApplication::processMouseEvent()
clicked_widget = 0;
sendEvent (scroll_over_widget, &wheel_ev);
}
}
} // end of if ( clicked_widget )
#ifdef F_HAVE_LIBGPM
if ( isGpmMouseEnabled() && gpm_ev.x != -1 )
@ -1920,7 +1922,7 @@ int FApplication::processTimerEvent()
timeval currentTime;
int activated = 0;
getCurrentTime (currentTime);
getCurrentTime (&currentTime);
if ( isTimerInUpdating() )
return 0;

View File

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

View File

@ -240,7 +240,8 @@ void FButtonGroup::insert (FToggleButton* button)
// setChecked the first FRadioButton
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) )
first_button->setChecked();
@ -254,8 +255,6 @@ void FButtonGroup::insert (FToggleButton* button)
"toggled",
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
{
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr )
menu_ptr->has_checkable_items = true;

View File

@ -1,8 +1,11 @@
// File: ffiledialog.cpp
// Provides: class FFileDialog
#include <vector>
#include "ffiledialog.h"
// non-member functions
//----------------------------------------------------------------------
bool sortByName ( const FFileDialog::dir_entry& lhs
@ -230,7 +233,6 @@ void FFileDialog::onKeyPress (FKeyEvent* ev)
default:
break;
}
}
//----------------------------------------------------------------------
@ -268,7 +270,8 @@ int FFileDialog::readDir()
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;
dir_entry entry;
@ -280,7 +283,9 @@ int FFileDialog::readDir()
char resolved_path[MAXPATHLEN] = {};
char symLink[MAXPATHLEN] = {};
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
{
@ -310,7 +315,6 @@ int FFileDialog::readDir()
}
else
break;
} // end while
if ( closedir (directory_stream) != 0 )
@ -326,11 +330,17 @@ int FFileDialog::readDir()
dir_num = numOfDirs();
// 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
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
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
filebrowser->clear();
@ -581,19 +591,18 @@ void FFileDialog::init()
//----------------------------------------------------------------------
char* FFileDialog::getHomeDir()
{
struct passwd* pwd;
pwd = getpwuid( geteuid() );
struct passwd pwd;
struct passwd* pwd_ptr;
char buf[1024];
if ( ! pwd )
if ( getpwuid_r (geteuid(), &pwd, buf, sizeof(buf), &pwd_ptr) )
return const_cast<char*>("");
else
{
pwd = getpwnam(pwd->pw_name);
if ( ! pwd )
if ( getpwnam_r (pwd.pw_name, &pwd, buf, sizeof(buf), &pwd_ptr) )
return const_cast<char*>("");
else
return pwd->pw_dir;
return pwd.pw_dir;
}
}
@ -695,7 +704,8 @@ int FFileDialog::changeDir (const FString& dirname)
{
int i = 1;
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();
end = dir_entries.end();

View File

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

View File

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

View File

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

View File

@ -2,6 +2,8 @@
// Provides: class FListBoxItem
// class FListBox
#include <algorithm>
#include "fapplication.h"
#include "flistbox.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
@ -1464,7 +1466,8 @@ void FListBox::drawList()
if ( inc_len > 0 ) // incremental search
{
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
setCursorPos (3 + b, 2 + int(y)); // first character

View File

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

View File

@ -2,6 +2,8 @@
// Provides: class FListViewItem
// class FListView
#include <vector>
#include "fapplication.h"
#include "flistview.h"
#include "fscrollbar.h"
@ -109,7 +111,7 @@ FListViewItem::FListViewItem ( const std::vector<FString>& cols
}
//----------------------------------------------------------------------
FListViewItem::~FListViewItem()
FListViewItem::~FListViewItem() // destructor
{ }

View File

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

View File

@ -1,6 +1,8 @@
// File: fmenu.cpp
// Provides: class FMenu
#include <vector>
#include "fapplication.h"
#include "fdialog.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());
@ -794,14 +796,14 @@ void FMenu::init(FWidget* parent)
{
if ( isMenuBar(parent) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(parent);
FMenuBar* mbar = static_cast<FMenuBar*>(parent);
if ( mbar )
mbar->calculateDimensions();
}
else if ( isMenu(parent) )
{
FMenu* smenu = dynamic_cast<FMenu*>(parent);
FMenu* smenu = static_cast<FMenu*>(parent);
if ( smenu )
smenu->calculateDimensions();
@ -1016,10 +1018,10 @@ FMenu* FMenu::superMenuAt (int x, int y)
if ( super && isMenu(super) )
{
if ( super->getTermGeometry().contains(x, y) )
return dynamic_cast<FMenu*>(super);
return static_cast<FMenu*>(super);
else
{
FMenu* smenu = dynamic_cast<FMenu*>(getSuperMenu());
FMenu* smenu = static_cast<FMenu*>(getSuperMenu());
if ( smenu )
return smenu->superMenuAt(x, y);

View File

@ -1,6 +1,8 @@
// File: fmenubar.cpp
// Provides: class FMenuBar
#include <vector>
#include "fapplication.h"
#include "fmenubar.h"
#include "fstatusbar.h"
@ -20,7 +22,7 @@ FMenuBar::FMenuBar(FWidget* parent)
}
//----------------------------------------------------------------------
FMenuBar::~FMenuBar()
FMenuBar::~FMenuBar() // destructor
{
setMenuBar(0);
}
@ -428,7 +430,8 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
}
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) )
{
FMenuBar* menubar_ptr = dynamic_cast<FMenuBar*>(parent);
FMenuBar* menubar_ptr = static_cast<FMenuBar*>(parent);
if ( menubar_ptr )
menubar_ptr->redraw();
}
else if ( isMenu(parent) )
{
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr )
menu_ptr->redraw();
@ -215,7 +215,7 @@ void FMenuItem::addAccelerator (int key, FWidget* obj)
if ( isMenu(super_menu) )
{
FMenu* menu_ptr = dynamic_cast<FMenu*>(super_menu);
FMenu* menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr )
menu_ptr->calculateDimensions();
@ -248,7 +248,7 @@ void FMenuItem::delAccelerator (FWidget* obj)
if ( isMenu(super_menu) )
{
FMenu* menu_ptr = dynamic_cast<FMenu*>(super_menu);
FMenu* menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr )
menu_ptr->calculateDimensions();
@ -297,7 +297,7 @@ void FMenuItem::onKeyPress (FKeyEvent* ev)
if ( isMenu(super_menu) )
{
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu )
smenu->onKeyPress(ev);
@ -305,7 +305,7 @@ void FMenuItem::onKeyPress (FKeyEvent* ev)
if ( isMenuBar(super_menu) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar )
{
@ -328,7 +328,7 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
if ( isMenu(super_menu) )
{
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu )
{
@ -336,20 +336,22 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
try
{
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDoubleClick_Event
, p2, t, b );
smenu->onMouseDoubleClick(_ev);
delete _ev;
}
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) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar )
{
@ -357,20 +359,22 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
try
{
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDoubleClick_Event
, p2, t, b );
mbar->onMouseDoubleClick(_ev);
delete _ev;
}
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) )
{
FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl )
{
@ -378,13 +382,15 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
try
{
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDoubleClick_Event
, p2, t, b );
dgl->onMouseDoubleClick(_ev);
delete _ev;
}
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) )
{
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu )
{
@ -409,20 +415,22 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
try
{
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDown_Event
, p2, t, b );
smenu->onMouseDown(_ev);
delete _ev;
}
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) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar )
{
@ -430,20 +438,22 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
try
{
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDown_Event
, p2, t, b );
mbar->onMouseDown(_ev);
delete _ev;
}
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) )
{
FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl )
{
@ -451,13 +461,15 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
try
{
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDown_Event
, p2, t, b );
dgl->onMouseDown(_ev);
delete _ev;
}
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) )
{
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu )
{
@ -487,7 +499,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isMenuBar(super_menu) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar )
{
@ -500,7 +512,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isWindowsMenu(super_menu) )
{
FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl )
{
@ -523,7 +535,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isMenu(super_menu) )
{
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu )
{
@ -536,7 +548,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isMenuBar(super_menu) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar )
{
@ -549,7 +561,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isWindowsMenu(super_menu) )
{
FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl )
{
@ -573,7 +585,7 @@ void FMenuItem::onAccel (FAccelEvent* ev)
return;
}
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( ! mbar )
return;
@ -639,7 +651,7 @@ void FMenuItem::onFocusOut (FFocusEvent*)
if ( super_menu && isMenuBar(super_menu) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar )
mbar->redraw();
@ -705,14 +717,15 @@ void FMenuItem::init (FWidget* parent)
if ( isMenuBar(parent) ) // Parent is menubar
{
FMenuBar* menubar_ptr = dynamic_cast<FMenuBar*>(parent);
FMenuBar* menubar_ptr = static_cast<FMenuBar*>(parent);
if ( menubar_ptr )
{
menubar_ptr->calculateDimensions();
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
@ -723,7 +736,7 @@ void FMenuItem::init (FWidget* parent)
}
else if ( isMenu(parent) ) // Parent is menu
{
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr )
menu_ptr->calculateDimensions();
@ -781,7 +794,7 @@ void FMenuItem::createDialogList (FMenu* winmenu)
while ( iter != dialog_list->end() && *iter )
{
FDialog* win = dynamic_cast<FDialog*>(*iter);
FDialog* win = static_cast<FDialog*>(*iter);
if ( win )
{
@ -797,7 +810,8 @@ void FMenuItem::createDialogList (FMenu* winmenu)
}
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;
}
@ -808,7 +822,7 @@ void FMenuItem::createDialogList (FMenu* winmenu)
(
"clicked",
F_METHOD_CALLBACK (win_item, &FMenuItem::cb_switchToDialog),
dynamic_cast<FWidget::data_ptr>(win)
static_cast<FWidget::data_ptr>(win)
);
win->addCallback

View File

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

View File

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

View File

@ -1,6 +1,8 @@
// File: fmessagebox.cpp
// Provides: class FMessageBox
#include <algorithm>
#include "fapplication.h"
#include "fmessagebox.h"
@ -426,7 +428,8 @@ void FMessageBox::draw()
int head_offset = 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() )
setReverse(true);

View File

@ -27,7 +27,6 @@ FObject::FObject (FObject* parent)
if ( parent == 0 )
{
timer_modify_lock = false;
if ( ! timer_list )
@ -95,8 +94,6 @@ FObject::~FObject() // destructor
++iter;
}
}
}
// 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
while ( time.tv_usec >= 1000000 )
while ( time->tv_usec >= 1000000 )
{
time.tv_usec -= 1000000;
time.tv_sec++;
time->tv_usec -= 1000000;
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_sec--;
time->tv_usec += 1000000;
time->tv_sec--;
}
else
{
time.tv_usec = 0;
time->tv_usec = 0;
break;
}
}
@ -232,7 +229,7 @@ int FObject::addTimer (int interval)
time_interval.tv_sec = interval / 1000;
time_interval.tv_usec = (interval % 1000) * 1000;
getCurrentTime (currentTime);
getCurrentTime (&currentTime);
timeval timeout = currentTime + time_interval;
timer_data t = { id, time_interval, timeout, this };

View File

@ -22,24 +22,6 @@
#include "fevent.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
@ -82,7 +64,7 @@ class FObject
void delChild (FObject*);
// Timer methods
static void getCurrentTime (timeval&);
static void getCurrentTime (timeval*);
int addTimer (int);
bool delTimer (int);
bool delOwnTimer();

View File

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

View File

@ -1,8 +1,10 @@
// File: foptimove.cpp
// Provides: class FOptiMove
#include <cstring>
#include "foptimove.h"
#include "string.h"
//----------------------------------------------------------------------
// class FOptiMove
@ -620,24 +622,42 @@ char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
//----------------------------------------------------------------------
void FOptiMove::printDurations()
{
std::cout << " speed: " << baudrate << " baud\r\n";
std::cout << " char_duration: " << char_duration << " ms\r\n";
std::cout << " cursor_home: " << F_cursor_home.duration << " ms\r\n";
std::cout << " cursor_to_ll: " << F_cursor_to_ll.duration << " ms\r\n";
std::cout << " carriage_return: " << F_carriage_return.duration << " ms\r\n";
std::cout << " tab: " << F_tab.duration << " ms\r\n";
std::cout << " back_tab: " << F_back_tab.duration << " ms\r\n";
std::cout << " cursor_up: " << F_cursor_up.duration << " ms\r\n";
std::cout << " cursor_down: " << 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";
std::cout << " speed: "
<< baudrate << " baud\r\n";
std::cout << " char_duration: "
<< char_duration << " ms\r\n";
std::cout << " cursor_home: "
<< F_cursor_home.duration << " ms\r\n";
std::cout << " cursor_to_ll: "
<< F_cursor_to_ll.duration << " ms\r\n";
std::cout << " carriage_return: "
<< F_carriage_return.duration << " ms\r\n";
std::cout << " tab: "
<< F_tab.duration << " ms\r\n";
std::cout << " back_tab: "
<< F_back_tab.duration << " ms\r\n";
std::cout << " cursor_up: "
<< F_cursor_up.duration << " ms\r\n";
std::cout << " cursor_down: "
<< 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 dst_len;
@ -874,7 +894,6 @@ int FOptiMove::relativeMove ( char*& move
std::strncpy (hmove, str, sizeof(move_buf) - 1);
htime = htime_r;
}
}
}
else // to_x < from_x
@ -924,7 +943,6 @@ int FOptiMove::relativeMove ( char*& move
std::strncpy (hmove, str, sizeof(move_buf) - 1);
htime = htime_l;
}
}
}
@ -947,7 +965,8 @@ int FOptiMove::relativeMove ( char*& move
inline bool FOptiMove::isWideMove ( int xold, int yold
, int xnew, int ynew )
{
return bool ( (xnew > MOVE_LIMIT)
&& (xnew < screen_width - 1 - MOVE_LIMIT)
&& (std::abs(xnew - xold) + std::abs(ynew - yold) > MOVE_LIMIT) );
return bool ( xnew > MOVE_LIMIT
&& xnew < screen_width - 1 - 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_clr_bol (char*&);
int set_clr_eol (char*&);
void set_auto_left_margin (bool&);
void set_eat_newline_glitch (bool&);
void set_auto_left_margin (const bool&);
void set_eat_newline_glitch (const bool&);
// Methods
char* moveCursor (int, int, int, int);
@ -94,7 +94,7 @@ class FOptiMove
void calculateCharDuration();
int capDuration (char*&, int);
int capDurationToLength (int);
int repeatedAppend (capability&, int, char*);
int repeatedAppend (const capability&, int, char*);
int relativeMove (char*&, int, int, int, int);
bool isWideMove (int, int, int, int);
@ -135,11 +135,11 @@ class FOptiMove
// 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; }
//----------------------------------------------------------------------
inline void FOptiMove::set_eat_newline_glitch (bool& bcap)
inline void FOptiMove::set_eat_newline_glitch (const bool& bcap)
{ eat_nl_glitch = bcap; }
#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
{
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr )
menu_ptr->has_checkable_items = true;

View File

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

View File

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

View File

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

View File

@ -2,6 +2,8 @@
// Provides: class FStatusKey
// class FStatusBar
#include <vector>
#include "fstatusbar.h"
//----------------------------------------------------------------------
@ -120,7 +122,7 @@ FStatusBar::FStatusBar(FWidget* parent)
}
//----------------------------------------------------------------------
FStatusBar::~FStatusBar()
FStatusBar::~FStatusBar() // destructor
{
// delete all keys
if ( ! key_list.empty() )

View File

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

View File

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

View File

@ -204,7 +204,7 @@ class FString
FString mid (uInt, uInt) const;
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 std::string&);
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)); }
//----------------------------------------------------------------------

View File

@ -1,6 +1,11 @@
// File: fterm.cpp
// Provides: class FTerm
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include "fterm.h"
#include "fcharmap.h"
#include "fkey_map.h"
@ -74,15 +79,15 @@ bool FTerm::cursor_optimisation;
bool FTerm::xterm_default_colors;
bool FTerm::use_alternate_screen = true;
termios FTerm::term_init;
char FTerm::termtype[30] = "";
char FTerm::termtype[256] = {};
char FTerm::term_name[256] = {};
#if DEBUG
char FTerm::termtype_256color[30] = "";
char FTerm::termtype_Answerback[30] = "";
char FTerm::termtype_SecDA[30] = "";
char FTerm::termtype_256color[256] = {};
char FTerm::termtype_Answerback[256] = {};
char FTerm::termtype_SecDA[256] = {};
#endif
char* FTerm::term_name = 0;
char* FTerm::locale_name = 0;
char* FTerm::locale_xterm = 0;
FPoint* FTerm::mouse = 0;
@ -249,7 +254,7 @@ bool FTerm::isKeyTimeout (timeval* time, register long timeout)
struct timeval now;
struct timeval diff;
FObject::getCurrentTime(now);
FObject::getCurrentTime(&now);
diff.tv_sec = now.tv_sec - time->tv_sec;
diff.tv_usec = now.tv_usec - time->tv_usec;
@ -309,7 +314,7 @@ void FTerm::setFreeBSDConsoleCursorStyle ( fc::freebsdConsoleCursorStyle style
#endif
//----------------------------------------------------------------------
void FTerm::setTTY (termios& t)
void FTerm::setTTY (const termios& t)
{
tcsetattr (stdin_no, TCSADRAIN, &t);
}
@ -758,7 +763,6 @@ bool FTerm::setOldFont()
setUnicodeMap (&screen_unicode_map);
delete[] screen_unicode_map.entries;
}
}
detectTermSize();
@ -777,7 +781,7 @@ char* FTerm::moveCursor (int xold, int yold, int xnew, int ynew)
if ( cursor_optimisation )
return opti_move->moveCursor (xold, yold, xnew, ynew);
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*& vs = tcap[fc::t_cursor_visible].string;
char*& ve = tcap[fc::t_cursor_normal].string;
char*& vs = TCAP(fc::t_cursor_visible);
char*& ve = TCAP(fc::t_cursor_normal);
if ( ve )
return ve;
@ -803,7 +807,7 @@ char* FTerm::enableCursor()
//----------------------------------------------------------------------
char* FTerm::disableCursor()
{
char*& vi = tcap[fc::t_cursor_invisible].string;
char*& vi = TCAP(fc::t_cursor_invisible);
if ( vi )
return vi;
@ -1277,8 +1281,8 @@ void FTerm::saveColorMap()
//----------------------------------------------------------------------
void FTerm::resetColorMap()
{
char*& op = tcap[fc::t_orig_pair].string;
char*& oc = tcap[fc::t_orig_colors].string;
char*& op = TCAP(fc::t_orig_pair);
char*& oc = TCAP(fc::t_orig_colors);
if ( op )
putstring (op);
@ -1312,8 +1316,8 @@ void FTerm::resetColorMap()
//----------------------------------------------------------------------
void FTerm::setPalette (short index, int r, int g, int b)
{
char*& Ic = tcap[fc::t_initialize_color].string;
char*& Ip = tcap[fc::t_initialize_pair].string;
char*& Ic = TCAP(fc::t_initialize_color);
char*& Ip = TCAP(fc::t_initialize_pair);
index = FOptiAttr::vga2ansi(index);
@ -1386,9 +1390,9 @@ void FTerm::resetBeep()
//----------------------------------------------------------------------
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);
}
}
@ -1442,9 +1446,8 @@ void FTerm::setEncoding (std::string enc)
opti_move->set_tabular (empty);
}
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()
{
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);
return true;
}
@ -1476,9 +1479,9 @@ bool FTerm::scrollTermForward()
//----------------------------------------------------------------------
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);
return true;
}
@ -2051,7 +2054,7 @@ int FTerm::openConsole()
if ( fd_tty >= 0 ) // console is already opened
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("/dev/tty", 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);
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
const char* term_basename = std::strrchr(term_name, '/');
@ -2890,13 +2893,13 @@ void FTerm::init_alt_charset()
{
// 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
uChar p1 = uChar(tcap[fc::t_acs_chars].string[n]);
uChar p2 = uChar(tcap[fc::t_acs_chars].string[n + 1]);
uChar p1 = uChar(TCAP(fc::t_acs_chars)[n]);
uChar p2 = uChar(TCAP(fc::t_acs_chars)[n + 1]);
(*vt100_alt_char)[p1] = p2;
}
}
@ -2942,42 +2945,44 @@ void FTerm::init_pc_charset()
if ( gnome_terminal || linux_terminal )
{
// 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 )
{
// 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");
}
else
{
// Select null mapping
tcap[fc::t_enter_pc_charset_mode].string = \
TCAP(fc::t_enter_pc_charset_mode) = \
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;
}
// 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 )
{
// 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");
}
else
{
// Select ascii mapping
tcap[fc::t_enter_pc_charset_mode].string = \
TCAP(fc::t_enter_pc_charset_mode) = \
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;
}
}
@ -3132,32 +3137,32 @@ void FTerm::init_termcaps()
tcap[i].string = tgetstr(tcap[i].tname, &buffer);
// set invisible cursor for cygwin terminal
if ( cygwin_terminal && ! tcap[fc::t_cursor_invisible].string )
tcap[fc::t_cursor_invisible].string = \
if ( cygwin_terminal && ! TCAP(fc::t_cursor_invisible) )
TCAP(fc::t_cursor_invisible) = \
const_cast<char*>(CSI "?25l");
// set visible cursor for cygwin terminal
if ( cygwin_terminal && ! tcap[fc::t_cursor_visible].string )
tcap[fc::t_cursor_visible].string = \
if ( cygwin_terminal && ! TCAP(fc::t_cursor_visible) )
TCAP(fc::t_cursor_visible) = \
const_cast<char*>(CSI "?25h");
// set ansi blink for cygwin terminal
if ( cygwin_terminal && ! tcap[fc::t_enter_blink_mode].string )
tcap[fc::t_enter_blink_mode].string = \
if ( cygwin_terminal && ! TCAP(fc::t_enter_blink_mode) )
TCAP(fc::t_enter_blink_mode) = \
const_cast<char*>(CSI "5m");
// set enter/exit alternative charset mode for rxvt terminal
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");
tcap[fc::t_exit_alt_charset_mode].string = \
TCAP(fc::t_exit_alt_charset_mode) = \
const_cast<char*>(ESC "(B");
}
// set exit underline for gnome terminal
if ( gnome_terminal )
tcap[fc::t_exit_underline_mode].string = \
TCAP(fc::t_exit_underline_mode) = \
const_cast<char*>(CSI "24m");
// set background color erase for cygwin terminal
@ -3169,45 +3174,45 @@ void FTerm::init_termcaps()
{
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");
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");
}
else
{
tcap[fc::t_set_a_foreground].string = \
TCAP(fc::t_set_a_foreground) = \
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");
}
tcap[fc::t_orig_pair].string = \
TCAP(fc::t_orig_pair) = \
const_cast<char*>(CSI "39;49;25m");
// avoid dim + underline
tcap[fc::t_enter_dim_mode].string = 0;
tcap[fc::t_exit_dim_mode].string = 0;
tcap[fc::t_enter_underline_mode].string = 0;
tcap[fc::t_exit_underline_mode].string = 0;
TCAP(fc::t_enter_dim_mode) = 0;
TCAP(fc::t_exit_dim_mode) = 0;
TCAP(fc::t_enter_underline_mode) = 0;
TCAP(fc::t_exit_underline_mode) = 0;
FTermcap::attr_without_color = 18;
}
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");
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");
}
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");
tcap[fc::t_set_a_background].string = \
TCAP(fc::t_set_a_background) = \
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);
tcap[fc::t_orig_pair].string = \
TCAP(fc::t_orig_pair) = \
const_cast<char*>(CSI "39;49m");
}
else if ( putty_terminal )
@ -3215,91 +3220,91 @@ void FTerm::init_termcaps()
FTermcap::background_color_erase = true;
FTermcap::osc_support = true;
tcap[fc::t_set_a_foreground].string = \
TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "%?%p1%{8}%<"
"%t3%p1%d"
"%e%p1%{16}%<"
"%t9%p1%{8}%-%d"
"%e38;5;%p1%d%;m");
tcap[fc::t_set_a_background].string = \
TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "%?%p1%{8}%<"
"%t4%p1%d"
"%e%p1%{16}%<"
"%t10%p1%{8}%-%d"
"%e48;5;%p1%d%;m");
if ( ! tcap[fc::t_clr_bol].string )
tcap[fc::t_clr_bol].string = \
if ( ! TCAP(fc::t_clr_bol) )
TCAP(fc::t_clr_bol) = \
const_cast<char*>(CSI "1K");
if ( ! tcap[fc::t_orig_pair].string )
tcap[fc::t_orig_pair].string = \
if ( ! TCAP(fc::t_orig_pair) )
TCAP(fc::t_orig_pair) = \
const_cast<char*>(CSI "39;49m");
if ( ! tcap[fc::t_orig_colors].string )
tcap[fc::t_orig_colors].string = \
if ( ! TCAP(fc::t_orig_colors) )
TCAP(fc::t_orig_colors) = \
const_cast<char*>(OSC "R");
if ( ! tcap[fc::t_column_address].string )
tcap[fc::t_column_address].string = \
if ( ! TCAP(fc::t_column_address) )
TCAP(fc::t_column_address) = \
const_cast<char*>(CSI "%i%p1%dG");
if ( ! tcap[fc::t_row_address].string )
tcap[fc::t_row_address].string = \
if ( ! TCAP(fc::t_row_address) )
TCAP(fc::t_row_address) = \
const_cast<char*>(CSI "%i%p1%dd");
if ( ! tcap[fc::t_enable_acs].string )
tcap[fc::t_enable_acs].string = \
if ( ! TCAP(fc::t_enable_acs) )
TCAP(fc::t_enable_acs) = \
const_cast<char*>(ESC "(B" ESC ")0");
if ( ! tcap[fc::t_set_attributes].string )
tcap[fc::t_set_attributes].string = \
if ( ! TCAP(fc::t_set_attributes) )
TCAP(fc::t_set_attributes) = \
const_cast<char*>(CSI "0%?%p1%p6%|"
"%t;1%;%?%p2%t;"
"4%;%?%p1%p3%|"
"%t;7%;%?%p4%t;"
"5%;m%?%p9%t\016%e\017%;");
if ( ! tcap[fc::t_enter_am_mode].string )
tcap[fc::t_enter_am_mode].string = \
if ( ! TCAP(fc::t_enter_am_mode) )
TCAP(fc::t_enter_am_mode) = \
const_cast<char*>(CSI "?7h");
if ( ! tcap[fc::t_exit_am_mode].string )
tcap[fc::t_exit_am_mode].string = \
if ( ! TCAP(fc::t_exit_am_mode) )
TCAP(fc::t_exit_am_mode) = \
const_cast<char*>(CSI "?7l");
if ( ! tcap[fc::t_enter_pc_charset_mode].string )
tcap[fc::t_enter_pc_charset_mode].string = \
if ( ! TCAP(fc::t_enter_pc_charset_mode) )
TCAP(fc::t_enter_pc_charset_mode) = \
const_cast<char*>(CSI "11m");
if ( ! tcap[fc::t_exit_pc_charset_mode].string )
tcap[fc::t_exit_pc_charset_mode].string = \
if ( ! TCAP(fc::t_exit_pc_charset_mode) )
TCAP(fc::t_exit_pc_charset_mode) = \
const_cast<char*>(CSI "10m");
if ( ! tcap[fc::t_key_mouse].string )
tcap[fc::t_key_mouse].string = \
if ( ! TCAP(fc::t_key_mouse) )
TCAP(fc::t_key_mouse) = \
const_cast<char*>(CSI "M");
}
// fallback if "AF" is not found
if ( ! tcap[fc::t_set_a_foreground].string )
tcap[fc::t_set_a_foreground].string = \
if ( ! TCAP(fc::t_set_a_foreground) )
TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "3%p1%dm");
// fallback if "AB" is not found
if ( ! tcap[fc::t_set_a_background].string )
tcap[fc::t_set_a_background].string = \
if ( ! TCAP(fc::t_set_a_background) )
TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "4%p1%dm");
// fallback if "Ic" is not found
if ( ! tcap[fc::t_initialize_color].string )
if ( ! TCAP(fc::t_initialize_color) )
{
if ( screen_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:"
"%p2%{255}%*%{1000}%/%2.2X/"
"%p3%{255}%*%{1000}%/%2.2X/"
@ -3307,7 +3312,7 @@ void FTerm::init_termcaps()
}
else
{
tcap[fc::t_initialize_color].string = \
TCAP(fc::t_initialize_color) = \
const_cast<char*>(ESC "P" OSC "4;%p1%d;rgb:"
"%p2%{255}%*%{1000}%/%2.2X/"
"%p3%{255}%*%{1000}%/%2.2X/"
@ -3316,7 +3321,7 @@ void FTerm::init_termcaps()
}
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:"
"%p2%{255}%*%{1000}%/%2.2X/"
"%p3%{255}%*%{1000}%/%2.2X/"
@ -3324,7 +3329,7 @@ void FTerm::init_termcaps()
}
else
{
tcap[fc::t_initialize_color].string = \
TCAP(fc::t_initialize_color) = \
const_cast<char*>(OSC "P%p1%x"
"%p2%{255}%*%{1000}%/%02x"
"%p3%{255}%*%{1000}%/%02x"
@ -3333,60 +3338,60 @@ void FTerm::init_termcaps()
}
// fallback if "ti" is not found
if ( ! tcap[fc::t_enter_ca_mode].string )
tcap[fc::t_enter_ca_mode].string = \
if ( ! TCAP(fc::t_enter_ca_mode) )
TCAP(fc::t_enter_ca_mode) = \
const_cast<char*>(ESC "7" CSI "?47h");
// fallback if "te" is not found
if ( ! tcap[fc::t_exit_ca_mode].string )
tcap[fc::t_exit_ca_mode].string = \
if ( ! TCAP(fc::t_exit_ca_mode) )
TCAP(fc::t_exit_ca_mode) = \
const_cast<char*>(CSI "?47l" ESC "8" CSI "m");
// set ansi move if "cm" is not found
if ( ! tcap[fc::t_cursor_address].string )
tcap[fc::t_cursor_address].string = \
if ( ! TCAP(fc::t_cursor_address) )
TCAP(fc::t_cursor_address) = \
const_cast<char*>(CSI "%i%p1%d;%p2%dH");
// test for standard ECMA-48 (ANSI X3.64) terminal
if ( tcap[fc::t_exit_underline_mode].string
&& std::strncmp(tcap[fc::t_exit_underline_mode].string, CSI "24m", 5) == 0 )
if ( TCAP(fc::t_exit_underline_mode)
&& std::strncmp(TCAP(fc::t_exit_underline_mode), CSI "24m", 5) == 0 )
{
// 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
tcap[fc::t_exit_dbl_underline_mode].string = \
TCAP(fc::t_exit_dbl_underline_mode) = \
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
tcap[fc::t_exit_dim_mode].string = \
TCAP(fc::t_exit_dim_mode) = \
const_cast<char*>(CSI "22m");
tcap[fc::t_exit_underline_mode].string = \
TCAP(fc::t_exit_underline_mode) = \
const_cast<char*>(CSI "24m");
tcap[fc::t_exit_blink_mode].string = \
TCAP(fc::t_exit_blink_mode) = \
const_cast<char*>(CSI "25m");
tcap[fc::t_exit_reverse_mode].string = \
TCAP(fc::t_exit_reverse_mode) = \
const_cast<char*>(CSI "27m");
tcap[fc::t_exit_secure_mode].string = \
TCAP(fc::t_exit_secure_mode) = \
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");
tcap[fc::t_exit_crossed_out_mode].string = \
TCAP(fc::t_exit_crossed_out_mode) = \
const_cast<char*>(CSI "29m");
}
#if defined(__FreeBSD__) || defined(__DragonFly__)
if ( isFreeBSDConsole() )
{
tcap[fc::t_acs_chars].string = \
TCAP(fc::t_acs_chars) = \
const_cast<char*>("-\036.\0370\333"
"a\260f\370g\361"
"h\261j\331k\277"
@ -3394,7 +3399,7 @@ void FTerm::init_termcaps()
"q\304t\303u\264"
"v\301w\302x\263"
"y\363z\362~\371");
tcap[fc::t_set_attributes].string = \
TCAP(fc::t_set_attributes) = \
const_cast<char*>(CSI "0%?%p1%p6%|"
"%t;1%;%?%p2%t;"
"4%;%?%p1%p3%|"
@ -3439,8 +3444,8 @@ void FTerm::init_termcaps()
key_up_string = tgetstr(const_cast<char*>("ku"), &buffer);
if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0))
|| ( tcap[fc::t_cursor_up].string
&& (std::strcmp(tcap[fc::t_cursor_up].string, CSI "A") == 0) ) )
|| ( TCAP(fc::t_cursor_up)
&& (std::strcmp(TCAP(fc::t_cursor_up), CSI "A") == 0) ) )
{
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
opti_move->setTabStop(int(FTermcap::tabstop));
opti_move->set_cursor_home (tcap[fc::t_cursor_home].string);
opti_move->set_cursor_to_ll (tcap[fc::t_cursor_to_ll].string);
opti_move->set_carriage_return (tcap[fc::t_carriage_return].string);
opti_move->set_tabular (tcap[fc::t_tab].string);
opti_move->set_back_tab (tcap[fc::t_back_tab].string);
opti_move->set_cursor_up (tcap[fc::t_cursor_up].string);
opti_move->set_cursor_down (tcap[fc::t_cursor_down].string);
opti_move->set_cursor_left (tcap[fc::t_cursor_left].string);
opti_move->set_cursor_right (tcap[fc::t_cursor_right].string);
cursor_addres_lengths = opti_move->set_cursor_address (tcap[fc::t_cursor_address].string);
opti_move->set_column_address (tcap[fc::t_column_address].string);
opti_move->set_row_address (tcap[fc::t_row_address].string);
opti_move->set_parm_up_cursor (tcap[fc::t_parm_up_cursor].string);
opti_move->set_parm_down_cursor (tcap[fc::t_parm_down_cursor].string);
opti_move->set_parm_left_cursor (tcap[fc::t_parm_left_cursor].string);
opti_move->set_parm_right_cursor (tcap[fc::t_parm_right_cursor].string);
opti_move->set_cursor_home (TCAP(fc::t_cursor_home));
opti_move->set_cursor_to_ll (TCAP(fc::t_cursor_to_ll));
opti_move->set_carriage_return (TCAP(fc::t_carriage_return));
opti_move->set_tabular (TCAP(fc::t_tab));
opti_move->set_back_tab (TCAP(fc::t_back_tab));
opti_move->set_cursor_up (TCAP(fc::t_cursor_up));
opti_move->set_cursor_down (TCAP(fc::t_cursor_down));
opti_move->set_cursor_left (TCAP(fc::t_cursor_left));
opti_move->set_cursor_right (TCAP(fc::t_cursor_right));
cursor_addres_lengths = \
opti_move->set_cursor_address (TCAP(fc::t_cursor_address));
opti_move->set_column_address (TCAP(fc::t_column_address));
opti_move->set_row_address (TCAP(fc::t_row_address));
opti_move->set_parm_up_cursor (TCAP(fc::t_parm_up_cursor));
opti_move->set_parm_down_cursor (TCAP(fc::t_parm_down_cursor));
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_eat_newline_glitch (FTermcap::eat_nl_glitch);
erase_ch_length = opti_move->set_erase_chars (tcap[fc::t_erase_chars].string);
repeat_char_length = opti_move->set_repeat_char (tcap[fc::t_repeat_char].string);
clr_bol_length = opti_move->set_clr_bol (tcap[fc::t_clr_bol].string);
clr_eol_length = opti_move->set_clr_eol (tcap[fc::t_clr_eol].string);
erase_ch_length = \
opti_move->set_erase_chars (TCAP(fc::t_erase_chars));
repeat_char_length = \
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
opti_attr->setNoColorVideo (int(FTermcap::attr_without_color));
opti_attr->set_enter_bold_mode (tcap[fc::t_enter_bold_mode].string);
opti_attr->set_exit_bold_mode (tcap[fc::t_exit_bold_mode].string);
opti_attr->set_enter_dim_mode (tcap[fc::t_enter_dim_mode].string);
opti_attr->set_exit_dim_mode (tcap[fc::t_exit_dim_mode].string);
opti_attr->set_enter_italics_mode (tcap[fc::t_enter_italics_mode].string);
opti_attr->set_exit_italics_mode (tcap[fc::t_exit_italics_mode].string);
opti_attr->set_enter_underline_mode (tcap[fc::t_enter_underline_mode].string);
opti_attr->set_exit_underline_mode (tcap[fc::t_exit_underline_mode].string);
opti_attr->set_enter_blink_mode (tcap[fc::t_enter_blink_mode].string);
opti_attr->set_exit_blink_mode (tcap[fc::t_exit_blink_mode].string);
opti_attr->set_enter_reverse_mode (tcap[fc::t_enter_reverse_mode].string);
opti_attr->set_exit_reverse_mode (tcap[fc::t_exit_reverse_mode].string);
opti_attr->set_enter_standout_mode (tcap[fc::t_enter_standout_mode].string);
opti_attr->set_exit_standout_mode (tcap[fc::t_exit_standout_mode].string);
opti_attr->set_enter_secure_mode (tcap[fc::t_enter_secure_mode].string);
opti_attr->set_exit_secure_mode (tcap[fc::t_exit_secure_mode].string);
opti_attr->set_enter_protected_mode (tcap[fc::t_enter_protected_mode].string);
opti_attr->set_exit_protected_mode (tcap[fc::t_exit_protected_mode].string);
opti_attr->set_enter_crossed_out_mode (tcap[fc::t_enter_crossed_out_mode].string);
opti_attr->set_exit_crossed_out_mode (tcap[fc::t_exit_crossed_out_mode].string);
opti_attr->set_enter_dbl_underline_mode (tcap[fc::t_enter_dbl_underline_mode].string);
opti_attr->set_exit_dbl_underline_mode (tcap[fc::t_exit_dbl_underline_mode].string);
opti_attr->set_set_attributes (tcap[fc::t_set_attributes].string);
opti_attr->set_exit_attribute_mode (tcap[fc::t_exit_attribute_mode].string);
opti_attr->set_enter_alt_charset_mode (tcap[fc::t_enter_alt_charset_mode].string);
opti_attr->set_exit_alt_charset_mode (tcap[fc::t_exit_alt_charset_mode].string);
opti_attr->set_enter_pc_charset_mode (tcap[fc::t_enter_pc_charset_mode].string);
opti_attr->set_exit_pc_charset_mode (tcap[fc::t_exit_pc_charset_mode].string);
opti_attr->set_a_foreground_color (tcap[fc::t_set_a_foreground].string);
opti_attr->set_a_background_color (tcap[fc::t_set_a_background].string);
opti_attr->set_foreground_color (tcap[fc::t_set_foreground].string);
opti_attr->set_background_color (tcap[fc::t_set_background].string);
opti_attr->set_term_color_pair (tcap[fc::t_set_color_pair].string);
opti_attr->set_orig_pair (tcap[fc::t_orig_pair].string);
opti_attr->set_orig_orig_colors (tcap[fc::t_orig_colors].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));
opti_attr->set_enter_dim_mode (TCAP(fc::t_enter_dim_mode));
opti_attr->set_exit_dim_mode (TCAP(fc::t_exit_dim_mode));
opti_attr->set_enter_italics_mode (TCAP(fc::t_enter_italics_mode));
opti_attr->set_exit_italics_mode (TCAP(fc::t_exit_italics_mode));
opti_attr->set_enter_underline_mode (TCAP(fc::t_enter_underline_mode));
opti_attr->set_exit_underline_mode (TCAP(fc::t_exit_underline_mode));
opti_attr->set_enter_blink_mode (TCAP(fc::t_enter_blink_mode));
opti_attr->set_exit_blink_mode (TCAP(fc::t_exit_blink_mode));
opti_attr->set_enter_reverse_mode (TCAP(fc::t_enter_reverse_mode));
opti_attr->set_exit_reverse_mode (TCAP(fc::t_exit_reverse_mode));
opti_attr->set_enter_standout_mode (TCAP(fc::t_enter_standout_mode));
opti_attr->set_exit_standout_mode (TCAP(fc::t_exit_standout_mode));
opti_attr->set_enter_secure_mode (TCAP(fc::t_enter_secure_mode));
opti_attr->set_exit_secure_mode (TCAP(fc::t_exit_secure_mode));
opti_attr->set_enter_protected_mode (TCAP(fc::t_enter_protected_mode));
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));
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));
opti_attr->set_exit_dbl_underline_mode (TCAP(fc::t_exit_dbl_underline_mode));
opti_attr->set_set_attributes (TCAP(fc::t_set_attributes));
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));
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));
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));
opti_attr->set_a_background_color (TCAP(fc::t_set_a_background));
opti_attr->set_foreground_color (TCAP(fc::t_set_foreground));
opti_attr->set_background_color (TCAP(fc::t_set_background));
opti_attr->set_term_color_pair (TCAP(fc::t_set_color_pair));
opti_attr->set_orig_pair (TCAP(fc::t_orig_pair));
opti_attr->set_orig_orig_colors (TCAP(fc::t_orig_colors));
opti_attr->setMaxColor (FTermcap::max_color);
if ( FTermcap::ansi_default_color )
@ -3560,7 +3568,7 @@ void FTerm::init_encoding()
}
else if ( isatty(stdout_no)
&& (std::strlen(termtype) > 0)
&& (tcap[fc::t_exit_alt_charset_mode].string != 0) )
&& (TCAP(fc::t_exit_alt_charset_mode) != 0) )
{
vt100_console = true;
Encoding = fc::VT100;
@ -3690,7 +3698,8 @@ void FTerm::init()
if ( stdin_status_flags == -1 )
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__)
// initialize Linux console
@ -3892,7 +3901,7 @@ void FTerm::init()
#endif
// xterm mouse support
if ( tcap[fc::t_key_mouse].string && ! linux_terminal )
if ( TCAP(fc::t_key_mouse) && ! linux_terminal )
{
mouse_support = true;
enableXTermMouse();
@ -3903,30 +3912,30 @@ void FTerm::init()
xtermMetaSendsESC(true);
// 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);
}
// 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);
}
// 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);
}
// 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);
}
@ -4017,16 +4026,16 @@ void FTerm::finish()
restoreTTYsettings();
// 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);
}
// 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);
}
@ -4095,23 +4104,23 @@ void FTerm::finish()
#endif
// 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);
}
// 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);
}
// 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);
}

View File

@ -36,7 +36,7 @@
#if defined(__linux__)
#include <linux/fb.h> // Linux framebuffer console
#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>
#endif
@ -53,7 +53,6 @@
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <langinfo.h>
#include <term.h> // termcap
@ -66,6 +65,7 @@
#include <csignal>
#include <map>
#include <queue>
#include <string>
#include "fc.h"
#include "fobject.h"
@ -173,16 +173,16 @@ class FTerm
static void setXTermDefaultColors (bool);
#if defined(__linux__)
static void setLinuxConsoleCursorStyle ( fc::linuxConsoleCursorStyle
, bool );
static void setLinuxConsoleCursorStyle \
(fc::linuxConsoleCursorStyle, bool);
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
static void setFreeBSDConsoleCursorStyle ( fc::freebsdConsoleCursorStyle
, bool );
static void setFreeBSDConsoleCursorStyle \
(fc::freebsdConsoleCursorStyle, bool);
#endif
static void setTTY (termios&);
static void setTTY (const termios&);
static void noHardwareEcho();
static bool setRawMode (bool);
static bool setRawMode();
@ -261,9 +261,9 @@ class FTerm
static int UTF8decode (const char[]);
#if DEBUG
static char termtype_256color[30];
static char termtype_Answerback[30];
static char termtype_SecDA[30];
static char termtype_256color[256];
static char termtype_Answerback[256];
static char termtype_SecDA[256];
#endif
protected:
@ -370,7 +370,8 @@ class FTerm
#if defined(__linux__)
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 getUnicodeMap ();
static void initLinuxConsole();
@ -445,8 +446,8 @@ class FTerm
static bool openbsd_terminal;
static bool screen_terminal;
static bool tmux_terminal;
static char termtype[30];
static char* term_name;
static char termtype[256];
static char term_name[256];
static char* locale_name;
static char* locale_xterm;
static FRect* term; // current terminal geometry

View File

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

View File

@ -12,8 +12,9 @@
#ifndef FTERMBUFFER_H
#define FTERMBUFFER_H
#include <vector>
#include <sstream> // std::stringstream
#include <string>
#include <vector>
#include "fvterm.h"
#include "fstring.h"

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,10 @@
// File: fvterm.cpp
// Provides: class FVTerm
#include <queue>
#include <string>
#include <vector>
#include "fapplication.h"
#include "fvterm.h"
#include "fwidget.h"
@ -289,12 +293,12 @@ void FVTerm::delPreprocessingHandler (FVTerm* instance)
int FVTerm::printf (const wchar_t* format, ...)
{
assert ( format != 0 );
static const int buf_size = 1024;
wchar_t buffer[buf_size];
static const int BufSize = 1024;
wchar_t buffer[BufSize];
va_list args;
va_start (args, format);
std::vswprintf (buffer, buf_size, format, args);
std::vswprintf (buffer, BufSize, format, args);
va_end (args);
FString str(buffer);
@ -1500,7 +1504,6 @@ void FVTerm::updateVTerm (term_area* area)
}
else if ( ! modified )
line_xmin++; // don't update covered character
}
_xmin = ax + line_xmin - ol;
@ -1871,7 +1874,7 @@ void FVTerm::scrollAreaForward (term_area* area)
if ( area == vdesktop )
{
if ( tcap[fc::t_scroll_forward].string )
if ( TCAP(fc::t_scroll_forward) )
{
setTermXY (0, vdesktop->height);
scrollTermForward();
@ -1932,7 +1935,7 @@ void FVTerm::scrollAreaReverse (term_area* area)
if ( area == vdesktop )
{
if ( tcap[fc::t_scroll_reverse].string )
if ( TCAP(fc::t_scroll_reverse) )
{
setTermXY (0, 0);
scrollTermReverse();
@ -2344,9 +2347,9 @@ void FVTerm::finish()
bool FVTerm::clearTerm (int fillchar)
{
// Clear the real terminal and put cursor at home
char*& cl = tcap[fc::t_clear_screen].string;
char*& cd = tcap[fc::t_clr_eos].string;
char*& cb = tcap[fc::t_clr_eol].string;
char*& cl = TCAP(fc::t_clear_screen);
char*& cd = TCAP(fc::t_clr_eos);
char*& cb = TCAP(fc::t_clr_eol);
bool ut = FTermcap::background_color_erase;
char_data* next = &next_attribute;
bool normal = isNormal(next);
@ -2401,10 +2404,10 @@ void FVTerm::updateTerminalLine (uInt y)
bool is_eol_clean = false;
bool draw_leading_ws = false;
bool draw_tailing_ws = false;
char*& ce = tcap[fc::t_clr_eol].string;
char*& cb = tcap[fc::t_clr_bol].string;
char*& ec = tcap[fc::t_erase_chars].string;
char*& rp = tcap[fc::t_repeat_char].string;
char*& ce = TCAP(fc::t_clr_eol);
char*& cb = TCAP(fc::t_clr_bol);
char*& ec = TCAP(fc::t_erase_chars);
char*& rp = TCAP(fc::t_repeat_char);
bool ut = FTermcap::background_color_erase;
char_data* first_char = &vt->text[y * uInt(vt->width)];
char_data* last_char = &vt->text[(y + 1) * uInt(vt->width) - 1];
@ -2782,8 +2785,8 @@ inline void FVTerm::charsetChanges (char_data*& next_char)
else if ( Encoding == fc::PC )
{
next_char->attr.bit.pc_charset = true;
if ( isXTerminal() && hasUTF8() && ch_enc < 0x20 ) // Character 0x00..0x1f
// Character 0x00..0x1f
if ( isXTerminal() && hasUTF8() && ch_enc < 0x20 )
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)
{
char* SA = tcap[fc::t_enter_am_mode].string;
char* RA = tcap[fc::t_exit_am_mode].string;
char* SA = TCAP(fc::t_enter_am_mode);
char* RA = TCAP(fc::t_exit_am_mode);
if ( ! FTermcap::automatic_right_margin )
{
@ -2846,11 +2849,11 @@ int FVTerm::appendLowerRight (char_data*& screen_char)
else
{
int x, y;
char* IC = tcap[fc::t_parm_ich].string;
char* im = tcap[fc::t_enter_insert_mode].string;
char* ei = tcap[fc::t_exit_insert_mode].string;
char* ip = tcap[fc::t_insert_padding].string;
char* ic = tcap[fc::t_insert_character].string;
char* IC = TCAP(fc::t_parm_ich);
char* im = TCAP(fc::t_enter_insert_mode);
char* ei = TCAP(fc::t_exit_insert_mode);
char* ip = TCAP(fc::t_insert_padding);
char* ic = TCAP(fc::t_insert_character);
x = getColumnNumber() - 2;
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();
tputs (c_string, 1, appendOutputBuffer);
}
//----------------------------------------------------------------------
inline void FVTerm::appendOutputBuffer (const char* const& s)
inline void FVTerm::appendOutputBuffer (const char*& s)
{
tputs (s, 1, appendOutputBuffer);
}

View File

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

View File

@ -1,6 +1,8 @@
// File: fwidget.cpp
// Provides: class FWidget
#include <vector>
#include "fapplication.h"
#include "fmenubar.h"
#include "fstatusbar.h"
@ -263,7 +265,6 @@ FPoint FWidget::getPrintPos()
int cy = cur.getY();
return FPoint ( cx - offset.getX1() - getX() + 1
, cy - offset.getY1() - getY() + 1 );
}
//----------------------------------------------------------------------
@ -1572,9 +1573,11 @@ void FWidget::drawFlatBorder()
setPrintPos (x1 - 1, y1 + y + 1);
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
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);
@ -1582,9 +1585,11 @@ void FWidget::drawFlatBorder()
for (int y = 0; y < getHeight(); 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
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);
}
@ -1594,9 +1599,11 @@ void FWidget::drawFlatBorder()
for (int x = 0; x < getWidth(); 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
print (fc::NF_border_line_bottom); // bottom line (at top)
// bottom line (at top)
print (fc::NF_border_line_bottom);
}
setPrintPos (x1, y2);
@ -1604,9 +1611,11 @@ void FWidget::drawFlatBorder()
for (int x = 0; x < getWidth(); 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
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
#define FWIDGET_H
#include <vector>
#include "fvterm.h"

View File

@ -384,7 +384,8 @@ void FWindow::setSize (int w, int h, bool adjust)
int old_height = getHeight();
FWidget::setSize (w, h, adjust);
if ( isVirtualWindow() && (getWidth() != old_width || getHeight() != old_height) )
if ( isVirtualWindow()
&& (getWidth() != old_width || getHeight() != old_height) )
{
FRect geometry = getTermGeometry();
geometry.move(-1, -1);
@ -461,7 +462,6 @@ FWindow* FWindow::getWindowWidgetAt (int x, int y)
}
}
while ( iter != begin );
}
return 0;
@ -779,7 +779,8 @@ void FWindow::setShadowSize (int right, int bottom)
new_right = getShadow().getX();
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();
geometry.move(-1, -1);

View File

@ -8,6 +8,7 @@
#include <cmath>
#include <cstdlib>
#include <limits>
#include <map>
#include <stack>
#include "fapplication.h"
@ -277,7 +278,6 @@ Calc::Calc (FWidget* parent)
);
calculator_buttons[button(key)] = btn;
}
calculator_buttons[On]->addAccelerator(fc::Fkey_dc); // del key
@ -449,8 +449,6 @@ inline void Calc::clearInfixOperator()
//----------------------------------------------------------------------
void Calc::calcInfixOperator()
{
using namespace std;
switch ( infix_operator )
{
case '*':
@ -576,8 +574,6 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
lDouble* x;
lDouble infinity = std::numeric_limits<lDouble>::infinity();
using namespace std;
if ( infix_operator )
x = &b;
else
@ -597,7 +593,7 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
if ( errno == EDOM || errno == ERANGE )
error = true;
if ( fabs(*x - infinity) < LDBL_EPSILON ) // x = ∞
if ( std::fabs(*x - infinity) < LDBL_EPSILON ) // x = ∞
error = true;
}
else
@ -633,7 +629,7 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
if ( errno == EDOM || errno == ERANGE )
error = true;
if ( fabs(*x - infinity) < LDBL_EPSILON ) // x = ∞
if ( std::fabs(*x - infinity) < LDBL_EPSILON ) // x = ∞
error = true;
}
else

View File

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

View File

@ -2,6 +2,8 @@
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "fapplication.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);
Line3->setSeparator();
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);
Copy->setStatusbarMessage ("Copy the input text into the clipboad");
FMenuItem* Paste = new FMenuItem (fc::Fckey_v, "&Paste", Edit);

View File

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

View File

@ -1,12 +1,14 @@
// File: string-operations.cpp
#include <clocale>
#include <iomanip>
#include <langinfo.h>
#include <term.h>
#include <unistd.h>
#include <clocale>
#include <iomanip>
#include <string>
#include <vector>
#include "fstring.h"
@ -70,19 +72,23 @@ int main (int, char**)
std::cout << " add: " << add1 << std::endl;
// 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;
// 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;
// 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;
// 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;
// Test: concatenate a FString and a wide character (operator +)
@ -102,19 +108,23 @@ int main (int, char**)
std::cout << " add: " << add9 << std::endl;
// 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;
// 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;
// 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;
// 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;
// Test: compare operators ==, <=, <, >=, >, !=

View File

@ -45,7 +45,6 @@ class AttribDlg : public FDialog
// Data Members
FButton* next_button;
FButton* back_button;
};
#pragma pack(pop)
@ -187,7 +186,7 @@ class AttribDemo : public FWidget
// Event handler
void onWheel (FWheelEvent* ev)
{
AttribDlg* p = dynamic_cast<AttribDlg*>(getParentWidget());
AttribDlg* p = static_cast<AttribDlg*>(getParentWidget());
if ( p )
p->onWheel(ev);

View File

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

View File

@ -2,6 +2,8 @@
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "fapplication.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
#include <iostream>
#include <fstream>
#include <iostream>
#include <string>
#include "final.h"
@ -97,7 +98,7 @@ ProgressDialog::ProgressDialog (FWidget* parent)
}
//----------------------------------------------------------------------
ProgressDialog::~ProgressDialog()
ProgressDialog::~ProgressDialog() // destructor
{
delOwnTimer();
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);
Line2->setSeparator();
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);
Copy->setStatusbarMessage ("Copy the input text into the clipboad");
FMenuItem* Paste = new FMenuItem (fc::Fckey_v, "&Paste", Edit);
@ -405,21 +407,21 @@ MyDialog::MyDialog (FWidget* parent)
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view),
dynamic_cast<FWidget::data_ptr>(File1)
static_cast<FWidget::data_ptr>(File1)
);
File2->addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view),
dynamic_cast<FWidget::data_ptr>(File2)
static_cast<FWidget::data_ptr>(File2)
);
File3->addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view),
dynamic_cast<FWidget::data_ptr>(File3)
static_cast<FWidget::data_ptr>(File3)
);
// Buttons
@ -563,7 +565,7 @@ MyDialog::MyDialog (FWidget* parent)
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_input2buttonText),
dynamic_cast<FWidget::data_ptr>(myLineEdit)
static_cast<FWidget::data_ptr>(myLineEdit)
);
MyButton5->addCallback
@ -588,21 +590,21 @@ MyDialog::MyDialog (FWidget* parent)
(
"toggled",
F_METHOD_CALLBACK (this, &MyDialog::cb_activateButton),
dynamic_cast<FWidget::data_ptr>(MyButton5)
static_cast<FWidget::data_ptr>(MyButton5)
);
myList->addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_setInput),
dynamic_cast<FWidget::data_ptr>(myLineEdit)
static_cast<FWidget::data_ptr>(myLineEdit)
);
myList->addCallback
(
"row-selected",
F_METHOD_CALLBACK (this, &MyDialog::cb_updateNumber),
dynamic_cast<FWidget::data_ptr>(tagged_count)
static_cast<FWidget::data_ptr>(tagged_count)
);
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()
{
FString str;
std::tm* now;
std::tm now;
std::time_t t;
t = std::time(0); // get current time
now = std::localtime(&t);
localtime_r(&t, &now);
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
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->redraw();

View File

@ -1,5 +1,7 @@
// File: windows.cpp
#include <vector>
#include "fapplication.h"
#include "fdialog.h"
#include "fdialoglistmenu.h"