diff --git a/ChangeLog b/ChangeLog index 6a5096e1..4a8117b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2017-09-11 Markus Gans + * Some code improvements + 2017-09-09 Markus Gans * Wrong UTF-8 string length fixed when attaching to FString diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 9ac9c790..fd2eee19 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -1,6 +1,8 @@ // File: fapplication.cpp // Provides: class FApplication +#include + #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) @@ -69,7 +71,7 @@ FApplication::FApplication ( int& _argc } //---------------------------------------------------------------------- -FApplication::~FApplication() // destructor +FApplication::~FApplication() // destructor { if ( zero_point ) delete zero_point; @@ -143,7 +145,7 @@ void FApplication::exit (int retcode) if ( ! rootObj ) // no global app object return; - if ( quit_now ) // don't overwrite quit code + if ( quit_now ) // don't overwrite quit code return; quit_now = true; @@ -213,7 +215,9 @@ bool FApplication::sendEvent ( const FObject* receiver return false; // For access to a protected base class member - FApplication* w = const_cast(static_cast(widget)); + const FApplication* const_w = static_cast(widget); + FApplication* w = const_cast(const_w); + // Sends event event directly to receiver return w->event(const_cast(event)); } @@ -314,7 +318,7 @@ void FApplication::init() try { - zero_point = new FPoint(0,0); + zero_point = new FPoint (0,0); event_queue = new eventQueue; } catch (const std::bad_alloc& ex) @@ -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,8 +698,7 @@ void FApplication::processKeyboardEvent() } } break; - - } // end of switch + } // end of switch } fifo_offset = int(std::strlen(fifo_buf)); @@ -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(); @@ -739,34 +742,34 @@ int FApplication::linuxModifierKeyCorrection (int& key_id) switch ( key_id ) { case fc::Fkey_up: - return fc::Fkey_sr; // Shift+Up + return fc::Fkey_sr; // Shift+Up case fc::Fkey_down: - return fc::Fkey_sf; // Shift+Down + return fc::Fkey_sf; // Shift+Down case fc::Fkey_left: - return fc::Fkey_sleft; // Shift+Left + return fc::Fkey_sleft; // Shift+Left case fc::Fkey_right: - return fc::Fkey_sright; // Shift+Right + return fc::Fkey_sright; // Shift+Right case fc::Fkey_ic: - return fc::Fkey_sic; // Shift+Ins + return fc::Fkey_sic; // Shift+Ins case fc::Fkey_dc: - return fc::Fkey_sdc; // Shift+Del + return fc::Fkey_sdc; // Shift+Del case fc::Fkey_home: - return fc::Fkey_shome; // Shift+Home + return fc::Fkey_shome; // Shift+Home case fc::Fkey_end: - return fc::Fkey_send; // Shift+End + return fc::Fkey_send; // Shift+End case fc::Fkey_ppage: - return fc::Fkey_sprevious; // Shift+PgUp + return fc::Fkey_sprevious; // Shift+PgUp case fc::Fkey_npage: - return fc::Fkey_snext; // Shift+PgDn + return fc::Fkey_snext; // Shift+PgDn default: return key_id; @@ -777,34 +780,34 @@ int FApplication::linuxModifierKeyCorrection (int& key_id) switch ( key_id ) { case fc::Fkey_up: - return fc::Fckey_up; // Ctrl+Up + return fc::Fckey_up; // Ctrl+Up case fc::Fkey_down: - return fc::Fckey_down; // Ctrl+Down + return fc::Fckey_down; // Ctrl+Down case fc::Fkey_left: - return fc::Fckey_left; // Ctrl+Left + return fc::Fckey_left; // Ctrl+Left case fc::Fkey_right: - return fc::Fckey_right; // Ctrl+Right + return fc::Fckey_right; // Ctrl+Right case fc::Fkey_ic: - return fc::Fckey_ic; // Ctrl+Ins + return fc::Fckey_ic; // Ctrl+Ins case fc::Fkey_dc: - return fc::Fckey_dc; // Ctrl+Del + return fc::Fckey_dc; // Ctrl+Del case fc::Fkey_home: - return fc::Fckey_home; // Ctrl+Home + return fc::Fckey_home; // Ctrl+Home case fc::Fkey_end: - return fc::Fckey_end; // Ctrl+End + return fc::Fckey_end; // Ctrl+End case fc::Fkey_ppage: - return fc::Fckey_ppage; // Ctrl+PgUp + return fc::Fckey_ppage; // Ctrl+PgUp case fc::Fkey_npage: - return fc::Fckey_npage; // Ctrl+PgDn + return fc::Fckey_npage; // Ctrl+PgDn default: return key_id; @@ -815,34 +818,34 @@ int FApplication::linuxModifierKeyCorrection (int& key_id) switch ( key_id ) { case fc::Fkey_up: - return fc::Fmkey_up; // Meta+Up + return fc::Fmkey_up; // Meta+Up case fc::Fkey_down: - return fc::Fmkey_down; // Meta+Down + return fc::Fmkey_down; // Meta+Down case fc::Fkey_left: - return fc::Fmkey_left; // Meta+Left + return fc::Fmkey_left; // Meta+Left case fc::Fkey_right: - return fc::Fmkey_right; // Meta+Right + return fc::Fmkey_right; // Meta+Right case fc::Fkey_ic: - return fc::Fmkey_ic; // Meta+Ins + return fc::Fmkey_ic; // Meta+Ins case fc::Fkey_dc: - return fc::Fmkey_dc; // Meta+Del + return fc::Fmkey_dc; // Meta+Del case fc::Fkey_home: - return fc::Fmkey_home; // Meta+Home + return fc::Fmkey_home; // Meta+Home case fc::Fkey_end: - return fc::Fmkey_end; // Meta+End + return fc::Fmkey_end; // Meta+End case fc::Fkey_ppage: - return fc::Fmkey_ppage; // Meta+PgUp + return fc::Fmkey_ppage; // Meta+PgUp case fc::Fkey_npage: - return fc::Fmkey_npage; // Meta+PgDn + return fc::Fmkey_npage; // Meta+PgDn default: return key_id; @@ -853,34 +856,34 @@ int FApplication::linuxModifierKeyCorrection (int& key_id) switch ( key_id ) { case fc::Fkey_up: - return fc::Fckey_sup; // Shift+Ctrl+Up + return fc::Fckey_sup; // Shift+Ctrl+Up case fc::Fkey_down: - return fc::Fckey_sdown; // Shift+Ctrl+Down + return fc::Fckey_sdown; // Shift+Ctrl+Down case fc::Fkey_left: - return fc::Fckey_sleft; // Shift+Ctrl+Left + return fc::Fckey_sleft; // Shift+Ctrl+Left case fc::Fkey_right: - return fc::Fckey_sright; // Shift+Ctrl+Right + return fc::Fckey_sright; // Shift+Ctrl+Right case fc::Fkey_ic: - return fc::Fckey_sic; // Shift+Ctrl+Ins + return fc::Fckey_sic; // Shift+Ctrl+Ins case fc::Fkey_dc: - return fc::Fckey_sdc; // Shift+Ctrl+Del + return fc::Fckey_sdc; // Shift+Ctrl+Del case fc::Fkey_home: - return fc::Fckey_shome; // Shift+Ctrl+Home + return fc::Fckey_shome; // Shift+Ctrl+Home case fc::Fkey_end: - return fc::Fckey_send; // Shift+Ctrl+End + return fc::Fckey_send; // Shift+Ctrl+End case fc::Fkey_ppage: - return fc::Fckey_sppage; // Shift+Ctrl+PgUp + return fc::Fckey_sppage; // Shift+Ctrl+PgUp case fc::Fkey_npage: - return fc::Fckey_snpage; // Shift+Ctrl+PgDn + return fc::Fckey_snpage; // Shift+Ctrl+PgDn default: return key_id; @@ -891,34 +894,34 @@ int FApplication::linuxModifierKeyCorrection (int& key_id) switch ( key_id ) { case fc::Fkey_up: - return fc::Fmkey_sup; // Shift+Meta+Up + return fc::Fmkey_sup; // Shift+Meta+Up case fc::Fkey_down: - return fc::Fmkey_sdown; // Shift+Meta+Down + return fc::Fmkey_sdown; // Shift+Meta+Down case fc::Fkey_left: - return fc::Fmkey_sright; // Shift+Meta+Left + return fc::Fmkey_sright; // Shift+Meta+Left case fc::Fkey_right: - return fc::Fmkey_sleft; // Shift+Meta+Right + return fc::Fmkey_sleft; // Shift+Meta+Right case fc::Fkey_ic: - return fc::Fmkey_sic; // Shift+Meta+Ins + return fc::Fmkey_sic; // Shift+Meta+Ins case fc::Fkey_dc: - return fc::Fmkey_sdc; // Shift+Meta+Del + return fc::Fmkey_sdc; // Shift+Meta+Del case fc::Fkey_home: - return fc::Fmkey_shome; // Shift+Meta+Home + return fc::Fmkey_shome; // Shift+Meta+Home case fc::Fkey_end: - return fc::Fmkey_send; // Shift+Meta+End + return fc::Fmkey_send; // Shift+Meta+End case fc::Fkey_ppage: - return fc::Fmkey_sppage; // Shift+Meta+PgUp + return fc::Fmkey_sppage; // Shift+Meta+PgUp case fc::Fkey_npage: - return fc::Fmkey_snpage; // Shift+Meta+PgDn + return fc::Fmkey_snpage; // Shift+Meta+PgDn default: return key_id; @@ -929,34 +932,34 @@ int FApplication::linuxModifierKeyCorrection (int& key_id) switch ( key_id ) { case fc::Fkey_up: - return fc::Fcmkey_up; // Ctrl+Meta+Up + return fc::Fcmkey_up; // Ctrl+Meta+Up case fc::Fkey_down: - return fc::Fcmkey_down; // Ctrl+Meta+Down + return fc::Fcmkey_down; // Ctrl+Meta+Down case fc::Fkey_left: - return fc::Fcmkey_left; // Ctrl+Meta+Left + return fc::Fcmkey_left; // Ctrl+Meta+Left case fc::Fkey_right: - return fc::Fcmkey_right; // Ctrl+Meta+Right + return fc::Fcmkey_right; // Ctrl+Meta+Right case fc::Fkey_ic: - return fc::Fcmkey_ic; // Ctrl+Meta+Ins + return fc::Fcmkey_ic; // Ctrl+Meta+Ins case fc::Fkey_dc: - return fc::Fcmkey_dc; // Ctrl+Meta+Del + return fc::Fcmkey_dc; // Ctrl+Meta+Del case fc::Fkey_home: - return fc::Fcmkey_home; // Ctrl+Meta+Home + return fc::Fcmkey_home; // Ctrl+Meta+Home case fc::Fkey_end: - return fc::Fcmkey_end; // Ctrl+Meta+End + return fc::Fcmkey_end; // Ctrl+Meta+End case fc::Fkey_ppage: - return fc::Fcmkey_ppage; // Ctrl+Meta+PgUp + return fc::Fcmkey_ppage; // Ctrl+Meta+PgUp case fc::Fkey_npage: - return fc::Fcmkey_npage; // Ctrl+Meta+PgDn + return fc::Fcmkey_npage; // Ctrl+Meta+PgDn default: return key_id; @@ -967,34 +970,34 @@ int FApplication::linuxModifierKeyCorrection (int& key_id) switch ( key_id ) { case fc::Fkey_up: - return fc::Fcmkey_sup; // Shift+Ctrl+Meta+Up + return fc::Fcmkey_sup; // Shift+Ctrl+Meta+Up case fc::Fkey_down: - return fc::Fcmkey_sdown; // Shift+Ctrl+Meta+Down + return fc::Fcmkey_sdown; // Shift+Ctrl+Meta+Down case fc::Fkey_left: - return fc::Fcmkey_sleft; // Shift+Ctrl+Meta+Left + return fc::Fcmkey_sleft; // Shift+Ctrl+Meta+Left case fc::Fkey_right: - return fc::Fcmkey_sright; // Shift+Ctrl+Meta+Right + return fc::Fcmkey_sright; // Shift+Ctrl+Meta+Right case fc::Fkey_ic: - return fc::Fcmkey_sic; // Shift+Ctrl+Meta+Ins + return fc::Fcmkey_sic; // Shift+Ctrl+Meta+Ins case fc::Fkey_dc: - return fc::Fcmkey_sdc; // Shift+Ctrl+Meta+Del + return fc::Fcmkey_sdc; // Shift+Ctrl+Meta+Del case fc::Fkey_home: - return fc::Fcmkey_shome; // Shift+Ctrl+Meta+Home + return fc::Fcmkey_shome; // Shift+Ctrl+Meta+Home case fc::Fkey_end: - return fc::Fcmkey_send; // Shift+Ctrl+Meta+End + return fc::Fcmkey_send; // Shift+Ctrl+Meta+End case fc::Fkey_ppage: - return fc::Fcmkey_sppage; // Shift+Ctrl+Meta+PgUp + return fc::Fcmkey_sppage; // Shift+Ctrl+Meta+PgUp case fc::Fkey_npage: - return fc::Fcmkey_snpage; // Shift+Ctrl+Meta+PgDn + return fc::Fcmkey_snpage; // Shift+Ctrl+Meta+PgDn default: return key_id; @@ -1198,7 +1201,7 @@ bool FApplication::parseX11Mouse() x = uChar(x11_mouse[1] - 0x20); y = uChar(x11_mouse[2] - 0x20); - new_mouse_position.setPoint(x,y); + new_mouse_position.setPoint (x, y); // fill bit field with 0 std::memset(&b_state, 0x00, sizeof(b_state)); @@ -1293,7 +1296,7 @@ bool FApplication::parseSGRMouse() y = uChar(10 * y + (*p - '0')); } - new_mouse_position.setPoint(x,y); + new_mouse_position.setPoint (x, y); // fill bit field with 0 std::memset(&b_state, 0x00, sizeof(b_state)); @@ -1491,7 +1494,7 @@ bool FApplication::parseUrxvtMouse() if ( y > getLineNumber() ) y = uChar(getLineNumber()); - new_mouse_position.setPoint(x,y); + new_mouse_position.setPoint (x, y); // fill bit field with 0 std::memset(&b_state, 0x00, sizeof(b_state)); @@ -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 (¤tTime); if ( isTimerInUpdating() ) return 0; diff --git a/src/fapplication.h b/src/fapplication.h index 9660a6d1..f701f989 100644 --- a/src/fapplication.h +++ b/src/fapplication.h @@ -38,6 +38,8 @@ #include #include +#include +#include #include "fevent.h" #include "fwidget.h" @@ -53,163 +55,163 @@ class FApplication : public FWidget { - public: - // Constructor - FApplication (int&, char*[], bool = false); + public: + // Constructor + FApplication (const int&, char*[], bool = false); - // Destructor - virtual ~FApplication(); + // Destructor + virtual ~FApplication(); - // Accessors - const char* getClassName() const; - int getArgc() const; - char** getArgv() const; - FWidget* getMainWidget() const; - FWidget* getFocusWidget() const; + // Accessors + const char* getClassName() const; + int getArgc() const; + char** getArgv() const; + FWidget* getMainWidget() const; + FWidget* getFocusWidget() const; - // Mutator - void setMainWidget (FWidget*); + // Mutator + void setMainWidget (FWidget*); - // Inquiry - static bool isQuit(); + // Inquiry + static bool isQuit(); - // Methods - int exec(); // run - int enter_loop(); - void exit_loop(); - static void exit (int = 0); - void quit(); - static bool sendEvent (const FObject*, const FEvent*); - static void queueEvent (const FObject*, const FEvent*); - static void sendQueuedEvents (); - static bool eventInQueue(); - static bool removeQueuedEvent(const FObject*); - static void print_cmd_Options(); + // Methods + int exec(); // run + int enter_loop(); + void exit_loop(); + static void exit (int = 0); + void quit(); + static bool sendEvent (const FObject*, const FEvent*); + static void queueEvent (const FObject*, const FEvent*); + static void sendQueuedEvents (); + static bool eventInQueue(); + static bool removeQueuedEvent(const FObject*); + static void print_cmd_Options(); - private: - // Typedefs and Enumerations - typedef std::pair eventPair; - typedef std::deque eventQueue; + private: + // Typedefs and Enumerations + typedef std::pair eventPair; + typedef std::deque eventQueue; - enum btn_state - { - Pressed = 1, - Released = 2, - DoubleClick = 3 - }; + enum btn_state + { + Pressed = 1, + Released = 2, + DoubleClick = 3 + }; #ifdef F_HAVE_LIBGPM - enum gpmEventType - { - no_event = 0, - keyboard_event = 1, - mouse_event = 2 - }; + enum gpmEventType + { + no_event = 0, + keyboard_event = 1, + mouse_event = 2 + }; #endif - // Constants - static const int NEED_MORE_DATA = -1; // parseKeyString return value + // Constants + static const int NEED_MORE_DATA = -1; // parseKeyString return value - // Disable copy constructor - FApplication (const FApplication&); + // Disable copy constructor + FApplication (const FApplication&); - // Disable assignment operator (=) - FApplication& operator = (const FApplication&); + // Disable assignment operator (=) + FApplication& operator = (const FApplication&); - // Methods - void init(); - void setExitMessage (std::string); - void cmd_options(); + // Methods + void init(); + void setExitMessage (std::string); + void cmd_options(); #ifdef F_HAVE_LIBGPM - int gpmEvent (bool = true); - bool processGpmEvent(); + int gpmEvent (bool = true); + bool processGpmEvent(); #endif - bool KeyPressed(); - ssize_t readKey(); - void processKeyboardEvent(); + bool KeyPressed(); + ssize_t readKey(); + void processKeyboardEvent(); #if defined(__linux__) - int linuxModifierKeyCorrection (int& key); + int linuxModifierKeyCorrection (const int&); #endif - bool processDialogSwitchAccelerator(); - bool processAccelerator (const FWidget*&); - void getX11ButtonState (int); - bool parseX11Mouse(); - bool parseSGRMouse(); - bool parseUrxvtMouse(); - void processMouseEvent(); - void processResizeEvent(); - int processTimerEvent(); - void processCloseWidget(); - bool processNextEvent(); + bool processDialogSwitchAccelerator(); + bool processAccelerator (const FWidget*&); + void getX11ButtonState (int); + bool parseX11Mouse(); + bool parseSGRMouse(); + bool parseUrxvtMouse(); + void processMouseEvent(); + void processResizeEvent(); + int processTimerEvent(); + void processCloseWidget(); + bool processNextEvent(); - // Data Members - int app_argc; - char** app_argv; - int key; + // Data Members + int app_argc; + char** app_argv; + int key; #ifdef F_HAVE_LIBGPM - Gpm_Event gpm_ev; - bool gpmMouseEvent; + Gpm_Event gpm_ev; + bool gpmMouseEvent; #endif - struct button_state // bit field - { - uChar left_button : 2; // 0..3 - uChar right_button : 2; // 0..3 - uChar middle_button : 2; // 0..3 - uChar shift_button : 1; // 0..1 - uChar control_button : 1; // 0..1 - uChar meta_button : 1; // 0..1 - uChar wheel_up : 1; // 0..1 - uChar wheel_down : 1; // 0..1 - uChar mouse_moved : 1; // 0..1 - uChar : 4; // padding bits - } b_state; + struct button_state // bit field + { + uChar left_button : 2; // 0..3 + uChar right_button : 2; // 0..3 + uChar middle_button : 2; // 0..3 + uChar shift_button : 1; // 0..1 + uChar control_button : 1; // 0..1 + uChar meta_button : 1; // 0..1 + uChar wheel_up : 1; // 0..1 + uChar wheel_down : 1; // 0..1 + uChar mouse_moved : 1; // 0..1 + uChar : 4; // padding bits + } b_state; - char k_buf[1024]; - char x11_mouse[4]; - char sgr_mouse[13]; - char urxvt_mouse[13]; - char fifo_buf[512]; - int fifo_offset; - bool fifo_in_use; - int fifo_buf_size; - long key_timeout; - long dblclick_interval; - struct timeval time_keypressed; - struct timeval time_mousepressed; - FPoint new_mouse_position; - static eventQueue* event_queue; - static int quit_code; - static bool quit_now; - static int loop_level; - static bool process_timer_event; - static FPoint* zero_point; - static uChar x11_button_state; - static FWidget* move_size_widget; - static FWidget* main_widget; - static FWidget* active_window; - static FWidget* focus_widget; - static FWidget* clicked_widget; - static FWidget* open_menu; + char k_buf[1024]; + char x11_mouse[4]; + char sgr_mouse[13]; + char urxvt_mouse[13]; + char fifo_buf[512]; + int fifo_offset; + bool fifo_in_use; + int fifo_buf_size; + long key_timeout; + long dblclick_interval; + struct timeval time_keypressed; + struct timeval time_mousepressed; + FPoint new_mouse_position; + static eventQueue* event_queue; + static int quit_code; + static bool quit_now; + static int loop_level; + static bool process_timer_event; + static FPoint* zero_point; + static uChar x11_button_state; + static FWidget* move_size_widget; + static FWidget* main_widget; + static FWidget* active_window; + static FWidget* focus_widget; + static FWidget* clicked_widget; + static FWidget* open_menu; - // Friend functions from FWidget - friend FWidget* FWidget::getMainWidget(); - friend FWidget* FWidget::getFocusWidget() const; - friend void FWidget::setFocusWidget (FWidget*); - friend FWidget* FWidget::getClickedWidget(); - friend void FWidget::setClickedWidget (FWidget*); - friend FWidget* FWidget::getMoveSizeWidget(); - friend void FWidget::setMoveSizeWidget (FWidget*); - friend FWidget* FWidget::getOpenMenu(); - friend void FWidget::setOpenMenu (FWidget*); + // Friend functions from FWidget + friend FWidget* FWidget::getMainWidget(); + friend FWidget* FWidget::getFocusWidget() const; + friend void FWidget::setFocusWidget (FWidget*); + friend FWidget* FWidget::getClickedWidget(); + friend void FWidget::setClickedWidget (FWidget*); + friend FWidget* FWidget::getMoveSizeWidget(); + friend void FWidget::setMoveSizeWidget (FWidget*); + friend FWidget* FWidget::getOpenMenu(); + friend void FWidget::setOpenMenu (FWidget*); - // Friend functions from FWindow - friend bool FWindow::activateWindow (bool); - friend FWindow* FWindow::getActiveWindow(); - friend void FWindow::unsetActiveWindow(); + // Friend functions from FWindow + friend bool FWindow::activateWindow (bool); + friend FWindow* FWindow::getActiveWindow(); + friend void FWindow::unsetActiveWindow(); }; #pragma pack(pop) diff --git a/src/fbutton.cpp b/src/fbutton.cpp index a02dce08..289c4971 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -553,7 +553,7 @@ void FButton::draw() for (int y = 1; y <= getHeight(); y++) { setPrintPos (1, y); - print (' '); // clear one left █ + print (' '); // clear one left █ } d = 1; @@ -610,7 +610,7 @@ void FButton::draw() for (int y = 0; y < getHeight(); y++) { setPrintPos (1 + d, 1 + y); - print (space); // full block █ + print (space); // full block █ } } @@ -632,7 +632,7 @@ void FButton::draw() setReverse(true); setPrintPos (1 + getWidth(), y); - print (' '); // clear right + print (' '); // clear right if ( isMonochron() ) setReverse(false); @@ -654,17 +654,17 @@ void FButton::draw() setColor (button_fg, button_bg); for (x = 0; x < i; x++) - print (space); // █ + print (space); // █ if ( hotkeypos == -1 ) - setCursorPos (1 + margin + i + mono_1st_char, 1 + j ); // first character + setCursorPos (1 + margin + i + mono_1st_char, 1 + j ); // first character else - setCursorPos (1 + margin + i + hotkeypos, 1 + j ); // hotkey + setCursorPos (1 + margin + i + hotkeypos, 1 + j ); // hotkey if ( is_ActiveFocus && (isMonochron() || getMaxColor() < 16) ) 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 ) { @@ -696,7 +696,7 @@ void FButton::draw() unsetBold(); for (x = i + length; x < getWidth() - 1; x++) - print (space); // █ + print (space); // █ if ( getHeight() >= 2 ) { @@ -705,14 +705,14 @@ void FButton::draw() setPrintPos (2 + d, 1 + i); for (int z = 1; z < getWidth(); z++) - print (space); // █ + print (space); // █ } for (i = j + 1; i < getHeight(); i++) { setPrintPos (2 + d, 1 + i); for (int z = 1; z < getWidth(); z++) - print (space); // █ + print (space); // █ } } @@ -725,7 +725,7 @@ void FButton::draw() setColor ( parent_widget->getForegroundColor() , parent_widget->getBackgroundColor() ); - print(' '); // restore background after button down + print(' '); // restore background after button down drawShadow(); } @@ -760,7 +760,7 @@ void FButton::updateButtonColor() else { button_fg = getForegroundColor(); - button_bg = getBackgroundColor() ; + button_bg = getBackgroundColor(); } } else // inactive diff --git a/src/fbutton.h b/src/fbutton.h index 125e15b0..fa495be8 100644 --- a/src/fbutton.h +++ b/src/fbutton.h @@ -40,97 +40,97 @@ class FButton : public FWidget { - public: - // Constructors - explicit FButton (FWidget* = 0); - FButton (const FString&, FWidget* = 0); + public: + // Constructors + explicit FButton (FWidget* = 0); + FButton (const FString&, FWidget* = 0); - // Destructor - virtual ~FButton(); + // Destructor + virtual ~FButton(); - // Accessors - const char* getClassName() const; - FString& getText(); + // Accessors + const char* getClassName() const; + FString& getText(); - // Mutators - void setForegroundColor (short); - void setBackgroundColor (short); - void setHotkeyForegroundColor (short); - void setFocusForegroundColor (short); - void setFocusBackgroundColor (short); - void setInactiveForegroundColor (short); - void setInactiveBackgroundColor (short); - bool setNoUnderline(bool); - bool setNoUnderline(); - bool unsetNoUnderline(); - bool setEnable(bool); - bool setEnable(); - bool unsetEnable(); - bool setDisable(); - bool setFocus(bool); - bool setFocus(); - bool unsetFocus(); - bool setFlat(bool); - bool setFlat(); - bool unsetFlat(); - bool setShadow(bool); - bool setShadow(); - bool unsetShadow(); - bool setDown(bool); - bool setDown(); - bool setUp(); - bool setClickAnimation(bool); - bool setClickAnimation(); - bool unsetClickAnimation(); - void setText (const FString&); + // Mutators + void setForegroundColor (short); + void setBackgroundColor (short); + void setHotkeyForegroundColor (short); + void setFocusForegroundColor (short); + void setFocusBackgroundColor (short); + void setInactiveForegroundColor (short); + void setInactiveBackgroundColor (short); + bool setNoUnderline(bool); + bool setNoUnderline(); + bool unsetNoUnderline(); + bool setEnable(bool); + bool setEnable(); + bool unsetEnable(); + bool setDisable(); + bool setFocus(bool); + bool setFocus(); + bool unsetFocus(); + bool setFlat(bool); + bool setFlat(); + bool unsetFlat(); + bool setShadow(bool); + bool setShadow(); + bool unsetShadow(); + bool setDown(bool); + bool setDown(); + bool setUp(); + bool setClickAnimation(bool); + bool setClickAnimation(); + bool unsetClickAnimation(); + void setText (const FString&); - // Inquiries - bool isFlat() const; - bool isDown() const; - bool hasShadow() const; - bool hasClickAnimation(); + // Inquiries + bool isFlat() const; + bool isDown() const; + bool hasShadow() const; + bool hasClickAnimation(); - // Methods - void hide(); + // Methods + void hide(); - // Event handlers - void onKeyPress (FKeyEvent*); - void onMouseDown (FMouseEvent*); - void onMouseUp (FMouseEvent*); - void onMouseMove (FMouseEvent*); - void onTimer (FTimerEvent*); - void onAccel (FAccelEvent*); - void onFocusIn (FFocusEvent*); - void onFocusOut (FFocusEvent*); + // Event handlers + void onKeyPress (FKeyEvent*); + void onMouseDown (FMouseEvent*); + void onMouseUp (FMouseEvent*); + void onMouseMove (FMouseEvent*); + void onTimer (FTimerEvent*); + void onAccel (FAccelEvent*); + void onFocusIn (FFocusEvent*); + void onFocusOut (FFocusEvent*); - private: - // Disable copy constructor - FButton (const FButton&); + private: + // Disable copy constructor + FButton (const FButton&); - // Disable assignment operator (=) - FButton& operator = (const FButton&); + // Disable assignment operator (=) + FButton& operator = (const FButton&); - // Methods - void init(); - uChar getHotkey(); - void setHotkeyAccelerator(); - void detectHotkey(); - void draw(); - void updateButtonColor(); - void processClick(); + // Methods + void init(); + uChar getHotkey(); + void setHotkeyAccelerator(); + void detectHotkey(); + void draw(); + void updateButtonColor(); + void processClick(); - // Data Members - FString text; - bool button_down; - bool click_animation; - int click_time; - short button_fg; - short button_bg; - short button_hotkey_fg; - short button_focus_fg; - short button_focus_bg; - short button_inactive_fg; - short button_inactive_bg; + // Data Members + FString text; + bool button_down; + bool click_animation; + int click_time; + short button_fg; + short button_bg; + short button_hotkey_fg; + short button_focus_fg; + short button_focus_bg; + short button_inactive_fg; + short button_inactive_bg; }; #pragma pack(pop) diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index 02a58fa5..7c874a93 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -240,7 +240,8 @@ void FButtonGroup::insert (FToggleButton* button) // setChecked the first FRadioButton if ( buttonlist.size() == 1 ) { - FToggleButton* first_button = static_cast(*buttonlist.begin()); + FToggleButton* first_button; + first_button = static_cast(*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); } //---------------------------------------------------------------------- diff --git a/src/fbuttongroup.h b/src/fbuttongroup.h index a193079a..b6aa4a45 100644 --- a/src/fbuttongroup.h +++ b/src/fbuttongroup.h @@ -43,77 +43,77 @@ class FToggleButton; class FButtonGroup : public FScrollView { - public: - // Constructors - explicit FButtonGroup (FWidget* = 0); - FButtonGroup (const FString&, FWidget* = 0); + public: + // Constructors + explicit FButtonGroup (FWidget* = 0); + FButtonGroup (const FString&, FWidget* = 0); - // Destructor - virtual ~FButtonGroup(); + // Destructor + virtual ~FButtonGroup(); - // Accessor - const char* getClassName() const; - FToggleButton* getFirstButton(); - FToggleButton* getLastButton(); - FToggleButton* getButton (int) const; - uInt getCount() const; - FString& getText(); + // Accessor + const char* getClassName() const; + FToggleButton* getFirstButton(); + FToggleButton* getLastButton(); + FToggleButton* getButton (int) const; + uInt getCount() const; + FString& getText(); - // Mutator - bool setEnable(bool); - bool setEnable(); - bool unsetEnable(); - bool setDisable(); - void setText (const FString&); + // Mutator + bool setEnable(bool); + bool setEnable(); + bool unsetEnable(); + bool setDisable(); + void setText (const FString&); - // Inquiries - bool isChecked(int) const; - bool hasFocusedButton() const; - bool hasCheckedButton() const; + // Inquiries + bool isChecked(int) const; + bool hasFocusedButton() const; + bool hasCheckedButton() const; - // Methods - void hide(); - void insert (FToggleButton*); - void remove (FToggleButton*); - void checkScrollSize (FToggleButton*); - void checkScrollSize (const FRect&); + // Methods + void hide(); + void insert (FToggleButton*); + void remove (FToggleButton*); + void checkScrollSize (FToggleButton*); + void checkScrollSize (const FRect&); - // Event handlers - void onMouseDown (FMouseEvent*); - void onAccel (FAccelEvent*); - void onFocusIn (FFocusEvent*); + // Event handlers + void onMouseDown (FMouseEvent*); + void onAccel (FAccelEvent*); + void onFocusIn (FFocusEvent*); - // Callback method - void cb_buttonToggled (FWidget*, data_ptr); + // Callback method + void cb_buttonToggled (FWidget*, data_ptr); - protected: - // Accessor - uChar getHotkey(); + protected: + // Accessor + uChar getHotkey(); - // Mutator - void setHotkeyAccelerator(); + // Mutator + void setHotkeyAccelerator(); - // Methods - virtual void draw(); - void drawLabel(); + // Methods + virtual void draw(); + void drawLabel(); - private: - // Disable copy constructor - FButtonGroup (const FButtonGroup&); + private: + // Disable copy constructor + FButtonGroup (const FButtonGroup&); - // Disable assignment operator (=) - FButtonGroup& operator = (const FButtonGroup&); + // Disable assignment operator (=) + FButtonGroup& operator = (const FButtonGroup&); - // Inquiries - bool isRadioButton (FToggleButton*) const; + // Inquiries + bool isRadioButton (FToggleButton*) const; - // Methods - void init(); - void directFocus(); + // Methods + void init(); + void directFocus(); - // Data Members - FString text; - FObjectList buttonlist; + // Data Members + FString text; + FObjectList buttonlist; }; #pragma pack(pop) diff --git a/src/fc.h b/src/fc.h index f0905b2a..fc62d598 100644 --- a/src/fc.h +++ b/src/fc.h @@ -34,1069 +34,1069 @@ class fc { - public: - // Event types - enum events - { - None_Event, // invalid event - KeyPress_Event, // key pressed - KeyUp_Event, // key released - KeyDown_Event, // key pressed - MouseDown_Event, // mouse button pressed - MouseUp_Event, // mouse button released - MouseDoubleClick_Event, // mouse button double click - MouseWheel_Event, // mouse wheel rolled - MouseMove_Event, // mouse move - FocusIn_Event, // focus in - FocusOut_Event, // focus out - ChildFocusIn_Event, // child focus in - ChildFocusOut_Event, // child focus out - WindowActive_Event, // activate window - WindowInactive_Event, // deactivate window - WindowRaised_Event, // raise window - WindowLowered_Event, // lower window - Accelerator_Event, // keyboard accelerator - Resize_Event, // terminal resize - Show_Event, // widget is shown - Hide_Event, // widget is hidden - Close_Event, // widget close - Timer_Event // timer event occur - }; + public: + // Event types + enum events + { + None_Event, // invalid event + KeyPress_Event, // key pressed + KeyUp_Event, // key released + KeyDown_Event, // key pressed + MouseDown_Event, // mouse button pressed + MouseUp_Event, // mouse button released + MouseDoubleClick_Event, // mouse button double click + MouseWheel_Event, // mouse wheel rolled + MouseMove_Event, // mouse move + FocusIn_Event, // focus in + FocusOut_Event, // focus out + ChildFocusIn_Event, // child focus in + ChildFocusOut_Event, // child focus out + WindowActive_Event, // activate window + WindowInactive_Event, // deactivate window + WindowRaised_Event, // raise window + WindowLowered_Event, // lower window + Accelerator_Event, // keyboard accelerator + Resize_Event, // terminal resize + Show_Event, // widget is shown + Hide_Event, // widget is hidden + Close_Event, // widget close + Timer_Event // timer event occur + }; - // Properties of a widget - enum widget_flags - { - shadow = 0x00000001, - trans_shadow = 0x00000002, - active = 0x00000004, - focus = 0x00000008, - scrollable = 0x00000010, - resizeable = 0x00000020, - modal = 0x00000040, - window_widget = 0x00000080, - dialog_widget = 0x00000100, - menu_widget = 0x00000200, - always_on_top = 0x00000400, - flat = 0x00000800, - no_underline = 0x00001000 - }; + // Properties of a widget + enum widget_flags + { + shadow = 0x00000001, + trans_shadow = 0x00000002, + active = 0x00000004, + focus = 0x00000008, + scrollable = 0x00000010, + resizeable = 0x00000020, + modal = 0x00000040, + window_widget = 0x00000080, + dialog_widget = 0x00000100, + menu_widget = 0x00000200, + always_on_top = 0x00000400, + flat = 0x00000800, + no_underline = 0x00001000 + }; - // Internal character encoding - enum encoding - { - UTF8, - VT100, - PC, - ASCII, - NUM_OF_ENCODINGS // number of items - }; + // Internal character encoding + enum encoding + { + UTF8, + VT100, + PC, + ASCII, + NUM_OF_ENCODINGS // number of items + }; - // VT100 line graphic keys - enum vt100_keys - { - vt100_key_rarrow = '+', // ► - arrow pointing right - vt100_key_larrow = ',', // ◄ - arrow pointing left - vt100_key_uarrow = '-', // ▲ - arrow pointing up - vt100_key_darrow = '.', // ▼ - arrow pointing down - vt100_key_block = '0', // █ - solid square block - vt100_key_nsup = 'I', // ⁿ - superscript letter n - vt100_key_blackrect = '_', // ▮ - black vertical rectangle - vt100_key_diamond = '`', // ◆ - diamond - vt100_key_ckboard = 'a', // ▒ - checker board (stipple) - vt100_key_htab = 'b', // ␉ - horizontal tab symbol - vt100_key_ff = 'c', // ␌ - form feed symbol - vt100_key_cr = 'd', // ␍ - carriage return symbol - vt100_key_lf = 'e', // ␊ - line feed symbol - vt100_key_degree = 'f', // ° - degree symbol - vt100_key_plminus = 'g', // ± - plus/minus - vt100_key_board = 'h', // ␤ - board of squares - vt100_key_lantern = 'i', // ␋ - lantern symbol - vt100_key_lrcorner = 'j', // ┘ - lower right corner - vt100_key_urcorner = 'k', // ┐ - upper right corner - vt100_key_ulcorner = 'l', // ┌ - upper left corner - vt100_key_llcorner = 'm', // └ - lower left corner - vt100_key_plus = 'n', // ┼ - large plus or crossover - vt100_key_s1 = 'o', // ⎺ - scan line 1 - vt100_key_s3 = 'p', // ⎻ - scan line 3 - vt100_key_hline = 'q', // ─ - horizontal line - vt100_key_s7 = 'r', // ⎼ - scan line 7 - vt100_key_s9 = 's', // ⎽ - scan line 9 - vt100_key_ltee = 't', // ├ - tee pointing right - vt100_key_rtee = 'u', // ┤ - tee pointing left - vt100_key_btee = 'v', // ┴ - tee pointing up - vt100_key_ttee = 'w', // ┬ - tee pointing down - vt100_key_vline = 'x', // │ - vertical line - vt100_key_lequal = 'y', // ≤ - less-than-or-equal-to - vt100_key_gequal = 'z', // ≥ - greater-than-or-equal-to - vt100_key_pi = '{', // π - greek pi - vt100_key_nequal = '|', // ≠ - not-equal - vt100_key_sterling = '}', // £ - UK pound sign - vt100_key_bullet = '~' // · - bullet - }; + // VT100 line graphic keys + enum vt100_keys + { + vt100_key_rarrow = '+', // ► - arrow pointing right + vt100_key_larrow = ',', // ◄ - arrow pointing left + vt100_key_uarrow = '-', // ▲ - arrow pointing up + vt100_key_darrow = '.', // ▼ - arrow pointing down + vt100_key_block = '0', // █ - solid square block + vt100_key_nsup = 'I', // ⁿ - superscript letter n + vt100_key_blackrect = '_', // ▮ - black vertical rectangle + vt100_key_diamond = '`', // ◆ - diamond + vt100_key_ckboard = 'a', // ▒ - checker board (stipple) + vt100_key_htab = 'b', // ␉ - horizontal tab symbol + vt100_key_ff = 'c', // ␌ - form feed symbol + vt100_key_cr = 'd', // ␍ - carriage return symbol + vt100_key_lf = 'e', // ␊ - line feed symbol + vt100_key_degree = 'f', // ° - degree symbol + vt100_key_plminus = 'g', // ± - plus/minus + vt100_key_board = 'h', // ␤ - board of squares + vt100_key_lantern = 'i', // ␋ - lantern symbol + vt100_key_lrcorner = 'j', // ┘ - lower right corner + vt100_key_urcorner = 'k', // ┐ - upper right corner + vt100_key_ulcorner = 'l', // ┌ - upper left corner + vt100_key_llcorner = 'm', // └ - lower left corner + vt100_key_plus = 'n', // ┼ - large plus or crossover + vt100_key_s1 = 'o', // ⎺ - scan line 1 + vt100_key_s3 = 'p', // ⎻ - scan line 3 + vt100_key_hline = 'q', // ─ - horizontal line + vt100_key_s7 = 'r', // ⎼ - scan line 7 + vt100_key_s9 = 's', // ⎽ - scan line 9 + vt100_key_ltee = 't', // ├ - tee pointing right + vt100_key_rtee = 'u', // ┤ - tee pointing left + vt100_key_btee = 'v', // ┴ - tee pointing up + vt100_key_ttee = 'w', // ┬ - tee pointing down + vt100_key_vline = 'x', // │ - vertical line + vt100_key_lequal = 'y', // ≤ - less-than-or-equal-to + vt100_key_gequal = 'z', // ≥ - greater-than-or-equal-to + vt100_key_pi = '{', // π - greek pi + vt100_key_nequal = '|', // ≠ - not-equal + vt100_key_sterling = '}', // £ - UK pound sign + vt100_key_bullet = '~' // · - bullet + }; - // Unicode characters - enum SpecialCharacter - { - Euro = 0x20ac, // € - Pound = 0x00a3, // £ - Pi = 0x03c0, // π - SuperscriptLatinSmallLetterN = 0x207F, // ⁿ - GreaterThanOrEqualTo = 0x2265, // ≥ - LessThanOrEqualTo = 0x2264, // ≤ - NotEqualTo = 0x2260, // ≠ - PlusMinus = 0x00b1, // ± - Times = 0x00d7, // × - Degree = 0x00b0, // ° - BlackVerticalRectangle = 0x25ae, // ▮ - SmallBullet = 0x00b7, // · - BlackDiamond = 0x25c6, // ◆ - SymbolForNewline = 0x2424, // ␤ - SymbolForVerticalTab = 0x240b, // ␋ - SymbolForHorizontalTab = 0x2409, // ␉ - SymbolForFormFeed = 0x240c, // ␌ - SymbolForCarriageReturn = 0x240d, // ␍ - SymbolForLineFeed = 0x240a, // ␊ - MediumShade = 0x2592, // ▒ - BoxDrawingsHorizontal = 0x2500, // ─ - BoxDrawingsVertical = 0x2502, // │ - BoxDrawingsDownAndRight = 0x250c, // ┌ - BoxDrawingsDownAndLeft = 0x2510, // ┐ - BoxDrawingsUpAndRight = 0x2514, // └ - BoxDrawingsUpAndLeft = 0x2518, // ┘ - BoxDrawingsCross = 0x253c, // ┼ - BoxDrawingsDownAndHorizontal = 0x252c, // ┬ - BoxDrawingsVerticalAndLeft = 0x2524, // ┤ - BoxDrawingsVerticalAndRight = 0x251c, // ├ - BoxDrawingsUpAndHorizontal = 0x2534, // ┴ - HorizontalScanLine1 = 0x23ba, // ⎺ - HorizontalScanLine3 = 0x23bb, // ⎻ - HorizontalScanLine7 = 0x23bc, // ⎼ - HorizontalScanLine9 = 0x23bd, // ⎽ - BlackUpPointingTriangle = 0x25b2, // ▲ - BlackDownPointingTriangle = 0x25bc, // ▼ - BlackRightPointingPointer = 0x25ba, // ► - BlackLeftPointingPointer = 0x25c4, // ◄ - Bullet = 0x2022, // • - FullBlock = 0x2588, // █ - UpperHalfBlock = 0x2580, // ▀ - LowerHalfBlock = 0x2584, // ▄ - LeftHalfBlock = 0x258c, // ▌ - RightHalfBlock = 0x2590, // ▐ - NF_rev_left_arrow2 = 0x1ab4, // ⊐ - NF_rev_right_arrow2 = 0x1ab5, // ► - NF_radio_button3 = 0x1ab7, // ) - NF_rev_border_corner_upper_right = 0x1ab8, // ⎤ - NF_rev_border_line_right = 0x1ab9, // ⎹ - NF_rev_border_line_vertical_left = 0x1aba, // ┤ - NF_rev_border_corner_lower_right = 0x1abb, // ⎦ - NF_border_line_left = 0x1abc, // ⎸ - NF_rev_up_arrow2 = 0x1abd, //⎹◣ - NF_rev_down_arrow2 = 0x1abe, //⎹◤ - NF_border_corner_middle_lower_left = 0x1ac0, // └ - NF_rev_up_arrow1 = 0x1ac1, // ◢⎸ - NF_rev_down_arrow1 = 0x1ac2, // ◥⎸ - NF_border_line_vertical_right = 0x1ac3, // ├ - NF_border_line_up_and_down = 0x1ac5, // ニ - NF_shadow_box_middle = 0x1ac6, // ニ - NF_shadow_box_hdd = 0x1ac7, // ニ - NF_rev_left_arrow1 = 0x1ac8, // ◄ - NF_rev_right_arrow1 = 0x1ac9, // ⊏ - NF_rev_menu_button1 = 0x1aca, // [ - NF_rev_menu_button2 = 0x1acb, // - - NF_border_corner_middle_upper_left = 0x1acc, // ┌ - NF_shadow_box_cd = 0x1acd, // ニ - NF_shadow_box_left = 0x1ace, // [ - NF_border_corner_middle_lower_right = 0x1acf, // ┘ - NF_border_corner_middle_upper_right = 0x1ad0, // ┐ - NF_shadow_box_net = 0x1ad1, // ニ - NF_rev_up_pointing_triangle1 = 0x1ad2, // ◢ - NF_border_corner_lower_left = 0x1ad3, // ⎣ - NF_border_line_bottom = 0x1ad4, // _ - NF_radio_button2 = 0x1ad5, // ⁐ - NF_radio_button2_checked = 0x1ad6, // ● - NF_rev_down_pointing_triangle1 = 0x1ad7, // ◥ - NF_border_line_upper = 0x1ad8, // ¯ - NF_radio_button1 = 0x1ad9, // ( - NF_border_corner_upper_left = 0x1ada, // ⎡ - NF_shadow_box_checked = 0x1adc, // ✓ - NF_rev_border_line_right_and_left = 0x1ae7, // || - NF_rev_up_pointing_triangle2 = 0x1ae8, // ◣ - NF_rev_down_pointing_triangle2 = 0x1ae9, // ◤ - NF_rev_menu_button3 = 0x1af4, // ] - NF_shadow_box_right = 0x1af5, // ] - NF_Bullet = 0x1af9, // ● - NF_check_mark = 0x1afb, // ✓ - SquareRoot = 0x221a // √ - }; + // Unicode characters + enum SpecialCharacter + { + Euro = 0x20ac, // € + Pound = 0x00a3, // £ + Pi = 0x03c0, // π + SuperscriptLatinSmallLetterN = 0x207F, // ⁿ + GreaterThanOrEqualTo = 0x2265, // ≥ + LessThanOrEqualTo = 0x2264, // ≤ + NotEqualTo = 0x2260, // ≠ + PlusMinus = 0x00b1, // ± + Times = 0x00d7, // × + Degree = 0x00b0, // ° + BlackVerticalRectangle = 0x25ae, // ▮ + SmallBullet = 0x00b7, // · + BlackDiamond = 0x25c6, // ◆ + SymbolForNewline = 0x2424, // ␤ + SymbolForVerticalTab = 0x240b, // ␋ + SymbolForHorizontalTab = 0x2409, // ␉ + SymbolForFormFeed = 0x240c, // ␌ + SymbolForCarriageReturn = 0x240d, // ␍ + SymbolForLineFeed = 0x240a, // ␊ + MediumShade = 0x2592, // ▒ + BoxDrawingsHorizontal = 0x2500, // ─ + BoxDrawingsVertical = 0x2502, // │ + BoxDrawingsDownAndRight = 0x250c, // ┌ + BoxDrawingsDownAndLeft = 0x2510, // ┐ + BoxDrawingsUpAndRight = 0x2514, // └ + BoxDrawingsUpAndLeft = 0x2518, // ┘ + BoxDrawingsCross = 0x253c, // ┼ + BoxDrawingsDownAndHorizontal = 0x252c, // ┬ + BoxDrawingsVerticalAndLeft = 0x2524, // ┤ + BoxDrawingsVerticalAndRight = 0x251c, // ├ + BoxDrawingsUpAndHorizontal = 0x2534, // ┴ + HorizontalScanLine1 = 0x23ba, // ⎺ + HorizontalScanLine3 = 0x23bb, // ⎻ + HorizontalScanLine7 = 0x23bc, // ⎼ + HorizontalScanLine9 = 0x23bd, // ⎽ + BlackUpPointingTriangle = 0x25b2, // ▲ + BlackDownPointingTriangle = 0x25bc, // ▼ + BlackRightPointingPointer = 0x25ba, // ► + BlackLeftPointingPointer = 0x25c4, // ◄ + Bullet = 0x2022, // • + FullBlock = 0x2588, // █ + UpperHalfBlock = 0x2580, // ▀ + LowerHalfBlock = 0x2584, // ▄ + LeftHalfBlock = 0x258c, // ▌ + RightHalfBlock = 0x2590, // ▐ + NF_rev_left_arrow2 = 0x1ab4, // ⊐ + NF_rev_right_arrow2 = 0x1ab5, // ► + NF_radio_button3 = 0x1ab7, // ) + NF_rev_border_corner_upper_right = 0x1ab8, // ⎤ + NF_rev_border_line_right = 0x1ab9, // ⎹ + NF_rev_border_line_vertical_left = 0x1aba, // ┤ + NF_rev_border_corner_lower_right = 0x1abb, // ⎦ + NF_border_line_left = 0x1abc, // ⎸ + NF_rev_up_arrow2 = 0x1abd, //⎹◣ + NF_rev_down_arrow2 = 0x1abe, //⎹◤ + NF_border_corner_middle_lower_left = 0x1ac0, // └ + NF_rev_up_arrow1 = 0x1ac1, // ◢⎸ + NF_rev_down_arrow1 = 0x1ac2, // ◥⎸ + NF_border_line_vertical_right = 0x1ac3, // ├ + NF_border_line_up_and_down = 0x1ac5, // ニ + NF_shadow_box_middle = 0x1ac6, // ニ + NF_shadow_box_hdd = 0x1ac7, // ニ + NF_rev_left_arrow1 = 0x1ac8, // ◄ + NF_rev_right_arrow1 = 0x1ac9, // ⊏ + NF_rev_menu_button1 = 0x1aca, // [ + NF_rev_menu_button2 = 0x1acb, // - + NF_border_corner_middle_upper_left = 0x1acc, // ┌ + NF_shadow_box_cd = 0x1acd, // ニ + NF_shadow_box_left = 0x1ace, // [ + NF_border_corner_middle_lower_right = 0x1acf, // ┘ + NF_border_corner_middle_upper_right = 0x1ad0, // ┐ + NF_shadow_box_net = 0x1ad1, // ニ + NF_rev_up_pointing_triangle1 = 0x1ad2, // ◢ + NF_border_corner_lower_left = 0x1ad3, // ⎣ + NF_border_line_bottom = 0x1ad4, // _ + NF_radio_button2 = 0x1ad5, // ⁐ + NF_radio_button2_checked = 0x1ad6, // ● + NF_rev_down_pointing_triangle1 = 0x1ad7, // ◥ + NF_border_line_upper = 0x1ad8, // ¯ + NF_radio_button1 = 0x1ad9, // ( + NF_border_corner_upper_left = 0x1ada, // ⎡ + NF_shadow_box_checked = 0x1adc, // ✓ + NF_rev_border_line_right_and_left = 0x1ae7, // || + NF_rev_up_pointing_triangle2 = 0x1ae8, // ◣ + NF_rev_down_pointing_triangle2 = 0x1ae9, // ◤ + NF_rev_menu_button3 = 0x1af4, // ] + NF_shadow_box_right = 0x1af5, // ] + NF_Bullet = 0x1af9, // ● + NF_check_mark = 0x1afb, // ✓ + SquareRoot = 0x221a // √ + }; - // keyboard - single keys - enum keys - { - Fckey_a = 0x0000001, // control-a - Fckey_b = 0x0000002, // control-b - Fckey_c = 0x0000003, // control-c - Fckey_d = 0x0000004, // control-d - Fckey_e = 0x0000005, // control-e - Fckey_f = 0x0000006, // control-f - Fckey_g = 0x0000007, // control-g - Fkey_erase = 0x0000008, // control-h - Fkey_tab = 0x0000009, // control-i - Fckey_j = 0x000000a, // control-j - Fckey_h = 0x000000b, // control-k - Fckey_l = 0x000000c, // control-l - Fkey_return = 0x000000d, // control-m - Fckey_n = 0x000000e, // control-n - Fckey_o = 0x000000f, // control-o - Fckey_p = 0x0000010, // control-p - Fckey_q = 0x0000011, // control-q - Fckey_r = 0x0000012, // control-r - Fckey_s = 0x0000013, // control-s - Fckey_t = 0x0000014, // control-t - Fckey_u = 0x0000015, // control-u - Fckey_v = 0x0000016, // control-v - Fckey_w = 0x0000017, // control-w - Fckey_x = 0x0000018, // control-x - Fckey_y = 0x0000019, // control-y - Fckey_z = 0x000001a, // control-t - Fkey_escape = 0x000001b, // control-[ - Fckey_backslash = 0x000001c, // control-'\' - Fckey_right_square_bracket = 0x000001d, // control-] - Fckey_caret = 0x000001e, // control-^ - Fckey_underscore = 0x000001f, // control-_ - Fkey_space = 0x0000020, - Fckey_space = 0x1000020, // control-space - Fkey_backspace = 0x1000100, - Fkey_catab = 0x1000101, - Fkey_clear = 0x1000102, - Fkey_ctab = 0x1000103, - Fkey_dc = 0x1000104, - Fkey_dl = 0x1000105, - Fkey_down = 0x1000106, - Fkey_eic = 0x1000107, - Fkey_eol = 0x1000108, - Fkey_eos = 0x1000109, - Fkey_f0 = 0x100010a, - Fkey_f1 = 0x100010b, - Fkey_f2 = 0x100010c, - Fkey_f3 = 0x100010d, - Fkey_f4 = 0x100010e, - Fkey_f5 = 0x100010f, - Fkey_f6 = 0x1000110, - Fkey_f7 = 0x1000111, - Fkey_f8 = 0x1000112, - Fkey_f9 = 0x1000113, - Fkey_f10 = 0x1000114, - Fkey_home = 0x1000115, - Fkey_ic = 0x1000116, // insert key - Fkey_il = 0x1000117, - Fkey_left = 0x1000118, - Fkey_ll = 0x1000119, - Fkey_npage = 0x100011a, - Fkey_ppage = 0x100011b, - Fkey_right = 0x100011c, - Fkey_sf = 0x100011d, - Fkey_sr = 0x100011e, - Fkey_stab = 0x100011f, - Fkey_up = 0x1000120, - Fkey_a1 = 0x1000121, - Fkey_a3 = 0x1000122, - Fkey_b2 = 0x1000123, - Fkey_c1 = 0x1000124, - Fkey_c3 = 0x1000125, - Fkey_btab = 0x1000126, - Fkey_beg = 0x1000127, - Fkey_cancel = 0x1000128, - Fkey_close = 0x1000129, - Fkey_command = 0x100012a, - Fkey_copy = 0x100012b, - Fkey_create = 0x100012c, - Fkey_end = 0x100012d, - Fkey_enter = 0x100012e, - Fkey_exit = 0x100012f, - Fkey_find = 0x1000130, - Fkey_help = 0x1000131, - Fkey_mark = 0x1000132, - Fkey_message = 0x1000133, - Fkey_move = 0x1000134, - Fkey_next = 0x1000135, - Fkey_open = 0x1000136, - Fkey_options = 0x1000137, - Fkey_previous = 0x1000138, - Fkey_print = 0x1000139, - Fkey_redo = 0x100013a, - Fkey_reference = 0x100013b, - Fkey_refresh = 0x100013c, - Fkey_replace = 0x100013d, - Fkey_restart = 0x100013e, - Fkey_resume = 0x100013f, - Fkey_save = 0x1000140, - Fkey_suspend = 0x1000141, - Fkey_undo = 0x1000142, - Fkey_sbeg = 0x1000143, - Fkey_scancel = 0x1000144, - Fkey_scommand = 0x1000145, - Fkey_scopy = 0x1000146, - Fkey_screate = 0x1000147, - Fkey_sdc = 0x1000148, - Fkey_sdl = 0x1000149, - Fkey_select = 0x100014a, - Fkey_send = 0x100014b, - Fkey_seol = 0x100014c, - Fkey_sexit = 0x100014d, - Fkey_sfind = 0x100014e, - Fkey_shelp = 0x100014f, - Fkey_shome = 0x1000150, - Fkey_sic = 0x1000151, - Fkey_sleft = 0x1000152, - Fkey_smessage = 0x1000153, - Fkey_smove = 0x1000154, - Fkey_snext = 0x1000155, - Fkey_soptions = 0x1000156, - Fkey_sprevious = 0x1000157, - Fkey_sprint = 0x1000158, - Fkey_sredo = 0x1000159, - Fkey_sreplace = 0x100015a, - Fkey_sright = 0x100015b, - Fkey_srsume = 0x100015c, - Fkey_ssave = 0x100015d, - Fkey_ssuspend = 0x100015e, - Fkey_sundo = 0x100015f, - Fkey_f11 = 0x1000160, - Fkey_f12 = 0x1000161, - Fkey_f13 = 0x1000162, - Fkey_f14 = 0x1000163, - Fkey_f15 = 0x1000164, - Fkey_f16 = 0x1000165, - Fkey_f17 = 0x1000166, - Fkey_f18 = 0x1000167, - Fkey_f19 = 0x1000168, - Fkey_f20 = 0x1000169, - Fkey_f21 = 0x100016a, - Fkey_f22 = 0x100016b, - Fkey_f23 = 0x100016c, - Fkey_f24 = 0x100016d, - Fkey_f25 = 0x100016e, - Fkey_f26 = 0x100016f, - Fkey_f27 = 0x1000170, - Fkey_f28 = 0x1000171, - Fkey_f29 = 0x1000172, - Fkey_f30 = 0x1000173, - Fkey_f31 = 0x1000174, - Fkey_f32 = 0x1000175, - Fkey_f33 = 0x1000176, - Fkey_f34 = 0x1000177, - Fkey_f35 = 0x1000178, - Fkey_f36 = 0x1000179, - Fkey_f37 = 0x100017a, - Fkey_f38 = 0x100017b, - Fkey_f39 = 0x100017c, - Fkey_f40 = 0x100017d, - Fkey_f41 = 0x100017e, - Fkey_f42 = 0x100017f, - Fkey_f43 = 0x1000180, - Fkey_f44 = 0x1000181, - Fkey_f45 = 0x1000182, - Fkey_f46 = 0x1000183, - Fkey_f47 = 0x1000184, - Fkey_f48 = 0x1000185, - Fkey_f49 = 0x1000186, - Fkey_f50 = 0x1000187, - Fkey_f51 = 0x1000188, - Fkey_f52 = 0x1000189, - Fkey_f53 = 0x100018a, - Fkey_f54 = 0x100018b, - Fkey_f55 = 0x100018c, - Fkey_f56 = 0x100018d, - Fkey_f57 = 0x100018e, - Fkey_f58 = 0x100018f, - Fkey_f59 = 0x1000190, - Fkey_f60 = 0x1000191, - Fkey_f61 = 0x1000192, - Fkey_f62 = 0x1000193, - Fkey_f63 = 0x1000194 - }; + // keyboard - single keys + enum keys + { + Fckey_a = 0x0000001, // control-a + Fckey_b = 0x0000002, // control-b + Fckey_c = 0x0000003, // control-c + Fckey_d = 0x0000004, // control-d + Fckey_e = 0x0000005, // control-e + Fckey_f = 0x0000006, // control-f + Fckey_g = 0x0000007, // control-g + Fkey_erase = 0x0000008, // control-h + Fkey_tab = 0x0000009, // control-i + Fckey_j = 0x000000a, // control-j + Fckey_h = 0x000000b, // control-k + Fckey_l = 0x000000c, // control-l + Fkey_return = 0x000000d, // control-m + Fckey_n = 0x000000e, // control-n + Fckey_o = 0x000000f, // control-o + Fckey_p = 0x0000010, // control-p + Fckey_q = 0x0000011, // control-q + Fckey_r = 0x0000012, // control-r + Fckey_s = 0x0000013, // control-s + Fckey_t = 0x0000014, // control-t + Fckey_u = 0x0000015, // control-u + Fckey_v = 0x0000016, // control-v + Fckey_w = 0x0000017, // control-w + Fckey_x = 0x0000018, // control-x + Fckey_y = 0x0000019, // control-y + Fckey_z = 0x000001a, // control-t + Fkey_escape = 0x000001b, // control-[ + Fckey_backslash = 0x000001c, // control-'\' + Fckey_right_square_bracket = 0x000001d, // control-] + Fckey_caret = 0x000001e, // control-^ + Fckey_underscore = 0x000001f, // control-_ + Fkey_space = 0x0000020, + Fckey_space = 0x1000020, // control-space + Fkey_backspace = 0x1000100, + Fkey_catab = 0x1000101, + Fkey_clear = 0x1000102, + Fkey_ctab = 0x1000103, + Fkey_dc = 0x1000104, + Fkey_dl = 0x1000105, + Fkey_down = 0x1000106, + Fkey_eic = 0x1000107, + Fkey_eol = 0x1000108, + Fkey_eos = 0x1000109, + Fkey_f0 = 0x100010a, + Fkey_f1 = 0x100010b, + Fkey_f2 = 0x100010c, + Fkey_f3 = 0x100010d, + Fkey_f4 = 0x100010e, + Fkey_f5 = 0x100010f, + Fkey_f6 = 0x1000110, + Fkey_f7 = 0x1000111, + Fkey_f8 = 0x1000112, + Fkey_f9 = 0x1000113, + Fkey_f10 = 0x1000114, + Fkey_home = 0x1000115, + Fkey_ic = 0x1000116, // insert key + Fkey_il = 0x1000117, + Fkey_left = 0x1000118, + Fkey_ll = 0x1000119, + Fkey_npage = 0x100011a, + Fkey_ppage = 0x100011b, + Fkey_right = 0x100011c, + Fkey_sf = 0x100011d, + Fkey_sr = 0x100011e, + Fkey_stab = 0x100011f, + Fkey_up = 0x1000120, + Fkey_a1 = 0x1000121, + Fkey_a3 = 0x1000122, + Fkey_b2 = 0x1000123, + Fkey_c1 = 0x1000124, + Fkey_c3 = 0x1000125, + Fkey_btab = 0x1000126, + Fkey_beg = 0x1000127, + Fkey_cancel = 0x1000128, + Fkey_close = 0x1000129, + Fkey_command = 0x100012a, + Fkey_copy = 0x100012b, + Fkey_create = 0x100012c, + Fkey_end = 0x100012d, + Fkey_enter = 0x100012e, + Fkey_exit = 0x100012f, + Fkey_find = 0x1000130, + Fkey_help = 0x1000131, + Fkey_mark = 0x1000132, + Fkey_message = 0x1000133, + Fkey_move = 0x1000134, + Fkey_next = 0x1000135, + Fkey_open = 0x1000136, + Fkey_options = 0x1000137, + Fkey_previous = 0x1000138, + Fkey_print = 0x1000139, + Fkey_redo = 0x100013a, + Fkey_reference = 0x100013b, + Fkey_refresh = 0x100013c, + Fkey_replace = 0x100013d, + Fkey_restart = 0x100013e, + Fkey_resume = 0x100013f, + Fkey_save = 0x1000140, + Fkey_suspend = 0x1000141, + Fkey_undo = 0x1000142, + Fkey_sbeg = 0x1000143, + Fkey_scancel = 0x1000144, + Fkey_scommand = 0x1000145, + Fkey_scopy = 0x1000146, + Fkey_screate = 0x1000147, + Fkey_sdc = 0x1000148, + Fkey_sdl = 0x1000149, + Fkey_select = 0x100014a, + Fkey_send = 0x100014b, + Fkey_seol = 0x100014c, + Fkey_sexit = 0x100014d, + Fkey_sfind = 0x100014e, + Fkey_shelp = 0x100014f, + Fkey_shome = 0x1000150, + Fkey_sic = 0x1000151, + Fkey_sleft = 0x1000152, + Fkey_smessage = 0x1000153, + Fkey_smove = 0x1000154, + Fkey_snext = 0x1000155, + Fkey_soptions = 0x1000156, + Fkey_sprevious = 0x1000157, + Fkey_sprint = 0x1000158, + Fkey_sredo = 0x1000159, + Fkey_sreplace = 0x100015a, + Fkey_sright = 0x100015b, + Fkey_srsume = 0x100015c, + Fkey_ssave = 0x100015d, + Fkey_ssuspend = 0x100015e, + Fkey_sundo = 0x100015f, + Fkey_f11 = 0x1000160, + Fkey_f12 = 0x1000161, + Fkey_f13 = 0x1000162, + Fkey_f14 = 0x1000163, + Fkey_f15 = 0x1000164, + Fkey_f16 = 0x1000165, + Fkey_f17 = 0x1000166, + Fkey_f18 = 0x1000167, + Fkey_f19 = 0x1000168, + Fkey_f20 = 0x1000169, + Fkey_f21 = 0x100016a, + Fkey_f22 = 0x100016b, + Fkey_f23 = 0x100016c, + Fkey_f24 = 0x100016d, + Fkey_f25 = 0x100016e, + Fkey_f26 = 0x100016f, + Fkey_f27 = 0x1000170, + Fkey_f28 = 0x1000171, + Fkey_f29 = 0x1000172, + Fkey_f30 = 0x1000173, + Fkey_f31 = 0x1000174, + Fkey_f32 = 0x1000175, + Fkey_f33 = 0x1000176, + Fkey_f34 = 0x1000177, + Fkey_f35 = 0x1000178, + Fkey_f36 = 0x1000179, + Fkey_f37 = 0x100017a, + Fkey_f38 = 0x100017b, + Fkey_f39 = 0x100017c, + Fkey_f40 = 0x100017d, + Fkey_f41 = 0x100017e, + Fkey_f42 = 0x100017f, + Fkey_f43 = 0x1000180, + Fkey_f44 = 0x1000181, + Fkey_f45 = 0x1000182, + Fkey_f46 = 0x1000183, + Fkey_f47 = 0x1000184, + Fkey_f48 = 0x1000185, + Fkey_f49 = 0x1000186, + Fkey_f50 = 0x1000187, + Fkey_f51 = 0x1000188, + Fkey_f52 = 0x1000189, + Fkey_f53 = 0x100018a, + Fkey_f54 = 0x100018b, + Fkey_f55 = 0x100018c, + Fkey_f56 = 0x100018d, + Fkey_f57 = 0x100018e, + Fkey_f58 = 0x100018f, + Fkey_f59 = 0x1000190, + Fkey_f60 = 0x1000191, + Fkey_f61 = 0x1000192, + Fkey_f62 = 0x1000193, + Fkey_f63 = 0x1000194 + }; - // Keyboard - modifier key combinations - enum metakeys - { - Fmkey_ic = 0x1500100, // M-insert - Fmkey_dc = 0x1500101, // M-delete - Fmkey_home = 0x1500102, // M-home - Fmkey_end = 0x1500103, // M-end - Fmkey_ppage = 0x1500104, // M-prev-page - Fmkey_npage = 0x1500105, // M-next-page - Fmkey_f1 = 0x1500106, // M-f1 - Fmkey_f2 = 0x1500107, // M-f2 - Fmkey_f3 = 0x1500108, // M-f3 - Fmkey_f4 = 0x1500109, // M-f4 - Fmkey_f5 = 0x150010a, // M-f5 - Fmkey_f6 = 0x150010b, // M-F6 - Fmkey_f7 = 0x150010c, // M-f7 - Fmkey_f8 = 0x150010d, // M-f8 - Fmkey_f9 = 0x150010e, // M-f9 - Fmkey_f10 = 0x150010f, // M-f10 - Fmkey_f11 = 0x1500110, // M-f11 - Fmkey_f12 = 0x1500111, // M-f12 - Fmkey_up = 0x1500112, // M-up - Fmkey_down = 0x1500113, // M-down - Fmkey_right = 0x1500114, // M-right - Fmkey_left = 0x1500115, // M-left - Fmkey_sic = 0x1500116, // shifted M-Insert - Fmkey_sdc = 0x1500117, // shifted M-Delete - Fmkey_shome = 0x1500118, // shifted M-Home - Fmkey_send = 0x1500119, // shifted M-End - Fmkey_sppage = 0x150011a, // shifted M-Page_Up - Fmkey_snpage = 0x150011b, // shifted M-Page_Down - Fmkey_sf1 = 0x150011c, // shifted M-F1 - Fmkey_sf2 = 0x150011d, // shifted M-F2 - Fmkey_sf3 = 0x150011e, // shifted M-F3 - Fmkey_sf4 = 0x150011f, // shifted M-F4 - Fmkey_sf5 = 0x1500120, // shifted M-F5 - Fmkey_sf6 = 0x1500121, // shifted M-F6 - Fmkey_sf7 = 0x1500122, // shifted M-F7 - Fmkey_sf8 = 0x1500123, // shifted M-F8 - Fmkey_sf9 = 0x1500124, // shifted M-F9 - Fmkey_sf10 = 0x1500125, // shifted M-F10 - Fmkey_sf11 = 0x1500126, // shifted M-F11 - Fmkey_sf12 = 0x1500127, // shifted M-F12 - Fmkey_sup = 0x1500128, // shifted M-Up - Fmkey_sdown = 0x1500129, // shifted M-Down - Fmkey_sright = 0x150012a, // shifted M-Right - Fmkey_sleft = 0x150012b, // shifted M-Left - Fckey_ic = 0x150012c, // control-Insert - Fckey_dc = 0x150012d, // control-Delete - Fckey_home = 0x150012e, // control-Home - Fckey_end = 0x150012f, // control-End - Fckey_ppage = 0x1500130, // control-Page_Up - Fckey_npage = 0x1500131, // control-Page_Down - Fckey_up = 0x1500132, // control-Up - Fckey_down = 0x1500133, // control-Down - Fckey_right = 0x1500134, // control-Right - Fckey_left = 0x1500135, // control-Left - Fckey_sic = 0x1500136, // shifted control-M-Insert - Fckey_sdc = 0x1500137, // shifted control-M-Delete - Fckey_shome = 0x1500138, // shifted control-M-Home - Fckey_send = 0x1500139, // shifted control-M-End - Fckey_sppage = 0x150013a, // shifted control-M-Page_Up - Fckey_snpage = 0x150013b, // shifted control-M-Page_Down - Fckey_sup = 0x150013c, // shifted control-M-Up - Fckey_sdown = 0x150013d, // shifted control-M-Down - Fckey_sright = 0x150013e, // shifted control-M-Right - Fckey_sleft = 0x150013f, // shifted control-M-Left - Fcmkey_ic = 0x1500140, // control-M-Insert - Fcmkey_dc = 0x1500141, // control-M-Delete - Fcmkey_home = 0x1500142, // control-M-Home - Fcmkey_end = 0x1500143, // control-M-End - Fcmkey_ppage = 0x1500144, // control-M-Page_Up - Fcmkey_npage = 0x1500145, // control-M-Page_Down - Fcmkey_up = 0x1500146, // control-M-Up - Fcmkey_down = 0x1500147, // control-M-Down - Fcmkey_right = 0x1500148, // control-M-Right - Fcmkey_left = 0x1500149, // control-M-Left - Fcmkey_sic = 0x150014a, // shifted control-M-Insert - Fcmkey_sdc = 0x150014b, // shifted control-M-Delete - Fcmkey_shome = 0x150014c, // shifted control-M-Home - Fcmkey_send = 0x150014d, // shifted control-M-End - Fcmkey_sppage = 0x150014e, // shifted control-M-Page_Up - Fcmkey_snpage = 0x150014f, // shifted control-M-Page_Down - Fcmkey_sf1 = 0x1500150, // shifted control-M-F1 - Fcmkey_sf2 = 0x1500151, // shifted control-M-F2 - Fcmkey_sf3 = 0x1500152, // shifted control-M-F3 - Fcmkey_sf4 = 0x1500153, // shifted control-M-F4 - Fcmkey_sf5 = 0x1500154, // shifted control-M-F5 - Fcmkey_sf6 = 0x1500155, // shifted control-M-F6 - Fcmkey_sf7 = 0x1500156, // shifted control-M-F7 - Fcmkey_sf8 = 0x1500157, // shifted control-M-F8 - Fcmkey_sf9 = 0x1500158, // shifted control-M-F9 - Fcmkey_sf10 = 0x1500159, // shifted control-M-F10 - Fcmkey_sf11 = 0x150015a, // shifted control-M-F11 - Fcmkey_sf12 = 0x150015b, // shifted control-M-F12 - Fcmkey_sup = 0x150015c, // shifted control-M-Up - Fcmkey_sdown = 0x150015d, // shifted control-M-Down - Fcmkey_sright = 0x150015e, // shifted control-M-Right - Fcmkey_sleft = 0x150015f, // shifted control-M-Left - Fkey_menu = 0x1600000, // menu - Fkey_smenu = 0x1600001, // shifted menu - Fckey_menu = 0x1600002, // control-menu - Fckey_smenu = 0x1600003, // shifted control-menu - Fmkey_menu = 0x1600004, // M-menu - Fmkey_smenu = 0x1600005, // shifted M-menu - Fcmkey_menu = 0x1600006, // control-M-menu - Fcmkey_smenu = 0x1600007, // shifted control-M-menu - Fkey_escape_mintty = 0x200001b, // mintty Esc - Fkey_mouse = 0x2000020, // xterm mouse - Fkey_extended_mouse = 0x2000021, // SGR extended mouse - Fkey_urxvt_mouse = 0x2000022, // urxvt mouse extension - Fmkey_meta = 0x20000e0, // meta key offset - Fmkey_tab = 0x20000e9, // M-tab - Fmkey_enter = 0x20000ea, // M-enter - Fmkey_space = 0x2000100, // M-' ' - Fmkey_bang = 0x2000101, // M-! - Fmkey_quotes = 0x2000102, // M-" - Fmkey_hash = 0x2000103, // M-# - Fmkey_dollar = 0x2000104, // M-$ - Fmkey_percent = 0x2000105, // M-% - Fmkey_ampersand = 0x2000106, // M-& - Fmkey_apostrophe = 0x2000107, // M-' - Fmkey_left_parenthesis = 0x2000108, // M-( - Fmkey_right_parenthesis = 0x2000109, // M-) - Fmkey_asterisk = 0x200010a, // M-* - Fmkey_plus = 0x200010b, // M-+ - Fmkey_comma = 0x200010c, // M-, - Fmkey_minus = 0x200010d, // M-'-' - Fmkey_full_stop = 0x200010e, // M-. - Fmkey_slash = 0x200010f, // M-/ - Fmkey_0 = 0x2000110, // M-0 - Fmkey_1 = 0x2000111, // M-1 - Fmkey_2 = 0x2000112, // M-2 - Fmkey_3 = 0x2000113, // M-3 - Fmkey_4 = 0x2000114, // M-4 - Fmkey_5 = 0x2000115, // M-5 - Fmkey_6 = 0x2000116, // M-6 - Fmkey_7 = 0x2000117, // M-7 - Fmkey_8 = 0x2000118, // M-8 - Fmkey_9 = 0x2000119, // M-9 - Fmkey_colon = 0x200011a, // M-: - Fmkey_semicolon = 0x200011b, // M-; - Fmkey_less_than = 0x200011c, // M-< - Fmkey_equals = 0x200011d, // M-= - Fmkey_greater_than = 0x200011e, // M-> - Fmkey_question_mark = 0x200011f, // M-? - Fmkey_at = 0x2000120, // M-@ - Fmkey_A = 0x2000121, // M-A - Fmkey_B = 0x2000122, // M-B - Fmkey_C = 0x2000123, // M-C - Fmkey_D = 0x2000124, // M-D - Fmkey_E = 0x2000125, // M-E - Fmkey_F = 0x2000126, // M-F - Fmkey_G = 0x2000127, // M-G - Fmkey_H = 0x2000128, // M-H - Fmkey_I = 0x2000129, // M-I - Fmkey_J = 0x200012a, // M-J - Fmkey_K = 0x200012b, // M-K - Fmkey_L = 0x200012c, // M-L - Fmkey_M = 0x200012d, // M-M - Fmkey_N = 0x200012e, // M-N - Fmkey_O = 0x200012f, // M-O - Fmkey_P = 0x2000130, // M-P - Fmkey_Q = 0x2000131, // M-Q - Fmkey_R = 0x2000132, // M-R - Fmkey_S = 0x2000133, // M-S - Fmkey_T = 0x2000134, // M-T - Fmkey_U = 0x2000135, // M-U - Fmkey_V = 0x2000136, // M-V - Fmkey_W = 0x2000137, // M-W - Fmkey_X = 0x2000138, // M-X - Fmkey_Y = 0x2000139, // M-Y - Fmkey_Z = 0x200013a, // M-Z - Fmkey_left_square_bracket = 0x200013b, // M-[ - Fmkey_backslash = 0x200013c, // M-'\' - Fmkey_right_square_bracket = 0x200013d, // M-] - Fmkey_caret = 0x200013e, // M-^ - Fmkey_underscore = 0x200013f, // M-_ - Fmkey_grave_accent = 0x2000140, // M-` - Fmkey_a = 0x2000141, // M-a - Fmkey_b = 0x2000142, // M-b - Fmkey_c = 0x2000143, // M-c - Fmkey_d = 0x2000144, // M-d - Fmkey_e = 0x2000145, // M-e - Fmkey_f = 0x2000146, // M-f - Fmkey_g = 0x2000147, // M-g - Fmkey_h = 0x2000148, // M-h - Fmkey_i = 0x2000149, // M-i - Fmkey_j = 0x200014a, // M-j - Fmkey_k = 0x200014b, // M-k - Fmkey_l = 0x200014c, // M-l - Fmkey_m = 0x200014d, // M-m - Fmkey_n = 0x200014e, // M-n - Fmkey_o = 0x200014f, // M-o - Fmkey_p = 0x2000150, // M-p - Fmkey_q = 0x2000151, // M-q - Fmkey_r = 0x2000152, // M-r - Fmkey_s = 0x2000153, // M-s - Fmkey_t = 0x2000154, // M-t - Fmkey_u = 0x2000155, // M-u - Fmkey_v = 0x2000156, // M-v - Fmkey_w = 0x2000157, // M-w - Fmkey_x = 0x2000158, // M-x - Fmkey_y = 0x2000159, // M-y - Fmkey_z = 0x200015a, // M-z - Fmkey_left_curly_bracket = 0x200015b, // M-{ - Fmkey_vertical_bar = 0x200015c, // M-| - Fmkey_right_curly_bracket = 0x200015d, // M-} - Fmkey_tilde = 0x200015e // M-~ - }; + // Keyboard - modifier key combinations + enum metakeys + { + Fmkey_ic = 0x1500100, // M-insert + Fmkey_dc = 0x1500101, // M-delete + Fmkey_home = 0x1500102, // M-home + Fmkey_end = 0x1500103, // M-end + Fmkey_ppage = 0x1500104, // M-prev-page + Fmkey_npage = 0x1500105, // M-next-page + Fmkey_f1 = 0x1500106, // M-f1 + Fmkey_f2 = 0x1500107, // M-f2 + Fmkey_f3 = 0x1500108, // M-f3 + Fmkey_f4 = 0x1500109, // M-f4 + Fmkey_f5 = 0x150010a, // M-f5 + Fmkey_f6 = 0x150010b, // M-F6 + Fmkey_f7 = 0x150010c, // M-f7 + Fmkey_f8 = 0x150010d, // M-f8 + Fmkey_f9 = 0x150010e, // M-f9 + Fmkey_f10 = 0x150010f, // M-f10 + Fmkey_f11 = 0x1500110, // M-f11 + Fmkey_f12 = 0x1500111, // M-f12 + Fmkey_up = 0x1500112, // M-up + Fmkey_down = 0x1500113, // M-down + Fmkey_right = 0x1500114, // M-right + Fmkey_left = 0x1500115, // M-left + Fmkey_sic = 0x1500116, // shifted M-Insert + Fmkey_sdc = 0x1500117, // shifted M-Delete + Fmkey_shome = 0x1500118, // shifted M-Home + Fmkey_send = 0x1500119, // shifted M-End + Fmkey_sppage = 0x150011a, // shifted M-Page_Up + Fmkey_snpage = 0x150011b, // shifted M-Page_Down + Fmkey_sf1 = 0x150011c, // shifted M-F1 + Fmkey_sf2 = 0x150011d, // shifted M-F2 + Fmkey_sf3 = 0x150011e, // shifted M-F3 + Fmkey_sf4 = 0x150011f, // shifted M-F4 + Fmkey_sf5 = 0x1500120, // shifted M-F5 + Fmkey_sf6 = 0x1500121, // shifted M-F6 + Fmkey_sf7 = 0x1500122, // shifted M-F7 + Fmkey_sf8 = 0x1500123, // shifted M-F8 + Fmkey_sf9 = 0x1500124, // shifted M-F9 + Fmkey_sf10 = 0x1500125, // shifted M-F10 + Fmkey_sf11 = 0x1500126, // shifted M-F11 + Fmkey_sf12 = 0x1500127, // shifted M-F12 + Fmkey_sup = 0x1500128, // shifted M-Up + Fmkey_sdown = 0x1500129, // shifted M-Down + Fmkey_sright = 0x150012a, // shifted M-Right + Fmkey_sleft = 0x150012b, // shifted M-Left + Fckey_ic = 0x150012c, // control-Insert + Fckey_dc = 0x150012d, // control-Delete + Fckey_home = 0x150012e, // control-Home + Fckey_end = 0x150012f, // control-End + Fckey_ppage = 0x1500130, // control-Page_Up + Fckey_npage = 0x1500131, // control-Page_Down + Fckey_up = 0x1500132, // control-Up + Fckey_down = 0x1500133, // control-Down + Fckey_right = 0x1500134, // control-Right + Fckey_left = 0x1500135, // control-Left + Fckey_sic = 0x1500136, // shifted control-M-Insert + Fckey_sdc = 0x1500137, // shifted control-M-Delete + Fckey_shome = 0x1500138, // shifted control-M-Home + Fckey_send = 0x1500139, // shifted control-M-End + Fckey_sppage = 0x150013a, // shifted control-M-Page_Up + Fckey_snpage = 0x150013b, // shifted control-M-Page_Down + Fckey_sup = 0x150013c, // shifted control-M-Up + Fckey_sdown = 0x150013d, // shifted control-M-Down + Fckey_sright = 0x150013e, // shifted control-M-Right + Fckey_sleft = 0x150013f, // shifted control-M-Left + Fcmkey_ic = 0x1500140, // control-M-Insert + Fcmkey_dc = 0x1500141, // control-M-Delete + Fcmkey_home = 0x1500142, // control-M-Home + Fcmkey_end = 0x1500143, // control-M-End + Fcmkey_ppage = 0x1500144, // control-M-Page_Up + Fcmkey_npage = 0x1500145, // control-M-Page_Down + Fcmkey_up = 0x1500146, // control-M-Up + Fcmkey_down = 0x1500147, // control-M-Down + Fcmkey_right = 0x1500148, // control-M-Right + Fcmkey_left = 0x1500149, // control-M-Left + Fcmkey_sic = 0x150014a, // shifted control-M-Insert + Fcmkey_sdc = 0x150014b, // shifted control-M-Delete + Fcmkey_shome = 0x150014c, // shifted control-M-Home + Fcmkey_send = 0x150014d, // shifted control-M-End + Fcmkey_sppage = 0x150014e, // shifted control-M-Page_Up + Fcmkey_snpage = 0x150014f, // shifted control-M-Page_Down + Fcmkey_sf1 = 0x1500150, // shifted control-M-F1 + Fcmkey_sf2 = 0x1500151, // shifted control-M-F2 + Fcmkey_sf3 = 0x1500152, // shifted control-M-F3 + Fcmkey_sf4 = 0x1500153, // shifted control-M-F4 + Fcmkey_sf5 = 0x1500154, // shifted control-M-F5 + Fcmkey_sf6 = 0x1500155, // shifted control-M-F6 + Fcmkey_sf7 = 0x1500156, // shifted control-M-F7 + Fcmkey_sf8 = 0x1500157, // shifted control-M-F8 + Fcmkey_sf9 = 0x1500158, // shifted control-M-F9 + Fcmkey_sf10 = 0x1500159, // shifted control-M-F10 + Fcmkey_sf11 = 0x150015a, // shifted control-M-F11 + Fcmkey_sf12 = 0x150015b, // shifted control-M-F12 + Fcmkey_sup = 0x150015c, // shifted control-M-Up + Fcmkey_sdown = 0x150015d, // shifted control-M-Down + Fcmkey_sright = 0x150015e, // shifted control-M-Right + Fcmkey_sleft = 0x150015f, // shifted control-M-Left + Fkey_menu = 0x1600000, // menu + Fkey_smenu = 0x1600001, // shifted menu + Fckey_menu = 0x1600002, // control-menu + Fckey_smenu = 0x1600003, // shifted control-menu + Fmkey_menu = 0x1600004, // M-menu + Fmkey_smenu = 0x1600005, // shifted M-menu + Fcmkey_menu = 0x1600006, // control-M-menu + Fcmkey_smenu = 0x1600007, // shifted control-M-menu + Fkey_escape_mintty = 0x200001b, // mintty Esc + Fkey_mouse = 0x2000020, // xterm mouse + Fkey_extended_mouse = 0x2000021, // SGR extended mouse + Fkey_urxvt_mouse = 0x2000022, // urxvt mouse extension + Fmkey_meta = 0x20000e0, // meta key offset + Fmkey_tab = 0x20000e9, // M-tab + Fmkey_enter = 0x20000ea, // M-enter + Fmkey_space = 0x2000100, // M-' ' + Fmkey_bang = 0x2000101, // M-! + Fmkey_quotes = 0x2000102, // M-" + Fmkey_hash = 0x2000103, // M-# + Fmkey_dollar = 0x2000104, // M-$ + Fmkey_percent = 0x2000105, // M-% + Fmkey_ampersand = 0x2000106, // M-& + Fmkey_apostrophe = 0x2000107, // M-' + Fmkey_left_parenthesis = 0x2000108, // M-( + Fmkey_right_parenthesis = 0x2000109, // M-) + Fmkey_asterisk = 0x200010a, // M-* + Fmkey_plus = 0x200010b, // M-+ + Fmkey_comma = 0x200010c, // M-, + Fmkey_minus = 0x200010d, // M-'-' + Fmkey_full_stop = 0x200010e, // M-. + Fmkey_slash = 0x200010f, // M-/ + Fmkey_0 = 0x2000110, // M-0 + Fmkey_1 = 0x2000111, // M-1 + Fmkey_2 = 0x2000112, // M-2 + Fmkey_3 = 0x2000113, // M-3 + Fmkey_4 = 0x2000114, // M-4 + Fmkey_5 = 0x2000115, // M-5 + Fmkey_6 = 0x2000116, // M-6 + Fmkey_7 = 0x2000117, // M-7 + Fmkey_8 = 0x2000118, // M-8 + Fmkey_9 = 0x2000119, // M-9 + Fmkey_colon = 0x200011a, // M-: + Fmkey_semicolon = 0x200011b, // M-; + Fmkey_less_than = 0x200011c, // M-< + Fmkey_equals = 0x200011d, // M-= + Fmkey_greater_than = 0x200011e, // M-> + Fmkey_question_mark = 0x200011f, // M-? + Fmkey_at = 0x2000120, // M-@ + Fmkey_A = 0x2000121, // M-A + Fmkey_B = 0x2000122, // M-B + Fmkey_C = 0x2000123, // M-C + Fmkey_D = 0x2000124, // M-D + Fmkey_E = 0x2000125, // M-E + Fmkey_F = 0x2000126, // M-F + Fmkey_G = 0x2000127, // M-G + Fmkey_H = 0x2000128, // M-H + Fmkey_I = 0x2000129, // M-I + Fmkey_J = 0x200012a, // M-J + Fmkey_K = 0x200012b, // M-K + Fmkey_L = 0x200012c, // M-L + Fmkey_M = 0x200012d, // M-M + Fmkey_N = 0x200012e, // M-N + Fmkey_O = 0x200012f, // M-O + Fmkey_P = 0x2000130, // M-P + Fmkey_Q = 0x2000131, // M-Q + Fmkey_R = 0x2000132, // M-R + Fmkey_S = 0x2000133, // M-S + Fmkey_T = 0x2000134, // M-T + Fmkey_U = 0x2000135, // M-U + Fmkey_V = 0x2000136, // M-V + Fmkey_W = 0x2000137, // M-W + Fmkey_X = 0x2000138, // M-X + Fmkey_Y = 0x2000139, // M-Y + Fmkey_Z = 0x200013a, // M-Z + Fmkey_left_square_bracket = 0x200013b, // M-[ + Fmkey_backslash = 0x200013c, // M-'\' + Fmkey_right_square_bracket = 0x200013d, // M-] + Fmkey_caret = 0x200013e, // M-^ + Fmkey_underscore = 0x200013f, // M-_ + Fmkey_grave_accent = 0x2000140, // M-` + Fmkey_a = 0x2000141, // M-a + Fmkey_b = 0x2000142, // M-b + Fmkey_c = 0x2000143, // M-c + Fmkey_d = 0x2000144, // M-d + Fmkey_e = 0x2000145, // M-e + Fmkey_f = 0x2000146, // M-f + Fmkey_g = 0x2000147, // M-g + Fmkey_h = 0x2000148, // M-h + Fmkey_i = 0x2000149, // M-i + Fmkey_j = 0x200014a, // M-j + Fmkey_k = 0x200014b, // M-k + Fmkey_l = 0x200014c, // M-l + Fmkey_m = 0x200014d, // M-m + Fmkey_n = 0x200014e, // M-n + Fmkey_o = 0x200014f, // M-o + Fmkey_p = 0x2000150, // M-p + Fmkey_q = 0x2000151, // M-q + Fmkey_r = 0x2000152, // M-r + Fmkey_s = 0x2000153, // M-s + Fmkey_t = 0x2000154, // M-t + Fmkey_u = 0x2000155, // M-u + Fmkey_v = 0x2000156, // M-v + Fmkey_w = 0x2000157, // M-w + Fmkey_x = 0x2000158, // M-x + Fmkey_y = 0x2000159, // M-y + Fmkey_z = 0x200015a, // M-z + Fmkey_left_curly_bracket = 0x200015b, // M-{ + Fmkey_vertical_bar = 0x200015c, // M-| + Fmkey_right_curly_bracket = 0x200015d, // M-} + Fmkey_tilde = 0x200015e // M-~ + }; - // Console color names - enum colornames - { - Default = -1, - Black = 0, - Blue = 1, - Green = 2, - Cyan = 3, - Red = 4, - Magenta = 5, - Brown = 6, - LightGray = 7, - DarkGray = 8, - LightBlue = 9, - LightGreen = 10, - LightCyan = 11, - LightRed = 12, - LightMagenta = 13, - Yellow = 14, - White = 15, - /* 256 color terminals */ - Grey0 = 16, // #000000 - NavyBlue = 17, // #00005f - DarkBlue = 18, // #000087 - Blue3 = 19, // #0000af - Blue2 = 20, // #0000d7 - Blue1 = 21, // #0000ff - DarkGreen = 22, // #005f00 - DarkCyan2 = 23, // #005f5f - DeepSkyBlue6 = 24, // #005f87 - DeepSkyBlue5 = 25, // #005faf - DodgerBlue3 = 26, // #005fd7 - DodgerBlue2 = 27, // #005fff - Green4 = 28, // #008700 - SpringGreen6 = 29, // #00875f - Turquoise4 = 30, // #008787 - DeepSkyBlue4 = 31, // #0087af - DeepSkyBlue3 = 32, // #0087d7 - DodgerBlue1 = 33, // #0087ff - Green2 = 34, // #00af00 - SpringGreen5 = 35, // #00af5f - DarkCyan = 36, // #00af87 - LightSeaGreen = 37, // #00afaf - DeepSkyBlue2 = 38, // #00afd7 - DeepSkyBlue1 = 39, // #00afff - Green3 = 40, // #00d700 - SpringGreen4 = 41, // #00d75f - SpringGreen3 = 42, // #00d787 - Cyan3 = 43, // #00d7af - DarkTurquoise = 44, // #00d7d7 - Turquoise2 = 45, // #00d7ff - Green1 = 46, // #00ff00 - SpringGreen2 = 47, // #00ff5f - SpringGreen1 = 48, // #00ff87 - MediumSpringGreen = 49, // #00ffaf - Cyan2 = 50, // #00ffd7 - Cyan1 = 51, // #00ffff - DarkRed = 52, // #5f0000 - DeepPink7 = 53, // #5f005f - Purple4 = 54, // #5f0087 - Purple3 = 55, // #5f00af - Purple2 = 56, // #5f00d7 - BlueViolet = 57, // #5f00ff - Orange4 = 58, // #5f5f00 - Grey37 = 59, // #5f5f5f - MediumPurple6 = 60, // #5f5f87 - SlateBlue3 = 61, // #5f5faf - SlateBlue2 = 62, // #5f5fd7 - RoyalBlue1 = 63, // #5f5fff - Chartreuse5 = 64, // #5f8700 - DarkSeaGreen8 = 65, // #5f875f - PaleTurquoise4 = 66, // #5f8787 - SteelBlue = 67, // #5f87af - SteelBlue3 = 68, // #5f87d7 - CornflowerBlue = 69, // #5f87ff - Chartreuse4 = 70, // #5faf00 - DarkSeaGreen7 = 71, // #5faf5f - CadetBlue2 = 72, // #5faf87 - CadetBlue1 = 73, // #5fafaf - SkyBlue3 = 74, // #5fafd7 - SteelBlue2 = 75, // #5fafff - Chartreuse3 = 76, // #5fd700 - PaleGreen3 = 77, // #5fd75f - SeaGreen4 = 78, // #5fd787 - Aquamarine3 = 79, // #5fd7af - MediumTurquoise = 80, // #5fd7d7 - SteelBlue1 = 81, // #5fd7ff - Chartreuse = 82, // #5fff00 - SeaGreen3 = 83, // #5fff5f - SeaGreen2 = 84, // #5fff87 - SeaGreen1 = 85, // #5fffaf - Aquamarine2 = 86, // #5fffd7 - DarkSlateGray2 = 87, // #5fffff - DarkRed2 = 88, // #870000 - DeepPink6 = 89, // #87005f - DarkMagenta2 = 90, // #870087 - DarkMagenta = 91, // #8700af - DarkViolet1 = 92, // #8700d7 - Purple1 = 93, // #8700ff - Orange3 = 94, // #875f00 - LightPink4 = 95, // #875f5f - Plum4 = 96, // #875f87 - MediumPurple5 = 97, // #875faf - MediumPurple4 = 98, // #875fd7 - SlateBlue1 = 99, // #875fff - Yellow6 = 100, // #878700 - Wheat4 = 101, // #87875f - Grey53 = 102, // #878787 - LightSlateGrey = 103, // #8787af - MediumPurple = 104, // #8787d7 - LightSlateBlue = 105, // #8787ff - Yellow5 = 106, // #87af00 - DarkOliveGreen5 = 107, // #87af5f - DarkSeaGreen6 = 108, // #87af87 - LightSkyBlue3 = 109, // #87afaf - LightSkyBlue2 = 110, // #87afd7 - SkyBlue2 = 111, // #87afff - Chartreuse2 = 112, // #87d700 - DarkOliveGreen4 = 113, // #87d75f - PaleGreen2 = 114, // #87d787 - DarkSeaGreen5 = 115, // #87d7af - DarkSlateGray3 = 116, // #87d7d7 - SkyBlue1 = 117, // #87d7ff - Chartreuse1 = 118, // #87ff00 - LightGreen3 = 119, // #87ff5f - LightGreen2 = 120, // #87ff87 - PaleGreen1 = 121, // #87ffaf - Aquamarine1 = 122, // #87ffd7 - DarkSlateGray1 = 123, // #87ffff - Red3 = 124, // #af0000 - DeepPink5 = 125, // #af005f - MediumVioletRed = 126, // #af0087 - Magenta6 = 127, // #af00af - DarkViolet = 128, // #af00d7 - Purple = 129, // #af00ff - DarkOrange3 = 130, // #af5f00 - IndianRed3 = 131, // #af5f5f - HotPink4 = 132, // #af5f87 - MediumOrchid3 = 133, // #af5faf - MediumOrchid = 134, // #af5fd7 - MediumPurple3 = 135, // #af5fff - DarkGoldenrod = 136, // #af8700 - LightSalmon3 = 137, // #af875f - RosyBrown = 138, // #af8787 - Grey63 = 139, // #af87af - MediumPurple2 = 140, // #af87d7 - MediumPurple1 = 141, // #af87ff - Gold3 = 142, // #afaf00 - DarkKhaki = 143, // #afaf5f - NavajoWhite3 = 144, // #afaf87 - Grey69 = 145, // #afafaf - LightSteelBlue3 = 146, // #afafd7 - LightSteelBlue = 147, // #afafff - Yellow4 = 148, // #afd700 - DarkOliveGreen3 = 149, // #afd75f - DarkSeaGreen4 = 150, // #afd787 - DarkSeaGreen3 = 151, // #afd7af - LightCyan3 = 152, // #afd7d7 - LightSkyBlue1 = 153, // #afd7ff - GreenYellow = 154, // #afff00 - DarkOliveGreen2 = 155, // #afff5f - PaleGreen = 156, // #afff87 - DarkSeaGreen2 = 157, // #afffaf - DarkSeaGreen1 = 158, // #afffd7 - PaleTurquoise1 = 159, // #afffff - Red2 = 160, // #d70000 - DeepPink4 = 161, // #d7005f - DeepPink3 = 162, // #d70087 - Magenta5 = 163, // #d700af - Magenta4 = 164, // #d700d7 - Magenta3 = 165, // #d700ff - DarkOrange2 = 166, // #d75f00 - IndianRed = 167, // #d75f5f - HotPink3 = 168, // #d75f87 - HotPink2 = 169, // #d75faf - Orchid = 170, // #d75fd7 - MediumOrchid2 = 171, // #d75fff - Orange2 = 172, // #d78700 - LightSalmon2 = 173, // #d7875f - LightPink3 = 174, // #d78787 - Pink3 = 175, // #d787af - Plum3 = 176, // #d787d7 - Violet = 177, // #d787ff - Gold2 = 178, // #d7af00 - LightGoldenrod5 = 179, // #d7af5f - Tan = 180, // #d7af87 - MistyRose3 = 181, // #d7afaf - Thistle3 = 182, // #d7afd7 - Plum2 = 183, // #d7afff - Yellow3 = 184, // #d7d700 - Khaki3 = 185, // #d7d75f - LightGoldenrod4 = 186, // #d7d787 - LightYellow3 = 187, // #d7d7af - Grey84 = 188, // #d7d7d7 - LightSteelBlue1 = 189, // #d7d7ff - Yellow2 = 190, // #d7ff00 - DarkOliveGreen1 = 191, // #d7ff5f - DarkOliveGreen = 192, // #d7ff87 - DarkSeaGreen = 193, // #d7ffaf - Honeydew2 = 194, // #d7ffd7 - LightCyan1 = 195, // #d7ffff - Red1 = 196, // #ff0000 - DeepPink2 = 197, // #ff005f - DeepPink1 = 198, // #ff0087 - DeepPink = 199, // #ff00af - Magenta2 = 200, // #ff00d7 - Magenta1 = 201, // #ff00ff - OrangeRed1 = 202, // #ff5f00 - IndianRed2 = 203, // #ff5f5f - IndianRed1 = 204, // #ff5f87 - HotPink1 = 205, // #ff5faf - HotPink = 206, // #ff5fd7 - MediumOrchid1 = 207, // #ff5fff - DarkOrange = 208, // #ff8700 - Salmon1 = 209, // #ff875f - LightCoral = 210, // #ff8787 - PaleVioletRed1 = 211, // #ff87af - Orchid2 = 212, // #ff87d7 - Orchid1 = 213, // #ff87ff - Orange1 = 214, // #ffaf00 - SandyBrown = 215, // #ffaf5f - LightSalmon1 = 216, // #ffaf87 - LightPink1 = 217, // #ffafaf - Pink1 = 218, // #ffafd7 - Plum1 = 219, // #ffafff - Gold1 = 220, // #ffd700 - LightGoldenrod3 = 221, // #ffd75f - LightGoldenrod2 = 222, // #ffd787 - NavajoWhite1 = 223, // #ffd7af - MistyRose1 = 224, // #ffd7d7 - Thistle1 = 225, // #ffd7ff - Yellow1 = 226, // #ffff00 - LightGoldenrod = 227, // #ffff5f - Khaki1 = 228, // #ffff87 - Wheat1 = 229, // #ffffaf - Cornsilk1 = 230, // #ffffd7 - Grey100 = 231, // #ffffff - Grey3 = 232, // #080808 - Grey7 = 233, // #121212 - Grey11 = 234, // #1c1c1c - Grey15 = 235, // #262626 - Grey19 = 236, // #303030 - Grey23 = 237, // #3a3a3a - Grey27 = 238, // #444444 - Grey30 = 239, // #4e4e4e - Grey35 = 240, // #585858 - Grey39 = 241, // #626262 - Grey42 = 242, // #6c6c6c - Grey46 = 243, // #767676 - Grey50 = 244, // #808080 - Grey54 = 245, // #8a8a8a - Grey58 = 246, // #949494 - Grey62 = 247, // #9e9e9e - Grey66 = 248, // #a8a8a8 - Grey70 = 249, // #b2b2b2 - Grey74 = 250, // #bcbcbc - Grey78 = 251, // #c6c6c6 - Grey82 = 252, // #d0d0d0 - Grey85 = 253, // #dadada - Grey89 = 254, // #e4e4e4 - Grey93 = 255 // #eeeeee - }; + // Console color names + enum colornames + { + Default = -1, + Black = 0, + Blue = 1, + Green = 2, + Cyan = 3, + Red = 4, + Magenta = 5, + Brown = 6, + LightGray = 7, + DarkGray = 8, + LightBlue = 9, + LightGreen = 10, + LightCyan = 11, + LightRed = 12, + LightMagenta = 13, + Yellow = 14, + White = 15, + /* 256 color terminals */ + Grey0 = 16, // #000000 + NavyBlue = 17, // #00005f + DarkBlue = 18, // #000087 + Blue3 = 19, // #0000af + Blue2 = 20, // #0000d7 + Blue1 = 21, // #0000ff + DarkGreen = 22, // #005f00 + DarkCyan2 = 23, // #005f5f + DeepSkyBlue6 = 24, // #005f87 + DeepSkyBlue5 = 25, // #005faf + DodgerBlue3 = 26, // #005fd7 + DodgerBlue2 = 27, // #005fff + Green4 = 28, // #008700 + SpringGreen6 = 29, // #00875f + Turquoise4 = 30, // #008787 + DeepSkyBlue4 = 31, // #0087af + DeepSkyBlue3 = 32, // #0087d7 + DodgerBlue1 = 33, // #0087ff + Green2 = 34, // #00af00 + SpringGreen5 = 35, // #00af5f + DarkCyan = 36, // #00af87 + LightSeaGreen = 37, // #00afaf + DeepSkyBlue2 = 38, // #00afd7 + DeepSkyBlue1 = 39, // #00afff + Green3 = 40, // #00d700 + SpringGreen4 = 41, // #00d75f + SpringGreen3 = 42, // #00d787 + Cyan3 = 43, // #00d7af + DarkTurquoise = 44, // #00d7d7 + Turquoise2 = 45, // #00d7ff + Green1 = 46, // #00ff00 + SpringGreen2 = 47, // #00ff5f + SpringGreen1 = 48, // #00ff87 + MediumSpringGreen = 49, // #00ffaf + Cyan2 = 50, // #00ffd7 + Cyan1 = 51, // #00ffff + DarkRed = 52, // #5f0000 + DeepPink7 = 53, // #5f005f + Purple4 = 54, // #5f0087 + Purple3 = 55, // #5f00af + Purple2 = 56, // #5f00d7 + BlueViolet = 57, // #5f00ff + Orange4 = 58, // #5f5f00 + Grey37 = 59, // #5f5f5f + MediumPurple6 = 60, // #5f5f87 + SlateBlue3 = 61, // #5f5faf + SlateBlue2 = 62, // #5f5fd7 + RoyalBlue1 = 63, // #5f5fff + Chartreuse5 = 64, // #5f8700 + DarkSeaGreen8 = 65, // #5f875f + PaleTurquoise4 = 66, // #5f8787 + SteelBlue = 67, // #5f87af + SteelBlue3 = 68, // #5f87d7 + CornflowerBlue = 69, // #5f87ff + Chartreuse4 = 70, // #5faf00 + DarkSeaGreen7 = 71, // #5faf5f + CadetBlue2 = 72, // #5faf87 + CadetBlue1 = 73, // #5fafaf + SkyBlue3 = 74, // #5fafd7 + SteelBlue2 = 75, // #5fafff + Chartreuse3 = 76, // #5fd700 + PaleGreen3 = 77, // #5fd75f + SeaGreen4 = 78, // #5fd787 + Aquamarine3 = 79, // #5fd7af + MediumTurquoise = 80, // #5fd7d7 + SteelBlue1 = 81, // #5fd7ff + Chartreuse = 82, // #5fff00 + SeaGreen3 = 83, // #5fff5f + SeaGreen2 = 84, // #5fff87 + SeaGreen1 = 85, // #5fffaf + Aquamarine2 = 86, // #5fffd7 + DarkSlateGray2 = 87, // #5fffff + DarkRed2 = 88, // #870000 + DeepPink6 = 89, // #87005f + DarkMagenta2 = 90, // #870087 + DarkMagenta = 91, // #8700af + DarkViolet1 = 92, // #8700d7 + Purple1 = 93, // #8700ff + Orange3 = 94, // #875f00 + LightPink4 = 95, // #875f5f + Plum4 = 96, // #875f87 + MediumPurple5 = 97, // #875faf + MediumPurple4 = 98, // #875fd7 + SlateBlue1 = 99, // #875fff + Yellow6 = 100, // #878700 + Wheat4 = 101, // #87875f + Grey53 = 102, // #878787 + LightSlateGrey = 103, // #8787af + MediumPurple = 104, // #8787d7 + LightSlateBlue = 105, // #8787ff + Yellow5 = 106, // #87af00 + DarkOliveGreen5 = 107, // #87af5f + DarkSeaGreen6 = 108, // #87af87 + LightSkyBlue3 = 109, // #87afaf + LightSkyBlue2 = 110, // #87afd7 + SkyBlue2 = 111, // #87afff + Chartreuse2 = 112, // #87d700 + DarkOliveGreen4 = 113, // #87d75f + PaleGreen2 = 114, // #87d787 + DarkSeaGreen5 = 115, // #87d7af + DarkSlateGray3 = 116, // #87d7d7 + SkyBlue1 = 117, // #87d7ff + Chartreuse1 = 118, // #87ff00 + LightGreen3 = 119, // #87ff5f + LightGreen2 = 120, // #87ff87 + PaleGreen1 = 121, // #87ffaf + Aquamarine1 = 122, // #87ffd7 + DarkSlateGray1 = 123, // #87ffff + Red3 = 124, // #af0000 + DeepPink5 = 125, // #af005f + MediumVioletRed = 126, // #af0087 + Magenta6 = 127, // #af00af + DarkViolet = 128, // #af00d7 + Purple = 129, // #af00ff + DarkOrange3 = 130, // #af5f00 + IndianRed3 = 131, // #af5f5f + HotPink4 = 132, // #af5f87 + MediumOrchid3 = 133, // #af5faf + MediumOrchid = 134, // #af5fd7 + MediumPurple3 = 135, // #af5fff + DarkGoldenrod = 136, // #af8700 + LightSalmon3 = 137, // #af875f + RosyBrown = 138, // #af8787 + Grey63 = 139, // #af87af + MediumPurple2 = 140, // #af87d7 + MediumPurple1 = 141, // #af87ff + Gold3 = 142, // #afaf00 + DarkKhaki = 143, // #afaf5f + NavajoWhite3 = 144, // #afaf87 + Grey69 = 145, // #afafaf + LightSteelBlue3 = 146, // #afafd7 + LightSteelBlue = 147, // #afafff + Yellow4 = 148, // #afd700 + DarkOliveGreen3 = 149, // #afd75f + DarkSeaGreen4 = 150, // #afd787 + DarkSeaGreen3 = 151, // #afd7af + LightCyan3 = 152, // #afd7d7 + LightSkyBlue1 = 153, // #afd7ff + GreenYellow = 154, // #afff00 + DarkOliveGreen2 = 155, // #afff5f + PaleGreen = 156, // #afff87 + DarkSeaGreen2 = 157, // #afffaf + DarkSeaGreen1 = 158, // #afffd7 + PaleTurquoise1 = 159, // #afffff + Red2 = 160, // #d70000 + DeepPink4 = 161, // #d7005f + DeepPink3 = 162, // #d70087 + Magenta5 = 163, // #d700af + Magenta4 = 164, // #d700d7 + Magenta3 = 165, // #d700ff + DarkOrange2 = 166, // #d75f00 + IndianRed = 167, // #d75f5f + HotPink3 = 168, // #d75f87 + HotPink2 = 169, // #d75faf + Orchid = 170, // #d75fd7 + MediumOrchid2 = 171, // #d75fff + Orange2 = 172, // #d78700 + LightSalmon2 = 173, // #d7875f + LightPink3 = 174, // #d78787 + Pink3 = 175, // #d787af + Plum3 = 176, // #d787d7 + Violet = 177, // #d787ff + Gold2 = 178, // #d7af00 + LightGoldenrod5 = 179, // #d7af5f + Tan = 180, // #d7af87 + MistyRose3 = 181, // #d7afaf + Thistle3 = 182, // #d7afd7 + Plum2 = 183, // #d7afff + Yellow3 = 184, // #d7d700 + Khaki3 = 185, // #d7d75f + LightGoldenrod4 = 186, // #d7d787 + LightYellow3 = 187, // #d7d7af + Grey84 = 188, // #d7d7d7 + LightSteelBlue1 = 189, // #d7d7ff + Yellow2 = 190, // #d7ff00 + DarkOliveGreen1 = 191, // #d7ff5f + DarkOliveGreen = 192, // #d7ff87 + DarkSeaGreen = 193, // #d7ffaf + Honeydew2 = 194, // #d7ffd7 + LightCyan1 = 195, // #d7ffff + Red1 = 196, // #ff0000 + DeepPink2 = 197, // #ff005f + DeepPink1 = 198, // #ff0087 + DeepPink = 199, // #ff00af + Magenta2 = 200, // #ff00d7 + Magenta1 = 201, // #ff00ff + OrangeRed1 = 202, // #ff5f00 + IndianRed2 = 203, // #ff5f5f + IndianRed1 = 204, // #ff5f87 + HotPink1 = 205, // #ff5faf + HotPink = 206, // #ff5fd7 + MediumOrchid1 = 207, // #ff5fff + DarkOrange = 208, // #ff8700 + Salmon1 = 209, // #ff875f + LightCoral = 210, // #ff8787 + PaleVioletRed1 = 211, // #ff87af + Orchid2 = 212, // #ff87d7 + Orchid1 = 213, // #ff87ff + Orange1 = 214, // #ffaf00 + SandyBrown = 215, // #ffaf5f + LightSalmon1 = 216, // #ffaf87 + LightPink1 = 217, // #ffafaf + Pink1 = 218, // #ffafd7 + Plum1 = 219, // #ffafff + Gold1 = 220, // #ffd700 + LightGoldenrod3 = 221, // #ffd75f + LightGoldenrod2 = 222, // #ffd787 + NavajoWhite1 = 223, // #ffd7af + MistyRose1 = 224, // #ffd7d7 + Thistle1 = 225, // #ffd7ff + Yellow1 = 226, // #ffff00 + LightGoldenrod = 227, // #ffff5f + Khaki1 = 228, // #ffff87 + Wheat1 = 229, // #ffffaf + Cornsilk1 = 230, // #ffffd7 + Grey100 = 231, // #ffffff + Grey3 = 232, // #080808 + Grey7 = 233, // #121212 + Grey11 = 234, // #1c1c1c + Grey15 = 235, // #262626 + Grey19 = 236, // #303030 + Grey23 = 237, // #3a3a3a + Grey27 = 238, // #444444 + Grey30 = 239, // #4e4e4e + Grey35 = 240, // #585858 + Grey39 = 241, // #626262 + Grey42 = 242, // #6c6c6c + Grey46 = 243, // #767676 + Grey50 = 244, // #808080 + Grey54 = 245, // #8a8a8a + Grey58 = 246, // #949494 + Grey62 = 247, // #9e9e9e + Grey66 = 248, // #a8a8a8 + Grey70 = 249, // #b2b2b2 + Grey74 = 250, // #bcbcbc + Grey78 = 251, // #c6c6c6 + Grey82 = 252, // #d0d0d0 + Grey85 = 253, // #dadada + Grey89 = 254, // #e4e4e4 + Grey93 = 255 // #eeeeee + }; - // Mouse/keyboard state values - enum ButtonState - { - NoButton = 0x00, - LeftButton = 0x01, - RightButton = 0x02, - MiddleButton = 0x04, - MouseButtonMask = 0x07, - ShiftButton = 0x08, - ControlButton = 0x10, - MetaButton = 0x20, - KeyButtonMask = 0x38 - }; + // Mouse/keyboard state values + enum ButtonState + { + NoButton = 0x00, + LeftButton = 0x01, + RightButton = 0x02, + MiddleButton = 0x04, + MouseButtonMask = 0x07, + ShiftButton = 0x08, + ControlButton = 0x10, + MetaButton = 0x20, + KeyButtonMask = 0x38 + }; - // Wheel state values - enum WheelState - { - NoWheel = 0x00, - WheelUp = 0x01, - WheelDown = 0x02, - WheelMask = 0x03 - }; + // Wheel state values + enum WheelState + { + NoWheel = 0x00, + WheelUp = 0x01, + WheelDown = 0x02, + WheelMask = 0x03 + }; - // Type of focus - enum FocusTypes - { - FocusNextWidget = 0x00, - FocusPreviousWidget = 0x01, - FocusDefiniteWidget = 0x03 // event default - }; + // Type of focus + enum FocusTypes + { + FocusNextWidget = 0x00, + FocusPreviousWidget = 0x01, + FocusDefiniteWidget = 0x03 // event default + }; - // Drag scrolling mode - enum dragScroll - { - noScroll = 0, - scrollUp = 1, - scrollDown = 2, - scrollUpSelect = 3, - scrollDownSelect = 4 - }; + // Drag scrolling mode + enum dragScroll + { + noScroll = 0, + scrollUp = 1, + scrollDown = 2, + scrollUpSelect = 3, + scrollDownSelect = 4 + }; - // Scroll bar visibility mode - enum scrollBarMode - { - Auto = 0, // Shows a scroll bar when area is larger than viewport - Hidden = 1, // Never shows a scroll bar - Scroll = 2 // Always shows a scroll bar - }; + // Scroll bar visibility mode + enum scrollBarMode + { + Auto = 0, // Shows a scroll bar when area is larger than viewport + Hidden = 1, // Never shows a scroll bar + Scroll = 2 // Always shows a scroll bar + }; - // Xterm cursor style - enum xtermCursorStyle - { - blinking_block = 0, - blinking_block_default = 1, - steady_block = 2, - blinking_underline = 3, - steady_underline = 4, - blinking_bar_xterm = 5, - steady_bar_xterm = 6 - }; + // Xterm cursor style + enum xtermCursorStyle + { + blinking_block = 0, + blinking_block_default = 1, + steady_block = 2, + blinking_underline = 3, + steady_underline = 4, + blinking_bar_xterm = 5, + steady_bar_xterm = 6 + }; - // Linux console and framebuffer cursor style - enum linuxConsoleCursorStyle - { - default_cursor = 0, - invisible_cursor = 1, - underscore_cursor = 2, - lower_third_cursor = 3, - lower_half_cursor = 4, - two_thirds_cursor = 5, - full_block_cursor = 6 - }; + // Linux console and framebuffer cursor style + enum linuxConsoleCursorStyle + { + default_cursor = 0, + invisible_cursor = 1, + underscore_cursor = 2, + lower_third_cursor = 3, + lower_half_cursor = 4, + two_thirds_cursor = 5, + full_block_cursor = 6 + }; - // BSD console cursor style - enum freebsdConsoleCursorStyle - { - normal_cursor = 0, - blink_cursor = 1, - destructive_cursor = 3 - }; + // BSD console cursor style + enum freebsdConsoleCursorStyle + { + normal_cursor = 0, + blink_cursor = 1, + destructive_cursor = 3 + }; - // KDE konsole cursor style - enum kdeKonsoleCursorShape - { - BlockCursor = 0, - IBeamCursor = 1, - UnderlineCursor = 2 - }; + // KDE konsole cursor style + enum kdeKonsoleCursorShape + { + BlockCursor = 0, + IBeamCursor = 1, + UnderlineCursor = 2 + }; - enum text_alignment - { - alignLeft = 1, - alignCenter = 2, - alignRight = 3 - }; + enum text_alignment + { + alignLeft = 1, + alignCenter = 2, + alignRight = 3 + }; - enum orientation - { - vertical = 0, - horizontal = 1 - }; + enum orientation + { + vertical = 0, + horizontal = 1 + }; - enum sides - { - top = 0, - right = 1, - bottom = 2, - left = 3 - }; + enum sides + { + top = 0, + right = 1, + bottom = 2, + left = 3 + }; - enum brackets_type - { - NoBrackets = 0, - SquareBrackets = 1, // [ ] - Parenthesis = 2, // ( ) - CurlyBrackets = 3, // { } - AngleBrackets = 4 // < > - }; + enum brackets_type + { + NoBrackets = 0, + SquareBrackets = 1, // [ ] + Parenthesis = 2, // ( ) + CurlyBrackets = 3, // { } + AngleBrackets = 4 // < > + }; - enum termcaps - { - t_bell, - t_erase_chars, - t_clear_screen, - t_clr_eos, - t_clr_eol, - t_clr_bol, - t_cursor_home, - t_cursor_to_ll, - t_carriage_return, - t_tab, - t_back_tab, - t_insert_padding, - t_insert_character, - t_parm_ich, - t_repeat_char, - t_initialize_color, - t_initialize_pair, - t_set_a_foreground, - t_set_a_background, - t_set_foreground, - t_set_background, - t_set_color_pair, - t_orig_pair, - t_orig_colors, - t_no_color_video, - t_cursor_address, - t_column_address, - t_row_address, - t_cursor_visible, - t_cursor_invisible, - t_cursor_normal, - t_cursor_up, - t_cursor_down, - t_cursor_left, - t_cursor_right, - t_parm_up_cursor, - t_parm_down_cursor, - t_parm_left_cursor, - t_parm_right_cursor, - t_save_cursor, - t_restore_cursor, - t_scroll_forward, - t_scroll_reverse, - t_enter_ca_mode, - t_exit_ca_mode, - t_enable_acs, - t_enter_bold_mode, - t_exit_bold_mode, - t_enter_dim_mode, - t_exit_dim_mode, - t_enter_italics_mode, - t_exit_italics_mode, - t_enter_underline_mode, - t_exit_underline_mode, - t_enter_blink_mode, - t_exit_blink_mode, - t_enter_reverse_mode, - t_exit_reverse_mode, - t_enter_standout_mode, - t_exit_standout_mode, - t_enter_secure_mode, - t_exit_secure_mode, - t_enter_protected_mode, - t_exit_protected_mode, - t_enter_crossed_out_mode, - t_exit_crossed_out_mode, - t_enter_dbl_underline_mode, - t_exit_dbl_underline_mode, - t_set_attributes, - t_exit_attribute_mode, - t_enter_alt_charset_mode, - t_exit_alt_charset_mode, - t_enter_pc_charset_mode, - t_exit_pc_charset_mode, - t_enter_insert_mode, - t_exit_insert_mode, - t_enter_am_mode, - t_exit_am_mode, - t_acs_chars, - t_keypad_xmit, - t_keypad_local, - t_key_mouse - }; + enum termcaps + { + t_bell, + t_erase_chars, + t_clear_screen, + t_clr_eos, + t_clr_eol, + t_clr_bol, + t_cursor_home, + t_cursor_to_ll, + t_carriage_return, + t_tab, + t_back_tab, + t_insert_padding, + t_insert_character, + t_parm_ich, + t_repeat_char, + t_initialize_color, + t_initialize_pair, + t_set_a_foreground, + t_set_a_background, + t_set_foreground, + t_set_background, + t_set_color_pair, + t_orig_pair, + t_orig_colors, + t_no_color_video, + t_cursor_address, + t_column_address, + t_row_address, + t_cursor_visible, + t_cursor_invisible, + t_cursor_normal, + t_cursor_up, + t_cursor_down, + t_cursor_left, + t_cursor_right, + t_parm_up_cursor, + t_parm_down_cursor, + t_parm_left_cursor, + t_parm_right_cursor, + t_save_cursor, + t_restore_cursor, + t_scroll_forward, + t_scroll_reverse, + t_enter_ca_mode, + t_exit_ca_mode, + t_enable_acs, + t_enter_bold_mode, + t_exit_bold_mode, + t_enter_dim_mode, + t_exit_dim_mode, + t_enter_italics_mode, + t_exit_italics_mode, + t_enter_underline_mode, + t_exit_underline_mode, + t_enter_blink_mode, + t_exit_blink_mode, + t_enter_reverse_mode, + t_exit_reverse_mode, + t_enter_standout_mode, + t_exit_standout_mode, + t_enter_secure_mode, + t_exit_secure_mode, + t_enter_protected_mode, + t_exit_protected_mode, + t_enter_crossed_out_mode, + t_exit_crossed_out_mode, + t_enter_dbl_underline_mode, + t_exit_dbl_underline_mode, + t_set_attributes, + t_exit_attribute_mode, + t_enter_alt_charset_mode, + t_exit_alt_charset_mode, + t_enter_pc_charset_mode, + t_exit_pc_charset_mode, + t_enter_insert_mode, + t_exit_insert_mode, + t_enter_am_mode, + t_exit_am_mode, + t_acs_chars, + t_keypad_xmit, + t_keypad_local, + t_key_mouse + }; - // Data Member - static const FString* empty_string; + // Data Member + static const FString* empty_string; }; #pragma pack(pop) diff --git a/src/fcharmap.h b/src/fcharmap.h index 48e127fb..824eac61 100644 --- a/src/fcharmap.h +++ b/src/fcharmap.h @@ -109,45 +109,45 @@ const int lastCharItem = int(sizeof(character) / sizeof(character[0])) - 1; static int vt100_key_to_utf8[][2] = { - {fc::vt100_key_rarrow , fc::BlackRightPointingPointer}, // ► - {fc::vt100_key_larrow , fc::BlackLeftPointingPointer}, // ◄ - {fc::vt100_key_uarrow , fc::BlackUpPointingTriangle}, // ▲ - {fc::vt100_key_darrow , fc::BlackDownPointingTriangle}, // ▼ - {fc::vt100_key_block , fc::FullBlock}, // █ - {fc::vt100_key_nsup , fc::SuperscriptLatinSmallLetterN}, // ⁿ - {fc::vt100_key_blackrect, fc::BlackVerticalRectangle}, // ▮ - {fc::vt100_key_diamond , fc::BlackDiamond}, // ◆ - {fc::vt100_key_ckboard , fc::MediumShade}, // ▒ - {fc::vt100_key_htab , fc::SymbolForHorizontalTab}, // ␉ - {fc::vt100_key_ff , fc::SymbolForFormFeed}, // ␌ - {fc::vt100_key_cr , fc::SymbolForCarriageReturn}, // ␍ - {fc::vt100_key_lf , fc::SymbolForLineFeed}, // ␊ - {fc::vt100_key_degree , fc::Degree}, // ° - {fc::vt100_key_plminus , fc::PlusMinus}, // ± - {fc::vt100_key_board , fc::SymbolForNewline}, // ␤ - {fc::vt100_key_lantern , fc::SymbolForVerticalTab}, // ␋ - {fc::vt100_key_lrcorner , fc::BoxDrawingsUpAndLeft}, // ┘ - {fc::vt100_key_urcorner , fc::BoxDrawingsDownAndLeft}, // ┐ - {fc::vt100_key_ulcorner , fc::BoxDrawingsDownAndRight}, // ┌ - {fc::vt100_key_llcorner , fc::BoxDrawingsUpAndRight}, // └ - {fc::vt100_key_plus , fc::BoxDrawingsCross}, // ┼ - {fc::vt100_key_s1 , fc::HorizontalScanLine1}, // ⎺ - {fc::vt100_key_s3 , fc::HorizontalScanLine3}, // ⎻ - {fc::vt100_key_hline , fc::BoxDrawingsHorizontal}, // ─ - {fc::vt100_key_s7 , fc::HorizontalScanLine7}, // ⎼ - {fc::vt100_key_s9 , fc::HorizontalScanLine9}, // ⎽ - {fc::vt100_key_ltee , fc::BoxDrawingsVerticalAndRight}, // ├ - {fc::vt100_key_rtee , fc::BoxDrawingsVerticalAndLeft}, // ┤ - {fc::vt100_key_btee , fc::BoxDrawingsUpAndHorizontal}, // ┴ - {fc::vt100_key_ttee , fc::BoxDrawingsDownAndHorizontal}, // ┬ - {fc::vt100_key_vline , fc::BoxDrawingsVertical}, // │ - {fc::vt100_key_lequal , fc::LessThanOrEqualTo}, // ≤ - {fc::vt100_key_gequal , fc::GreaterThanOrEqualTo}, // ≥ - {fc::vt100_key_pi , fc::Pi}, // π - {fc::vt100_key_nequal , fc::NotEqualTo}, // ≠ - {fc::vt100_key_sterling , fc::Pound}, // £ - {fc::vt100_key_bullet , fc::SmallBullet}, // · - {fc::vt100_key_diamond , fc::Bullet} // ◆ + {fc::vt100_key_rarrow , fc::BlackRightPointingPointer}, // ► + {fc::vt100_key_larrow , fc::BlackLeftPointingPointer}, // ◄ + {fc::vt100_key_uarrow , fc::BlackUpPointingTriangle}, // ▲ + {fc::vt100_key_darrow , fc::BlackDownPointingTriangle}, // ▼ + {fc::vt100_key_block , fc::FullBlock}, // █ + {fc::vt100_key_nsup , fc::SuperscriptLatinSmallLetterN}, // ⁿ + {fc::vt100_key_blackrect, fc::BlackVerticalRectangle}, // ▮ + {fc::vt100_key_diamond , fc::BlackDiamond}, // ◆ + {fc::vt100_key_ckboard , fc::MediumShade}, // ▒ + {fc::vt100_key_htab , fc::SymbolForHorizontalTab}, // ␉ + {fc::vt100_key_ff , fc::SymbolForFormFeed}, // ␌ + {fc::vt100_key_cr , fc::SymbolForCarriageReturn}, // ␍ + {fc::vt100_key_lf , fc::SymbolForLineFeed}, // ␊ + {fc::vt100_key_degree , fc::Degree}, // ° + {fc::vt100_key_plminus , fc::PlusMinus}, // ± + {fc::vt100_key_board , fc::SymbolForNewline}, // ␤ + {fc::vt100_key_lantern , fc::SymbolForVerticalTab}, // ␋ + {fc::vt100_key_lrcorner , fc::BoxDrawingsUpAndLeft}, // ┘ + {fc::vt100_key_urcorner , fc::BoxDrawingsDownAndLeft}, // ┐ + {fc::vt100_key_ulcorner , fc::BoxDrawingsDownAndRight}, // ┌ + {fc::vt100_key_llcorner , fc::BoxDrawingsUpAndRight}, // └ + {fc::vt100_key_plus , fc::BoxDrawingsCross}, // ┼ + {fc::vt100_key_s1 , fc::HorizontalScanLine1}, // ⎺ + {fc::vt100_key_s3 , fc::HorizontalScanLine3}, // ⎻ + {fc::vt100_key_hline , fc::BoxDrawingsHorizontal}, // ─ + {fc::vt100_key_s7 , fc::HorizontalScanLine7}, // ⎼ + {fc::vt100_key_s9 , fc::HorizontalScanLine9}, // ⎽ + {fc::vt100_key_ltee , fc::BoxDrawingsVerticalAndRight}, // ├ + {fc::vt100_key_rtee , fc::BoxDrawingsVerticalAndLeft}, // ┤ + {fc::vt100_key_btee , fc::BoxDrawingsUpAndHorizontal}, // ┴ + {fc::vt100_key_ttee , fc::BoxDrawingsDownAndHorizontal}, // ┬ + {fc::vt100_key_vline , fc::BoxDrawingsVertical}, // │ + {fc::vt100_key_lequal , fc::LessThanOrEqualTo}, // ≤ + {fc::vt100_key_gequal , fc::GreaterThanOrEqualTo}, // ≥ + {fc::vt100_key_pi , fc::Pi}, // π + {fc::vt100_key_nequal , fc::NotEqualTo}, // ≠ + {fc::vt100_key_sterling , fc::Pound}, // £ + {fc::vt100_key_bullet , fc::SmallBullet}, // · + {fc::vt100_key_diamond , fc::Bullet} // ◆ }; const int lastKeyItem = int ( sizeof(vt100_key_to_utf8) diff --git a/src/fcheckbox.h b/src/fcheckbox.h index 5be0af9e..0fb129ba 100644 --- a/src/fcheckbox.h +++ b/src/fcheckbox.h @@ -45,28 +45,28 @@ class FCheckBox : public FToggleButton { - public: - // Constructors - explicit FCheckBox (FWidget* = 0); - FCheckBox (const FString&, FWidget* = 0); + public: + // Constructors + explicit FCheckBox (FWidget* = 0); + FCheckBox (const FString&, FWidget* = 0); - // Destructor - virtual ~FCheckBox(); + // Destructor + virtual ~FCheckBox(); - // Accessor - const char* getClassName() const; + // Accessor + const char* getClassName() const; - private: - // Disable copy constructor - FCheckBox (const FCheckBox&); + private: + // Disable copy constructor + FCheckBox (const FCheckBox&); - // Disable assignment operator (=) - FCheckBox& operator = (const FCheckBox&); + // Disable assignment operator (=) + FCheckBox& operator = (const FCheckBox&); - // Methods - void init(); - void draw(); - void drawCheckButton(); + // Methods + void init(); + void draw(); + void drawCheckButton(); }; #pragma pack(pop) diff --git a/src/fcheckmenuitem.cpp b/src/fcheckmenuitem.cpp index 993d5009..259a0e8c 100644 --- a/src/fcheckmenuitem.cpp +++ b/src/fcheckmenuitem.cpp @@ -37,9 +37,9 @@ void FCheckMenuItem::init (FWidget* parent) if ( ! parent ) return; - if ( isMenu(parent) ) // Parent is menu + if ( isMenu(parent) ) // Parent is menu { - FMenu* menu_ptr = dynamic_cast(parent); + FMenu* menu_ptr = static_cast(parent); if ( menu_ptr ) menu_ptr->has_checkable_items = true; diff --git a/src/fcheckmenuitem.h b/src/fcheckmenuitem.h index 95045e4c..6a3e9e4f 100644 --- a/src/fcheckmenuitem.h +++ b/src/fcheckmenuitem.h @@ -45,28 +45,28 @@ class FCheckMenuItem : public FMenuItem { - public: - // Constructors - explicit FCheckMenuItem (FWidget* = 0); - FCheckMenuItem (const FString&, FWidget* = 0); + public: + // Constructors + explicit FCheckMenuItem (FWidget* = 0); + FCheckMenuItem (const FString&, FWidget* = 0); - // Destructor - virtual ~FCheckMenuItem(); + // Destructor + virtual ~FCheckMenuItem(); - // Accessor - const char* getClassName() const; + // Accessor + const char* getClassName() const; - private: - // Disable copy constructor - FCheckMenuItem (const FCheckMenuItem&); + private: + // Disable copy constructor + FCheckMenuItem (const FCheckMenuItem&); - // Disable assignment operator (=) - FCheckMenuItem& operator = (const FCheckMenuItem&); + // Disable assignment operator (=) + FCheckMenuItem& operator = (const FCheckMenuItem&); - // Methods - void init (FWidget*); - void processToggle(); - void processClicked(); + // Methods + void init (FWidget*); + void processToggle(); + void processClicked(); }; #pragma pack(pop) diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 32c7eb55..9117dcac 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -1187,7 +1187,7 @@ void FDialog::drawBorder() // lower left corner border ⎣ print (fc::NF_border_corner_lower_left); - for (int x = 1; x < getWidth() - 1; x++) // low line _ + for (int x = 1; x < getWidth() - 1; x++) // low line _ print (fc::NF_border_line_bottom); setPrintPos (x2, y2); @@ -1204,7 +1204,7 @@ void FDialog::drawBorder() void FDialog::drawTitleBar() { static const int menu_btn = 3; - int i,x,length, zoom_btn; + int i, x, length, zoom_btn; // draw the title button setPrintPos (1, 1); @@ -1325,7 +1325,7 @@ void FDialog::drawTitleBar() } } } - else // is not zoomed + else // is not zoomed { if ( isNewFont() ) { diff --git a/src/fdialog.h b/src/fdialog.h index 7f62398e..f8010cfa 100644 --- a/src/fdialog.h +++ b/src/fdialog.h @@ -48,122 +48,122 @@ class FDialog : public FWindow { - public: + public: + // Using-declaration + using FWindow::setResizeable; + using FWindow::move; + using FWindow::setPos; + + // Enumeration + enum DialogCode + { + Reject = 0, + Accept = 1 + }; + + // Constructors + explicit FDialog (FWidget* = 0); + FDialog (const FString&, FWidget* = 0); + + // Destructor + virtual ~FDialog(); + + // Accessors + virtual const char* getClassName() const; + FString getText() const; + + // Mutators + bool setDialogWidget (bool); + bool setDialogWidget(); + bool unsetDialogWidget(); + bool setModal (bool); + bool setModal(); + bool unsetModal(); + bool setResizeable (bool); + bool setScrollable (bool); + bool setScrollable(); + bool unsetScrollable(); + void setText (const FString&); + + // Inquiries + bool isModal(); + bool isScrollable(); + + // Methods + void show(); + void hide(); + int exec(); + void setPos (int, int, bool = true); + void move (int, int); + void setSize (int, int, bool = true); + void activateDialog(); + + // Event handlers + void onKeyPress (FKeyEvent*); + void onMouseDown (FMouseEvent*); + void onMouseUp (FMouseEvent*); + void onMouseMove (FMouseEvent*); + void onMouseDoubleClick (FMouseEvent*); + void onAccel (FAccelEvent*); + void onWindowActive (FEvent*); + void onWindowInactive (FEvent*); + void onWindowRaised (FEvent*); + void onWindowLowered (FEvent*); + + protected: + // Methods + virtual void done (int); + virtual void draw(); + void drawDialogShadow(); + + // Event handlers + virtual void onShow (FShowEvent*); + virtual void onHide (FHideEvent*); + virtual void onClose (FCloseEvent*); + + private: // Using-declaration - using FWindow::setResizeable; - using FWindow::move; - using FWindow::setPos; + using FWidget::drawBorder; - // Enumeration - enum DialogCode - { - Reject = 0, - Accept = 1 - }; + // Disable copy constructor + FDialog (const FDialog&); - // Constructors - explicit FDialog (FWidget* = 0); - FDialog (const FString&, FWidget* = 0); + // Disable assignment operator (=) + FDialog& operator = (const FDialog&); - // Destructor - virtual ~FDialog(); + // Methods + void init(); + virtual void drawBorder(); + void drawTitleBar(); + void leaveMenu(); + void openMenu(); + void selectFirstMenuItem(); + void setZoomItem(); + static void addDialog (FWidget*); + static void delDialog (FWidget*); - // Accessors - virtual const char* getClassName() const; - FString getText() const; + // Callback methods + void cb_move (FWidget*, data_ptr); + void cb_zoom (FWidget*, data_ptr); + void cb_close (FWidget*, data_ptr); - // Mutators - bool setDialogWidget (bool); - bool setDialogWidget(); - bool unsetDialogWidget(); - bool setModal (bool); - bool setModal(); - bool unsetModal(); - bool setResizeable (bool); - bool setScrollable (bool); - bool setScrollable(); - bool unsetScrollable(); - void setText (const FString&); + // Data Members + FString tb_text; // title bar text + int result_code; + bool zoom_button_pressed; + bool zoom_button_active; + FPoint titlebar_click_pos; + FPoint resize_click_pos; + FRect save_geometry; // required by keyboard move/size + FMenu* dialog_menu; + FMenuItem* dgl_menuitem; + FMenuItem* move_size_item; + FMenuItem* zoom_item; + FMenuItem* close_item; + FToolTip* tooltip; - // Inquiries - bool isModal(); - bool isScrollable(); - - // Methods - void show(); - void hide(); - int exec(); - void setPos (int, int, bool = true); - void move (int, int); - void setSize (int, int, bool = true); - void activateDialog(); - - // Event handlers - void onKeyPress (FKeyEvent*); - void onMouseDown (FMouseEvent*); - void onMouseUp (FMouseEvent*); - void onMouseMove (FMouseEvent*); - void onMouseDoubleClick (FMouseEvent*); - void onAccel (FAccelEvent*); - void onWindowActive (FEvent*); - void onWindowInactive (FEvent*); - void onWindowRaised (FEvent*); - void onWindowLowered (FEvent*); - - protected: - // Methods - virtual void done (int); - virtual void draw(); - void drawDialogShadow(); - - // Event handlers - virtual void onShow (FShowEvent*); - virtual void onHide (FHideEvent*); - virtual void onClose (FCloseEvent*); - - private: - // Using-declaration - using FWidget::drawBorder; - - // Disable copy constructor - FDialog (const FDialog&); - - // Disable assignment operator (=) - FDialog& operator = (const FDialog&); - - // Methods - void init(); - virtual void drawBorder(); - void drawTitleBar(); - void leaveMenu(); - void openMenu(); - void selectFirstMenuItem(); - void setZoomItem(); - static void addDialog (FWidget*); - static void delDialog (FWidget*); - - // Callback methods - void cb_move (FWidget*, data_ptr); - void cb_zoom (FWidget*, data_ptr); - void cb_close (FWidget*, data_ptr); - - // Data Members - FString tb_text; // title bar text - int result_code; - bool zoom_button_pressed; - bool zoom_button_active; - FPoint titlebar_click_pos; - FPoint resize_click_pos; - FRect save_geometry; // required by keyboard move/size - FMenu* dialog_menu; - FMenuItem* dgl_menuitem; - FMenuItem* move_size_item; - FMenuItem* zoom_item; - FMenuItem* close_item; - FToolTip* tooltip; - - // Friend function from FMenu - friend void FMenu::hideSuperMenus(); + // Friend function from FMenu + friend void FMenu::hideSuperMenus(); }; #pragma pack(pop) diff --git a/src/fdialoglistmenu.h b/src/fdialoglistmenu.h index d774f00c..da6ebf13 100644 --- a/src/fdialoglistmenu.h +++ b/src/fdialoglistmenu.h @@ -52,26 +52,26 @@ class FDialogListMenu : public FMenu { - public: - // Constructors - explicit FDialogListMenu (FWidget* = 0); - FDialogListMenu (const FString&, FWidget* = 0); + public: + // Constructors + explicit FDialogListMenu (FWidget* = 0); + FDialogListMenu (const FString&, FWidget* = 0); - // Destructor - virtual ~FDialogListMenu(); + // Destructor + virtual ~FDialogListMenu(); - // Accessors - virtual const char* getClassName() const; + // Accessors + virtual const char* getClassName() const; - private: - // Disable copy constructor - FDialogListMenu (const FDialogListMenu&); + private: + // Disable copy constructor + FDialogListMenu (const FDialogListMenu&); - // Disable assignment operator (=) - FDialogListMenu& operator = (const FDialogListMenu&); + // Disable assignment operator (=) + FDialogListMenu& operator = (const FDialogListMenu&); - // Method - void init(); + // Method + void init(); }; #pragma pack(pop) diff --git a/src/fevent.h b/src/fevent.h index 30bcf25f..d9318559 100644 --- a/src/fevent.h +++ b/src/fevent.h @@ -64,15 +64,15 @@ #pragma pack(push) #pragma pack(1) -class FEvent // event base class +class FEvent // event base class { - public: - explicit FEvent(int); - virtual ~FEvent(); - int type() const; + public: + explicit FEvent(int); + virtual ~FEvent(); + int type() const; - protected: - int t; + protected: + int t; }; #pragma pack(pop) @@ -85,20 +85,20 @@ class FEvent // event base class #pragma pack(push) #pragma pack(1) -class FKeyEvent : public FEvent // keyboard event +class FKeyEvent : public FEvent // keyboard event { - public: - FKeyEvent (int, int); - ~FKeyEvent(); + public: + FKeyEvent (int, int); + ~FKeyEvent(); - int key() const; - bool isAccepted() const; - void accept(); - void ignore(); + int key() const; + bool isAccepted() const; + void accept(); + void ignore(); - protected: - int k; - bool accpt; + protected: + int k; + bool accpt; }; #pragma pack(pop) @@ -111,25 +111,25 @@ class FKeyEvent : public FEvent // keyboard event #pragma pack(push) #pragma pack(1) -class FMouseEvent : public FEvent // mouse event +class FMouseEvent : public FEvent // mouse event { - public: - FMouseEvent (int, const FPoint&, int); - FMouseEvent (int, const FPoint&, const FPoint&, int); - ~FMouseEvent(); + public: + FMouseEvent (int, const FPoint&, int); + FMouseEvent (int, const FPoint&, const FPoint&, int); + ~FMouseEvent(); - const FPoint& getPos() const; - const FPoint& getTermPos() const; - int getX() const; - int getY() const; - int getTermX() const; - int getTermY() const; - int getButton() const; + const FPoint& getPos() const; + const FPoint& getTermPos() const; + int getX() const; + int getY() const; + int getTermX() const; + int getTermY() const; + int getButton() const; - protected: - FPoint p; - FPoint tp; - int b; + protected: + FPoint p; + FPoint tp; + int b; }; #pragma pack(pop) @@ -142,25 +142,25 @@ class FMouseEvent : public FEvent // mouse event #pragma pack(push) #pragma pack(1) -class FWheelEvent : public FEvent // wheel event +class FWheelEvent : public FEvent // wheel event { - public: - FWheelEvent (int, const FPoint&, int); - FWheelEvent (int, const FPoint&, const FPoint&, int); - ~FWheelEvent(); + public: + FWheelEvent (int, const FPoint&, int); + FWheelEvent (int, const FPoint&, const FPoint&, int); + ~FWheelEvent(); - const FPoint& getPos() const; - const FPoint& getTermPos() const; - int getX() const; - int getY() const; - int getTermX() const; - int getTermY() const; - int getWheel() const; + const FPoint& getPos() const; + const FPoint& getTermPos() const; + int getX() const; + int getY() const; + int getTermX() const; + int getTermY() const; + int getWheel() const; - protected: - FPoint p; - FPoint tp; - int w; + protected: + FPoint p; + FPoint tp; + int w; }; #pragma pack(pop) @@ -173,22 +173,22 @@ class FWheelEvent : public FEvent // wheel event #pragma pack(push) #pragma pack(1) -class FFocusEvent : public FEvent // focus event +class FFocusEvent : public FEvent // focus event { - public: - explicit FFocusEvent (int); - ~FFocusEvent(); + public: + explicit FFocusEvent (int); + ~FFocusEvent(); - bool gotFocus() const; - bool lostFocus() const; - fc::FocusTypes getFocusType() const; - void setFocusType(fc::FocusTypes); - bool isAccepted() const; - void accept(); - void ignore(); - protected: - bool accpt; - fc::FocusTypes focus_type; + bool gotFocus() const; + bool lostFocus() const; + fc::FocusTypes getFocusType() const; + void setFocusType(fc::FocusTypes); + bool isAccepted() const; + void accept(); + void ignore(); + protected: + bool accpt; + fc::FocusTypes focus_type; }; #pragma pack(pop) @@ -201,26 +201,26 @@ class FFocusEvent : public FEvent // focus event #pragma pack(push) #pragma pack(1) -class FAccelEvent : public FEvent // focus event +class FAccelEvent : public FEvent // focus event { - private: - // Disable copy constructor - FAccelEvent (const FAccelEvent&); - // Disable assignment operator (=) - FAccelEvent& operator = (const FAccelEvent&); + private: + // Disable copy constructor + FAccelEvent (const FAccelEvent&); + // Disable assignment operator (=) + FAccelEvent& operator = (const FAccelEvent&); - public: - FAccelEvent (int, void*); - ~FAccelEvent(); + public: + FAccelEvent (int, void*); + ~FAccelEvent(); - void* focusedWidget() const; - bool isAccepted() const; - void accept(); - void ignore(); + void* focusedWidget() const; + bool isAccepted() const; + void accept(); + void ignore(); - protected: - bool accpt; - void* focus_widget; + protected: + bool accpt; + void* focus_widget; }; #pragma pack(pop) @@ -230,18 +230,18 @@ class FAccelEvent : public FEvent // focus event // class FResizeEvent //---------------------------------------------------------------------- -class FResizeEvent : public FEvent // resize event +class FResizeEvent : public FEvent // resize event { - public: - explicit FResizeEvent (int); - ~FResizeEvent(); + public: + explicit FResizeEvent (int); + ~FResizeEvent(); - bool isAccepted() const; - void accept(); - void ignore(); + bool isAccepted() const; + void accept(); + void ignore(); - protected: - bool accpt; + protected: + bool accpt; }; @@ -250,11 +250,11 @@ class FResizeEvent : public FEvent // resize event // class FShowEvent //---------------------------------------------------------------------- -class FShowEvent : public FEvent // show event +class FShowEvent : public FEvent // show event { - public: - explicit FShowEvent (int); - ~FShowEvent(); + public: + explicit FShowEvent (int); + ~FShowEvent(); }; @@ -263,11 +263,11 @@ class FShowEvent : public FEvent // show event // class FHideEvent //---------------------------------------------------------------------- -class FHideEvent : public FEvent // hide event +class FHideEvent : public FEvent // hide event { - public: - explicit FHideEvent (int); - ~FHideEvent(); + public: + explicit FHideEvent (int); + ~FHideEvent(); }; @@ -276,18 +276,18 @@ class FHideEvent : public FEvent // hide event // class FCloseEvent //---------------------------------------------------------------------- -class FCloseEvent : public FEvent // close event +class FCloseEvent : public FEvent // close event { - public: - explicit FCloseEvent(int); - ~FCloseEvent(); + public: + explicit FCloseEvent(int); + ~FCloseEvent(); - bool isAccepted() const; - void accept(); - void ignore(); + bool isAccepted() const; + void accept(); + void ignore(); - protected: - bool accpt; + protected: + bool accpt; }; @@ -299,16 +299,16 @@ class FCloseEvent : public FEvent // close event #pragma pack(push) #pragma pack(1) -class FTimerEvent : public FEvent // timer event +class FTimerEvent : public FEvent // timer event { - public: - FTimerEvent(int, int); - ~FTimerEvent(); + public: + FTimerEvent(int, int); + ~FTimerEvent(); - int timerId() const; + int timerId() const; - protected: - int id; + protected: + int id; }; #pragma pack(pop) diff --git a/src/ffiledialog.cpp b/src/ffiledialog.cpp index 8a245f44..92c58bb7 100644 --- a/src/ffiledialog.cpp +++ b/src/ffiledialog.cpp @@ -1,8 +1,11 @@ // File: ffiledialog.cpp // Provides: class FFileDialog +#include + #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(); @@ -525,9 +535,9 @@ void FFileDialog::init() cancel->setGeometry(19, 10, 9, 1); if ( dlg_type == FFileDialog::Save ) - open = new FButton("&Save",this); + open = new FButton("&Save", this); else - open = new FButton("&Open",this); + open = new FButton("&Open", this); open->setGeometry(30, 10, 9, 1); setGeometry (x, y, getWidth(), getHeight()); @@ -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(""); else { - pwd = getpwnam(pwd->pw_name); - - if ( ! pwd ) + if ( getpwnam_r (pwd.pw_name, &pwd, buf, sizeof(buf), &pwd_ptr) ) return const_cast(""); else - return pwd->pw_dir; + return pwd.pw_dir; } } @@ -695,7 +704,8 @@ int FFileDialog::changeDir (const FString& dirname) { int i = 1; std::vector::const_iterator iter, end; - const char* const baseName = basename(const_cast(lastdir.c_str())); + const char* const baseName = \ + basename(const_cast(lastdir.c_str())); iter = dir_entries.begin(); end = dir_entries.end(); diff --git a/src/ffiledialog.h b/src/ffiledialog.h index 416b566a..16e6c78a 100644 --- a/src/ffiledialog.h +++ b/src/ffiledialog.h @@ -46,6 +46,7 @@ #include #include +#include #include "fbutton.h" #include "fcheckbox.h" @@ -66,102 +67,102 @@ class FFileDialog : public FDialog { - public: - // Enumeration - enum DialogType - { - Open = 0, - Save = 1 - }; + public: + // Enumeration + enum DialogType + { + Open = 0, + Save = 1 + }; - // Constructors - explicit FFileDialog (FWidget* = 0); - FFileDialog (const FFileDialog&); // copy constructor - FFileDialog ( const FString& - , const FString& - , DialogType = FFileDialog::Open - , FWidget* = 0 ); - // Destructor - ~FFileDialog(); + // Constructors + explicit FFileDialog (FWidget* = 0); + FFileDialog (const FFileDialog&); // copy constructor + FFileDialog ( const FString& + , const FString& + , DialogType = FFileDialog::Open + , FWidget* = 0 ); + // Destructor + ~FFileDialog(); - // Assignment operator (=) - FFileDialog& operator = (const FFileDialog&); + // Assignment operator (=) + FFileDialog& operator = (const FFileDialog&); - // Accessors - const char* getClassName() const; - const FString getPath() const; - const FString getFilter() const; - const FString getSelectedFile() const; - bool getShowHiddenFiles(); + // Accessors + const char* getClassName() const; + const FString getPath() const; + const FString getFilter() const; + const FString getSelectedFile() const; + bool getShowHiddenFiles(); - // Mutators - void setPath (const FString&); - void setFilter (const FString&); - bool setShowHiddenFiles(bool); - bool setShowHiddenFiles(); - bool unsetShowHiddenFiles(); + // Mutators + void setPath (const FString&); + void setFilter (const FString&); + bool setShowHiddenFiles(bool); + bool setShowHiddenFiles(); + bool unsetShowHiddenFiles(); - // Event handler - void onKeyPress (FKeyEvent*); + // Event handler + void onKeyPress (FKeyEvent*); - // Methods - int readDir(); - static const FString fileOpenChooser ( FWidget* - , const FString& = FString() - , const FString& = FString() ); - static const FString fileSaveChooser ( FWidget* - , const FString& = FString() - , const FString& = FString() ); + // Methods + int readDir(); + static const FString fileOpenChooser ( FWidget* + , const FString& = FString() + , const FString& = FString() ); + static const FString fileSaveChooser ( FWidget* + , const FString& = FString() + , const FString& = FString() ); - protected: - // Method - void adjustSize(); + protected: + // Method + void adjustSize(); - private: - // Typedef - struct dir_entry - { - char* name; - uChar type; - }; + private: + // Typedef + struct dir_entry + { + char* name; + uChar type; + }; - typedef std::vector dirEntries; + typedef std::vector dirEntries; - // Method - void init(); - static char* getHomeDir(); - inline bool pattern_match (const char* const, char*&); - void clear(); - int numOfDirs(); - int changeDir (const FString&); - void printPath (const FString&); + // Method + void init(); + static char* getHomeDir(); + inline bool pattern_match (const char* const, char*&); + void clear(); + int numOfDirs(); + int changeDir (const FString&); + void printPath (const FString&); - // Callback methods - void cb_processActivate (FWidget*, data_ptr); - void cb_processRowChanged (FWidget*, data_ptr); - void cb_processClicked (FWidget*, data_ptr); - void cb_processCancel (FWidget*, data_ptr); - void cb_processOpen (FWidget*, data_ptr); - void cb_processShowHidden (FWidget*, data_ptr); + // Callback methods + void cb_processActivate (FWidget*, data_ptr); + void cb_processRowChanged (FWidget*, data_ptr); + void cb_processClicked (FWidget*, data_ptr); + void cb_processCancel (FWidget*, data_ptr); + void cb_processOpen (FWidget*, data_ptr); + void cb_processShowHidden (FWidget*, data_ptr); - // Data Members - DIR* directory_stream; - dirEntries dir_entries; - FString directory; - FString filter_pattern; - FListBox* filebrowser; - FLineEdit* filename; - FCheckBox* hidden; - FButton* cancel; - FButton* open; - DialogType dlg_type; - bool show_hidden; + // Data Members + DIR* directory_stream; + dirEntries dir_entries; + FString directory; + FString filter_pattern; + FListBox* filebrowser; + FLineEdit* filename; + FCheckBox* hidden; + FButton* cancel; + FButton* open; + DialogType dlg_type; + bool show_hidden; - // Friend functions - friend bool sortByName ( const FFileDialog::dir_entry& - , const FFileDialog::dir_entry& ); - friend bool sortDirFirst ( const FFileDialog::dir_entry& - , const FFileDialog::dir_entry& ); + // Friend functions + friend bool sortByName ( const FFileDialog::dir_entry& + , const FFileDialog::dir_entry& ); + friend bool sortDirFirst ( const FFileDialog::dir_entry& + , const FFileDialog::dir_entry& ); }; #pragma pack(pop) diff --git a/src/fkey_map.h b/src/fkey_map.h index f57f222f..ce0d98a0 100644 --- a/src/fkey_map.h +++ b/src/fkey_map.h @@ -3,6 +3,7 @@ #ifndef FKEYMAP_H #define FKEYMAP_H +#include #pragma pack(push) #pragma pack(1) @@ -448,12 +449,12 @@ static keyname FkeyName[] = { fc::Fckey_e , "Ctrl+E" }, { fc::Fckey_f , "Ctrl+F" }, { fc::Fckey_g , "Ctrl+G" }, - { fc::Fkey_erase , "Backspace" }, // Ctrl+H - { fc::Fkey_tab , "Tab" }, // Ctrl+I + { fc::Fkey_erase , "Backspace" }, // Ctrl+H + { fc::Fkey_tab , "Tab" }, // Ctrl+I { fc::Fckey_j , "Ctrl+J" }, { fc::Fckey_h , "Ctrl+K" }, { fc::Fckey_l , "Ctrl+L" }, - { fc::Fkey_return , "Return" }, // Ctrl+M + { fc::Fkey_return , "Return" }, // Ctrl+M { fc::Fckey_n , "Ctrl+N" }, { fc::Fckey_o , "Ctrl+O" }, { fc::Fckey_p , "Ctrl+P" }, @@ -467,13 +468,13 @@ static keyname FkeyName[] = { fc::Fckey_x , "Ctrl+X" }, { fc::Fckey_y , "Ctrl+Y" }, { fc::Fckey_z , "Ctrl+Z" }, - { fc::Fkey_escape , "Esc" }, // Ctrl+[ + { fc::Fkey_escape , "Esc" }, // Ctrl+[ { fc::Fckey_backslash , "Ctrl+\\" }, { fc::Fckey_right_square_bracket, "Ctrl+]" }, { fc::Fckey_caret , "Ctrl+^" }, { fc::Fckey_underscore , "Ctrl+_" }, { fc::Fkey_space , "Space" }, - { fc::Fckey_space , "Ctrl+Space" }, // Ctrl+(Space or @) + { fc::Fckey_space , "Ctrl+Space" }, // Ctrl+(Space or @) { fc::Fkey_backspace , "Backspace" }, { fc::Fkey_catab , "Clear-All-Tabs" }, { fc::Fkey_clear , "Clear-Screen" }, diff --git a/src/flabel.cpp b/src/flabel.cpp index 1ccbdf8c..1b8b2107 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -45,7 +45,7 @@ FLabel::FLabel (const FString& txt, FWidget* parent) } //---------------------------------------------------------------------- -FLabel::~FLabel() // destructor +FLabel::~FLabel() // destructor { delAccelerator(); } diff --git a/src/flabel.h b/src/flabel.h index 3b90e87d..a78d7495 100644 --- a/src/flabel.h +++ b/src/flabel.h @@ -28,6 +28,7 @@ #ifndef FLABEL_H #define FLABEL_H +#include #include "fwidget.h" @@ -40,79 +41,79 @@ class FLabel : public FWidget { - public: - // Using-declaration - using FWidget::setEnable; + public: + // Using-declaration + using FWidget::setEnable; - // Constructor - explicit FLabel (FWidget* = 0); - FLabel (const FString&, FWidget* = 0); + // Constructor + explicit FLabel (FWidget* = 0); + FLabel (const FString&, FWidget* = 0); - // Destructor - virtual ~FLabel(); + // Destructor + virtual ~FLabel(); - // Accessors - const char* getClassName() const; - FTerm* getAccelWidget(); - fc::text_alignment getAlignment(); - FString& getText(); + // Accessors + const char* getClassName() const; + FTerm* getAccelWidget(); + fc::text_alignment getAlignment(); + FString& getText(); - // Mutators - void setAccelWidget (FWidget* = 0); - void setAlignment(fc::text_alignment); - bool setEmphasis(bool); - bool setEmphasis(); - bool unsetEmphasis(); - bool setReverseMode(bool); - bool setReverseMode(); - bool unsetReverseMode(); - bool setEnable (bool); - void setNumber(long); - void setText (const FString&); + // Mutators + void setAccelWidget (FWidget* = 0); + void setAlignment(fc::text_alignment); + bool setEmphasis(bool); + bool setEmphasis(); + bool unsetEmphasis(); + bool setReverseMode(bool); + bool setReverseMode(); + bool unsetReverseMode(); + bool setEnable (bool); + void setNumber(long); + void setText (const FString&); - // Inquiries - bool hasEmphasis(); - bool hasReverseMode(); + // Inquiries + bool hasEmphasis(); + bool hasReverseMode(); - // Methods - void hide(); + // Methods + void hide(); - // Event handlers - void onMouseDown (FMouseEvent*); - void onAccel (FAccelEvent*); + // Event handlers + void onMouseDown (FMouseEvent*); + void onAccel (FAccelEvent*); - // Callback method - void cb_accel_widget_destroyed (FWidget*, data_ptr); + // Callback method + void cb_accel_widget_destroyed (FWidget*, data_ptr); - private: - // Typedef - typedef std::vector multiLineText; + private: + // Typedef + typedef std::vector multiLineText; - // Disable copy constructor - FLabel (const FLabel&); + // Disable copy constructor + FLabel (const FLabel&); - // Disable assignment operator (=) - FLabel& operator = (const FLabel&); + // Disable assignment operator (=) + FLabel& operator = (const FLabel&); - // Methods - void init(); - uChar getHotkey(); - int getHotkeyPos (wchar_t*&, wchar_t*&, uInt); - void setHotkeyAccelerator(); - int getAlignOffset (int); - void printLine (wchar_t*&, uInt, int, int = 0); - void draw(); + // Methods + void init(); + uChar getHotkey(); + int getHotkeyPos (wchar_t*&, wchar_t*&, uInt); + void setHotkeyAccelerator(); + int getAlignOffset (int); + void printLine (wchar_t*&, uInt, int, int = 0); + void draw(); - // Data Members - multiLineText multiline_text; - bool multiline; - FString text; - fc::text_alignment alignment; - short emphasis_color; - short ellipsis_color; - bool emphasis; - bool reverse_mode; - FWidget* accel_widget; + // Data Members + multiLineText multiline_text; + bool multiline; + FString text; + fc::text_alignment alignment; + short emphasis_color; + short ellipsis_color; + bool emphasis; + bool reverse_mode; + FWidget* accel_widget; }; #pragma pack(pop) diff --git a/src/flineedit.cpp b/src/flineedit.cpp index 4d523d2e..6172ddd3 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -272,7 +272,7 @@ void FLineEdit::onKeyPress (FKeyEvent* ev) ev->accept(); break; - case fc::Fkey_dc: // del key + case fc::Fkey_dc: // del key if ( len > 0 && cursor_pos < len ) { text.remove(uInt(cursor_pos), 1); @@ -306,7 +306,7 @@ void FLineEdit::onKeyPress (FKeyEvent* ev) ev->accept(); break; - case fc::Fkey_ic: // insert key + case fc::Fkey_ic: // insert key insert_mode = not insert_mode; if ( insert_mode ) diff --git a/src/flineedit.h b/src/flineedit.h index 2b6b4aff..12b81ac5 100644 --- a/src/flineedit.h +++ b/src/flineedit.h @@ -41,97 +41,97 @@ class FLineEdit : public FWidget { - public: - // Enumeration - enum label_o - { - label_above = 0, - label_left = 1 - }; + public: + // Enumeration + enum label_o + { + label_above = 0, + label_left = 1 + }; - // Constructor - explicit FLineEdit (FWidget* = 0); - FLineEdit (const FString&, FWidget* = 0); + // Constructor + explicit FLineEdit (FWidget* = 0); + FLineEdit (const FString&, FWidget* = 0); - // Destructor - virtual ~FLineEdit(); + // Destructor + virtual ~FLineEdit(); - // Accessors - const char* getClassName() const; - FString getText() const; - int getLabelOrientation(); + // Accessors + const char* getClassName() const; + FString getText() const; + int getLabelOrientation(); - // Mutators - void setText (const FString&); - void setLabelText (const FString&); - void setLabelOrientation(const label_o); - bool setEnable(bool); - bool setEnable(); - bool unsetEnable(); - bool setDisable(); - bool setFocus(bool); - bool setFocus(); - bool unsetFocus(); - bool setShadow(bool); - bool setShadow(); - bool unsetShadow(); + // Mutators + void setText (const FString&); + void setLabelText (const FString&); + void setLabelOrientation(const label_o); + bool setEnable(bool); + bool setEnable(); + bool unsetEnable(); + bool setDisable(); + bool setFocus(bool); + bool setFocus(); + bool unsetFocus(); + bool setShadow(bool); + bool setShadow(); + bool unsetShadow(); - // Inquiry - bool hasShadow(); + // Inquiry + bool hasShadow(); - // Methods - void hide(); - void clearText(); + // Methods + void hide(); + void clearText(); - // Event handlers - void onKeyPress (FKeyEvent*); - void onMouseDown (FMouseEvent*); - void onMouseUp (FMouseEvent*); - void onMouseMove (FMouseEvent*); - void onTimer (FTimerEvent*); - void onAccel (FAccelEvent*); - void onHide (FHideEvent*); - void onFocusIn (FFocusEvent*); - void onFocusOut (FFocusEvent*); + // Event handlers + void onKeyPress (FKeyEvent*); + void onMouseDown (FMouseEvent*); + void onMouseUp (FMouseEvent*); + void onMouseMove (FMouseEvent*); + void onTimer (FTimerEvent*); + void onAccel (FAccelEvent*); + void onHide (FHideEvent*); + void onFocusIn (FFocusEvent*); + void onFocusOut (FFocusEvent*); - protected: - void adjustLabel(); - void adjustSize(); + protected: + void adjustLabel(); + void adjustSize(); - private: - // Enumeration - enum dragScroll - { - noScroll = 0, - scrollLeft = 1, - scrollRight = 2 - }; + private: + // Enumeration + enum dragScroll + { + noScroll = 0, + scrollLeft = 1, + scrollRight = 2 + }; - // Disable copy constructor - FLineEdit (const FLineEdit&); + // Disable copy constructor + FLineEdit (const FLineEdit&); - // Disable assignment operator (=) - FLineEdit& operator = (const FLineEdit&); + // Disable assignment operator (=) + FLineEdit& operator = (const FLineEdit&); - // Methods - void init(); - bool hasHotkey(); - void draw(); - void drawInputField(); - void processActivate(); - void processChanged(); + // Methods + void init(); + bool hasHotkey(); + void draw(); + void drawInputField(); + void processActivate(); + void processChanged(); - // Data Members - FString text; - FString label_text; - FLabel* label; - label_o label_orientation; - dragScroll drag_scroll; - bool scroll_timer; - int scroll_repeat; - bool insert_mode; - int cursor_pos; - int text_offset; + // Data Members + FString text; + FString label_text; + FLabel* label; + label_o label_orientation; + dragScroll drag_scroll; + bool scroll_timer; + int scroll_repeat; + bool insert_mode; + int cursor_pos; + int text_offset; }; #pragma pack(pop) diff --git a/src/flistbox.cpp b/src/flistbox.cpp index c2f2b6c0..5d058f73 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -2,6 +2,8 @@ // Provides: class FListBoxItem // class FListBox +#include + #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 @@ -403,7 +405,7 @@ void FListBox::clear() //---------------------------------------------------------------------- void FListBox::onKeyPress (FKeyEvent* ev) { - static const int padding_space = 2; // 1 leading space + 1 tailing space + static const int padding_space = 2; // 1 leading space + 1 tailing space int element_count = int(getCount()); int current_before = current; int xoffset_before = xoffset; @@ -1306,8 +1308,8 @@ void FListBox::draw() for (int y = 2; y < getHeight(); y++) { - setPrintPos (getWidth(),y); - print (' '); // clear right side of the scrollbar + setPrintPos (getWidth(), y); + print (' '); // clear right side of the scrollbar } } @@ -1448,7 +1450,7 @@ void FListBox::drawList() setColor ( wc.selected_current_element_fg , wc.selected_current_element_bg ); - setCursorPos (3, 2 + int(y)); // first character + setCursorPos (3, 2 + int(y)); // first character } else { @@ -1464,10 +1466,11 @@ 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 + setCursorPos (3 + b, 2 + int(y)); // first character } else setColor ( wc.current_element_fg @@ -1793,7 +1796,7 @@ void FListBox::cb_VBarChange (FWidget*, data_ptr) //---------------------------------------------------------------------- void FListBox::cb_HBarChange (FWidget*, data_ptr) { - static const int padding_space = 2; // 1 leading space + 1 tailing space + static const int padding_space = 2; // 1 leading space + 1 tailing space FScrollbar::sType scrollType; int distance = 1; int xoffset_before = xoffset; diff --git a/src/flistbox.h b/src/flistbox.h index 69776280..a81e0905 100644 --- a/src/flistbox.h +++ b/src/flistbox.h @@ -30,6 +30,8 @@ #ifndef FLISTBOX_H #define FLISTBOX_H +#include + #include "fscrollbar.h" #include "fstring.h" #include "fwidget.h" @@ -44,35 +46,35 @@ class FListBoxItem { - public: - // Constructors - FListBoxItem (); - FListBoxItem (const FListBoxItem&); // copy constructor - explicit FListBoxItem (const FString&, FWidget::data_ptr = 0); + public: + // Constructors + FListBoxItem (); + FListBoxItem (const FListBoxItem&); // copy constructor + explicit FListBoxItem (const FString&, FWidget::data_ptr = 0); - // Destructor - virtual ~FListBoxItem(); + // Destructor + virtual ~FListBoxItem(); - // Assignment operator (=) - FListBoxItem& operator = (const FListBoxItem&); + // Assignment operator (=) + FListBoxItem& operator = (const FListBoxItem&); - // Accessors - virtual FString& getText(); - virtual FWidget::data_ptr getData() const; + // Accessors + virtual FString& getText(); + virtual FWidget::data_ptr getData() const; - // Mutators - void setText (const FString&); - void setData (FWidget::data_ptr); + // Mutators + void setText (const FString&); + void setData (FWidget::data_ptr); - private: - // Friend classes - friend class FListBox; + private: + // Friend classes + friend class FListBox; - // Data Members - FString text; - FWidget::data_ptr data_pointer; - fc::brackets_type brackets; - bool selected; + // Data Members + FString text; + FWidget::data_ptr data_pointer; + fc::brackets_type brackets; + bool selected; }; #pragma pack(pop) @@ -104,154 +106,154 @@ inline void FListBoxItem::setData (FWidget::data_ptr data) class FListBox : public FWidget { - public: - // Typedef - typedef std::vector listBoxItems; + public: + // Typedef + typedef std::vector listBoxItems; - // Using-declaration - using FWidget::setGeometry; + // Using-declaration + using FWidget::setGeometry; - // Constructor - explicit FListBox (FWidget* = 0); - template - FListBox (Iterator, Iterator, InsertConverter, FWidget* = 0); - template - FListBox (Container, LazyConverter, FWidget* = 0); + // Constructor + explicit FListBox (FWidget* = 0); + template + FListBox (Iterator, Iterator, InsertConverter, FWidget* = 0); + template + FListBox (Container, LazyConverter, FWidget* = 0); - // Destructor - ~FListBox(); + // Destructor + ~FListBox(); - // Accessors - const char* getClassName() const; - uInt getCount() const; - FListBoxItem getItem (int); - FListBoxItem getItem (listBoxItems::iterator) const; - int currentItem() const; - FString& getText(); + // Accessors + const char* getClassName() const; + uInt getCount() const; + FListBoxItem getItem (int); + FListBoxItem getItem (listBoxItems::iterator) const; + int currentItem() const; + FString& getText(); - // Mutators - void setCurrentItem (int); - void setCurrentItem (listBoxItems::iterator); - void selectItem (int); - void selectItem (listBoxItems::iterator); - void unselectItem (int); - void unselectItem (listBoxItems::iterator); - void showInsideBrackets (int, fc::brackets_type); - void showNoBrackets (int); - void showNoBrackets (listBoxItems::iterator); - void setGeometry (int, int, int, int, bool = true); - void setMultiSelection (bool); - void setMultiSelection (); - void unsetMultiSelection (); - bool setDisable(); - bool setFocus (bool); - bool setFocus(); - bool unsetFocus(); - void setText (const FString&); + // Mutators + void setCurrentItem (int); + void setCurrentItem (listBoxItems::iterator); + void selectItem (int); + void selectItem (listBoxItems::iterator); + void unselectItem (int); + void unselectItem (listBoxItems::iterator); + void showInsideBrackets (int, fc::brackets_type); + void showNoBrackets (int); + void showNoBrackets (listBoxItems::iterator); + void setGeometry (int, int, int, int, bool = true); + void setMultiSelection (bool); + void setMultiSelection (); + void unsetMultiSelection (); + bool setDisable(); + bool setFocus (bool); + bool setFocus(); + bool unsetFocus(); + void setText (const FString&); - // Inquiries - bool isSelected (int); - bool isSelected (listBoxItems::iterator) const; - bool isMultiSelection() const; - bool hasBrackets (int); - bool hasBrackets (listBoxItems::iterator) const; + // Inquiries + bool isSelected (int); + bool isSelected (listBoxItems::iterator) const; + bool isMultiSelection() const; + bool hasBrackets (int); + bool hasBrackets (listBoxItems::iterator) const; - // Methods - void hide(); - template - void insert (Iterator, Iterator, InsertConverter); - template - void insert (Container, LazyConverter); - void insert (FListBoxItem); - void insert ( const FString& - , fc::brackets_type = fc::NoBrackets - , bool = false - , data_ptr = 0 ); - void insert ( long - , fc::brackets_type = fc::NoBrackets - , bool = false - , data_ptr = 0 ); - void remove (int); - void clear(); + // Methods + void hide(); + template + void insert (Iterator, Iterator, InsertConverter); + template + void insert (Container, LazyConverter); + void insert (FListBoxItem); + void insert ( const FString& + , fc::brackets_type = fc::NoBrackets + , bool = false + , data_ptr = 0 ); + void insert ( long + , fc::brackets_type = fc::NoBrackets + , bool = false + , data_ptr = 0 ); + void remove (int); + void clear(); - // Event handlers - void onKeyPress (FKeyEvent*); - void onMouseDown (FMouseEvent*); - void onMouseUp (FMouseEvent*); - void onMouseMove (FMouseEvent*); - void onMouseDoubleClick (FMouseEvent*); - void onWheel (FWheelEvent*); - void onTimer (FTimerEvent*); - void onFocusIn (FFocusEvent*); - void onFocusOut (FFocusEvent*); + // Event handlers + void onKeyPress (FKeyEvent*); + void onMouseDown (FMouseEvent*); + void onMouseUp (FMouseEvent*); + void onMouseMove (FMouseEvent*); + void onMouseDoubleClick (FMouseEvent*); + void onWheel (FWheelEvent*); + void onTimer (FTimerEvent*); + void onFocusIn (FFocusEvent*); + void onFocusOut (FFocusEvent*); - protected: - // Methods - void adjustYOffset(); - void adjustSize(); + protected: + // Methods + void adjustYOffset(); + void adjustSize(); - private: - // Enumeration - enum convert_type - { - no_convert = 0, - direct_convert = 1, - lazy_convert = 2 - }; + private: + // Enumeration + enum convert_type + { + no_convert = 0, + direct_convert = 1, + lazy_convert = 2 + }; - // Disable copy constructor - FListBox (const FListBox&); + // Disable copy constructor + FListBox (const FListBox&); - // Disable assignment operator (=) - FListBox& operator = (const FListBox&); + // Disable assignment operator (=) + FListBox& operator = (const FListBox&); - // Accessors - static FString& getString (listBoxItems::iterator); + // Accessors + static FString& getString (listBoxItems::iterator); - // Methods - void init(); - void draw(); - void drawLabel(); - void drawList(); - void recalculateHorizontalBar (int, bool); - void recalculateVerticalBar (int); - void processClick(); - void processSelect(); - void processChanged(); - listBoxItems::iterator index2iterator (int); + // Methods + void init(); + void draw(); + void drawLabel(); + void drawList(); + void recalculateHorizontalBar (int, bool); + void recalculateVerticalBar (int); + void processClick(); + void processSelect(); + void processChanged(); + listBoxItems::iterator index2iterator (int); - // Callback methods - void cb_VBarChange (FWidget*, data_ptr); - void cb_HBarChange (FWidget*, data_ptr); + // Callback methods + void cb_VBarChange (FWidget*, data_ptr); + void cb_HBarChange (FWidget*, data_ptr); - // Function Pointer - void (*convertToItem) ( FListBoxItem& - , FWidget::data_ptr - , int index ); + // Function Pointer + void (*convertToItem) ( FListBoxItem& + , FWidget::data_ptr + , int index ); - // Data Members - listBoxItems data; - FWidget::data_ptr source_container; - convert_type conv_type; - FScrollbar* vbar; - FScrollbar* hbar; - FString text; - FString inc_search; - bool multi_select; - bool mouse_select; - fc::dragScroll drag_scroll; - bool scroll_timer; - int scroll_repeat; - int scroll_distance; - int current; - int last_current; - int secect_from_item; - int xoffset; - int yoffset; - int last_yoffset; - int nf_offset; - int max_line_width; + // Data Members + listBoxItems data; + FWidget::data_ptr source_container; + convert_type conv_type; + FScrollbar* vbar; + FScrollbar* hbar; + FString text; + FString inc_search; + bool multi_select; + bool mouse_select; + fc::dragScroll drag_scroll; + bool scroll_timer; + int scroll_repeat; + int scroll_distance; + int current; + int last_current; + int secect_from_item; + int xoffset; + int yoffset; + int last_yoffset; + int nf_offset; + int max_line_width; }; #pragma pack(pop) diff --git a/src/flistview.cpp b/src/flistview.cpp index 2219d08c..cdc4e438 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -2,6 +2,8 @@ // Provides: class FListViewItem // class FListView +#include + #include "fapplication.h" #include "flistview.h" #include "fscrollbar.h" @@ -109,7 +111,7 @@ FListViewItem::FListViewItem ( const std::vector& cols } //---------------------------------------------------------------------- -FListViewItem::~FListViewItem() +FListViewItem::~FListViewItem() // destructor { } @@ -1074,7 +1076,7 @@ void FListView::draw() for (int y = 2; y < getHeight(); y++) { - setPrintPos (getWidth(),y); + setPrintPos (getWidth(), y); print (' '); // clear right side of the scrollbar } } @@ -1233,7 +1235,7 @@ void FListView::drawList() { setColor ( wc.current_element_focus_fg , wc.current_element_focus_bg ); - setCursorPos (3, 2 + int(y)); // first character + setCursorPos (3, 2 + int(y)); // first character } else setColor ( wc.current_element_fg diff --git a/src/flistview.h b/src/flistview.h index 1607a877..3b0016ce 100644 --- a/src/flistview.h +++ b/src/flistview.h @@ -30,6 +30,8 @@ #ifndef FLISTVIEW_H #define FLISTVIEW_H +#include + #include "fscrollbar.h" #include "fstring.h" #include "ftermbuffer.h" @@ -47,55 +49,56 @@ class FListView; class FListViewItem : public FObject { - public: - FListViewItem (const FListViewItem&); // copy constructor - FListViewItem (FListViewItem*); - FListViewItem (FListView*); - FListViewItem ( const std::vector& - , FWidget::data_ptr = 0 - , FListView* = 0 ); - FListViewItem ( const std::vector& - , FWidget::data_ptr = 0 - , FListViewItem* = 0 ); + public: + // Constructor + FListViewItem (const FListViewItem&); // copy constructor + explicit FListViewItem (FListViewItem*); + explicit FListViewItem (FListView*); + FListViewItem ( const std::vector& + , FWidget::data_ptr = 0 + , FListView* = 0 ); + FListViewItem ( const std::vector& + , FWidget::data_ptr = 0 + , FListViewItem* = 0 ); - // Destructor - ~FListViewItem(); + // Destructor + ~FListViewItem(); - // Assignment operator (=) - FListViewItem& operator = (const FListViewItem&); + // Assignment operator (=) + FListViewItem& operator = (const FListViewItem&); - // Accessors - const char* getClassName() const; - uInt getColumnCount() const; - FString getText (int) const; + // Accessors + const char* getClassName() const; + uInt getColumnCount() const; + FString getText (int) const; - // Mutator - void setText (int, const FString&); + // Mutator + void setText (int, const FString&); - // Inquiry - bool isExpand(); + // Inquiry + bool isExpand(); - // Methods - void insert (FListViewItem*); - void expand(); - void collapse(); + // Methods + void insert (FListViewItem*); + void expand(); + void collapse(); - private: - // Inquiry - bool isExpandable(); + private: + // Inquiry + bool isExpandable(); - // Methods - int getVisibleLines(); + // Methods + int getVisibleLines(); - // Data Member - std::vector column_value; - FWidget::data_ptr data_pointer; - int visible_lines; - bool expandable; - bool is_expand; + // Data Member + std::vector column_value; + FWidget::data_ptr data_pointer; + int visible_lines; + bool expandable; + bool is_expand; - // Friend class - friend class FListView; + // Friend class + friend class FListView; }; #pragma pack(pop) @@ -127,126 +130,126 @@ inline bool FListViewItem::isExpandable() class FListView : public FWidget { - public: - // Typedef - typedef std::vector listViewItems; + public: + // Typedef + typedef std::vector listViewItems; - // Using-declaration - using FWidget::setGeometry; + // Using-declaration + using FWidget::setGeometry; - // Constructor - explicit FListView (FWidget* = 0); + // Constructor + explicit FListView (FWidget* = 0); - // Destructor - ~FListView(); + // Destructor + ~FListView(); - // Accessors - const char* getClassName() const; - fc::text_alignment getColumnAlignment (int) const; - FString getColumnText (int) const; - FListViewItem* getCurrentItem() const; + // Accessors + const char* getClassName() const; + fc::text_alignment getColumnAlignment (int) const; + FString getColumnText (int) const; + FListViewItem* getCurrentItem() const; - // Mutators - void setGeometry (int, int, int, int, bool = true); - void setColumnAlignment (int, fc::text_alignment); - void setColumnText (int, const FString&); - bool setTreeView (bool); - bool setTreeView(); - bool unsetTreeView(); + // Mutators + void setGeometry (int, int, int, int, bool = true); + void setColumnAlignment (int, fc::text_alignment); + void setColumnText (int, const FString&); + bool setTreeView (bool); + bool setTreeView(); + bool unsetTreeView(); - // Methods - virtual int addColumn (const FString&, int = USE_MAX_SIZE); - void insert (FListViewItem*); - void insert ( const std::vector& - , data_ptr = 0 - , FListView* = 0 ); - void insert ( const std::vector& - , data_ptr = 0 - , FListView* = 0 ); + // Methods + virtual int addColumn (const FString&, int = USE_MAX_SIZE); + void insert (FListViewItem*); + void insert ( const std::vector& + , data_ptr = 0 + , FListView* = 0 ); + void insert ( const std::vector& + , data_ptr = 0 + , FListView* = 0 ); - // Event handlers - void onKeyPress (FKeyEvent*); - void onMouseDown (FMouseEvent*); - void onMouseUp (FMouseEvent*); - void onMouseMove (FMouseEvent*); - void onMouseDoubleClick (FMouseEvent*); - void onWheel (FWheelEvent*); - void onTimer (FTimerEvent*); - void onFocusIn (FFocusEvent*); - void onFocusOut (FFocusEvent*); + // Event handlers + void onKeyPress (FKeyEvent*); + void onMouseDown (FMouseEvent*); + void onMouseUp (FMouseEvent*); + void onMouseMove (FMouseEvent*); + void onMouseDoubleClick (FMouseEvent*); + void onWheel (FWheelEvent*); + void onTimer (FTimerEvent*); + void onFocusIn (FFocusEvent*); + void onFocusOut (FFocusEvent*); - protected: - // Methods - void adjustYOffset(); - void adjustSize(); + protected: + // Methods + void adjustYOffset(); + void adjustSize(); - private: - // Typedef - struct Header - { - public: - Header() - : name() - , width (0) - , fixed_width (false) - , alignment (fc::alignLeft) - { } + private: + // Typedef + struct Header + { + public: + Header() + : name() + , width (0) + , fixed_width (false) + , alignment (fc::alignLeft) + { } - ~Header() - { } + ~Header() + { } - FString name; - int width; - bool fixed_width; - fc::text_alignment alignment; - }; + FString name; + int width; + bool fixed_width; + fc::text_alignment alignment; + }; - typedef std::vector
headerItems; + typedef std::vector
headerItems; - // Constants - static const int USE_MAX_SIZE = -1; + // Constants + static const int USE_MAX_SIZE = -1; - // Disable copy constructor - FListView (const FListView&); + // Disable copy constructor + FListView (const FListView&); - // Disable assignment operator (=) - FListView& operator = (const FListView&); + // Disable assignment operator (=) + FListView& operator = (const FListView&); - // Methods - void init(); - uInt getAlignOffset (fc::text_alignment, uInt, uInt); - void draw(); - void drawColumnLabels(); - void drawList(); - void recalculateHorizontalBar (int); - void recalculateVerticalBar (int); - void processClick(); - void processChanged(); - listViewItems::iterator index2iterator (int); + // Methods + void init(); + uInt getAlignOffset (fc::text_alignment, uInt, uInt); + void draw(); + void drawColumnLabels(); + void drawList(); + void recalculateHorizontalBar (int); + void recalculateVerticalBar (int); + void processClick(); + void processChanged(); + listViewItems::iterator index2iterator (int); - // Callback methods - void cb_VBarChange (FWidget*, data_ptr); - void cb_HBarChange (FWidget*, data_ptr); + // Callback methods + void cb_VBarChange (FWidget*, data_ptr); + void cb_HBarChange (FWidget*, data_ptr); - // Data Members - listViewItems data; - headerItems header; - FTermBuffer headerline; - FScrollbar* vbar; - FScrollbar* hbar; - fc::dragScroll drag_scroll; - int scroll_repeat; - int scroll_distance; - bool scroll_timer; - bool tree_view; - int current; - int xoffset; - int yoffset; - int nf_offset; - int max_line_width; + // Data Members + listViewItems data; + headerItems header; + FTermBuffer headerline; + FScrollbar* vbar; + FScrollbar* hbar; + fc::dragScroll drag_scroll; + int scroll_repeat; + int scroll_distance; + bool scroll_timer; + bool tree_view; + int current; + int xoffset; + int yoffset; + int nf_offset; + int max_line_width; - // Friend class - friend class FListViewItem; + // Friend class + friend class FListViewItem; }; #pragma pack(pop) diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 92e807d7..11d8763b 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -1,6 +1,8 @@ // File: fmenu.cpp // Provides: class FMenu +#include + #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(getRootWidget()); @@ -299,7 +301,7 @@ void FMenu::onMouseDown (FMouseEvent* ev) iter = item_list.begin(); end = item_list.end(); mouse_pos = ev->getPos(); - mouse_pos -= FPoint(getRightPadding(),getTopPadding()); + mouse_pos -= FPoint(getRightPadding(), getTopPadding()); while ( iter != end ) { @@ -404,7 +406,7 @@ void FMenu::onMouseUp (FMouseEvent* ev) iter = item_list.begin(); end = item_list.end(); mouse_pos = ev->getPos(); - mouse_pos -= FPoint(getRightPadding(),getTopPadding()); + mouse_pos -= FPoint(getRightPadding(), getTopPadding()); while ( iter != end ) { @@ -492,7 +494,7 @@ void FMenu::onMouseMove (FMouseEvent* ev) iter = item_list.begin(); end = item_list.end(); mouse_pos = ev->getPos(); - mouse_pos -= FPoint(getRightPadding(),getTopPadding()); + mouse_pos -= FPoint(getRightPadding(), getTopPadding()); if ( getTermGeometry().contains(ev->getTermPos()) ) mouse_over_menu = true; @@ -794,14 +796,14 @@ void FMenu::init(FWidget* parent) { if ( isMenuBar(parent) ) { - FMenuBar* mbar = dynamic_cast(parent); + FMenuBar* mbar = static_cast(parent); if ( mbar ) mbar->calculateDimensions(); } else if ( isMenu(parent) ) { - FMenu* smenu = dynamic_cast(parent); + FMenu* smenu = static_cast(parent); if ( smenu ) smenu->calculateDimensions(); @@ -820,7 +822,7 @@ void FMenu::calculateDimensions() std::vector::const_iterator iter, end; iter = item_list.begin(); end = item_list.end(); - max_item_width = 10; // minimum width + max_item_width = 10; // minimum width // find the maximum item width while ( iter != end ) @@ -994,11 +996,11 @@ bool FMenu::containsMenuStructure (int x, int y) // Check mouse click position for item, menu and all sub menus FMenuItem* si = getSelectedItem(); - if ( getTermGeometry().contains(x,y) ) + if ( getTermGeometry().contains(x, y) ) return true; else if ( si && si->hasMenu() && open_sub_menu ) - return si->getMenu()->containsMenuStructure(x,y); - else if ( item && item->getTermGeometry().contains(x,y) ) + return si->getMenu()->containsMenuStructure(x, y); + else if ( item && item->getTermGeometry().contains(x, y) ) return true; else return false; @@ -1008,21 +1010,21 @@ bool FMenu::containsMenuStructure (int x, int y) FMenu* FMenu::superMenuAt (int x, int y) { // Check mouse click position for super menu - if ( getTermGeometry().contains(x,y) ) + if ( getTermGeometry().contains(x, y) ) return 0; FWidget* super = getSuperMenu(); if ( super && isMenu(super) ) { - if ( super->getTermGeometry().contains(x,y) ) - return dynamic_cast(super); + if ( super->getTermGeometry().contains(x, y) ) + return static_cast(super); else { - FMenu* smenu = dynamic_cast(getSuperMenu()); + FMenu* smenu = static_cast(getSuperMenu()); if ( smenu ) - return smenu->superMenuAt(x,y); + return smenu->superMenuAt(x, y); } } @@ -1312,16 +1314,16 @@ void FMenu::drawItems() if ( is_radio_btn ) { if ( isNewFont() ) - print (fc::NF_Bullet); // NF_Bullet ● + print (fc::NF_Bullet); // NF_Bullet ● else - print (fc::Bullet); // Bullet ● + print (fc::Bullet); // Bullet ● } else { if ( isNewFont() ) - print (fc::NF_check_mark); // NF_check_mark ✓ + print (fc::NF_check_mark); // NF_check_mark ✓ else - print (fc::SquareRoot); // SquareRoot √ + print (fc::SquareRoot); // SquareRoot √ } } else diff --git a/src/fmenu.h b/src/fmenu.h index 65a8985d..5b357296 100644 --- a/src/fmenu.h +++ b/src/fmenu.h @@ -50,110 +50,110 @@ class FMenu : public FWindow, public FMenuList { - public: - // Constructor - explicit FMenu (FWidget* = 0); - FMenu (const FString&, FWidget* = 0); + public: + // Constructor + explicit FMenu (FWidget* = 0); + FMenu (const FString&, FWidget* = 0); - // Destructor - virtual ~FMenu(); + // Destructor + virtual ~FMenu(); - // Accessors - virtual const char* getClassName() const; - FString getText() const; - FMenuItem* getItem() const; + // Accessors + virtual const char* getClassName() const; + FString getText() const; + FMenuItem* getItem() const; - // Mutators - bool setEnable(bool); - bool setEnable(); - bool unsetEnable(); - bool setDisable(); - void setSelected(); - void unsetSelected(); - bool setMenuWidget (bool); - bool setMenuWidget(); - bool unsetMenuWidget(); - void setStatusbarMessage (const FString&); - void setMenu (FMenu*); - void setText (const FString&); + // Mutators + bool setEnable(bool); + bool setEnable(); + bool unsetEnable(); + bool setDisable(); + void setSelected(); + void unsetSelected(); + bool setMenuWidget (bool); + bool setMenuWidget(); + bool unsetMenuWidget(); + void setStatusbarMessage (const FString&); + void setMenu (FMenu*); + void setText (const FString&); - // Inquiries - bool isEnabled() const; - bool isSelected() const; - bool hasHotkey() const; - bool hasMenu() const; + // Inquiries + bool isEnabled() const; + bool isSelected() const; + bool hasHotkey() const; + bool hasMenu() const; - // Methods - void show(); - void hide(); + // Methods + void show(); + void hide(); - // Event handlers - void onKeyPress (FKeyEvent*); - void onMouseDown (FMouseEvent*); - void onMouseUp (FMouseEvent*); - void onMouseMove (FMouseEvent*); - void onAccel (FAccelEvent*); + // Event handlers + void onKeyPress (FKeyEvent*); + void onMouseDown (FMouseEvent*); + void onMouseUp (FMouseEvent*); + void onMouseMove (FMouseEvent*); + void onAccel (FAccelEvent*); - // Callback method - void cb_menuitem_toggled (FWidget*, data_ptr); + // Callback method + void cb_menuitem_toggled (FWidget*, data_ptr); - private: - // Disable copy constructor - FMenu (const FMenu&); + private: + // Disable copy constructor + FMenu (const FMenu&); - // Disable assignment operator (=) - FMenu& operator = (const FMenu&); + // Disable assignment operator (=) + FMenu& operator = (const FMenu&); - // Accessors - FWidget* getSuperMenu() const; + // Accessors + FWidget* getSuperMenu() const; - // Mutators - void setSuperMenu (FWidget*); + // Mutators + void setSuperMenu (FWidget*); - // Inquiries - bool isWindowsMenu (FWidget*) const; - bool isMenuBar (FWidget*) const; - bool isMenu (FWidget*) const; - bool isRadioMenuItem (FWidget*) const; - bool isSubMenu() const; + // Inquiries + bool isWindowsMenu (FWidget*) const; + bool isMenuBar (FWidget*) const; + bool isMenu (FWidget*) const; + bool isRadioMenuItem (FWidget*) const; + bool isSubMenu() const; - // Methods - void init(FWidget*); - void calculateDimensions(); - void adjustItems(); - int adjustX(int); - void openSubMenu (FMenu*); - void hideSubMenus(); - void hideSuperMenus(); - bool containsMenuStructure (const FPoint&); - bool containsMenuStructure (int, int); - FMenu* superMenuAt (const FPoint&); - FMenu* superMenuAt (int, int); - bool selectNextItem(); - bool selectPrevItem(); - void keypressMenuBar (FKeyEvent*&); - bool hotkeyMenu (FKeyEvent*&); - int getHotkeyPos (wchar_t*&, wchar_t*&, uInt); - void draw(); - void drawItems(); - void drawSeparator(int); - void processActivate(); + // Methods + void init(FWidget*); + void calculateDimensions(); + void adjustItems(); + int adjustX(int); + void openSubMenu (FMenu*); + void hideSubMenus(); + void hideSuperMenus(); + bool containsMenuStructure (const FPoint&); + bool containsMenuStructure (int, int); + FMenu* superMenuAt (const FPoint&); + FMenu* superMenuAt (int, int); + bool selectNextItem(); + bool selectPrevItem(); + void keypressMenuBar (FKeyEvent*&); + bool hotkeyMenu (FKeyEvent*&); + int getHotkeyPos (wchar_t*&, wchar_t*&, uInt); + void draw(); + void drawItems(); + void drawSeparator(int); + void processActivate(); - // Friend classes - friend class FApplication; - friend class FCheckMenuItem; - friend class FDialog; - friend class FMenuBar; - friend class FMenuItem; - friend class FRadioMenuItem; + // Friend classes + friend class FApplication; + friend class FCheckMenuItem; + friend class FDialog; + friend class FMenuBar; + friend class FMenuItem; + friend class FRadioMenuItem; - // Data Members - FMenuItem* item; - FWidget* super_menu; - FMenu* open_sub_menu; - uInt max_item_width; - bool mouse_down; - bool has_checkable_items; + // Data Members + FMenuItem* item; + FWidget* super_menu; + FMenu* open_sub_menu; + uInt max_item_width; + bool mouse_down; + bool has_checkable_items; }; #pragma pack(pop) diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index 29d33884..d0ed36ce 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -1,6 +1,8 @@ // File: fmenubar.cpp // Provides: class FMenuBar +#include + #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; } } } diff --git a/src/fmenubar.h b/src/fmenubar.h index 27d1950b..32363e5e 100644 --- a/src/fmenubar.h +++ b/src/fmenubar.h @@ -49,60 +49,60 @@ class FMenuBar : public FWindow, public FMenuList { - public: - // Constructor - explicit FMenuBar (FWidget* = 0); + public: + // Constructor + explicit FMenuBar (FWidget* = 0); - // Destructor - virtual ~FMenuBar(); + // Destructor + virtual ~FMenuBar(); - // Accessors - virtual const char* getClassName() const; + // Accessors + virtual const char* getClassName() const; - // Methods - void hide(); - void resetMenu(); - void adjustSize(); + // Methods + void hide(); + void resetMenu(); + void adjustSize(); - // Event handlers - void onKeyPress (FKeyEvent*); - void onMouseDown (FMouseEvent*); - void onMouseUp (FMouseEvent*); - void onMouseMove (FMouseEvent*); - void onAccel (FAccelEvent*); + // Event handlers + void onKeyPress (FKeyEvent*); + void onMouseDown (FMouseEvent*); + void onMouseUp (FMouseEvent*); + void onMouseMove (FMouseEvent*); + void onAccel (FAccelEvent*); - // Callback methods - void cb_item_deactivated (FWidget*, data_ptr); + // Callback methods + void cb_item_deactivated (FWidget*, data_ptr); - private: - // Disable copy constructor - FMenuBar (const FMenuBar&); + private: + // Disable copy constructor + FMenuBar (const FMenuBar&); - // Disable assignment operator (=) - FMenuBar& operator = (const FMenuBar&); + // Disable assignment operator (=) + FMenuBar& operator = (const FMenuBar&); - // Inquiry - bool isMenu (FMenuItem*) const; + // Inquiry + bool isMenu (FMenuItem*) const; - // Methods - void init(); - void calculateDimensions(); - bool selectNextItem(); - bool selectPrevItem(); - bool hotkeyMenu (FKeyEvent*&); - int getHotkeyPos (wchar_t*&, wchar_t*&, uInt); - void draw(); - void drawItems(); - void adjustItems(); - void leaveMenuBar(); + // Methods + void init(); + void calculateDimensions(); + bool selectNextItem(); + bool selectPrevItem(); + bool hotkeyMenu (FKeyEvent*&); + int getHotkeyPos (wchar_t*&, wchar_t*&, uInt); + void draw(); + void drawItems(); + void adjustItems(); + void leaveMenuBar(); - // Friend classes - friend class FMenu; - friend class FMenuItem; + // Friend classes + friend class FMenu; + friend class FMenuItem; - // Data Members - bool mouse_down; - bool drop_down; + // Data Members + bool mouse_down; + bool drop_down; }; #pragma pack(pop) diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index 0e5c9fbf..f72bb8b9 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -136,14 +136,14 @@ bool FMenuItem::setFocus (bool on) if ( isMenuBar(parent) ) { - FMenuBar* menubar_ptr = dynamic_cast(parent); + FMenuBar* menubar_ptr = static_cast(parent); if ( menubar_ptr ) menubar_ptr->redraw(); } else if ( isMenu(parent) ) { - FMenu* menu_ptr = dynamic_cast(parent); + FMenu* menu_ptr = static_cast(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(super_menu); + FMenu* menu_ptr = static_cast(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(super_menu); + FMenu* menu_ptr = static_cast(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(super_menu); + FMenu* smenu = static_cast(super_menu); if ( smenu ) smenu->onKeyPress(ev); @@ -305,7 +305,7 @@ void FMenuItem::onKeyPress (FKeyEvent* ev) if ( isMenuBar(super_menu) ) { - FMenuBar* mbar = dynamic_cast(super_menu); + FMenuBar* mbar = static_cast(super_menu); if ( mbar ) { @@ -328,7 +328,7 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev) if ( isMenu(super_menu) ) { - FMenu* smenu = dynamic_cast(super_menu); + FMenu* smenu = static_cast(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(super_menu); + FMenuBar* mbar = static_cast(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(super_menu); + FDialog* dgl = static_cast(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(super_menu); + FMenu* smenu = static_cast(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(super_menu); + FMenuBar* mbar = static_cast(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(super_menu); + FDialog* dgl = static_cast(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(super_menu); + FMenu* smenu = static_cast(super_menu); if ( smenu ) { @@ -487,7 +499,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev) if ( isMenuBar(super_menu) ) { - FMenuBar* mbar = dynamic_cast(super_menu); + FMenuBar* mbar = static_cast(super_menu); if ( mbar ) { @@ -500,7 +512,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev) if ( isWindowsMenu(super_menu) ) { - FDialog* dgl = dynamic_cast(super_menu); + FDialog* dgl = static_cast(super_menu); if ( dgl ) { @@ -523,7 +535,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev) if ( isMenu(super_menu) ) { - FMenu* smenu = dynamic_cast(super_menu); + FMenu* smenu = static_cast(super_menu); if ( smenu ) { @@ -536,7 +548,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev) if ( isMenuBar(super_menu) ) { - FMenuBar* mbar = dynamic_cast(super_menu); + FMenuBar* mbar = static_cast(super_menu); if ( mbar ) { @@ -549,7 +561,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev) if ( isWindowsMenu(super_menu) ) { - FDialog* dgl = dynamic_cast(super_menu); + FDialog* dgl = static_cast(super_menu); if ( dgl ) { @@ -573,7 +585,7 @@ void FMenuItem::onAccel (FAccelEvent* ev) return; } - FMenuBar* mbar = dynamic_cast(super_menu); + FMenuBar* mbar = static_cast(super_menu); if ( ! mbar ) return; @@ -639,7 +651,7 @@ void FMenuItem::onFocusOut (FFocusEvent*) if ( super_menu && isMenuBar(super_menu) ) { - FMenuBar* mbar = dynamic_cast(super_menu); + FMenuBar* mbar = static_cast(super_menu); if ( mbar ) mbar->redraw(); @@ -703,16 +715,17 @@ void FMenuItem::init (FWidget* parent) if ( menu_list ) menu_list->insert(this); - if ( isMenuBar(parent) ) // Parent is menubar + if ( isMenuBar(parent) ) // Parent is menubar { - FMenuBar* menubar_ptr = dynamic_cast(parent); + FMenuBar* menubar_ptr = static_cast(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 @@ -721,9 +734,9 @@ void FMenuItem::init (FWidget* parent) F_METHOD_CALLBACK (parent, &FMenuBar::cb_item_deactivated) ); } - else if ( isMenu(parent) ) // Parent is menu + else if ( isMenu(parent) ) // Parent is menu { - FMenu* menu_ptr = dynamic_cast(parent); + FMenu* menu_ptr = static_cast(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(*iter); + FDialog* win = static_cast(*iter); if ( win ) { @@ -797,18 +810,19 @@ 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; } if ( n < 9 ) - win_item->addAccelerator (fc::Fmkey_1 + n); // Meta + 1..9 + win_item->addAccelerator (fc::Fmkey_1 + n); // Meta + 1..9 win_item->addCallback ( "clicked", F_METHOD_CALLBACK (win_item, &FMenuItem::cb_switchToDialog), - dynamic_cast(win) + static_cast(win) ); win->addCallback diff --git a/src/fmenuitem.h b/src/fmenuitem.h index 8bda3146..4a2bd224 100644 --- a/src/fmenuitem.h +++ b/src/fmenuitem.h @@ -48,115 +48,115 @@ class FMenuList; class FMenuItem : public FWidget { - public: - // Using-declarations - using FWidget::addAccelerator; - using FWidget::delAccelerator; - using FWidget::setEnable; + public: + // Using-declarations + using FWidget::addAccelerator; + using FWidget::delAccelerator; + using FWidget::setEnable; - // Constructor - explicit FMenuItem (FWidget* = 0); - FMenuItem (const FString&, FWidget* = 0); - FMenuItem (int, const FString&, FWidget* = 0); + // Constructor + explicit FMenuItem (FWidget* = 0); + FMenuItem (const FString&, FWidget* = 0); + FMenuItem (int, const FString&, FWidget* = 0); - // Destructor - virtual ~FMenuItem(); + // Destructor + virtual ~FMenuItem(); - // Accessors - const char* getClassName() const; - int getHotkey() const; - FMenu* getMenu() const; - uInt getTextLength() const; - FString getText() const; + // Accessors + const char* getClassName() const; + int getHotkey() const; + FMenu* getMenu() const; + uInt getTextLength() const; + FString getText() const; - // Mutators - bool setEnable (bool); - bool setFocus (bool); - bool setFocus(); - bool unsetFocus(); - void setSelected(); - void unsetSelected(); - void setSeparator(); - void unsetSeparator(); - void setChecked(); - void unsetChecked(); - void setMenu (FMenu*); - void setText (const FString&); + // Mutators + bool setEnable (bool); + bool setFocus (bool); + bool setFocus(); + bool unsetFocus(); + void setSelected(); + void unsetSelected(); + void setSeparator(); + void unsetSeparator(); + void setChecked(); + void unsetChecked(); + void setMenu (FMenu*); + void setText (const FString&); - // Inquiries - bool isSelected() const; - bool isSeparator() const; - bool isChecked() const; - bool hasHotkey() const; - bool hasMenu() const; + // Inquiries + bool isSelected() const; + bool isSeparator() const; + bool isChecked() const; + bool hasHotkey() const; + bool hasMenu() const; - // Methods - void addAccelerator (int, FWidget*); - void delAccelerator (FWidget*); - void openMenu(); + // Methods + void addAccelerator (int, FWidget*); + void delAccelerator (FWidget*); + void openMenu(); - // Event handlers - void onKeyPress (FKeyEvent*); - void onMouseDoubleClick (FMouseEvent*); - void onMouseDown (FMouseEvent*); - void onMouseUp (FMouseEvent*); - void onMouseMove (FMouseEvent*); - void onAccel (FAccelEvent*); - void onFocusIn (FFocusEvent*); - void onFocusOut (FFocusEvent*); + // Event handlers + void onKeyPress (FKeyEvent*); + void onMouseDoubleClick (FMouseEvent*); + void onMouseDown (FMouseEvent*); + void onMouseUp (FMouseEvent*); + void onMouseMove (FMouseEvent*); + void onAccel (FAccelEvent*); + void onFocusIn (FFocusEvent*); + void onFocusOut (FFocusEvent*); - protected: - // Accessor - FWidget* getSuperMenu() const; + protected: + // Accessor + FWidget* getSuperMenu() const; - // Mutator - void setSuperMenu (FWidget*); + // Mutator + void setSuperMenu (FWidget*); - // Inquiries - bool isWindowsMenu (FWidget*) const; - bool isMenuBar (FWidget*) const; - bool isMenu (FWidget*) const; + // Inquiries + bool isWindowsMenu (FWidget*) const; + bool isMenuBar (FWidget*) const; + bool isMenu (FWidget*) const; - // Data Members - FString text; - bool selected; - bool separator; - bool checkable; - bool checked; - bool radio_button; - bool dialog_index; - uInt text_length; - int hotkey; - int accel_key; - FMenu* menu; - FWidget* super_menu; - FDialog* associated_window; + // Data Members + FString text; + bool selected; + bool separator; + bool checkable; + bool checked; + bool radio_button; + bool dialog_index; + uInt text_length; + int hotkey; + int accel_key; + FMenu* menu; + FWidget* super_menu; + FDialog* associated_window; - private: - // Disable copy constructor - FMenuItem (const FMenuItem&); + private: + // Disable copy constructor + FMenuItem (const FMenuItem&); - // Disable assignment operator (=) - FMenuItem& operator = (const FMenuItem&); + // Disable assignment operator (=) + FMenuItem& operator = (const FMenuItem&); - // Methods - void init (FWidget*); - uChar hotKey(); - void processActivate(); - void processDeactivate(); - void createDialogList (FMenu*); + // Methods + void init (FWidget*); + uChar hotKey(); + void processActivate(); + void processDeactivate(); + void createDialogList (FMenu*); - // Callback methods - void cb_switchToDialog (FWidget*, data_ptr); - void cb_destroyDialog (FWidget*, data_ptr); + // Callback methods + void cb_switchToDialog (FWidget*, data_ptr); + void cb_destroyDialog (FWidget*, data_ptr); - virtual void processClicked(); + virtual void processClicked(); - // Friend classes - friend class FDialogListMenu; - friend class FMenuList; - friend class FMenuBar; - friend class FMenu; + // Friend classes + friend class FDialogListMenu; + friend class FMenuList; + friend class FMenuBar; + friend class FMenu; }; #pragma pack(pop) diff --git a/src/fmenulist.cpp b/src/fmenulist.cpp index 4716e852..66fb60f9 100644 --- a/src/fmenulist.cpp +++ b/src/fmenulist.cpp @@ -1,6 +1,8 @@ // File: fmenulist.cpp // Provides: class FMenuList +#include + #include "fmenulist.h" //---------------------------------------------------------------------- diff --git a/src/fmenulist.h b/src/fmenulist.h index 46519501..89ba2eeb 100644 --- a/src/fmenulist.h +++ b/src/fmenulist.h @@ -19,6 +19,8 @@ #ifndef FMENULIST_H #define FMENULIST_H +#include + #include "fmenuitem.h" #include "fwidget.h" @@ -32,46 +34,46 @@ class FMenuList { - public: - // Constructor - explicit FMenuList(); + public: + // Constructor + explicit FMenuList(); - // Destructor - virtual ~FMenuList(); + // Destructor + virtual ~FMenuList(); - // Accessors - virtual const char* getClassName() const; - uInt getCount() const; - FMenuItem* getItem (int) const; - FMenuItem* getSelectedItem() const; + // Accessors + virtual const char* getClassName() const; + uInt getCount() const; + FMenuItem* getItem (int) const; + FMenuItem* getSelectedItem() const; - // Mutators - void enableItem (int); - void disableItem (int); - void setSelectedItem (FMenuItem*); + // Mutators + void enableItem (int); + void disableItem (int); + void setSelectedItem (FMenuItem*); - // Inquiries - bool isSelected (int) const; - bool hasSelectedItem() const; + // Inquiries + bool isSelected (int) const; + bool hasSelectedItem() const; - // Methods - virtual void insert (FMenuItem*); - virtual void remove (FMenuItem*); - void remove (int); - void clear(); - void selectFirstItem(); - void unselectItem(); + // Methods + virtual void insert (FMenuItem*); + virtual void remove (FMenuItem*); + void remove (int); + void clear(); + void selectFirstItem(); + void unselectItem(); - protected: - FMenuItem* selected_item; - std::vector item_list; + protected: + FMenuItem* selected_item; + std::vector item_list; - private: - // Disable copy constructor - FMenuList (const FMenuList&); + private: + // Disable copy constructor + FMenuList (const FMenuList&); - // Disable assignment operator (=) - FMenuList& operator = (const FMenuList&); + // Disable assignment operator (=) + FMenuList& operator = (const FMenuList&); }; #pragma pack(pop) diff --git a/src/fmessagebox.cpp b/src/fmessagebox.cpp index bc807e29..f80db00b 100644 --- a/src/fmessagebox.cpp +++ b/src/fmessagebox.cpp @@ -1,6 +1,8 @@ // File: fmessagebox.cpp // Provides: class FMessageBox +#include + #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); diff --git a/src/fmessagebox.h b/src/fmessagebox.h index 62f84032..b12100dd 100644 --- a/src/fmessagebox.h +++ b/src/fmessagebox.h @@ -54,96 +54,96 @@ class FMessageBox : public FDialog { - public: - // Enumeration - enum - { - Reject = 0, - Ok = 1, - Cancel = 2, - Yes = 3, - No = 4, - Abort = 5, - Retry = 6, - Ignore = 7 - }; + public: + // Enumeration + enum + { + Reject = 0, + Ok = 1, + Cancel = 2, + Yes = 3, + No = 4, + Abort = 5, + Retry = 6, + Ignore = 7 + }; - // Constructors - explicit FMessageBox (FWidget* = 0); - FMessageBox (const FMessageBox&); // copy constructor - FMessageBox ( const FString&, const FString& - , int, int, int - , FWidget* = 0 ); - // Destructor - ~FMessageBox(); + // Constructors + explicit FMessageBox (FWidget* = 0); + FMessageBox (const FMessageBox&); // copy constructor + FMessageBox ( const FString&, const FString& + , int, int, int + , FWidget* = 0 ); + // Destructor + ~FMessageBox(); - // Assignment operator (=) - FMessageBox& operator = (const FMessageBox&); + // Assignment operator (=) + FMessageBox& operator = (const FMessageBox&); - // Accessor - const char* getClassName() const; - const FString getTitlebarText() const; - const FString getHeadline() const; - const FString getText() const; + // Accessor + const char* getClassName() const; + const FString getTitlebarText() const; + const FString getHeadline() const; + const FString getText() const; - // Mutator - void setTitlebarText (const FString&); - void setHeadline (const FString&); - bool setCenterText(bool); - bool setCenterText(); - bool unsetCenterText(); - void setText (const FString&); + // Mutator + void setTitlebarText (const FString&); + void setHeadline (const FString&); + bool setCenterText(bool); + bool setCenterText(); + bool unsetCenterText(); + void setText (const FString&); - // Methods - static int info ( FWidget* - , const FString& - , const FString& - , int = FMessageBox::Ok - , int = 0 - , int = 0 ); - - static int info ( FWidget* - , const FString& - , int - , int = FMessageBox::Ok - , int = 0 - , int = 0 ); - - static int error ( FWidget* + // Methods + static int info ( FWidget* + , const FString& , const FString& , int = FMessageBox::Ok , int = 0 , int = 0 ); - protected: - // Method - void adjustSize(); - // Callback method - void cb_processClick (FWidget*, data_ptr); + static int info ( FWidget* + , const FString& + , int + , int = FMessageBox::Ok + , int = 0 + , int = 0 ); - private: - // Typedef - typedef std::vector textLines; + static int error ( FWidget* + , const FString& + , int = FMessageBox::Ok + , int = 0 + , int = 0 ); + protected: + // Method + void adjustSize(); - // Methods - void init (int, int, int); - void calculateDimensions(); - virtual void draw(); - void resizeButtons(); - void adjustButtons(); + // Callback method + void cb_processClick (FWidget*, data_ptr); - // Data Members - FString headline_text; - FString text; - FString* text_components; - textLines text_split; - uInt max_line_width; - bool center_text; - short emphasis_color; - uInt num_buttons; - uInt text_num_lines; - int button_digit[3]; - FButton* button[3]; + private: + // Typedef + typedef std::vector textLines; + + // Methods + void init (int, int, int); + void calculateDimensions(); + virtual void draw(); + void resizeButtons(); + void adjustButtons(); + + // Data Members + FString headline_text; + FString text; + FString* text_components; + textLines text_split; + uInt max_line_width; + bool center_text; + short emphasis_color; + uInt num_buttons; + uInt text_num_lines; + int button_digit[3]; + FButton* button[3]; }; #pragma pack(pop) diff --git a/src/fobject.cpp b/src/fobject.cpp index 473f266e..5ec7fc29 100644 --- a/src/fobject.cpp +++ b/src/fobject.cpp @@ -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 (¤tTime); timeval timeout = currentTime + time_interval; timer_data t = { id, time_interval, timeout, this }; diff --git a/src/fobject.h b/src/fobject.h index 68616745..b2a5e9b6 100644 --- a/src/fobject.h +++ b/src/fobject.h @@ -12,7 +12,7 @@ #define FOBJECT_H #include -#include // need for gettimeofday +#include // need for gettimeofday #include #include #include @@ -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 @@ -50,76 +32,76 @@ typedef long double lDouble; class FObject { - public: - // Typedef - typedef std::list FObjectList; + public: + // Typedef + typedef std::list FObjectList; - // Constructor - explicit FObject (FObject* = 0); + // Constructor + explicit FObject (FObject* = 0); - // Destructor - virtual ~FObject(); + // Destructor + virtual ~FObject(); - // Accessors - virtual const char* getClassName() const; - FObject* getParent() const; - FObject* getChild (int) const; - const FObjectList& getChildren() const; - int numOfChildren() const; + // Accessors + virtual const char* getClassName() const; + FObject* getParent() const; + FObject* getChild (int) const; + const FObjectList& getChildren() const; + int numOfChildren() const; - // Inquiries - bool hasParent() const; - bool hasChildren() const; - bool isChild (FObject*) const; - bool isDirectChild (FObject*) const; - bool isWidget() const; - bool isInstanceOf (const char*) const; - bool isTimerInUpdating() const; + // Inquiries + bool hasParent() const; + bool hasChildren() const; + bool isChild (FObject*) const; + bool isDirectChild (FObject*) const; + bool isWidget() const; + bool isInstanceOf (const char*) const; + bool isTimerInUpdating() const; - // Methods - void removeParent(); - void addChild (FObject*); - void delChild (FObject*); + // Methods + void removeParent(); + void addChild (FObject*); + void delChild (FObject*); - // Timer methods - static void getCurrentTime (timeval&); - int addTimer (int); - bool delTimer (int); - bool delOwnTimer(); - bool delAllTimer(); + // Timer methods + static void getCurrentTime (timeval*); + int addTimer (int); + bool delTimer (int); + bool delOwnTimer(); + bool delAllTimer(); - protected: - struct timer_data - { - int id; - timeval interval; - timeval timeout; - FObject* object; - }; + protected: + struct timer_data + { + int id; + timeval interval; + timeval timeout; + FObject* object; + }; - // Typedef - typedef std::vector TimerList; + // Typedef + typedef std::vector TimerList; - // Event handler - virtual bool event (FEvent*); - virtual void onTimer (FTimerEvent*); + // Event handler + virtual bool event (FEvent*); + virtual void onTimer (FTimerEvent*); - // Data Members - static TimerList* timer_list; - bool widget_object; + // Data Members + static TimerList* timer_list; + bool widget_object; - private: - // Disable copy constructor - FObject (const FObject&); + private: + // Disable copy constructor + FObject (const FObject&); - // Disable assignment operator (=) - FObject& operator = (const FObject&); + // Disable assignment operator (=) + FObject& operator = (const FObject&); - // Data Members - FObject* parent_obj; - FObjectList children_list; - bool has_parent; - static bool timer_modify_lock; + // Data Members + FObject* parent_obj; + FObjectList children_list; + bool has_parent; + static bool timer_modify_lock; }; #pragma pack(pop) diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index 62db3abd..7bca1d58 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -60,7 +60,7 @@ FOptiAttr::FOptiAttr() } //---------------------------------------------------------------------- -FOptiAttr::~FOptiAttr() // destructor +FOptiAttr::~FOptiAttr() // destructor { } diff --git a/src/foptiattr.h b/src/foptiattr.h index a4d663f7..c7a5c56d 100644 --- a/src/foptiattr.h +++ b/src/foptiattr.h @@ -11,11 +11,11 @@ #ifndef FOPTIATTR_H #define FOPTIATTR_H - -#include // need for std::swap #include #include // need for tparm +#include // need for std::swap + #include "fc.h" @@ -28,244 +28,243 @@ class FOptiAttr { - public: - // Typedef - typedef struct - { - int code; // character code - short fg_color; // foreground color - short bg_color; // background color + public: + // Typedef + typedef struct + { + int code; // character code + short fg_color; // foreground color + short bg_color; // background color - union attribute - { - struct - { - // Attribute byte #1 - uChar bold : 1; // bold - uChar dim : 1; // dim - uChar italic : 1; // italic - uChar underline : 1; // underline - uChar blink : 1; // blink - uChar reverse : 1; // reverse - uChar standout : 1; // standout - uChar invisible : 1; // invisible - // Attribute byte #2 - uChar protect : 1; // protect mode - uChar crossed_out : 1; // crossed out - uChar dbl_underline : 1; // double underline - uChar alt_charset : 1; // alternate character set (vt100) - uChar pc_charset : 1; // pc character set (CP437) - uChar transparent : 1; // transparent - uChar trans_shadow : 1; // transparent shadow - uChar inherit_bg : 1; // inherit background - // Attribute byte #3 - uChar no_changes : 1; // no changes required - uChar printed : 1; // is printed to VTerm - uChar : 6; // padding bits - } bit; + union attribute + { + struct + { + // Attribute byte #1 + uChar bold : 1; // bold + uChar dim : 1; // dim + uChar italic : 1; // italic + uChar underline : 1; // underline + uChar blink : 1; // blink + uChar reverse : 1; // reverse + uChar standout : 1; // standout + uChar invisible : 1; // invisible + // Attribute byte #2 + uChar protect : 1; // protect mode + uChar crossed_out : 1; // crossed out + uChar dbl_underline : 1; // double underline + uChar alt_charset : 1; // alternate character set (vt100) + uChar pc_charset : 1; // pc character set (CP437) + uChar transparent : 1; // transparent + uChar trans_shadow : 1; // transparent shadow + uChar inherit_bg : 1; // inherit background + // Attribute byte #3 + uChar no_changes : 1; // no changes required + uChar printed : 1; // is printed to VTerm + uChar : 6; // padding bits + } bit; - uChar byte1; - uChar byte2; - uChar byte3; - } attr; + uChar byte1; + uChar byte2; + uChar byte3; + } attr; + } char_data; - } char_data; + // Constructor + explicit FOptiAttr(); - // Constructor - explicit FOptiAttr(); + // Destructor + ~FOptiAttr(); - // Destructor - ~FOptiAttr(); + // Friend operator functions + friend bool operator == (const char_data&, const char_data&); + friend bool operator != (const char_data&, const char_data&); - // Friend operator functions - friend bool operator == (const char_data&, const char_data&); - friend bool operator != (const char_data&, const char_data&); + // Mutators + void setMaxColor (const int&); + void setNoColorVideo (int); + void setDefaultColorSupport(); + void setCygwinTerminal(); + void set_enter_bold_mode (char*&); + void set_exit_bold_mode (char*&); + void set_enter_dim_mode (char*&); + void set_exit_dim_mode (char*&); + void set_enter_italics_mode (char*&); + void set_exit_italics_mode (char*&); + void set_enter_underline_mode (char*&); + void set_exit_underline_mode (char*&); + void set_enter_blink_mode (char*&); + void set_exit_blink_mode (char*&); + void set_enter_reverse_mode (char*&); + void set_exit_reverse_mode (char*&); + void set_enter_secure_mode (char*&); + void set_exit_secure_mode (char*&); + void set_enter_protected_mode (char*&); + void set_exit_protected_mode (char*&); + void set_enter_crossed_out_mode (char*&); + void set_exit_crossed_out_mode (char*&); + void set_enter_dbl_underline_mode (char*&); + void set_exit_dbl_underline_mode (char*&); + void set_enter_standout_mode (char*&); + void set_exit_standout_mode (char*&); + void set_set_attributes (char*&); + void set_exit_attribute_mode (char*&); + void set_enter_alt_charset_mode (char*&); + void set_exit_alt_charset_mode (char*&); + void set_enter_pc_charset_mode (char*&); + void set_exit_pc_charset_mode (char*&); + void set_a_foreground_color (char*&); + void set_a_background_color (char*&); + void set_foreground_color (char*&); + void set_background_color (char*&); + void set_term_color_pair (char*&); + void set_orig_pair (char*&); + void set_orig_orig_colors (char*&); - // Mutators - void setMaxColor (int&); - void setNoColorVideo (int); - void setDefaultColorSupport(); - void setCygwinTerminal(); - void set_enter_bold_mode (char*&); - void set_exit_bold_mode (char*&); - void set_enter_dim_mode (char*&); - void set_exit_dim_mode (char*&); - void set_enter_italics_mode (char*&); - void set_exit_italics_mode (char*&); - void set_enter_underline_mode (char*&); - void set_exit_underline_mode (char*&); - void set_enter_blink_mode (char*&); - void set_exit_blink_mode (char*&); - void set_enter_reverse_mode (char*&); - void set_exit_reverse_mode (char*&); - void set_enter_secure_mode (char*&); - void set_exit_secure_mode (char*&); - void set_enter_protected_mode (char*&); - void set_exit_protected_mode (char*&); - void set_enter_crossed_out_mode (char*&); - void set_exit_crossed_out_mode (char*&); - void set_enter_dbl_underline_mode (char*&); - void set_exit_dbl_underline_mode (char*&); - void set_enter_standout_mode (char*&); - void set_exit_standout_mode (char*&); - void set_set_attributes (char*&); - void set_exit_attribute_mode (char*&); - void set_enter_alt_charset_mode (char*&); - void set_exit_alt_charset_mode (char*&); - void set_enter_pc_charset_mode (char*&); - void set_exit_pc_charset_mode (char*&); - void set_a_foreground_color (char*&); - void set_a_background_color (char*&); - void set_foreground_color (char*&); - void set_background_color (char*&); - void set_term_color_pair (char*&); - void set_orig_pair (char*&); - void set_orig_orig_colors (char*&); + // Inquiry + static bool isNormal (char_data*&); - // Inquiry - static bool isNormal (char_data*&); + // Methods + void init(); + static short vga2ansi (register short); + char* changeAttribute (char_data*&, char_data*&); - // Methods - void init(); - static short vga2ansi (register short); - char* changeAttribute (char_data*&, char_data*&); + private: + // Typedefs and Enumerations + typedef unsigned char uChar; - private: - // Typedefs and Enumerations - typedef unsigned char uChar; + typedef struct + { + char* cap; + bool caused_reset; + } capability; - typedef struct - { - char* cap; - bool caused_reset; - } capability; + enum init_reset_tests + { + no_test = 0x00, + test_ansi_reset = 0x01, // ANSI X3.64 terminal + test_adm3_reset = 0x02, // Lear Siegler ADM-3 terminal + same_like_ue = 0x04, + same_like_se = 0x08, + same_like_me = 0x10, + all_tests = 0x1f + }; - enum init_reset_tests - { - no_test = 0x00, - test_ansi_reset = 0x01, // ANSI X3.64 terminal - test_adm3_reset = 0x02, // Lear Siegler ADM-3 terminal - same_like_ue = 0x04, - same_like_se = 0x08, - same_like_me = 0x10, - all_tests = 0x1f - }; + enum default_color + { + Default = -1, + Black = 0, + LightGray = 7 + }; - enum default_color - { - Default = -1, - Black = 0, - LightGray = 7 - }; + // Disable copy constructor + FOptiAttr (const FOptiAttr&); - // Disable copy constructor - FOptiAttr (const FOptiAttr&); + // Disable assignment operator (=) + FOptiAttr& operator = (const FOptiAttr&); - // Disable assignment operator (=) - FOptiAttr& operator = (const FOptiAttr&); + // Mutators + bool setTermBold (char_data*&); + bool unsetTermBold (char_data*&); + bool setTermDim (char_data*&); + bool unsetTermDim (char_data*&); + bool setTermItalic (char_data*&); + bool unsetTermItalic (char_data*&); + bool setTermUnderline (char_data*&); + bool unsetTermUnderline (char_data*&); + bool setTermBlink (char_data*&); + bool unsetTermBlink (char_data*&); + bool setTermReverse (char_data*&); + bool unsetTermReverse (char_data*&); + bool setTermStandout (char_data*&); + bool unsetTermStandout (char_data*&); + bool setTermInvisible (char_data*&); + bool unsetTermInvisible (char_data*&); + bool setTermProtected (char_data*&); + bool unsetTermProtected (char_data*&); + bool setTermCrossedOut (char_data*&); + bool unsetTermCrossedOut (char_data*&); + bool setTermDoubleUnderline (char_data*&); + bool unsetTermDoubleUnderline (char_data*&); + bool setTermAttributes ( char_data*& + , bool, bool, bool + , bool, bool, bool + , bool, bool, bool ); + bool unsetTermAttributes (char_data*&); + bool setTermAltCharset (char_data*&); + bool unsetTermAltCharset (char_data*&); + bool setTermPCcharset (char_data*&); + bool unsetTermPCcharset (char_data*&); + bool setTermDefaultColor (char_data*&); - // Mutators - bool setTermBold (char_data*&); - bool unsetTermBold (char_data*&); - bool setTermDim (char_data*&); - bool unsetTermDim (char_data*&); - bool setTermItalic (char_data*&); - bool unsetTermItalic (char_data*&); - bool setTermUnderline (char_data*&); - bool unsetTermUnderline (char_data*&); - bool setTermBlink (char_data*&); - bool unsetTermBlink (char_data*&); - bool setTermReverse (char_data*&); - bool unsetTermReverse (char_data*&); - bool setTermStandout (char_data*&); - bool unsetTermStandout (char_data*&); - bool setTermInvisible (char_data*&); - bool unsetTermInvisible (char_data*&); - bool setTermProtected (char_data*&); - bool unsetTermProtected (char_data*&); - bool setTermCrossedOut (char_data*&); - bool unsetTermCrossedOut (char_data*&); - bool setTermDoubleUnderline (char_data*&); - bool unsetTermDoubleUnderline (char_data*&); - bool setTermAttributes ( char_data*& - , bool, bool, bool - , bool, bool, bool - , bool, bool, bool ); - bool unsetTermAttributes (char_data*&); - bool setTermAltCharset (char_data*&); - bool unsetTermAltCharset (char_data*&); - bool setTermPCcharset (char_data*&); - bool unsetTermPCcharset (char_data*&); - bool setTermDefaultColor (char_data*&); + // Inquiries + static bool hasColor (char_data*&); + static bool hasAttribute (char_data*&); + static bool hasNoAttribute (char_data*&); - // Inquiries - static bool hasColor (char_data*&); - static bool hasAttribute (char_data*&); - static bool hasNoAttribute (char_data*&); + // Methods + bool colorChange (char_data*&, char_data*&); + void resetColor (char_data*&); + void prevent_no_color_video_attributes (char_data*&); + void change_color (char_data*&, char_data*&); + void resetAttribute (char_data*&); + void reset (char_data*&); + bool caused_reset_attributes (char*&, uChar = all_tests); + void detectSwitchOn (char_data*&, char_data*&); + void detectSwitchOff (char_data*&, char_data*&); + bool switchOn(); + bool switchOff(); + bool append_sequence (char*&); + bool replace_sequence (char*&); - // Methods - bool colorChange (char_data*&, char_data*&); - void resetColor (char_data*&); - void prevent_no_color_video_attributes (char_data*&); - void change_color (char_data*&, char_data*&); - void resetAttribute (char_data*&); - void reset (char_data*&); - bool caused_reset_attributes (char*&, uChar = all_tests); - void detectSwitchOn (char_data*&, char_data*&); - void detectSwitchOff (char_data*&, char_data*&); - bool switchOn(); - bool switchOff(); - bool append_sequence (char*&); - bool replace_sequence (char*&); + // Data Members + capability F_enter_bold_mode; + capability F_exit_bold_mode; + capability F_enter_dim_mode; + capability F_exit_dim_mode; + capability F_enter_italics_mode; + capability F_exit_italics_mode; + capability F_enter_underline_mode; + capability F_exit_underline_mode; + capability F_enter_blink_mode; + capability F_exit_blink_mode; + capability F_enter_reverse_mode; + capability F_exit_reverse_mode; + capability F_enter_standout_mode; + capability F_exit_standout_mode; + capability F_enter_secure_mode; + capability F_exit_secure_mode; + capability F_enter_protected_mode; + capability F_exit_protected_mode; + capability F_enter_crossed_out_mode; + capability F_exit_crossed_out_mode; + capability F_enter_dbl_underline_mode; + capability F_exit_dbl_underline_mode; + capability F_set_attributes; + capability F_exit_attribute_mode; + capability F_enter_alt_charset_mode; + capability F_exit_alt_charset_mode; + capability F_enter_pc_charset_mode; + capability F_exit_pc_charset_mode; + capability F_set_a_foreground; + capability F_set_a_background; + capability F_set_foreground; + capability F_set_background; + capability F_set_color_pair; + capability F_orig_pair; + capability F_orig_colors; - // Data Members - capability F_enter_bold_mode; - capability F_exit_bold_mode; - capability F_enter_dim_mode; - capability F_exit_dim_mode; - capability F_enter_italics_mode; - capability F_exit_italics_mode; - capability F_enter_underline_mode; - capability F_exit_underline_mode; - capability F_enter_blink_mode; - capability F_exit_blink_mode; - capability F_enter_reverse_mode; - capability F_exit_reverse_mode; - capability F_enter_standout_mode; - capability F_exit_standout_mode; - capability F_enter_secure_mode; - capability F_exit_secure_mode; - capability F_enter_protected_mode; - capability F_exit_protected_mode; - capability F_enter_crossed_out_mode; - capability F_exit_crossed_out_mode; - capability F_enter_dbl_underline_mode; - capability F_exit_dbl_underline_mode; - capability F_set_attributes; - capability F_exit_attribute_mode; - capability F_enter_alt_charset_mode; - capability F_exit_alt_charset_mode; - capability F_enter_pc_charset_mode; - capability F_exit_pc_charset_mode; - capability F_set_a_foreground; - capability F_set_a_background; - capability F_set_foreground; - capability F_set_background; - capability F_set_color_pair; - capability F_orig_pair; - capability F_orig_colors; + char_data on; + char_data off; - char_data on; - char_data off; - - int max_color; - int attr_without_color; - bool ansi_default_color; - bool monochron; - bool fake_reverse; - bool cygwin_terminal; - char attr_buf[8192]; - char* attr_ptr; + int max_color; + int attr_without_color; + bool ansi_default_color; + bool monochron; + bool fake_reverse; + bool cygwin_terminal; + char attr_buf[8192]; + char* attr_ptr; }; #pragma pack(pop) @@ -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; } //---------------------------------------------------------------------- diff --git a/src/foptimove.cpp b/src/foptimove.cpp index c480cd9a..591b327a 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -1,8 +1,10 @@ // File: foptimove.cpp // Provides: class FOptiMove +#include + #include "foptimove.h" -#include "string.h" + //---------------------------------------------------------------------- // class FOptiMove @@ -45,7 +47,7 @@ FOptiMove::FOptiMove (int baud) } //---------------------------------------------------------------------- -FOptiMove::~FOptiMove() // destructor +FOptiMove::~FOptiMove() // destructor { } @@ -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"; } @@ -647,9 +667,9 @@ void FOptiMove::calculateCharDuration() { if ( baudrate != 0 ) { - static const int baudbyte = 9; // = 7 bit + 1 parity + 1 stop + static const int baudbyte = 9; // = 7 bit + 1 parity + 1 stop char_duration = (baudbyte * 1000 * 10) - / (baudrate > 0 ? baudrate : 9600); // milliseconds + / (baudrate > 0 ? baudrate : 9600); // milliseconds if ( char_duration <= 0 ) char_duration = 1; @@ -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; @@ -786,7 +806,7 @@ int FOptiMove::relativeMove ( char*& move vtime = repeatedAppend (F_cursor_down, num, move); } } - else // to_y < from_y + else // to_y < from_y { num = from_y - to_y; @@ -874,10 +894,9 @@ int FOptiMove::relativeMove ( char*& move std::strncpy (hmove, str, sizeof(move_buf) - 1); htime = htime_r; } - } } - else // to_x < from_x + else // to_x < from_x { num = from_x - to_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 ); } diff --git a/src/foptimove.h b/src/foptimove.h index eb5ba90d..823b4467 100644 --- a/src/foptimove.h +++ b/src/foptimove.h @@ -34,112 +34,112 @@ class FOptiMove { - public: - // Constructor - explicit FOptiMove (int = 0); + public: + // Constructor + explicit FOptiMove (int = 0); - // Destructor - ~FOptiMove(); + // Destructor + ~FOptiMove(); - // Mutators - void setBaudRate (int); - void setTabStop (int); - void setTermSize (int, int); - int set_cursor_home (char*&); - int set_cursor_to_ll (char*&); - int set_carriage_return (char*&); - int set_tabular (char*&); - int set_back_tab (char*&); - int set_cursor_up (char*&); - int set_cursor_down (char*&); - int set_cursor_left (char*&); - int set_cursor_right (char*&); - int set_cursor_address (char*&); - int set_column_address (char*&); - int set_row_address (char*&); - int set_parm_up_cursor (char*&); - int set_parm_down_cursor (char*&); - int set_parm_left_cursor (char*&); - int set_parm_right_cursor (char*&); - int set_erase_chars (char*&); - 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&); + // Mutators + void setBaudRate (int); + void setTabStop (int); + void setTermSize (int, int); + int set_cursor_home (char*&); + int set_cursor_to_ll (char*&); + int set_carriage_return (char*&); + int set_tabular (char*&); + int set_back_tab (char*&); + int set_cursor_up (char*&); + int set_cursor_down (char*&); + int set_cursor_left (char*&); + int set_cursor_right (char*&); + int set_cursor_address (char*&); + int set_column_address (char*&); + int set_row_address (char*&); + int set_parm_up_cursor (char*&); + int set_parm_down_cursor (char*&); + int set_parm_left_cursor (char*&); + int set_parm_right_cursor (char*&); + int set_erase_chars (char*&); + int set_repeat_char (char*&); + int set_clr_bol (char*&); + int set_clr_eol (char*&); + void set_auto_left_margin (const bool&); + void set_eat_newline_glitch (const bool&); - // Methods - char* moveCursor (int, int, int, int); - void printDurations(); + // Methods + char* moveCursor (int, int, int, int); + void printDurations(); - private: - // Typedefs - typedef unsigned char uChar; - typedef unsigned int uInt; + private: + // Typedefs + typedef unsigned char uChar; + typedef unsigned int uInt; - typedef struct - { - char* cap; - int duration; - int length; - } capability; + typedef struct + { + char* cap; + int duration; + int length; + } capability; - // Constants - static const int LONG_DURATION = INT_MAX; - // value for a long capability waiting time - static const int MOVE_LIMIT = 7; - // maximum character distance to avoid direct cursor addressing + // Constants + static const int LONG_DURATION = INT_MAX; + // value for a long capability waiting time + static const int MOVE_LIMIT = 7; + // maximum character distance to avoid direct cursor addressing - // Methods - void calculateCharDuration(); - int capDuration (char*&, int); - int capDurationToLength (int); - int repeatedAppend (capability&, int, char*); - int relativeMove (char*&, int, int, int, int); - bool isWideMove (int, int, int, int); + // Methods + void calculateCharDuration(); + int capDuration (char*&, int); + int capDurationToLength (int); + int repeatedAppend (const capability&, int, char*); + int relativeMove (char*&, int, int, int, int); + bool isWideMove (int, int, int, int); - // Data Members - capability F_cursor_home; - capability F_carriage_return; - capability F_cursor_to_ll; - capability F_tab; - capability F_back_tab; - capability F_cursor_up; - capability F_cursor_down; - capability F_cursor_left; - capability F_cursor_right; - capability F_cursor_address; - capability F_column_address; - capability F_row_address; - capability F_parm_up_cursor; - capability F_parm_down_cursor; - capability F_parm_left_cursor; - capability F_parm_right_cursor; - capability F_erase_chars; - capability F_repeat_char; - capability F_clr_bol; - capability F_clr_eol; + // Data Members + capability F_cursor_home; + capability F_carriage_return; + capability F_cursor_to_ll; + capability F_tab; + capability F_back_tab; + capability F_cursor_up; + capability F_cursor_down; + capability F_cursor_left; + capability F_cursor_right; + capability F_cursor_address; + capability F_column_address; + capability F_row_address; + capability F_parm_up_cursor; + capability F_parm_down_cursor; + capability F_parm_left_cursor; + capability F_parm_right_cursor; + capability F_erase_chars; + capability F_repeat_char; + capability F_clr_bol; + capability F_clr_eol; - bool automatic_left_margin; - bool eat_nl_glitch; + bool automatic_left_margin; + bool eat_nl_glitch; - char move_buf[512]; - int char_duration; - int baudrate; - int tabstop; - int screen_width; - int screen_height; + char move_buf[512]; + int char_duration; + int baudrate; + int tabstop; + int screen_width; + int screen_height; }; #pragma pack(pop) // 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 diff --git a/src/fpoint.h b/src/fpoint.h index 28a52fb3..897715aa 100644 --- a/src/fpoint.h +++ b/src/fpoint.h @@ -20,45 +20,45 @@ class FPoint { - public: - // Constructors - FPoint (); - FPoint (const FPoint&); // copy constructor - FPoint (int, int); + public: + // Constructors + FPoint (); + FPoint (const FPoint&); // copy constructor + FPoint (int, int); - // Destructor - virtual ~FPoint(); + // Destructor + virtual ~FPoint(); - // Overloaded operators - FPoint& operator = (const FPoint&); - FPoint& operator += (const FPoint&); - FPoint& operator -= (const FPoint&); + // Overloaded operators + FPoint& operator = (const FPoint&); + FPoint& operator += (const FPoint&); + FPoint& operator -= (const FPoint&); - friend inline bool operator == (const FPoint&, const FPoint&); - friend inline bool operator != (const FPoint&, const FPoint&); - friend inline FPoint operator + (const FPoint&, const FPoint&); - friend inline FPoint operator - (const FPoint&, const FPoint&); - friend inline FPoint operator - (const FPoint&); + friend inline bool operator == (const FPoint&, const FPoint&); + friend inline bool operator != (const FPoint&, const FPoint&); + friend inline FPoint operator + (const FPoint&, const FPoint&); + friend inline FPoint operator - (const FPoint&, const FPoint&); + friend inline FPoint operator - (const FPoint&); - // Accessors - virtual const char* getClassName(); - int getX() const; - int getY() const; - void setX (int); - void setY (int); - void setPoint (int, int); + // Accessors + virtual const char* getClassName(); + int getX() const; + int getY() const; + void setX (int); + void setY (int); + void setPoint (int, int); - // Inquiry - bool isNull() const; + // Inquiry + bool isNull() const; - // Point references - short& x_ref(); - short& y_ref(); + // Point references + short& x_ref(); + short& y_ref(); - private: - // Data Members - short xpos; - short ypos; + private: + // Data Members + short xpos; + short ypos; }; #pragma pack(pop) diff --git a/src/fprogressbar.cpp b/src/fprogressbar.cpp index be1d0b3b..de0800e0 100644 --- a/src/fprogressbar.cpp +++ b/src/fprogressbar.cpp @@ -19,7 +19,7 @@ FProgressbar::FProgressbar(FWidget* parent) } //---------------------------------------------------------------------- -FProgressbar::~FProgressbar() +FProgressbar::~FProgressbar() // destructor { } @@ -214,7 +214,7 @@ void FProgressbar::drawBar() else { setColor (wc.progressbar_fg, wc.progressbar_bg); - print (fc::LeftHalfBlock); // ▌ + print (fc::LeftHalfBlock); // ▌ } i++; diff --git a/src/fprogressbar.h b/src/fprogressbar.h index 27a04821..d31fc4fe 100644 --- a/src/fprogressbar.h +++ b/src/fprogressbar.h @@ -40,43 +40,43 @@ class FProgressbar : public FWidget { - public: - // Using-declarations - using FWidget::setGeometry; + public: + // Using-declarations + using FWidget::setGeometry; - // Constructor - explicit FProgressbar(FWidget* = 0); + // Constructor + explicit FProgressbar(FWidget* = 0); - // Destructor - virtual ~FProgressbar(); + // Destructor + virtual ~FProgressbar(); - // Accessors - const char* getClassName() const; - int getPercentage(); + // Accessors + const char* getClassName() const; + int getPercentage(); - // Mutators - void setPercentage (int); - void setGeometry (int, int, int, int, bool = true); - bool setShadow (bool); - bool setShadow(); - bool unsetShadow(); + // Mutators + void setPercentage (int); + void setGeometry (int, int, int, int, bool = true); + bool setShadow (bool); + bool setShadow(); + bool unsetShadow(); - // Inquiries - bool hasShadow(); + // Inquiries + bool hasShadow(); - // Methods - void hide(); - void reset(); + // Methods + void hide(); + void reset(); - private: - // Methods - virtual void draw(); - void drawPercentage(); - void drawBar(); + private: + // Methods + virtual void draw(); + void drawPercentage(); + void drawBar(); - // Data Members - int percentage; - int bar_length; + // Data Members + int percentage; + int bar_length; }; #pragma pack(pop) diff --git a/src/fradiobutton.h b/src/fradiobutton.h index 96c04c3d..e7fbef6b 100644 --- a/src/fradiobutton.h +++ b/src/fradiobutton.h @@ -45,28 +45,28 @@ class FRadioButton : public FToggleButton { - public: - // Constructors - explicit FRadioButton (FWidget* = 0); - FRadioButton (const FString&, FWidget* = 0); + public: + // Constructors + explicit FRadioButton (FWidget* = 0); + FRadioButton (const FString&, FWidget* = 0); - // Destructor - virtual ~FRadioButton(); + // Destructor + virtual ~FRadioButton(); - // Accessor - const char* getClassName() const; + // Accessor + const char* getClassName() const; - private: - // Disable copy constructor - FRadioButton (const FRadioButton&); + private: + // Disable copy constructor + FRadioButton (const FRadioButton&); - // Disable assignment operator (=) - FRadioButton& operator = (const FRadioButton&); + // Disable assignment operator (=) + FRadioButton& operator = (const FRadioButton&); - // Methods - void init(); - void draw(); - void drawRadioButton(); + // Methods + void init(); + void draw(); + void drawRadioButton(); }; #pragma pack(pop) diff --git a/src/fradiomenuitem.cpp b/src/fradiomenuitem.cpp index aed99a1a..c74fe456 100644 --- a/src/fradiomenuitem.cpp +++ b/src/fradiomenuitem.cpp @@ -38,9 +38,9 @@ void FRadioMenuItem::init (FWidget* parent) if ( ! parent ) return; - if ( isMenu(parent) ) // Parent is menu + if ( isMenu(parent) ) // Parent is menu { - FMenu* menu_ptr = dynamic_cast(parent); + FMenu* menu_ptr = static_cast(parent); if ( menu_ptr ) menu_ptr->has_checkable_items = true; diff --git a/src/fradiomenuitem.h b/src/fradiomenuitem.h index 5617e8b1..93278e39 100644 --- a/src/fradiomenuitem.h +++ b/src/fradiomenuitem.h @@ -45,28 +45,28 @@ class FRadioMenuItem : public FMenuItem { - public: - // Constructors - explicit FRadioMenuItem (FWidget* = 0); - FRadioMenuItem (const FString&, FWidget* = 0); + public: + // Constructors + explicit FRadioMenuItem (FWidget* = 0); + FRadioMenuItem (const FString&, FWidget* = 0); - // Destructor - virtual ~FRadioMenuItem(); + // Destructor + virtual ~FRadioMenuItem(); - // Accessor - const char* getClassName() const; + // Accessor + const char* getClassName() const; - private: - // Disable copy constructor - FRadioMenuItem (const FRadioMenuItem&); + private: + // Disable copy constructor + FRadioMenuItem (const FRadioMenuItem&); - // Disable assignment operator (=) - FRadioMenuItem& operator = (const FRadioMenuItem&); + // Disable assignment operator (=) + FRadioMenuItem& operator = (const FRadioMenuItem&); - // Methods - void init (FWidget*); - void processToggle(); - void processClicked(); + // Methods + void init (FWidget*); + void processToggle(); + void processClicked(); }; #pragma pack(pop) diff --git a/src/frect.cpp b/src/frect.cpp index d31cbe69..8bb8ba02 100644 --- a/src/frect.cpp +++ b/src/frect.cpp @@ -1,6 +1,8 @@ // File: frect.cpp // Provides: class FRect +#include + #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 diff --git a/src/frect.h b/src/frect.h index d170614d..97db71b3 100644 --- a/src/frect.h +++ b/src/frect.h @@ -24,82 +24,82 @@ class FRect { - public: - // Constructors - FRect (); - FRect (const FRect&); // copy constructor - FRect (int, int, int, int); - FRect (const FPoint&, const FPoint&); + public: + // Constructors + FRect (); + FRect (const FRect&); // copy constructor + FRect (int, int, int, int); + FRect (const FPoint&, const FPoint&); - // Destructor - virtual ~FRect(); + // Destructor + virtual ~FRect(); - // Overloaded operators - FRect& operator = (const FRect&); + // Overloaded operators + FRect& operator = (const FRect&); - friend FRect operator + (const FRect&, const FPoint&); - friend FRect operator - (const FRect&, const FPoint&); - friend bool operator == (const FRect&, const FRect&); - friend bool operator != (const FRect&, const FRect&); + friend FRect operator + (const FRect&, const FPoint&); + friend FRect operator - (const FRect&, const FPoint&); + friend bool operator == (const FRect&, const FRect&); + friend bool operator != (const FRect&, const FRect&); - // Accessors - virtual const char* getClassName(); - int getX1() const; - int getY1() const; - int getX2() const; - int getY2() const; - int getX() const; - int getY() const; - FPoint getPos() const; - FPoint getUpperLeftPos() const; - FPoint getUpperRightPos() const; - FPoint getLowerLeftPos() const; - FPoint getLowerRightPos() const; - int getWidth() const; - int getHeight() const; + // Accessors + virtual const char* getClassName(); + int getX1() const; + int getY1() const; + int getX2() const; + int getY2() const; + int getX() const; + int getY() const; + FPoint getPos() const; + FPoint getUpperLeftPos() const; + FPoint getUpperRightPos() const; + FPoint getLowerLeftPos() const; + FPoint getLowerRightPos() const; + int getWidth() const; + int getHeight() const; - // Mutators - void setX1 (int); - void setY1 (int); - void setX2 (int); - void setY2 (int); - void setX (int); - void setY (int); - void setPos (int, int); - void setPos (const FPoint&); - void setWidth (int); - void setHeight (int); - void setSize (int, int); - void setRect (const FRect&); - void setRect (int, int, int, int); - void setCoordinates (const FPoint&, const FPoint&); - void setCoordinates (int, int, int, int); + // Mutators + void setX1 (int); + void setY1 (int); + void setX2 (int); + void setY2 (int); + void setX (int); + void setY (int); + void setPos (int, int); + void setPos (const FPoint&); + void setWidth (int); + void setHeight (int); + void setSize (int, int); + void setRect (const FRect&); + void setRect (int, int, int, int); + void setCoordinates (const FPoint&, const FPoint&); + void setCoordinates (int, int, int, int); - // Inquiry - bool isNull() const; + // Inquiry + bool isNull() const; - // Coordinate references - short& x1_ref(); - short& y1_ref(); - short& x2_ref(); - short& y2_ref(); + // Coordinate references + short& x1_ref(); + short& y1_ref(); + short& x2_ref(); + short& y2_ref(); - // Methods - void move (int, int); - void move (const FPoint&); - bool contains (int, int) const; - bool contains (const FPoint&) const; - bool contains (const FRect&) const; - bool overlap (const FRect&) const; - FRect intersect (const FRect&) const; - FRect combined (const FRect&) const; + // Methods + void move (int, int); + void move (const FPoint&); + bool contains (int, int) const; + bool contains (const FPoint&) const; + bool contains (const FRect&) const; + bool overlap (const FRect&) const; + FRect intersect (const FRect&) const; + FRect combined (const FRect&) const; - private: - // Data Members - short X1; - short Y1; - short X2; - short Y2; + private: + // Data Members + short X1; + short Y1; + short X2; + short Y2; }; #pragma pack(pop) @@ -159,23 +159,23 @@ inline int FRect::getY() const //---------------------------------------------------------------------- inline FPoint FRect::getPos() const -{ return FPoint(X1,Y1); } +{ return FPoint(X1, Y1); } //---------------------------------------------------------------------- inline FPoint FRect::getUpperLeftPos() const -{ return FPoint(X1,Y1); } +{ return FPoint(X1, Y1); } //---------------------------------------------------------------------- inline FPoint FRect::getUpperRightPos() const -{ return FPoint(X2,Y1); } +{ return FPoint(X2, Y1); } //---------------------------------------------------------------------- inline FPoint FRect::getLowerLeftPos() const -{ return FPoint(X1,Y2); } +{ return FPoint(X1, Y2); } //---------------------------------------------------------------------- inline FPoint FRect::getLowerRightPos() const -{ return FPoint(X2,Y2); } +{ return FPoint(X2, Y2); } //---------------------------------------------------------------------- inline int FRect::getWidth() const diff --git a/src/fscrollbar.cpp b/src/fscrollbar.cpp index 43fd05b6..01b7686b 100644 --- a/src/fscrollbar.cpp +++ b/src/fscrollbar.cpp @@ -1,6 +1,8 @@ // File: fscrollbar.cpp // Provides: class FScrollbar +#include + #include "fscrollbar.h" //---------------------------------------------------------------------- @@ -19,8 +21,8 @@ FScrollbar::FScrollbar(FWidget* parent) , slider_click_stop_pos(-1) , current_slider_pos(-1) , slider_pos(0) - , slider_length(18) // = bar_length - , bar_length(18) // = length - 2 + , slider_length(18) // = bar_length + , bar_length(18) // = length - 2 , val(0) , min(0) , max(99) @@ -46,8 +48,8 @@ FScrollbar::FScrollbar(int o, FWidget* parent) , slider_click_stop_pos(-1) , current_slider_pos(-1) , slider_pos(0) - , slider_length(18) // = bar_length - , bar_length(18) // = length - 2 + , slider_length(18) // = bar_length + , bar_length(18) // = length - 2 , val(0) , min(0) , max(99) @@ -62,7 +64,7 @@ FScrollbar::FScrollbar(int o, FWidget* parent) } //---------------------------------------------------------------------- -FScrollbar::~FScrollbar() +FScrollbar::~FScrollbar() // destructor { delOwnTimer(); } @@ -163,7 +165,7 @@ void FScrollbar::setGeometry (int x, int y, int w, int h, bool adjust) setWidth(isNewFont() ? 2 : 1); setHeight(length); } - else // horizontal + else // horizontal { setWidth(length); setHeight(1); @@ -243,7 +245,7 @@ void FScrollbar::drawButtons() print (fc::NF_rev_down_arrow1); print (fc::NF_rev_down_arrow2); } - else // horizontal + else // horizontal { print (fc::NF_rev_left_arrow1); print (fc::NF_rev_left_arrow2); @@ -261,15 +263,15 @@ void FScrollbar::drawButtons() if ( bar_orientation == fc::vertical ) { - print (fc::BlackUpPointingTriangle); // ▲ + print (fc::BlackUpPointingTriangle); // ▲ setPrintPos (1, length); - print (fc::BlackDownPointingTriangle); // ▼ + print (fc::BlackDownPointingTriangle); // ▼ } - else // horizontal + else // horizontal { - print (fc::BlackLeftPointingPointer); // ◄ + print (fc::BlackLeftPointingPointer); // ◄ setPrintPos (length, 1); - print (fc::BlackRightPointingPointer); // ► + print (fc::BlackRightPointingPointer); // ► } if ( isMonochron() ) @@ -294,10 +296,10 @@ void FScrollbar::drawBar() setPrintPos (1, 1 + z); if ( isNewFont() ) - print (fc::NF_border_line_left); // ⎸ + print (fc::NF_border_line_left); // ⎸ if ( isMonochron() || max_color < 16 ) - print (fc::MediumShade); // ▒ + print (fc::MediumShade); // ▒ else print (' '); } @@ -327,7 +329,7 @@ void FScrollbar::drawBar() setPrintPos (1, 1 + z); if ( isNewFont() ) - print (fc::NF_border_line_left); // ⎸ + print (fc::NF_border_line_left); // ⎸ if ( isMonochron() || max_color < 16 ) print (fc::MediumShade); @@ -348,9 +350,9 @@ void FScrollbar::drawBar() for (; z < slider_pos; z++) { if ( isNewFont() ) - print (fc::NF_border_line_upper); // ¯ + print (fc::NF_border_line_upper); // ¯ else if ( isMonochron() || max_color < 16 ) - print (fc::MediumShade); // ▒ + print (fc::MediumShade); // ▒ else print (' '); } @@ -374,9 +376,9 @@ void FScrollbar::drawBar() for (; z <= bar_length; z++) { if ( isNewFont() ) - print (fc::NF_border_line_upper); // ¯ + print (fc::NF_border_line_upper); // ¯ else if ( isMonochron() || max_color < 16 ) - print (fc::MediumShade); // ▒ + print (fc::MediumShade); // ▒ else print (' '); } @@ -638,7 +640,7 @@ FScrollbar::sType FScrollbar::getClickedScrollType (int x, int y) } else if ( y == getHeight() ) { - stype = FScrollbar::scrollStepForward; // increment button + stype = FScrollbar::scrollStepForward; // increment button } else stype = FScrollbar::noScroll; diff --git a/src/fscrollbar.h b/src/fscrollbar.h index 16c1374b..ce77332d 100644 --- a/src/fscrollbar.h +++ b/src/fscrollbar.h @@ -40,92 +40,92 @@ class FScrollbar : public FWidget { - public: - // Using-declarations - using FWidget::setGeometry; + public: + // Using-declarations + using FWidget::setGeometry; - // Enumeration - enum sType - { - noScroll = 0, - scrollJump = 1, - scrollStepBackward = 2, - scrollStepForward = 3, - scrollPageBackward = 4, - scrollPageForward = 5, - scrollWheelUp = 6, - scrollWheelDown = 7 - }; + // Enumeration + enum sType + { + noScroll = 0, + scrollJump = 1, + scrollStepBackward = 2, + scrollStepForward = 3, + scrollPageBackward = 4, + scrollPageForward = 5, + scrollWheelUp = 6, + scrollWheelDown = 7 + }; - // Constructors - explicit FScrollbar(FWidget* = 0); - FScrollbar (int = fc::vertical, FWidget* = 0); + // Constructors + explicit FScrollbar(FWidget* = 0); + FScrollbar (int = fc::vertical, FWidget* = 0); - // Destructor - virtual ~FScrollbar(); + // Destructor + virtual ~FScrollbar(); - // Accessors - const char* getClassName() const; - int getValue() const; - sType getScrollType() const; + // Accessors + const char* getClassName() const; + int getValue() const; + sType getScrollType() const; - // Mutators - void setMinimum (int); - void setMaximum (int); - void setRange (int, int); - void setValue (int); - void setSteps (double); - void setPageSize (int, int); - void setOrientation (int); - void setGeometry (int, int, int, int, bool = true); + // Mutators + void setMinimum (int); + void setMaximum (int); + void setRange (int, int); + void setValue (int); + void setSteps (double); + void setPageSize (int, int); + void setOrientation (int); + void setGeometry (int, int, int, int, bool = true); - // Methods - void resize(); - void redraw(); - void calculateSliderValues(); - void drawButtons(); - void drawBar(); + // Methods + void resize(); + void redraw(); + void calculateSliderValues(); + void drawButtons(); + void drawBar(); - // Event handlers - void onMouseDown (FMouseEvent*); - void onMouseUp (FMouseEvent*); - void onMouseMove (FMouseEvent*); - void onWheel (FWheelEvent*); - void onTimer (FTimerEvent*); + // Event handlers + void onMouseDown (FMouseEvent*); + void onMouseUp (FMouseEvent*); + void onMouseMove (FMouseEvent*); + void onWheel (FWheelEvent*); + void onTimer (FTimerEvent*); - private: - // Disable copy constructor - FScrollbar (const FScrollbar&); + private: + // Disable copy constructor + FScrollbar (const FScrollbar&); - // Disable assignment operator (=) - FScrollbar& operator = (const FScrollbar&); + // Disable assignment operator (=) + FScrollbar& operator = (const FScrollbar&); - // Methods - void init(); - void draw(); - sType getClickedScrollType (int, int); - void processMiddleButton (int, int); - void processScroll(); + // Methods + void init(); + void draw(); + sType getClickedScrollType (int, int); + void processMiddleButton (int, int); + void processScroll(); - // Data Members - sType scroll_type; - bool threshold_reached; - int threshold_time; - int repeat_time; - int slider_click_pos; - int slider_click_stop_pos; - int current_slider_pos; - int slider_pos; - int slider_length; - int bar_length; - int val; - int min; - int max; - double steps; - int pageSize; - int length; - int bar_orientation; - int max_color; + // Data Members + sType scroll_type; + bool threshold_reached; + int threshold_time; + int repeat_time; + int slider_click_pos; + int slider_click_stop_pos; + int current_slider_pos; + int slider_pos; + int slider_length; + int bar_length; + int val; + int min; + int max; + double steps; + int pageSize; + int length; + int bar_orientation; + int max_color; }; #pragma pack(pop) diff --git a/src/fscrollview.cpp b/src/fscrollview.cpp index f78ef67c..2e110ce0 100644 --- a/src/fscrollview.cpp +++ b/src/fscrollview.cpp @@ -13,7 +13,7 @@ //---------------------------------------------------------------------- FScrollView::FScrollView (FWidget* parent) : FWidget(parent) - , scroll_geometry(1,1,1,1) + , scroll_geometry(1, 1, 1, 1) , viewport_geometry() , viewport(0) , vbar(0) @@ -28,7 +28,7 @@ FScrollView::FScrollView (FWidget* parent) } //---------------------------------------------------------------------- -FScrollView::~FScrollView() // destructor +FScrollView::~FScrollView() // destructor { delete vbar; delete hbar; @@ -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); @@ -712,8 +715,8 @@ void FScrollView::copy2area() for (int y = 0; y < y_end; y++) // line loop { - char_data* vc; // viewport character - char_data* ac; // area character + char_data* vc; // viewport character + char_data* ac; // area character int v_line_len = viewport->width; int a_line_len = print_area->width + print_area->right_shadow; vc = &viewport->text[(dy + y) * v_line_len + dx]; @@ -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; } diff --git a/src/fscrollview.h b/src/fscrollview.h index cbabad03..d2499d23 100644 --- a/src/fscrollview.h +++ b/src/fscrollview.h @@ -42,121 +42,121 @@ class FScrollView : public FWidget { - public: - // Using-declaration - using FWidget::setGeometry; - using FWidget::setPrintPos; - using FWidget::setPos; + public: + // Using-declaration + using FWidget::setGeometry; + using FWidget::setPrintPos; + using FWidget::setPos; - // Constructor - explicit FScrollView (FWidget* = 0); + // Constructor + explicit FScrollView (FWidget* = 0); - // Destructor - virtual ~FScrollView(); + // Destructor + virtual ~FScrollView(); - // Accessors - const char* getClassName() const; - int getViewportWidth() const; - int getViewportHeight() const; - int getScrollWidth() const; - int getScrollHeight() const; - const FPoint getScrollPos() const; - int getScrollX() const; - int getScrollY() const; + // Accessors + const char* getClassName() const; + int getViewportWidth() const; + int getViewportHeight() const; + int getScrollWidth() const; + int getScrollHeight() const; + const FPoint getScrollPos() const; + int getScrollX() const; + int getScrollY() const; - // Mutator - virtual void setScrollWidth (int); - virtual void setScrollHeight (int); - virtual void setScrollSize (int, int); - virtual void setX (int, bool = true); - virtual void setY (int, bool = true); - virtual void setPos (int, int, bool = true); - virtual void setWidth (int, bool = true); - virtual void setHeight (int, bool = true); - virtual void setSize (int, int, bool = true); - void setGeometry (int, int, int, int, bool = true); - void setCursorPos (register int, register int); - void setPrintPos (register int, register int); - bool setViewportPrint (bool); - bool setViewportPrint(); - bool unsetViewportPrint(); - bool setBorder (bool); - bool setBorder(); - bool unsetBorder(); - void setHorizontalScrollBarMode (fc::scrollBarMode); - void setVerticalScrollBarMode (fc::scrollBarMode); + // Mutator + virtual void setScrollWidth (int); + virtual void setScrollHeight (int); + virtual void setScrollSize (int, int); + virtual void setX (int, bool = true); + virtual void setY (int, bool = true); + virtual void setPos (int, int, bool = true); + virtual void setWidth (int, bool = true); + virtual void setHeight (int, bool = true); + virtual void setSize (int, int, bool = true); + void setGeometry (int, int, int, int, bool = true); + void setCursorPos (register int, register int); + void setPrintPos (register int, register int); + bool setViewportPrint (bool); + bool setViewportPrint(); + bool unsetViewportPrint(); + bool setBorder (bool); + bool setBorder(); + bool unsetBorder(); + void setHorizontalScrollBarMode (fc::scrollBarMode); + void setVerticalScrollBarMode (fc::scrollBarMode); - // Inquiries - bool hasBorder(); - bool isViewportPrint(); + // Inquiries + bool hasBorder(); + bool isViewportPrint(); - // Method - virtual void clearArea (int = ' '); - void scrollToX (int); - void scrollToY (int); - void scrollTo (const FPoint&); - void scrollTo (int, int); - void scrollBy (int, int); - virtual void draw(); + // Method + virtual void clearArea (int = ' '); + void scrollToX (int); + void scrollToY (int); + void scrollTo (const FPoint&); + void scrollTo (int, int); + void scrollBy (int, int); + virtual void draw(); - // Event handlers - void onKeyPress (FKeyEvent*); - void onWheel (FWheelEvent*); - void onFocusIn (FFocusEvent*); - void onChildFocusIn (FFocusEvent*); - void onChildFocusOut (FFocusEvent*); + // Event handlers + void onKeyPress (FKeyEvent*); + void onWheel (FWheelEvent*); + void onFocusIn (FFocusEvent*); + void onChildFocusIn (FFocusEvent*); + void onChildFocusOut (FFocusEvent*); - protected: - // Using-declaration - using FVTerm::clearArea; + protected: + // Using-declaration + using FVTerm::clearArea; - // Accessor - term_area* getPrintArea(); + // Accessor + term_area* getPrintArea(); - // Method - void adjustSize(); - void copy2area(); + // Method + void adjustSize(); + void copy2area(); - private: - // Constants - static const int vertical_border_spacing = 2; - static const int horizontal_border_spacing = 2; + private: + // Constants + static const int vertical_border_spacing = 2; + static const int horizontal_border_spacing = 2; - // Disable copy constructor - FScrollView (const FScrollView&); + // Disable copy constructor + FScrollView (const FScrollView&); - // Disable assignment operator (=) - FScrollView& operator = (const FScrollView&); + // Disable assignment operator (=) + FScrollView& operator = (const FScrollView&); - // Accessors - FPoint getViewportCursorPos(); + // Accessors + FPoint getViewportCursorPos(); - // Methods - void init (FWidget*); - void calculateScrollbarPos(); - void setHorizontalScrollBarVisibility(); - void setVerticalScrollBarVisibility(); - void setViewportCursor(); - void redrawHBar(); - void redrawVBar(); - void drawHBar(); - void drawVBar(); + // Methods + void init (FWidget*); + void calculateScrollbarPos(); + void setHorizontalScrollBarVisibility(); + void setVerticalScrollBarVisibility(); + void setViewportCursor(); + void redrawHBar(); + void redrawVBar(); + void drawHBar(); + void drawVBar(); - // Callback methods - void cb_VBarChange (FWidget*, data_ptr); - void cb_HBarChange (FWidget*, data_ptr); + // Callback methods + void cb_VBarChange (FWidget*, data_ptr); + void cb_HBarChange (FWidget*, data_ptr); - // Data Members - FRect scroll_geometry; - FRect viewport_geometry; - term_area* viewport; // virtual scroll content - FScrollbar* vbar; - FScrollbar* hbar; - int nf_offset; - bool border; - bool use_own_print_area; - fc::scrollBarMode vMode; // fc:Auto, fc::Hidden or fc::Scroll - fc::scrollBarMode hMode; + // Data Members + FRect scroll_geometry; + FRect viewport_geometry; + term_area* viewport; // virtual scroll content + FScrollbar* vbar; + FScrollbar* hbar; + int nf_offset; + bool border; + bool use_own_print_area; + fc::scrollBarMode vMode; // fc:Auto, fc::Hidden or fc::Scroll + fc::scrollBarMode hMode; }; #pragma pack(pop) diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index 1c551eea..0d76b651 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -2,6 +2,8 @@ // Provides: class FStatusKey // class FStatusBar +#include + #include "fstatusbar.h" //---------------------------------------------------------------------- @@ -84,7 +86,7 @@ bool FStatusKey::setMouseFocus(bool on) //---------------------------------------------------------------------- void FStatusKey::init (FWidget* parent) { - setGeometry (1,1,1,1); + setGeometry (1, 1, 1, 1); if ( parent && parent->isInstanceOf("FStatusBar") ) { @@ -120,7 +122,7 @@ FStatusBar::FStatusBar(FWidget* parent) } //---------------------------------------------------------------------- -FStatusBar::~FStatusBar() +FStatusBar::~FStatusBar() // destructor { // delete all keys if ( ! key_list.empty() ) diff --git a/src/fstatusbar.h b/src/fstatusbar.h index ea321785..387f423b 100644 --- a/src/fstatusbar.h +++ b/src/fstatusbar.h @@ -36,6 +36,8 @@ #ifndef FSTATUSBAR_H #define FSTATUSBAR_H +#include + #include "fwindow.h" @@ -51,60 +53,60 @@ class FStatusBar; class FStatusKey : public FWidget { - public: - // Constructors - explicit FStatusKey (FWidget* = 0); - FStatusKey (int, const FString&, FWidget* = 0); + public: + // Constructors + explicit FStatusKey (FWidget* = 0); + FStatusKey (int, const FString&, FWidget* = 0); - // Destructor - virtual ~FStatusKey(); + // Destructor + virtual ~FStatusKey(); - // Accessors - virtual const char* getClassName() const; - virtual int getKey() const; - virtual FString getText() const; + // Accessors + virtual const char* getClassName() const; + virtual int getKey() const; + virtual FString getText() const; - // Mutators - void setActive(); - void unsetActive(); - bool setMouseFocus(bool); - bool setMouseFocus(); - bool unsetMouseFocus(); + // Mutators + void setActive(); + void unsetActive(); + bool setMouseFocus(bool); + bool setMouseFocus(); + bool unsetMouseFocus(); - // Inquiry - bool isActivated() const; - bool hasMouseFocus() const; + // Inquiry + bool isActivated() const; + bool hasMouseFocus() const; - // Event handler - void onAccel (FAccelEvent*); + // Event handler + void onAccel (FAccelEvent*); - protected: - // Mutators - void setKey (int); - void setText (const FString&); + protected: + // Mutators + void setKey (int); + void setText (const FString&); - private: - // Disable copy constructor - FStatusKey (const FStatusKey&); + private: + // Disable copy constructor + FStatusKey (const FStatusKey&); - // Disable assignment operator (=) - FStatusKey& operator = (const FStatusKey&); + // Disable assignment operator (=) + FStatusKey& operator = (const FStatusKey&); - // Methods - void init (FWidget*); - void processActivate(); - FStatusBar* getConnectedStatusbar() const; - void setConnectedStatusbar (FStatusBar*); + // Methods + void init (FWidget*); + void processActivate(); + FStatusBar* getConnectedStatusbar() const; + void setConnectedStatusbar (FStatusBar*); - // Friend class - friend class FStatusBar; + // Friend class + friend class FStatusBar; - // Data Members - int key; - FString text; - bool active; - bool mouse_focus; - FStatusBar* bar; + // Data Members + int key; + FString text; + bool active; + bool mouse_focus; + FStatusBar* bar; }; #pragma pack(pop) @@ -168,67 +170,67 @@ inline void FStatusKey::setConnectedStatusbar (FStatusBar* sb) class FStatusBar : public FWindow { - public: - // Constructor - explicit FStatusBar (FWidget* = 0); + public: + // Constructor + explicit FStatusBar (FWidget* = 0); - // Destructor - virtual ~FStatusBar(); + // Destructor + virtual ~FStatusBar(); - // Accessors - virtual const char* getClassName() const; - FStatusKey* getStatusKey (int) const; - FString getMessage() const; - uInt getCount() const; + // Accessors + virtual const char* getClassName() const; + FStatusKey* getStatusKey (int) const; + FString getMessage() const; + uInt getCount() const; - // Mutators - void activateKey (int); - void deactivateKey (int); - void setMessage (const FString&); + // Mutators + void activateKey (int); + void deactivateKey (int); + void setMessage (const FString&); - // Inquiries - bool isActivated (int) const; - bool hasActivatedKey(); + // Inquiries + bool isActivated (int) const; + bool hasActivatedKey(); - // Methods - void hide(); - void drawMessage(); - void clearMessage(); - void insert (FStatusKey*); - void remove (FStatusKey*); - void remove (int); - void clear(); - void adjustSize(); + // Methods + void hide(); + void drawMessage(); + void clearMessage(); + void insert (FStatusKey*); + void remove (FStatusKey*); + void remove (int); + void clear(); + void adjustSize(); - // Event handlers - void onMouseDown (FMouseEvent*); - void onMouseUp (FMouseEvent*); - void onMouseMove (FMouseEvent*); + // Event handlers + void onMouseDown (FMouseEvent*); + void onMouseUp (FMouseEvent*); + void onMouseMove (FMouseEvent*); - // Callback method - void cb_statuskey_activated (FWidget*, data_ptr); + // Callback method + void cb_statuskey_activated (FWidget*, data_ptr); - private: - // Typedef - typedef std::vector keyList; + private: + // Typedef + typedef std::vector keyList; - // Disable copy constructor - FStatusBar (const FStatusBar&); + // Disable copy constructor + FStatusBar (const FStatusBar&); - // Disable assignment operator (=) - FStatusBar& operator = (const FStatusBar&); + // Disable assignment operator (=) + FStatusBar& operator = (const FStatusBar&); - // Methods - void init(); - void draw(); - void drawKeys(); + // Methods + void init(); + void draw(); + void drawKeys(); - // Data Members - keyList key_list; - FString text; - bool mouse_down; - int x; - int x_msg; + // Data Members + keyList key_list; + FString text; + bool mouse_down; + int x; + int x_msg; }; #pragma pack(pop) diff --git a/src/fstring.cpp b/src/fstring.cpp index 40e8acd1..d44fe0ec 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -1,6 +1,9 @@ // File: fstring.cpp // Provides: class FString +#include +#include + #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; @@ -808,7 +811,7 @@ double FString::toDouble() const if ( ret >= HUGE_VAL || ret <= -HUGE_VAL ) throw std::overflow_error ("overflow"); - if ( std::fabs(ret) < DBL_EPSILON ) // ret == 0.0l + if ( std::fabs(ret) < DBL_EPSILON ) // ret == 0.0l throw std::underflow_error ("underflow"); } @@ -1155,7 +1158,6 @@ FString& FString::setFormatedNumber (uLong num, char separator) if ( num && ++n % 3 == 0 ) *--s = separator; - } while ( num ); diff --git a/src/fstring.h b/src/fstring.h index f6c0ae7c..d2d0e5d6 100644 --- a/src/fstring.h +++ b/src/fstring.h @@ -40,290 +40,290 @@ class FString { - public: - // Typedef - typedef const wchar_t* iterator; + public: + // Typedef + typedef const wchar_t* iterator; - // Constructors - FString (); - explicit FString (int); - explicit FString (uInt); - FString (int, wchar_t); - FString (uInt, wchar_t); - FString (int, char); - FString (uInt, char); - FString (const FString&); // implicit conversion copy constructor - FString (const std::wstring&); // implicit conversion constructor - FString (const wchar_t*); // implicit conversion constructor - FString (const std::string&); // implicit conversion constructor - FString (const char*); // implicit conversion constructor - FString (const wchar_t); // implicit conversion constructor - FString (const char); // implicit conversion constructor + // Constructors + FString (); + explicit FString (int); + explicit FString (uInt); + FString (int, wchar_t); + FString (uInt, wchar_t); + FString (int, char); + FString (uInt, char); + FString (const FString&); // implicit conversion copy constructor + FString (const std::wstring&); // implicit conversion constructor + FString (const wchar_t*); // implicit conversion constructor + FString (const std::string&); // implicit conversion constructor + FString (const char*); // implicit conversion constructor + FString (const wchar_t); // implicit conversion constructor + FString (const char); // implicit conversion constructor - // Destructor - virtual ~FString (); + // Destructor + virtual ~FString (); - // Overloaded operators - FString& operator = (const FString&); - FString& operator = (const std::wstring&); - const FString& operator = (const wchar_t*); - FString& operator = (const std::string&); - const FString& operator = (const char*); - const FString& operator = (const wchar_t); - const FString& operator = (const char); + // Overloaded operators + FString& operator = (const FString&); + FString& operator = (const std::wstring&); + const FString& operator = (const wchar_t*); + FString& operator = (const std::string&); + const FString& operator = (const char*); + const FString& operator = (const wchar_t); + const FString& operator = (const char); - const FString& operator += (const FString&); - const FString& operator += (const std::wstring&); - const FString& operator += (const wchar_t*); - const FString& operator += (const std::string&); - const FString& operator += (const char*); - const FString& operator += (const wchar_t); - const FString& operator += (const char); + const FString& operator += (const FString&); + const FString& operator += (const std::wstring&); + const FString& operator += (const wchar_t*); + const FString& operator += (const std::string&); + const FString& operator += (const char*); + const FString& operator += (const wchar_t); + const FString& operator += (const char); - const FString operator + (const FString&); - const FString operator + (const std::wstring&); - const FString operator + (const wchar_t*); - const FString operator + (const std::string&); - const FString operator + (const char*); - const FString operator + (const wchar_t); - const FString operator + (const char); + const FString operator + (const FString&); + const FString operator + (const std::wstring&); + const FString operator + (const wchar_t*); + const FString operator + (const std::string&); + const FString operator + (const char*); + const FString operator + (const wchar_t); + const FString operator + (const char); - wchar_t& operator [] (int); - wchar_t& operator [] (uInt); - const FString& operator () (); + wchar_t& operator [] (int); + wchar_t& operator [] (uInt); + const FString& operator () (); - bool operator < (const FString&) const; - bool operator < (const std::wstring&) const; - bool operator < (const wchar_t*) const; - bool operator < (const std::string&) const; - bool operator < (const char*) const; - bool operator < (const wchar_t) const; - bool operator < (const char) const; - bool operator <= (const FString&) const; - bool operator <= (const std::wstring&) const; - bool operator <= (const wchar_t*) const; - bool operator <= (const std::string&) const; - bool operator <= (const char*) const; - bool operator <= (const wchar_t) const; - bool operator <= (const char) const; - bool operator == (const FString&) const; - bool operator == (const std::wstring&) const; - bool operator == (const wchar_t*) const; - bool operator == (const std::string&) const; - bool operator == (const char*) const; - bool operator == (const wchar_t) const; - bool operator == (const char) const; - bool operator != (const FString&) const; - bool operator != (const std::wstring&) const; - bool operator != (const wchar_t*) const; - bool operator != (const std::string&) const; - bool operator != (const char*) const; - bool operator != (const wchar_t) const; - bool operator != (const char) const; - bool operator >= (const FString&) const; - bool operator >= (const std::wstring&) const; - bool operator >= (const wchar_t*) const; - bool operator >= (const std::string&) const; - bool operator >= (const char*) const; - bool operator >= (const wchar_t) const; - bool operator >= (const char) const; - bool operator > (const FString&) const; - bool operator > (const std::wstring&) const; - bool operator > (const wchar_t*) const; - bool operator > (const std::string&) const; - bool operator > (const char*) const; - bool operator > (const wchar_t) const; - bool operator > (const char) const; + bool operator < (const FString&) const; + bool operator < (const std::wstring&) const; + bool operator < (const wchar_t*) const; + bool operator < (const std::string&) const; + bool operator < (const char*) const; + bool operator < (const wchar_t) const; + bool operator < (const char) const; + bool operator <= (const FString&) const; + bool operator <= (const std::wstring&) const; + bool operator <= (const wchar_t*) const; + bool operator <= (const std::string&) const; + bool operator <= (const char*) const; + bool operator <= (const wchar_t) const; + bool operator <= (const char) const; + bool operator == (const FString&) const; + bool operator == (const std::wstring&) const; + bool operator == (const wchar_t*) const; + bool operator == (const std::string&) const; + bool operator == (const char*) const; + bool operator == (const wchar_t) const; + bool operator == (const char) const; + bool operator != (const FString&) const; + bool operator != (const std::wstring&) const; + bool operator != (const wchar_t*) const; + bool operator != (const std::string&) const; + bool operator != (const char*) const; + bool operator != (const wchar_t) const; + bool operator != (const char) const; + bool operator >= (const FString&) const; + bool operator >= (const std::wstring&) const; + bool operator >= (const wchar_t*) const; + bool operator >= (const std::string&) const; + bool operator >= (const char*) const; + bool operator >= (const wchar_t) const; + bool operator >= (const char) const; + bool operator > (const FString&) const; + bool operator > (const std::wstring&) const; + bool operator > (const wchar_t*) const; + bool operator > (const std::string&) const; + bool operator > (const char*) const; + bool operator > (const wchar_t) const; + bool operator > (const char) const; - operator const char* () const { return c_str(); } + operator const char* () const { return c_str(); } - // Non-member operators - friend std::ostream& operator << (std::ostream& outstr, const FString& s); - friend std::istream& operator >> (std::istream& instr, FString& s); - friend std::wostream& operator << (std::wostream& outstr, const FString& s); - friend std::wistream& operator >> (std::wistream& instr, FString& s); + // Non-member operators + friend std::ostream& operator << (std::ostream& outstr, const FString& s); + friend std::istream& operator >> (std::istream& instr, FString& s); + friend std::wostream& operator << (std::wostream& outstr, const FString& s); + friend std::wistream& operator >> (std::wistream& instr, FString& s); - friend const FString operator + (const FString&, const FString&); - friend const FString operator + (const FString&, const wchar_t); - friend const FString operator + (const std::wstring&, const FString&); - friend const FString operator + (const wchar_t*, const FString&); - friend const FString operator + (const std::string&, const FString&); - friend const FString operator + (const char*, const FString&); - friend const FString operator + (const wchar_t, const FString&); - friend const FString operator + (const char, const FString&); - friend const FString operator + (const wchar_t, const std::wstring&); + friend const FString operator + (const FString&, const FString&); + friend const FString operator + (const FString&, const wchar_t); + friend const FString operator + (const std::wstring&, const FString&); + friend const FString operator + (const wchar_t*, const FString&); + friend const FString operator + (const std::string&, const FString&); + friend const FString operator + (const char*, const FString&); + friend const FString operator + (const wchar_t, const FString&); + friend const FString operator + (const char, const FString&); + friend const FString operator + (const wchar_t, const std::wstring&); - // inquiries - bool isNull() const; - bool isEmpty() const; + // inquiries + bool isNull() const; + bool isEmpty() const; - // Methods - uInt getLength() const; - uInt getUTF8length() const; + // Methods + uInt getLength() const; + uInt getUTF8length() const; - iterator begin() const; - iterator end() const; - wchar_t front() const; - wchar_t back() const; + iterator begin() const; + iterator end() const; + wchar_t front() const; + wchar_t back() const; - FString& sprintf (const wchar_t*, ...); - FString& sprintf (const char*, ...) - #if defined(__clang__) - __attribute__((__format__ (__printf__, 2, 3))) - #elif defined(__GNUC__) - __attribute__ ((format (printf, 2, 3))) - #endif - ; - FString clear(); + FString& sprintf (const wchar_t*, ...); + FString& sprintf (const char*, ...) +#if defined(__clang__) + __attribute__((__format__ (__printf__, 2, 3))) +#elif defined(__GNUC__) + __attribute__ ((format (printf, 2, 3))) +#endif + ; + FString clear(); - const wchar_t* wc_str() const; - const char* c_str() const; - const std::string toString() const; + const wchar_t* wc_str() const; + const char* c_str() const; + const std::string toString() const; - FString toLower() const; - FString toUpper() const; + FString toLower() const; + FString toUpper() const; - sInt16 toShort() const; - uInt16 toUShort() const; - int toInt() const; - uInt toUInt() const; - long toLong() const; - uLong toULong() const; - float toFloat() const; - double toDouble() const; + sInt16 toShort() const; + uInt16 toUShort() const; + int toInt() const; + uInt toUInt() const; + long toLong() const; + uLong toULong() const; + float toFloat() const; + double toDouble() const; - FString ltrim() const; - FString rtrim() const; - FString trim() const; + FString ltrim() const; + FString rtrim() const; + FString trim() const; - FString left (int) const; - FString left (uInt) const; - FString right (int) const; - FString right (uInt) const; - FString mid (int, int) const; - FString mid (uInt, uInt) const; + FString left (int) const; + FString left (uInt) const; + FString right (int) const; + FString right (uInt) const; + FString mid (int, int) const; + FString mid (uInt, uInt) const; - std::vector split (const FString&); - std::vector split (std::wstring&); - std::vector split (const wchar_t*); - std::vector split (const std::string&); - std::vector split (const char*); - std::vector split (const wchar_t); - std::vector split (const char); + std::vector split (const FString&); + std::vector split (const std::wstring&); + std::vector split (const wchar_t*); + std::vector split (const std::string&); + std::vector split (const char*); + std::vector split (const wchar_t); + std::vector split (const char); - FString& setString (const wchar_t*); - FString& setString (const char*); + FString& setString (const wchar_t*); + FString& setString (const char*); - FString& setNumber (sInt16); - FString& setNumber (uInt16); - FString& setNumber (int); - FString& setNumber (uInt); - FString& setNumber (long); - FString& setNumber (uLong); - FString& setNumber (float, int = 8); - FString& setNumber (double, int = 11); - FString& setNumber (lDouble, int = 11); + FString& setNumber (sInt16); + FString& setNumber (uInt16); + FString& setNumber (int); + FString& setNumber (uInt); + FString& setNumber (long); + FString& setNumber (uLong); + FString& setNumber (float, int = 8); + FString& setNumber (double, int = 11); + FString& setNumber (lDouble, int = 11); - FString& setFormatedNumber (sInt16, char = nl_langinfo(THOUSEP)[0]); - FString& setFormatedNumber (uInt16, char = nl_langinfo(THOUSEP)[0]); - FString& setFormatedNumber (int, char = nl_langinfo(THOUSEP)[0]); - FString& setFormatedNumber (uInt, char = nl_langinfo(THOUSEP)[0]); - FString& setFormatedNumber (long, char = nl_langinfo(THOUSEP)[0]); - FString& setFormatedNumber (uLong, char = nl_langinfo(THOUSEP)[0]); + FString& setFormatedNumber (sInt16, char = nl_langinfo(THOUSEP)[0]); + FString& setFormatedNumber (uInt16, char = nl_langinfo(THOUSEP)[0]); + FString& setFormatedNumber (int, char = nl_langinfo(THOUSEP)[0]); + FString& setFormatedNumber (uInt, char = nl_langinfo(THOUSEP)[0]); + FString& setFormatedNumber (long, char = nl_langinfo(THOUSEP)[0]); + FString& setFormatedNumber (uLong, char = nl_langinfo(THOUSEP)[0]); - const FString& insert (const FString&, uInt); - const FString& insert (const wchar_t*, uInt); - const FString& insert (const char*, uInt); - const FString& insert (const wchar_t, uInt); - const FString& insert (const char, uInt); + const FString& insert (const FString&, uInt); + const FString& insert (const wchar_t*, uInt); + const FString& insert (const char*, uInt); + const FString& insert (const wchar_t, uInt); + const FString& insert (const char, uInt); - FString replace (const FString&, const FString&); - FString replace (const FString&, const std::wstring&); - FString replace (const FString&, const wchar_t*); - FString replace (const FString&, const std::string&); - FString replace (const FString&, const char*); - FString replace (const FString&, const wchar_t); - FString replace (const FString&, const char); - FString replace (const std::wstring&, const FString&); - FString replace (const std::wstring&, const std::wstring&); - FString replace (const std::wstring&, const wchar_t*); - FString replace (const std::wstring&, const std::string&); - FString replace (const std::wstring&, const char*); - FString replace (const std::wstring&, const wchar_t); - FString replace (const std::wstring&, const char); - FString replace (const std::string&, const FString&); - FString replace (const std::string&, const std::wstring&); - FString replace (const std::string&, const wchar_t*); - FString replace (const std::string&, const std::string&); - FString replace (const std::string&, const char*); - FString replace (const std::string&, const wchar_t); - FString replace (const std::string&, const char); - FString replace (const wchar_t*, const FString&); - FString replace (const wchar_t*, const std::wstring&); - FString replace (const wchar_t*, const wchar_t*); - FString replace (const wchar_t*, const std::string&); - FString replace (const wchar_t*, const char*); - FString replace (const wchar_t*, const wchar_t); - FString replace (const wchar_t*, const char); - FString replace (const char*, const FString&); - FString replace (const char*, const std::wstring&); - FString replace (const char*, const wchar_t*); - FString replace (const char*, const std::string&); - FString replace (const char*, const char*); - FString replace (const char*, const wchar_t); - FString replace (const char*, const char); - FString replace (const wchar_t, const FString&); - FString replace (const wchar_t, const std::wstring&); - FString replace (const wchar_t, const wchar_t*); - FString replace (const wchar_t, const std::string&); - FString replace (const wchar_t, const char*); - FString replace (const wchar_t, const wchar_t); - FString replace (const wchar_t, const char); - FString replace (const char, const FString&); - FString replace (const char, const std::wstring&); - FString replace (const char, const wchar_t*); - FString replace (const char, const std::string&); - FString replace (const char, const char*); - FString replace (const char, const wchar_t); - FString replace (const char, const char); + FString replace (const FString&, const FString&); + FString replace (const FString&, const std::wstring&); + FString replace (const FString&, const wchar_t*); + FString replace (const FString&, const std::string&); + FString replace (const FString&, const char*); + FString replace (const FString&, const wchar_t); + FString replace (const FString&, const char); + FString replace (const std::wstring&, const FString&); + FString replace (const std::wstring&, const std::wstring&); + FString replace (const std::wstring&, const wchar_t*); + FString replace (const std::wstring&, const std::string&); + FString replace (const std::wstring&, const char*); + FString replace (const std::wstring&, const wchar_t); + FString replace (const std::wstring&, const char); + FString replace (const std::string&, const FString&); + FString replace (const std::string&, const std::wstring&); + FString replace (const std::string&, const wchar_t*); + FString replace (const std::string&, const std::string&); + FString replace (const std::string&, const char*); + FString replace (const std::string&, const wchar_t); + FString replace (const std::string&, const char); + FString replace (const wchar_t*, const FString&); + FString replace (const wchar_t*, const std::wstring&); + FString replace (const wchar_t*, const wchar_t*); + FString replace (const wchar_t*, const std::string&); + FString replace (const wchar_t*, const char*); + FString replace (const wchar_t*, const wchar_t); + FString replace (const wchar_t*, const char); + FString replace (const char*, const FString&); + FString replace (const char*, const std::wstring&); + FString replace (const char*, const wchar_t*); + FString replace (const char*, const std::string&); + FString replace (const char*, const char*); + FString replace (const char*, const wchar_t); + FString replace (const char*, const char); + FString replace (const wchar_t, const FString&); + FString replace (const wchar_t, const std::wstring&); + FString replace (const wchar_t, const wchar_t*); + FString replace (const wchar_t, const std::string&); + FString replace (const wchar_t, const char*); + FString replace (const wchar_t, const wchar_t); + FString replace (const wchar_t, const char); + FString replace (const char, const FString&); + FString replace (const char, const std::wstring&); + FString replace (const char, const wchar_t*); + FString replace (const char, const std::string&); + FString replace (const char, const char*); + FString replace (const char, const wchar_t); + FString replace (const char, const char); - FString replaceControlCodes() const; - FString expandTabs (int = 8) const; - FString removeDel() const; - FString removeBackspaces() const; + FString replaceControlCodes() const; + FString expandTabs (int = 8) const; + FString removeDel() const; + FString removeBackspaces() const; - const FString& overwrite (const FString&, uInt); - const FString& overwrite (const wchar_t*, uInt); - const FString& overwrite (const wchar_t, uInt); + const FString& overwrite (const FString&, uInt); + const FString& overwrite (const wchar_t*, uInt); + const FString& overwrite (const wchar_t, uInt); - const FString& remove (uInt, uInt); - bool includes (const FString&); - bool includes (const wchar_t*); - bool includes (const char*); - bool includes (const wchar_t); - bool includes (const char); + const FString& remove (uInt, uInt); + bool includes (const FString&); + bool includes (const wchar_t*); + bool includes (const char*); + bool includes (const wchar_t); + bool includes (const char); - private: - // Constants - static const uInt FWDBUFFER = 15; - static const uInt INPBUFFER = 200; - static const uInt CHAR_SIZE = sizeof(wchar_t); // bytes per character - static const char* const bad_alloc_str; + private: + // Constants + static const uInt FWDBUFFER = 15; + static const uInt INPBUFFER = 200; + static const uInt CHAR_SIZE = sizeof(wchar_t); // bytes per character + static const char* const bad_alloc_str; - // Methods - void initLength (uInt); - void _assign (const wchar_t*); - void _insert (uInt, uInt, const wchar_t*); - void _remove (uInt, uInt); - char* wc_to_c_str (const wchar_t*) const; - wchar_t* c_to_wc_str (const char*) const; - wchar_t* extractToken (wchar_t**, const wchar_t*, const wchar_t*); + // Methods + void initLength (uInt); + void _assign (const wchar_t*); + void _insert (uInt, uInt, const wchar_t*); + void _remove (uInt, uInt); + char* wc_to_c_str (const wchar_t*) const; + wchar_t* c_to_wc_str (const char*) const; + wchar_t* extractToken (wchar_t**, const wchar_t*, const wchar_t*); - // Data Members - wchar_t* string; - uInt length; - uInt bufsize; - mutable char* c_string; + // Data Members + wchar_t* string; + uInt length; + uInt bufsize; + mutable char* c_string; }; @@ -363,7 +363,7 @@ inline wchar_t FString::back() const } //---------------------------------------------------------------------- -inline std::vector FString::split (std::wstring& s) +inline std::vector FString::split (const std::wstring& s) { return split(FString(s)); } //---------------------------------------------------------------------- diff --git a/src/fswitch.h b/src/fswitch.h index 1c5cc80e..8343fae2 100644 --- a/src/fswitch.h +++ b/src/fswitch.h @@ -45,39 +45,39 @@ class FSwitch : public FToggleButton { - public: - // Constructors - explicit FSwitch (FWidget* = 0); - FSwitch (const FString&, FWidget* = 0); + public: + // Constructors + explicit FSwitch (FWidget* = 0); + FSwitch (const FString&, FWidget* = 0); - // Destructor - virtual ~FSwitch(); + // Destructor + virtual ~FSwitch(); - // Accessor - const char* getClassName() const; + // Accessor + const char* getClassName() const; - // Mutator - void setText (const FString&); + // Mutator + void setText (const FString&); - // Event handlers - void onKeyPress (FKeyEvent*); - void onMouseDown (FMouseEvent*); - void onMouseUp (FMouseEvent*); + // Event handlers + void onKeyPress (FKeyEvent*); + void onMouseDown (FMouseEvent*); + void onMouseUp (FMouseEvent*); - private: - // Disable copy constructor - FSwitch (const FSwitch&); + private: + // Disable copy constructor + FSwitch (const FSwitch&); - // Disable assignment operator (=) - FSwitch& operator = (const FSwitch&); + // Disable assignment operator (=) + FSwitch& operator = (const FSwitch&); - // Methods - void draw(); - void drawCheckButton(); + // Methods + void draw(); + void drawCheckButton(); - // Data Members - int switch_offset_pos; - bool button_pressed; + // Data Members + int switch_offset_pos; + bool button_pressed; }; #pragma pack(pop) diff --git a/src/fterm.cpp b/src/fterm.cpp index ff7be6cf..d7388479 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -1,6 +1,11 @@ // File: fterm.cpp // Provides: class FTerm +#include +#include +#include +#include + #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); } @@ -359,8 +364,8 @@ bool FTerm::setRawMode (bool on) t.c_iflag &= uInt(~(IXON | BRKINT | PARMRK)); // defines the terminal special characters for noncanonical read - t.c_cc[VTIME] = 0; // Timeout in deciseconds - t.c_cc[VMIN] = 1; // Minimum number of characters + t.c_cc[VTIME] = 0; // Timeout in deciseconds + t.c_cc[VMIN] = 1; // Minimum number of characters // set the new termios settings setTTY (t); @@ -386,7 +391,7 @@ bool FTerm::setRawMode (bool on) } //---------------------------------------------------------------------- -bool FTerm::setUTF8 (bool on) // UTF-8 (Unicode) +bool FTerm::setUTF8 (bool on) // UTF-8 (Unicode) { if ( on == utf8_state ) return utf8_state; @@ -465,7 +470,7 @@ int FTerm::parseKeyString ( char buffer[] char* k = Fkey[i].string; len = (k) ? int(std::strlen(k)) : 0; - if ( k && std::strncmp(k, buffer, uInt(len)) == 0 ) // found + if ( k && std::strncmp(k, buffer, uInt(len)) == 0 ) // found { n = len; @@ -486,7 +491,7 @@ int FTerm::parseKeyString ( char buffer[] char* kmeta = Fmetakey[i].string; // The string is never null len = int(std::strlen(kmeta)); - if ( std::strncmp(kmeta, buffer, uInt(len)) == 0 ) // found + if ( std::strncmp(kmeta, buffer, uInt(len)) == 0 ) // found { if ( len == 2 && ( buffer[1] == 'O' || buffer[1] == '[' @@ -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; } @@ -1727,8 +1730,8 @@ void FTerm::initCygwinCharMap() for (int i = 0; i <= lastCharItem; i++ ) { - if ( character[i][fc::UTF8] == fc::BlackUpPointingTriangle // ▲ - || character[i][fc::UTF8] == fc::BlackDownPointingTriangle // ▼ + if ( character[i][fc::UTF8] == fc::BlackUpPointingTriangle // ▲ + || character[i][fc::UTF8] == fc::BlackDownPointingTriangle // ▼ || character[i][fc::UTF8] == fc::SquareRoot ) // SquareRoot √ character[i][fc::PC] = character[i][fc::ASCII]; } @@ -1788,10 +1791,10 @@ void FTerm::xtermMetaSendsESC (bool on) // activate/deactivate the xterm meta key sends escape prefix if ( on ) - putstring (CSI "?1036s" // save meta key sends escape - CSI "?1036h"); // enable meta key sends escape + putstring (CSI "?1036s" // save meta key sends escape + CSI "?1036h"); // enable meta key sends escape else - putstring (CSI "?1036r"); // restore meta key sends escape + putstring (CSI "?1036r"); // restore meta key sends escape std::fflush(stdout); } @@ -1804,17 +1807,17 @@ void FTerm::xtermMouse (bool on) return; if ( on ) - putstring (CSI "?1001s" // save old highlight mouse tracking - CSI "?1000h" // enable x11 mouse tracking - CSI "?1002h" // enable cell motion mouse tracking - CSI "?1015h" // enable urxvt mouse mode - CSI "?1006h"); // enable SGR mouse mode + putstring (CSI "?1001s" // save old highlight mouse tracking + CSI "?1000h" // enable x11 mouse tracking + CSI "?1002h" // enable cell motion mouse tracking + CSI "?1015h" // enable urxvt mouse mode + CSI "?1006h"); // enable SGR mouse mode else - putstring (CSI "?1006l" // disable SGR mouse mode - CSI "?1015l" // disable urxvt mouse mode - CSI "?1002l" // disable cell motion mouse tracking - CSI "?1000l" // disable x11 mouse tracking - CSI "?1001r"); // restore old highlight mouse tracking + putstring (CSI "?1006l" // disable SGR mouse mode + CSI "?1015l" // disable urxvt mouse mode + CSI "?1002l" // disable cell motion mouse tracking + CSI "?1000l" // disable x11 mouse tracking + CSI "?1001r"); // restore old highlight mouse tracking std::fflush(stdout); } @@ -1938,7 +1941,7 @@ uChar FTerm::readAttributeController (uChar index) res = inb (attrib_cntlr_read); inb (input_status_1); // switch to data mode - index = (index & 0x1f) | 0x20; // set bit 5 (enable display) + index = (index & 0x1f) | 0x20; // set bit 5 (enable display) outb (index, attrib_cntlr_write); inb (attrib_cntlr_read); return res; @@ -1958,7 +1961,7 @@ void FTerm::writeAttributeController (uChar index, uChar data) outb (data, attrib_cntlr_write); inb (input_status_1); // switch to data mode - index = (index & 0x1f) | 0x20; // set bit 5 (enable display) + index = (index & 0x1f) | 0x20; // set bit 5 (enable display) outb (index, attrib_cntlr_write); outb (data, attrib_cntlr_write); } @@ -1985,7 +1988,7 @@ int FTerm::setBlinkAsIntensity (bool on) // Uses blink-bit as background intensity. // That permits 16 colors for background - if ( getuid() != 0 ) // Direct hardware access requires root privileges + if ( getuid() != 0 ) // Direct hardware access requires root privileges return -2; if ( fd_tty < 0 ) @@ -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, '/'); @@ -2258,7 +2261,7 @@ int FTerm::setScreenFont ( uChar* fontdata, uInt count try { - font.data = new uChar[data_size](); // initialize with 0 + font.data = new uChar[data_size](); // initialize with 0 } catch (const std::bad_alloc& ex) { @@ -2757,14 +2760,14 @@ char* FTerm::parseSecDA (char*& current_termtype) switch ( terminal_id_type ) { - case 0: // DEC VT100 + case 0: // DEC VT100 if ( terminal_id_version == 115 ) kde_konsole = true; else if ( terminal_id_version == 136 ) putty_terminal = true; // PuTTY break; - case 1: // DEC VT220 + case 1: // DEC VT220 if ( ! sec_da_supported ) { if ( terminal_id_version == 2 ) // also used by apple terminal @@ -2779,11 +2782,11 @@ char* FTerm::parseSecDA (char*& current_termtype) } break; - case 2: // DEC VT240 - case 18: // DEC VT330 - case 19: // DEC VT340 + case 2: // DEC VT240 + case 18: // DEC VT330 + case 19: // DEC VT340 - case 24: // DEC VT320 + case 24: // DEC VT320 #if defined(__NetBSD__) || defined(__OpenBSD__) if ( terminal_id_version == 20 && isWSConsConsole() ) { @@ -2798,10 +2801,10 @@ char* FTerm::parseSecDA (char*& current_termtype) } break; #endif - case 41: // DEC VT420 - case 61: // DEC VT510 - case 64: // DEC VT520 - case 65: // DEC VT525 + case 41: // DEC VT420 + case 61: // DEC VT510 + case 64: // DEC VT520 + case 65: // DEC VT525 break; case 32: // Tera Term @@ -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; } } @@ -2918,14 +2921,14 @@ void FTerm::init_alt_charset() uInt* p = std::find ( character[0] , character[lastCharItem] + num , utf8char ); - if ( p != character[lastCharItem] + num ) // found in character + if ( p != character[lastCharItem] + num ) // found in character { int item = int(std::distance(character[0], p) / num); if ( altChar ) - character[item][fc::VT100] = altChar; // update alternate character set + character[item][fc::VT100] = altChar; // update alternate character set else - character[item][fc::VT100] = 0; // delete vt100 char in character + character[item][fc::VT100] = 0; // delete vt100 char in character } } } @@ -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(ESC "%@" ESC "(U"); } else { // Select null mapping - tcap[fc::t_enter_pc_charset_mode].string = \ + TCAP(fc::t_enter_pc_charset_mode) = \ const_cast(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(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(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(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(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(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(ESC "(0"); - tcap[fc::t_exit_alt_charset_mode].string = \ + TCAP(fc::t_exit_alt_charset_mode) = \ const_cast(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(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(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(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(CSI "3%p1%dm"); - tcap[fc::t_set_a_background].string = \ + TCAP(fc::t_set_a_background) = \ const_cast(CSI "4%p1%dm"); } - tcap[fc::t_orig_pair].string = \ + TCAP(fc::t_orig_pair) = \ const_cast(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; - FTermcap::attr_without_color = 18; + 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(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(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(CSI "38;5;%p1%dm"); - tcap[fc::t_set_a_background].string = \ + TCAP(fc::t_set_a_background) = \ const_cast(CSI "48;5;%p1%dm"); - tcap[fc::t_exit_attribute_mode].string = \ + TCAP(fc::t_exit_attribute_mode) = \ const_cast(CSI "0m" SI); - tcap[fc::t_orig_pair].string = \ + TCAP(fc::t_orig_pair) = \ const_cast(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(CSI "21m"); // Exit single underline, too - tcap[fc::t_exit_dbl_underline_mode].string = \ + TCAP(fc::t_exit_dbl_underline_mode) = \ const_cast(CSI "24m"); - tcap[fc::t_exit_bold_mode].string = \ + TCAP(fc::t_exit_bold_mode) = \ const_cast(CSI "22m"); // Exit dim, too - tcap[fc::t_exit_dim_mode].string = \ + TCAP(fc::t_exit_dim_mode) = \ const_cast(CSI "22m"); - tcap[fc::t_exit_underline_mode].string = \ + TCAP(fc::t_exit_underline_mode) = \ const_cast(CSI "24m"); - tcap[fc::t_exit_blink_mode].string = \ + TCAP(fc::t_exit_blink_mode) = \ const_cast(CSI "25m"); - tcap[fc::t_exit_reverse_mode].string = \ + TCAP(fc::t_exit_reverse_mode) = \ const_cast(CSI "27m"); - tcap[fc::t_exit_secure_mode].string = \ + TCAP(fc::t_exit_secure_mode) = \ const_cast(CSI "28m"); - tcap[fc::t_enter_crossed_out_mode].string = \ + TCAP(fc::t_enter_crossed_out_mode) = \ const_cast(CSI "9m"); - tcap[fc::t_exit_crossed_out_mode].string = \ + TCAP(fc::t_exit_crossed_out_mode) = \ const_cast(CSI "29m"); } #if defined(__FreeBSD__) || defined(__DragonFly__) if ( isFreeBSDConsole() ) { - tcap[fc::t_acs_chars].string = \ + TCAP(fc::t_acs_chars) = \ const_cast("-\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(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("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; @@ -3625,10 +3633,10 @@ void FTerm::init() { opti_move = new FOptiMove(); opti_attr = new FOptiAttr(); - term = new FRect(0,0,0,0); - mouse = new FPoint(0,0); - vt100_alt_char = new std::map; - encoding_set = new std::map; + term = new FRect(0, 0, 0, 0); + mouse = new FPoint(0, 0); + vt100_alt_char = new std::map; + encoding_set = new std::map; } catch (const std::bad_alloc& ex) { @@ -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 @@ -3752,8 +3761,8 @@ void FTerm::init() struct termios t; tcgetattr (stdin_no, &t); t.c_lflag &= uInt(~(ICANON | ECHO)); - t.c_cc[VTIME] = 1; // Timeout in deciseconds - t.c_cc[VMIN] = 0; // Minimum number of characters + t.c_cc[VTIME] = 1; // Timeout in deciseconds + t.c_cc[VMIN] = 0; // Minimum number of characters tcsetattr (stdin_no, TCSANOW, &t); // Initialize 256 colors terminals @@ -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); } @@ -3983,13 +3992,13 @@ void FTerm::init() // set 200 Hz beep (100 ms) setBeep(200, 100); - signal(SIGTERM, FTerm::signal_handler); // Termination signal - signal(SIGQUIT, FTerm::signal_handler); // Quit from keyboard (Ctrl-\) - signal(SIGINT, FTerm::signal_handler); // Keyboard interrupt (Ctrl-C) - signal(SIGABRT, FTerm::signal_handler); // Abort signal from abort(3) - signal(SIGILL, FTerm::signal_handler); // Illegal Instruction - signal(SIGSEGV, FTerm::signal_handler); // Invalid memory reference - signal(SIGWINCH, FTerm::signal_handler); // Window resize signal + signal(SIGTERM, FTerm::signal_handler); // Termination signal + signal(SIGQUIT, FTerm::signal_handler); // Quit from keyboard (Ctrl-\) + signal(SIGINT, FTerm::signal_handler); // Keyboard interrupt (Ctrl-C) + signal(SIGABRT, FTerm::signal_handler); // Abort signal from abort(3) + signal(SIGILL, FTerm::signal_handler); // Illegal Instruction + signal(SIGSEGV, FTerm::signal_handler); // Invalid memory reference + signal(SIGWINCH, FTerm::signal_handler); // Window resize signal // turn off hardware echo noHardwareEcho(); @@ -4002,13 +4011,13 @@ void FTerm::init() void FTerm::finish() { // set default signal handler - signal(SIGWINCH, SIG_DFL); // Window resize signal - signal(SIGSEGV, SIG_DFL); // Invalid memory reference - signal(SIGILL, SIG_DFL); // Illegal Instruction - signal(SIGABRT, SIG_DFL); // Abort signal from abort(3) - signal(SIGINT, SIG_DFL); // Keyboard interrupt (Ctrl-C) - signal(SIGQUIT, SIG_DFL); // Quit from keyboard (Ctrl-\) - signal(SIGTERM, SIG_DFL); // Termination signal + signal(SIGWINCH, SIG_DFL); // Window resize signal + signal(SIGSEGV, SIG_DFL); // Invalid memory reference + signal(SIGILL, SIG_DFL); // Illegal Instruction + signal(SIGABRT, SIG_DFL); // Abort signal from abort(3) + signal(SIGINT, SIG_DFL); // Keyboard interrupt (Ctrl-C) + signal(SIGQUIT, SIG_DFL); // Quit from keyboard (Ctrl-\) + signal(SIGTERM, SIG_DFL); // Termination signal if ( xterm_title && xterm_terminal && ! rxvt_terminal ) setXTermTitle (*xterm_title); @@ -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); } @@ -4169,7 +4178,7 @@ uInt FTerm::cp437_to_unicode (uChar c) for (register uInt i = 0; i <= lastCP437Item; i++) { - if ( cp437_to_ucs[i][0] == c ) // found + if ( cp437_to_ucs[i][0] == c ) // found { ucs = cp437_to_ucs[i][1]; break; diff --git a/src/fterm.h b/src/fterm.h index ae60bf34..6a6559c5 100644 --- a/src/fterm.h +++ b/src/fterm.h @@ -34,9 +34,9 @@ #endif #if defined(__linux__) - #include // Linux framebuffer console - #include // need for gpm keyboard modifiers - #include // is deprecated, use instead + #include // Linux framebuffer console + #include // need for gpm keyboard modifiers + #include // is deprecated #include #endif @@ -53,10 +53,9 @@ #include #include - #include #include -#include // termcap +#include // termcap #include #include #include @@ -66,6 +65,7 @@ #include #include #include +#include #include "fc.h" #include "fobject.h" @@ -91,397 +91,398 @@ class FTerm { - public: - // Typedefs - typedef FOptiAttr::char_data char_data; + public: + // Typedefs + typedef FOptiAttr::char_data char_data; - static struct modifier_key // bit field - { - uChar shift : 1; // 0..1 - uChar alt_gr : 1; // 0..1 - uChar ctrl : 1; // 0..1 - uChar alt : 1; // 0..1 - uChar : 4; // padding bits - } mod_key; + static struct modifier_key // bit field + { + uChar shift : 1; // 0..1 + uChar alt_gr : 1; // 0..1 + uChar ctrl : 1; // 0..1 + uChar alt : 1; // 0..1 + uChar : 4; // padding bits + } mod_key; - // Constructor - explicit FTerm (bool = false); + // Constructor + explicit FTerm (bool = false); - // Destructor - virtual ~FTerm(); + // Destructor + virtual ~FTerm(); - // Accessors - virtual const char* getClassName() const; - static termios getTTY(); - static int getLineNumber(); - static int getColumnNumber(); - static const FString getKeyName (int); + // Accessors + virtual const char* getClassName() const; + static termios getTTY(); + static int getLineNumber(); + static int getColumnNumber(); + static const FString getKeyName (int); #if defined(__linux__) - static modifier_key& getLinuxModifierKey(); + static modifier_key& getLinuxModifierKey(); #endif - static char* getTermType(); - static char* getTermName(); - static int getTabstop(); - static int getMaxColor(); + static char* getTermType(); + static char* getTermName(); + static int getTabstop(); + static int getMaxColor(); #if defined(__linux__) - static fc::linuxConsoleCursorStyle getLinuxConsoleCursorStyle(); + static fc::linuxConsoleCursorStyle getLinuxConsoleCursorStyle(); #endif #if defined(__FreeBSD__) || defined(__DragonFly__) - static fc::freebsdConsoleCursorStyle getFreeBSDConsoleCursorStyle(); + static fc::freebsdConsoleCursorStyle getFreeBSDConsoleCursorStyle(); #endif #if DEBUG - static const FString& getAnswerbackString(); - static const FString& getSecDAString(); + static const FString& getAnswerbackString(); + static const FString& getSecDAString(); #endif - // Inquiries - static bool isKeyTimeout (timeval*, register long); - static bool isNormal (char_data*&); - static bool isRaw(); - static bool hasPCcharset(); - static bool hasUTF8(); - static bool hasVT100(); - static bool hasASCII(); - static bool isMonochron(); - static bool isXTerminal(); - static bool isAnsiTerminal(); - static bool isRxvtTerminal(); - static bool isUrxvtTerminal(); - static bool isMltermTerminal(); - static bool isPuttyTerminal(); - static bool isKdeTerminal(); - static bool isGnomeTerminal(); - static bool isKtermTerminal(); - static bool isTeraTerm(); - static bool isCygwinTerminal(); - static bool isMinttyTerm(); - static bool isLinuxTerm(); - static bool isScreenTerm(); - static bool isTmuxTerm(); - static bool isInputDataPending(); - static bool isNewFont(); - static bool isUTF8(); - static bool isUTF8_linux_terminal(); + // Inquiries + static bool isKeyTimeout (timeval*, register long); + static bool isNormal (char_data*&); + static bool isRaw(); + static bool hasPCcharset(); + static bool hasUTF8(); + static bool hasVT100(); + static bool hasASCII(); + static bool isMonochron(); + static bool isXTerminal(); + static bool isAnsiTerminal(); + static bool isRxvtTerminal(); + static bool isUrxvtTerminal(); + static bool isMltermTerminal(); + static bool isPuttyTerminal(); + static bool isKdeTerminal(); + static bool isGnomeTerminal(); + static bool isKtermTerminal(); + static bool isTeraTerm(); + static bool isCygwinTerminal(); + static bool isMinttyTerm(); + static bool isLinuxTerm(); + static bool isScreenTerm(); + static bool isTmuxTerm(); + static bool isInputDataPending(); + static bool isNewFont(); + static bool isUTF8(); + static bool isUTF8_linux_terminal(); - // Mutators - static bool setCursorOptimisation (bool); - static void setXTermDefaultColors (bool); + // Mutators + static bool setCursorOptimisation (bool); + 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 noHardwareEcho(); - static bool setRawMode (bool); - static bool setRawMode(); - static bool unsetRawMode(); - static bool setCookedMode(); - static void disableAltScreen(); - static bool setUTF8 (bool); - static bool setUTF8(); - static bool unsetUTF8(); - static bool setNonBlockingInput (bool); - static bool setNonBlockingInput(); - static bool unsetNonBlockingInput(); + static void setTTY (const termios&); + static void noHardwareEcho(); + static bool setRawMode (bool); + static bool setRawMode(); + static bool unsetRawMode(); + static bool setCookedMode(); + static void disableAltScreen(); + static bool setUTF8 (bool); + static bool setUTF8(); + static bool unsetUTF8(); + static bool setNonBlockingInput (bool); + static bool setNonBlockingInput(); + static bool unsetNonBlockingInput(); - // Methods - static int parseKeyString (char[], int, timeval*); - static bool& unprocessedInput(); - static bool setVGAFont(); - static bool setNewFont(); - static bool setOldFont(); - static char* moveCursor (int, int, int, int); - static void printMoveDurations(); - static char* enableCursor(); - static char* disableCursor(); - static void detectTermSize(); - static void setTermSize (int, int); - static void setKDECursor (fc::kdeKonsoleCursorShape); - static const FString* getXTermFont(); - static const FString* getXTermTitle(); - static const FString getXTermColorName (int); - static void setXTermCursorStyle (fc::xtermCursorStyle); - static void setXTermTitle (const FString&); - static void setXTermForeground (const FString&); - static void setXTermBackground (const FString&); - static void setXTermCursorColor (const FString&); - static void setXTermMouseForeground (const FString&); - static void setXTermMouseBackground (const FString&); - static void setXTermHighlightBackground (const FString&); - static void setXTermDefaults(); - static void resetXTermColors(); - static void resetXTermForeground(); - static void resetXTermBackground(); - static void resetXTermCursorColor(); - static void resetXTermMouseForeground(); - static void resetXTermMouseBackground(); - static void resetXTermHighlightBackground(); - static void resetXTermDefaults(); - static void saveColorMap(); - static void resetColorMap(); - static void setPalette (short, int, int, int); - static void setBeep (int, int); - static void resetBeep(); - static void beep(); + // Methods + static int parseKeyString (char[], int, timeval*); + static bool& unprocessedInput(); + static bool setVGAFont(); + static bool setNewFont(); + static bool setOldFont(); + static char* moveCursor (int, int, int, int); + static void printMoveDurations(); + static char* enableCursor(); + static char* disableCursor(); + static void detectTermSize(); + static void setTermSize (int, int); + static void setKDECursor (fc::kdeKonsoleCursorShape); + static const FString* getXTermFont(); + static const FString* getXTermTitle(); + static const FString getXTermColorName (int); + static void setXTermCursorStyle (fc::xtermCursorStyle); + static void setXTermTitle (const FString&); + static void setXTermForeground (const FString&); + static void setXTermBackground (const FString&); + static void setXTermCursorColor (const FString&); + static void setXTermMouseForeground (const FString&); + static void setXTermMouseBackground (const FString&); + static void setXTermHighlightBackground (const FString&); + static void setXTermDefaults(); + static void resetXTermColors(); + static void resetXTermForeground(); + static void resetXTermBackground(); + static void resetXTermCursorColor(); + static void resetXTermMouseForeground(); + static void resetXTermMouseBackground(); + static void resetXTermHighlightBackground(); + static void resetXTermDefaults(); + static void saveColorMap(); + static void resetColorMap(); + static void setPalette (short, int, int, int); + static void setBeep (int, int); + static void resetBeep(); + static void beep(); - static void setEncoding (std::string); - static std::string getEncoding(); + static void setEncoding (std::string); + static std::string getEncoding(); - static bool scrollTermForward(); - static bool scrollTermReverse(); + static bool scrollTermForward(); + static bool scrollTermReverse(); - static const FString getAnswerbackMsg(); - static const FString getSecDA(); + static const FString getAnswerbackMsg(); + static const FString getSecDA(); - // function pointer -> static function - static int (*Fputchar)(int); + // function pointer -> static function + static int (*Fputchar)(int); - static void putstringf (const char* const, ...) - #if defined(__clang__) - __attribute__((__format__ (__printf__, 1, 2))) - #elif defined(__GNUC__) - __attribute__ ((format (printf, 1, 2))) - #endif - ; - static void putstring (const char* const, int = 1); - static int putchar_ASCII (register int); - static int putchar_UTF8 (register int); - static int UTF8decode (const char[]); + static void putstringf (const char* const, ...) +#if defined(__clang__) + __attribute__((__format__ (__printf__, 1, 2))) +#elif defined(__GNUC__) + __attribute__ ((format (printf, 1, 2))) +#endif + ; + static void putstring (const char* const, int = 1); + static int putchar_ASCII (register int); + static int putchar_UTF8 (register int); + 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: - // Methods + protected: + // Methods #if defined(__linux__) - static void initLinuxConsoleCharMap(); + static void initLinuxConsoleCharMap(); #endif #if defined(__FreeBSD__) || defined(__DragonFly__) - static void initFreeBSDConsoleCharMap(); + static void initFreeBSDConsoleCharMap(); #endif - static void initCygwinCharMap(); - static void initTeraTermCharMap(); + static void initCygwinCharMap(); + static void initTeraTermCharMap(); - static bool charEncodable (uInt); - static uInt charEncode (uInt); - static uInt charEncode (uInt, fc::encoding); - static char* changeAttribute ( char_data*& - , char_data*& ); - static bool hasChangedTermSize(); - static void changeTermSizeFinished(); - static void xtermMetaSendsESC (bool); - static void xtermMouse (bool); - static void enableXTermMouse(); - static void disableXTermMouse(); + static bool charEncodable (uInt); + static uInt charEncode (uInt); + static uInt charEncode (uInt, fc::encoding); + static char* changeAttribute ( char_data*& + , char_data*& ); + static bool hasChangedTermSize(); + static void changeTermSizeFinished(); + static void xtermMetaSendsESC (bool); + static void xtermMouse (bool); + static void enableXTermMouse(); + static void disableXTermMouse(); #ifdef F_HAVE_LIBGPM - static bool gpmMouse (bool); - static bool enableGpmMouse(); - static bool disableGpmMouse(); - static bool isGpmMouseEnabled(); + static bool gpmMouse (bool); + static bool enableGpmMouse(); + static bool disableGpmMouse(); + static bool isGpmMouseEnabled(); #endif // F_HAVE_LIBGPM - static FPoint& getMousePos(); - static void setMousePos (const FPoint&); - static void setMousePos (short, short); + static FPoint& getMousePos(); + static void setMousePos (const FPoint&); + static void setMousePos (short, short); - // Data Members - static int stdin_no; - static int stdout_no; - static int erase_ch_length; - static int repeat_char_length; - static int clr_bol_length; - static int clr_eol_length; - static int cursor_addres_lengths; - static bool NewFont; - static bool VGAFont; - static bool no_shadow_character; - static bool no_half_block_character; - static bool cursor_optimisation; - static bool xterm_default_colors; - static bool use_alternate_screen; - static fc::encoding Encoding; - static char exit_message[8192]; + // Data Members + static int stdin_no; + static int stdout_no; + static int erase_ch_length; + static int repeat_char_length; + static int clr_bol_length; + static int clr_eol_length; + static int cursor_addres_lengths; + static bool NewFont; + static bool VGAFont; + static bool no_shadow_character; + static bool no_half_block_character; + static bool cursor_optimisation; + static bool xterm_default_colors; + static bool use_alternate_screen; + static fc::encoding Encoding; + static char exit_message[8192]; - private: - // Typedefs - typedef FTermcap::tcap_map termcap_map; + private: + // Typedefs + typedef FTermcap::tcap_map termcap_map; - typedef struct - { - uChar red; - uChar green; - uChar blue; - } dacreg; + typedef struct + { + uChar red; + uChar green; + uChar blue; + } dacreg; - // Constants - static const int NEED_MORE_DATA = -1; // parseKeyString return value + // Constants + static const int NEED_MORE_DATA = -1; // parseKeyString return value - // Disable copy constructor - FTerm (const FTerm&); - // Disable assignment operator (=) - FTerm& operator = (const FTerm&); + // Disable copy constructor + FTerm (const FTerm&); + // Disable assignment operator (=) + FTerm& operator = (const FTerm&); - // Inquiries + // Inquiries #if defined(__linux__) - static int isLinuxConsole(); + static int isLinuxConsole(); #endif #if defined(__FreeBSD__) || defined(__DragonFly__) - static bool isFreeBSDConsole(); + static bool isFreeBSDConsole(); #endif #if defined(__NetBSD__) || defined(__OpenBSD__) - static bool isWSConsConsole(); + static bool isWSConsConsole(); #endif - // Methods + // Methods #if defined(__linux__) - static uInt16 getInputStatusRegisterOne(); - static uChar readAttributeController (uChar); - static void writeAttributeController (uChar, uChar); - static uChar getAttributeMode(); - static void setAttributeMode (uChar); - static int setBlinkAsIntensity (bool); - static int getFramebuffer_bpp(); + static uInt16 getInputStatusRegisterOne(); + static uChar readAttributeController (uChar); + static void writeAttributeController (uChar, uChar); + static uChar getAttributeMode(); + static void setAttributeMode (uChar); + static int setBlinkAsIntensity (bool); + static int getFramebuffer_bpp(); #endif - static int openConsole(); - static int closeConsole(); - static void getSystemTermType(); - static void storeTTYsettings(); - static void restoreTTYsettings(); + static int openConsole(); + static int closeConsole(); + static void getSystemTermType(); + static void storeTTYsettings(); + static void restoreTTYsettings(); #if defined(__linux__) - static int getScreenFont(); - static int setScreenFont (uChar*, uInt, uInt, uInt, bool = false); - static int setUnicodeMap (struct unimapdesc*); - static int getUnicodeMap (); - static void initLinuxConsole(); + static int getScreenFont(); + static int setScreenFont ( uChar*, uInt, uInt, uInt + , bool = false ); + static int setUnicodeMap (struct unimapdesc*); + static int getUnicodeMap (); + static void initLinuxConsole(); #endif #if defined(__FreeBSD__) || defined(__DragonFly__) - static bool saveFreeBSDAltKey(); - static bool setFreeBSDAltKey (uInt); - static bool setFreeBSDAlt2Meta(); - static bool resetFreeBSDAlt2Meta(); - static void initFreeBSDConsole(); + static bool saveFreeBSDAltKey(); + static bool setFreeBSDAltKey (uInt); + static bool setFreeBSDAlt2Meta(); + static bool resetFreeBSDAlt2Meta(); + static void initFreeBSDConsole(); #endif #if defined(__NetBSD__) || defined(__OpenBSD__) - static bool saveWSConsEncoding(); - static bool setWSConsEncoding (kbd_t); - static bool setWSConsMetaEsc(); - static bool resetWSConsEncoding(); - static void initWSConsConsole(); + static bool saveWSConsEncoding(); + static bool setWSConsEncoding (kbd_t); + static bool setWSConsMetaEsc(); + static bool resetWSConsEncoding(); + static void initWSConsConsole(); #endif - static uInt getBaudRate (const struct termios*); - static char* init_256colorTerminal(); - static char* parseAnswerbackMsg (char*&); - static char* parseSecDA (char*&); - static void oscPrefix(); - static void oscPostfix(); - static void init_alt_charset(); - static void init_pc_charset(); - static void init_termcaps(); - static void init_encoding(); - void init(); - void finish(); - static uInt cp437_to_unicode (uChar); - static void signal_handler (int); + static uInt getBaudRate (const struct termios*); + static char* init_256colorTerminal(); + static char* parseAnswerbackMsg (char*&); + static char* parseSecDA (char*&); + static void oscPrefix(); + static void oscPostfix(); + static void init_alt_charset(); + static void init_pc_charset(); + static void init_termcaps(); + static void init_encoding(); + void init(); + void finish(); + static uInt cp437_to_unicode (uChar); + static void signal_handler (int); - // Data Members - static std::map * vt100_alt_char; - static std::map * encoding_set; - static FTermcap::tcap_map* tcap; + // Data Members + static std::map * vt100_alt_char; + static std::map * encoding_set; + static FTermcap::tcap_map* tcap; - static bool mouse_support; - static bool terminal_detection; - static bool raw_mode; - static bool input_data_pending; - static bool non_blocking_stdin; - static bool gpm_mouse_enabled; - static bool pc_charset_console; - static bool utf8_input; - static bool utf8_state; - static bool utf8_console; - static bool utf8_linux_terminal; - static bool force_vt100; - static bool vt100_console; - static bool ascii_console; - static bool color256; - static bool monochron; - static bool xterm_terminal; - static bool ansi_terminal; - static bool rxvt_terminal; - static bool urxvt_terminal; - static bool mlterm_terminal; - static bool putty_terminal; - static bool kde_konsole; - static bool gnome_terminal; - static bool kterm_terminal; - static bool tera_terminal; - static bool cygwin_terminal; - static bool mintty_terminal; - static bool linux_terminal; - static bool netbsd_terminal; - static bool openbsd_terminal; - static bool screen_terminal; - static bool tmux_terminal; - static char termtype[30]; - static char* term_name; - static char* locale_name; - static char* locale_xterm; - static FRect* term; // current terminal geometry - static FPoint* mouse; // mouse click position + static bool mouse_support; + static bool terminal_detection; + static bool raw_mode; + static bool input_data_pending; + static bool non_blocking_stdin; + static bool gpm_mouse_enabled; + static bool pc_charset_console; + static bool utf8_input; + static bool utf8_state; + static bool utf8_console; + static bool utf8_linux_terminal; + static bool force_vt100; + static bool vt100_console; + static bool ascii_console; + static bool color256; + static bool monochron; + static bool xterm_terminal; + static bool ansi_terminal; + static bool rxvt_terminal; + static bool urxvt_terminal; + static bool mlterm_terminal; + static bool putty_terminal; + static bool kde_konsole; + static bool gnome_terminal; + static bool kterm_terminal; + static bool tera_terminal; + static bool cygwin_terminal; + static bool mintty_terminal; + static bool linux_terminal; + static bool netbsd_terminal; + static bool openbsd_terminal; + static bool screen_terminal; + static bool tmux_terminal; + static char termtype[256]; + static char term_name[256]; + static char* locale_name; + static char* locale_xterm; + static FRect* term; // current terminal geometry + static FPoint* mouse; // mouse click position - static int stdin_status_flags; - static int fd_tty; - static uInt baudrate; - static bool resize_term; + static int stdin_status_flags; + static int fd_tty; + static uInt baudrate; + static bool resize_term; - static struct termios term_init; - static fc::linuxConsoleCursorStyle linux_console_cursor_style; - static fc::freebsdConsoleCursorStyle freebsd_console_cursor_style; - static struct console_font_op screen_font; - static struct unimapdesc screen_unicode_map; + static struct termios term_init; + static fc::linuxConsoleCursorStyle linux_console_cursor_style; + static fc::freebsdConsoleCursorStyle freebsd_console_cursor_style; + static struct console_font_op screen_font; + static struct unimapdesc screen_unicode_map; #if defined(__FreeBSD__) || defined(__DragonFly__) - static uInt bsd_alt_keymap; + static uInt bsd_alt_keymap; #endif #if defined(__NetBSD__) || defined(__OpenBSD__) - static kbd_t wscons_keyboard_encoding; + static kbd_t wscons_keyboard_encoding; #endif - static FOptiMove* opti_move; - static FOptiAttr* opti_attr; - static const FString* xterm_font; - static const FString* xterm_title; - static const FString* answer_back; - static const FString* sec_da; + static FOptiMove* opti_move; + static FOptiAttr* opti_attr; + static const FString* xterm_font; + static const FString* xterm_title; + static const FString* answer_back; + static const FString* sec_da; - struct - { - dacreg d[16]; - } color_map; + struct + { + dacreg d[16]; + } color_map; }; #pragma pack(pop) diff --git a/src/ftermbuffer.cpp b/src/ftermbuffer.cpp index 024a6f0c..bc2db509 100644 --- a/src/ftermbuffer.cpp +++ b/src/ftermbuffer.cpp @@ -1,6 +1,9 @@ // File: ftermbuffer.cpp // Provides: class FTermBuffer +#include +#include + #include "ftermbuffer.h" @@ -15,7 +18,7 @@ FTermBuffer::FTermBuffer() { } //---------------------------------------------------------------------- -FTermBuffer::~FTermBuffer() // destructor +FTermBuffer::~FTermBuffer() // destructor { } @@ -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); @@ -116,7 +119,7 @@ int FTermBuffer::write (const FString& s) { while ( *p ) { - char_data nc; // next character + char_data nc; // next character nc = FVTerm::getAttribute(); nc.code = *p; nc.attr.bit.no_changes = false; @@ -126,7 +129,7 @@ int FTermBuffer::write (const FString& s) p++; len++; - } // end of while + } // end of while } return len; @@ -135,7 +138,7 @@ int FTermBuffer::write (const FString& s) //---------------------------------------------------------------------- int FTermBuffer::write (register int c) { - char_data nc; // next character + char_data nc; // next character nc = FVTerm::getAttribute(); nc.code = c; nc.attr.bit.no_changes = false; @@ -148,8 +151,9 @@ int FTermBuffer::write (register int c) // FTermBuffer non-member operators //---------------------------------------------------------------------- -std::vector< FTermBuffer::char_data>& operator << ( std::vector& termString - , const FTermBuffer& buf ) +std::vector& operator << \ + ( std::vector& termString + , const FTermBuffer& buf ) { if ( ! buf.data.empty() ) termString.assign(buf.data.begin(), buf.data.end()); diff --git a/src/ftermbuffer.h b/src/ftermbuffer.h index e96454c2..7c118983 100644 --- a/src/ftermbuffer.h +++ b/src/ftermbuffer.h @@ -12,8 +12,9 @@ #ifndef FTERMBUFFER_H #define FTERMBUFFER_H -#include #include // std::stringstream +#include +#include #include "fvterm.h" #include "fstring.h" @@ -28,50 +29,50 @@ class FTermBuffer { - public: - // Typedef - typedef FOptiAttr::char_data char_data; + public: + // Typedef + typedef FOptiAttr::char_data char_data; - // Constructor - explicit FTermBuffer(); + // Constructor + explicit FTermBuffer(); - // Destructor - virtual ~FTermBuffer(); + // Destructor + virtual ~FTermBuffer(); - // Overloaded operators - template FTermBuffer& operator << (const type&); - // Non-member operators - friend std::vector& operator << ( std::vector& - , const FTermBuffer& ); + // Overloaded operators + template FTermBuffer& operator << (const type&); + // Non-member operators + friend std::vector& operator << ( std::vector& + , const FTermBuffer& ); - // Accessors - virtual const char* getClassName() const; - int getLength() const; + // Accessors + virtual const char* getClassName() const; + int getLength() const; - // Inquiry - bool isEmpty () const; + // Inquiry + bool isEmpty() const; - // Methods - void clear(); - int writef (const wchar_t*, ...); - int writef (const char*, ...) - #if defined(__clang__) - __attribute__((__format__ (__printf__, 2, 3))) - #elif defined(__GNUC__) - __attribute__ ((format (printf, 2, 3))) - #endif - ; - int write (const std::wstring&); - int write (const wchar_t*); - int write (const char*); - int write (const std::string&); - int write (const FString&); - int write (int); - FTermBuffer& write (); - std::vector getBuffer(); + // Methods + void clear(); + int writef (const wchar_t*, ...); + int writef (const char*, ...) +#if defined(__clang__) + __attribute__((__format__ (__printf__, 2, 3))) +#elif defined(__GNUC__) + __attribute__ ((format (printf, 2, 3))) +#endif + ; + int write (const std::wstring&); + int write (const wchar_t*); + int write (const char*); + int write (const std::string&); + int write (const FString&); + int write (int); + FTermBuffer& write (); + std::vector getBuffer(); - private: - std::vector data; + private: + std::vector data; }; #pragma pack(pop) diff --git a/src/ftermcap.h b/src/ftermcap.h index 6d106843..239710ca 100644 --- a/src/ftermcap.h +++ b/src/ftermcap.h @@ -11,6 +11,10 @@ #ifndef FTERMCAP_H #define FTERMCAP_H +// FTermcap string macro +#define TCAP(s) tcap[(s)].string + +#include //---------------------------------------------------------------------- // class FTermcap @@ -20,50 +24,50 @@ class FTermcap { - public: - // Typedef - typedef struct - { - char* string; - char tname[3]; - } - tcap_map; + public: + // Typedef + typedef struct + { + char* string; + char tname[3]; + } + tcap_map; - // Constructors - FTermcap() - { } + // Constructors + FTermcap() + { } - // Destructor - ~FTermcap() - { } + // Destructor + ~FTermcap() + { } - // Accessor - static tcap_map* getTermcapMap() - { - return tcap; - } + // Accessor + static tcap_map* getTermcapMap() + { + return tcap; + } - // Mutator - static void setTermcapMap (tcap_map* t) - { - tcap = t; - } + // Mutator + static void setTermcapMap (tcap_map* t) + { + tcap = t; + } - // Data Members - static bool background_color_erase; - static bool automatic_left_margin; - static bool automatic_right_margin; - static bool eat_nl_glitch; - static bool ansi_default_color; - static bool osc_support; - static bool no_utf8_acs_chars; - static int max_color; - static int tabstop; - static int attr_without_color; + // Data Members + static bool background_color_erase; + static bool automatic_left_margin; + static bool automatic_right_margin; + static bool eat_nl_glitch; + static bool ansi_default_color; + static bool osc_support; + static bool no_utf8_acs_chars; + static int max_color; + static int tabstop; + static int attr_without_color; - private: - // Data Members - static tcap_map* tcap; + private: + // Data Members + static tcap_map* tcap; }; #pragma pack(pop) diff --git a/src/ftextview.h b/src/ftextview.h index e8599236..5778074b 100644 --- a/src/ftextview.h +++ b/src/ftextview.h @@ -28,6 +28,8 @@ #ifndef FTEXTVIEW_H #define FTEXTVIEW_H +#include + #include "fapplication.h" #include "fscrollbar.h" #include "fstatusbar.h" @@ -44,78 +46,78 @@ class FTextView : public FWidget { - public: - // Using-declarations - using FWidget::setGeometry; + public: + // Using-declarations + using FWidget::setGeometry; - // Typedef - typedef std::vector stringLines; + // Typedef + typedef std::vector stringLines; - // Constructor - explicit FTextView (FWidget* = 0); + // Constructor + explicit FTextView (FWidget* = 0); - // Destructor - ~FTextView(); + // Destructor + ~FTextView(); - // Accessors - const char* getClassName() const; - uInt getColumns() const; - uInt getRows() const; - const FString getText() const; - const stringLines& getLines() const; + // Accessors + const char* getClassName() const; + uInt getColumns() const; + uInt getRows() const; + const FString getText() const; + const stringLines& getLines() const; - // Mutators - void setGeometry (int, int, int, int, bool = true); - void setPosition (int); - void setText (const FString&); + // Mutators + void setGeometry (int, int, int, int, bool = true); + void setPosition (int); + void setText (const FString&); - // Methods - void hide(); - void append (const FString&); - void insert (const FString&, int); - void replaceRange (const FString&, int, int); - void deleteRange (int, int); - void deleteLine (int); - void clear(); + // Methods + void hide(); + void append (const FString&); + void insert (const FString&, int); + void replaceRange (const FString&, int, int); + void deleteRange (int, int); + void deleteLine (int); + void clear(); - // Event handlers - void onKeyPress (FKeyEvent*); - void onMouseDown (FMouseEvent*); - void onMouseUp (FMouseEvent*); - void onMouseMove (FMouseEvent*); - void onWheel (FWheelEvent*); - void onFocusIn (FFocusEvent*); - void onFocusOut (FFocusEvent*); + // Event handlers + void onKeyPress (FKeyEvent*); + void onMouseDown (FMouseEvent*); + void onMouseUp (FMouseEvent*); + void onMouseMove (FMouseEvent*); + void onWheel (FWheelEvent*); + void onFocusIn (FFocusEvent*); + void onFocusOut (FFocusEvent*); - protected: - // Method - void adjustSize(); + protected: + // Method + void adjustSize(); - private: - // Disable copy constructor - FTextView (const FTextView&); + private: + // Disable copy constructor + FTextView (const FTextView&); - // Disable assignment operator (=) - FTextView& operator = (const FTextView&); + // Disable assignment operator (=) + FTextView& operator = (const FTextView&); - // Methods - void init(); - void draw(); - void drawText(); - void processChanged(); + // Methods + void init(); + void draw(); + void drawText(); + void processChanged(); - // Callback methods - void cb_VBarChange (FWidget*, data_ptr); - void cb_HBarChange (FWidget*, data_ptr); + // Callback methods + void cb_VBarChange (FWidget*, data_ptr); + void cb_HBarChange (FWidget*, data_ptr); - // Data Members - stringLines data; - FScrollbar* vbar; - FScrollbar* hbar; - int xoffset; - int yoffset; - int nf_offset; - uInt maxLineWidth; + // Data Members + stringLines data; + FScrollbar* vbar; + FScrollbar* hbar; + int xoffset; + int yoffset; + int nf_offset; + uInt maxLineWidth; }; #pragma pack(pop) diff --git a/src/ftogglebutton.h b/src/ftogglebutton.h index 9c586f34..f9ac34a8 100644 --- a/src/ftogglebutton.h +++ b/src/ftogglebutton.h @@ -43,99 +43,99 @@ class FButtonGroup; class FToggleButton : public FWidget { - public: - // Using-declaration - using FWidget::setGeometry; + public: + // Using-declaration + using FWidget::setGeometry; - // Constructors - explicit FToggleButton (FWidget* = 0); - FToggleButton (const FString&, FWidget* = 0); + // Constructors + explicit FToggleButton (FWidget* = 0); + FToggleButton (const FString&, FWidget* = 0); - // Destructor - virtual ~FToggleButton(); + // Destructor + virtual ~FToggleButton(); - // Accessors - virtual const char* getClassName() const; - FString& getText(); + // Accessors + virtual const char* getClassName() const; + FString& getText(); - // Mutators - void setGeometry (int, int, int, int, bool = true); - bool setNoUnderline (bool); - bool setNoUnderline(); - bool unsetNoUnderline(); - bool setEnable (bool); - bool setEnable(); - bool unsetEnable(); - bool setDisable(); - bool setFocus (bool); - bool setFocus(); - bool unsetFocus(); - bool setChecked (bool); - bool setChecked(); - bool unsetChecked(); - virtual void setText (const FString&); + // Mutators + void setGeometry (int, int, int, int, bool = true); + bool setNoUnderline (bool); + bool setNoUnderline(); + bool unsetNoUnderline(); + bool setEnable (bool); + bool setEnable(); + bool unsetEnable(); + bool setDisable(); + bool setFocus (bool); + bool setFocus(); + bool unsetFocus(); + bool setChecked (bool); + bool setChecked(); + bool unsetChecked(); + virtual void setText (const FString&); - // Inquiries - bool isChecked(); + // Inquiries + bool isChecked(); - // Methods - void hide(); + // Methods + void hide(); - // Event handlers - void onMouseDown (FMouseEvent*); - void onMouseUp (FMouseEvent*); - void onWheel (FWheelEvent*); - void onAccel (FAccelEvent*); - void onFocusIn (FFocusEvent*); - void onFocusOut (FFocusEvent*); + // Event handlers + void onMouseDown (FMouseEvent*); + void onMouseUp (FMouseEvent*); + void onWheel (FWheelEvent*); + void onAccel (FAccelEvent*); + void onFocusIn (FFocusEvent*); + void onFocusOut (FFocusEvent*); - protected: - // Accessor - uChar getHotkey(); - FButtonGroup* getGroup() const; + protected: + // Accessor + uChar getHotkey(); + FButtonGroup* getGroup() const; - // Mutator - void setHotkeyAccelerator(); + // Mutator + void setHotkeyAccelerator(); - // Inquiries - bool isRadioButton() const; - bool isCheckboxButton() const; - bool hasGroup() const; + // Inquiries + bool isRadioButton() const; + bool isCheckboxButton() const; + bool hasGroup() const; - // Methods - virtual void draw(); - void drawLabel(); - void processClick(); - void processToggle(); + // Methods + virtual void draw(); + void drawLabel(); + void processClick(); + void processToggle(); - // Event handler - virtual void onKeyPress (FKeyEvent*); + // Event handler + virtual void onKeyPress (FKeyEvent*); - // Data Members - bool checked; - int label_offset_pos; - int button_width; // plus margin spaces + // Data Members + bool checked; + int label_offset_pos; + int button_width; // plus margin spaces - private: - // Disable copy constructor - FToggleButton (const FToggleButton&); + private: + // Disable copy constructor + FToggleButton (const FToggleButton&); - // Disable assignment operator (=) - FToggleButton& operator = (const FToggleButton&); + // Disable assignment operator (=) + FToggleButton& operator = (const FToggleButton&); - // Mutator - void setGroup (FButtonGroup*); + // Mutator + void setGroup (FButtonGroup*); - // Methods - void init(); + // Methods + void init(); - // Friend classes - friend class FButtonGroup; + // Friend classes + friend class FButtonGroup; - // Data Members - FButtonGroup* button_group; - bool focus_inside_group; - FString text; + // Data Members + FButtonGroup* button_group; + bool focus_inside_group; + FString text; }; #pragma pack(pop) diff --git a/src/ftooltip.cpp b/src/ftooltip.cpp index f4111590..ccbd7ba8 100644 --- a/src/ftooltip.cpp +++ b/src/ftooltip.cpp @@ -137,7 +137,7 @@ void FToolTip::calculateDimensions() max_line_width = len; } - h = int(text_num_lines) + 2 ; + h = int(text_num_lines) + 2; w = int(max_line_width + 4); if ( r ) diff --git a/src/ftooltip.h b/src/ftooltip.h index 6eb2dffe..c3cea5ba 100644 --- a/src/ftooltip.h +++ b/src/ftooltip.h @@ -33,6 +33,8 @@ #ifndef FTOOLTIP_H #define FTOOLTIP_H +#include + #include "fwindow.h" @@ -45,50 +47,50 @@ class FToolTip : public FWindow { - public: - // Constructor - explicit FToolTip (FWidget* = 0); - FToolTip (const FString&, FWidget* = 0); + public: + // Constructor + explicit FToolTip (FWidget* = 0); + FToolTip (const FString&, FWidget* = 0); - // Destructor - virtual ~FToolTip (); + // Destructor + virtual ~FToolTip (); - // Accessors - const char* getClassName() const; - const FString getText() const; + // Accessors + const char* getClassName() const; + const FString getText() const; - // Mutators - void setText (const FString&); + // Mutators + void setText (const FString&); - // Methods - virtual void draw(); - void show(); - void hide(); + // Methods + virtual void draw(); + void show(); + void hide(); - // Event handler - void onMouseDown (FMouseEvent*); + // Event handler + void onMouseDown (FMouseEvent*); - private: - // Typedef - typedef std::vector textLines; + private: + // Typedef + typedef std::vector textLines; - // Disable copy constructor - FToolTip (const FToolTip&); + // Disable copy constructor + FToolTip (const FToolTip&); - // Disable assignment operator (=) - FToolTip& operator = (const FToolTip&); + // Disable assignment operator (=) + FToolTip& operator = (const FToolTip&); - // Methods - void init(); - void calculateDimensions(); - virtual void adjustSize(); + // Methods + void init(); + void calculateDimensions(); + virtual void adjustSize(); - // Data Members - FString text; - FString* text_components; - textLines text_split; - uInt max_line_width; - uInt text_num_lines; + // Data Members + FString text; + FString* text_components; + textLines text_split; + uInt max_line_width; + uInt text_num_lines; }; #pragma pack(pop) diff --git a/src/ftypes.h b/src/ftypes.h index 34ad0c86..54530d0e 100644 --- a/src/ftypes.h +++ b/src/ftypes.h @@ -5,6 +5,8 @@ #include +#define null NULL + typedef unsigned char uChar; typedef unsigned int uInt; typedef unsigned long uLong; diff --git a/src/fvterm.cpp b/src/fvterm.cpp index c6ce5198..851cf863 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -1,6 +1,10 @@ // File: fvterm.cpp // Provides: class FVTerm +#include +#include +#include + #include "fapplication.h" #include "fvterm.h" #include "fwidget.h" @@ -105,7 +109,7 @@ void FVTerm::setTermXY (register int x, register int y) appendOutputBuffer(move_str); 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, ...) { 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); @@ -475,7 +479,7 @@ int FVTerm::print (term_area* area, const FString& s) int ax = area->cursor_x - 1; int ay = area->cursor_y - 1; - char_data nc; // next character + char_data nc; // next character nc.code = *p; nc.fg_color = next_attribute.fg_color; nc.bg_color = next_attribute.bg_color; @@ -503,7 +507,7 @@ int FVTerm::print (term_area* area, const FString& s) && ax < area->width + area->right_shadow && ay < area->height + area->bottom_shadow ) { - char_data* ac; // area character + char_data* ac; // area character int line_len = area->width + area->right_shadow; ac = &area->text[ay * line_len + ax]; @@ -553,7 +557,7 @@ int FVTerm::print (term_area* area, const FString& s) p++; len++; - } // end of while + } // end of while } return len; @@ -639,7 +643,7 @@ int FVTerm::print (term_area* area, const std::vector& termString) && ax < area->width + area->right_shadow && ay < area->height + area->bottom_shadow ) { - char_data* ac; // area character + char_data* ac; // area character int line_len = area->width + area->right_shadow; ac = &area->text[ay * line_len + ax]; @@ -689,7 +693,7 @@ int FVTerm::print (term_area* area, const std::vector& termString) len++; ++iter; - } // end of while + } // end of while return len; } @@ -713,7 +717,7 @@ int FVTerm::print (register int c) //---------------------------------------------------------------------- int FVTerm::print (term_area* area, register int c) { - char_data nc; // next character + char_data nc; // next character int width, height, rsh, bsh, ax, ay; if ( ! area ) @@ -753,7 +757,7 @@ int FVTerm::print (term_area* area, register int c) && ax < area->width + area->right_shadow && ay < area->height + area->bottom_shadow ) { - char_data* ac; // area character + char_data* ac; // area character int line_len = area->width + area->right_shadow; ac = &area->text[ay * line_len + ax]; @@ -1087,10 +1091,10 @@ void FVTerm::restoreVTerm (const FRect& box) //---------------------------------------------------------------------- void FVTerm::restoreVTerm (int x, int y, int w, int h) { - char_data* tc; // terminal character - char_data* sc; // shown character - char_data s_ch; // shadow character - char_data i_ch; // inherit background character + char_data* tc; // terminal character + char_data* sc; // shown character + char_data s_ch; // shadow character + char_data i_ch; // inherit background character FWidget* widget; x--; @@ -1248,7 +1252,7 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y , win->width + win->right_shadow , win->height + win->bottom_shadow ); - if ( found && geometry.contains(x,y) ) + if ( found && geometry.contains(x, y) ) { char_data* tmp; int line_len = win->width + win->right_shadow; @@ -1336,8 +1340,8 @@ void FVTerm::updateVTerm (term_area* area) // Update area data on VTerm int ax, ay, aw, ah, rsh, bsh, y_end, ol; - char_data* tc; // terminal character - char_data* ac; // area character + char_data* tc; // terminal character + char_data* ac; // area character if ( ! area ) return; @@ -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; @@ -1574,7 +1577,7 @@ bool FVTerm::isInsideArea (int x, int y, term_area* area) ah = area->height; FRect area_geometry(ax, ay, aw, ah); - if ( area_geometry.contains(x,y) ) + if ( area_geometry.contains(x, y) ) return true; else return false; @@ -1613,8 +1616,8 @@ void FVTerm::getArea (int ax, int ay, term_area* area) // Copies a block from the virtual terminal position to the given area int y_end; int length; - char_data* tc; // terminal character - char_data* ac; // area character + char_data* tc; // terminal character + char_data* ac; // area character if ( ! area ) return; @@ -1661,8 +1664,8 @@ void FVTerm::getArea (int x, int y, int w, int h, term_area* area) { // Copies a block from the virtual terminal rectangle to the given area int y_end, length, dx, dy; - char_data* tc; // terminal character - char_data* ac; // area character + char_data* tc; // terminal character + char_data* ac; // area character if ( ! area ) return; @@ -1719,8 +1722,8 @@ void FVTerm::putArea (int ax, int ay, term_area* area) { // Copies the given area block to the virtual terminal position int aw, ah, rsh, bsh, y_end, length, ol; - char_data* tc; // terminal character - char_data* ac; // area character + char_data* tc; // terminal character + char_data* ac; // area character if ( ! area ) return; @@ -1833,10 +1836,10 @@ void FVTerm::scrollAreaForward (term_area* area) int total_width; int length; int y_max; - char_data nc; // next character - char_data* lc; // last character - char_data* sc; // source character - char_data* dc; // destination character + char_data nc; // next character + char_data* lc; // last character + char_data* sc; // source character + char_data* dc; // destination character if ( ! area ) return; @@ -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(); @@ -1894,10 +1897,10 @@ void FVTerm::scrollAreaReverse (term_area* area) int total_width; int length; int y_max; - char_data nc; // next character - char_data* lc; // last character - char_data* sc; // source character - char_data* dc; // destination character + char_data nc; // next character + char_data* lc; // last character + char_data* sc; // source character + char_data* dc; // destination character if ( ! area ) return; @@ -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(); @@ -2058,9 +2061,9 @@ FVTerm::char_data FVTerm::getCharacter ( character_type char_type { // Gets the overlapped or the covered character for the position (x,y) int xx, yy; - char_data* cc; // covered character - char_data s_ch; // shadow character - char_data i_ch; // inherit background character + char_data* cc; // covered character + char_data s_ch; // shadow character + char_data i_ch; // inherit background character FWidget* w; x--; @@ -2120,7 +2123,7 @@ FVTerm::char_data FVTerm::getCharacter ( character_type char_type , win->height + win->bottom_shadow ); // window visible and contains current character - if ( geometry.contains(x,y) ) + if ( geometry.contains(x, y) ) { char_data* tmp; int line_len = win->width + win->right_shadow; @@ -2257,7 +2260,7 @@ void FVTerm::init() try { - term_pos = new FPoint(-1,-1); + term_pos = new FPoint(-1, -1); output_buffer = new std::queue; } catch (const std::bad_alloc& ex) @@ -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); @@ -2367,11 +2370,11 @@ bool FVTerm::clearTerm (int fillchar) { setTermXY (0, 0); appendOutputBuffer (cd); - term_pos->setPoint(-1,-1); + term_pos->setPoint(-1, -1); } else if ( cb ) { - term_pos->setPoint(-1,-1); + term_pos->setPoint(-1, -1); for (int i = 0; i < getLineNumber(); i++) { @@ -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]; @@ -2653,7 +2656,7 @@ void FVTerm::updateTerminalLine (uInt y) { if ( FTermcap::eat_nl_glitch ) { - term_pos->setPoint(-1,-1); + term_pos->setPoint(-1, -1); } else if ( FTermcap::automatic_right_margin ) { @@ -2677,7 +2680,7 @@ bool FVTerm::updateTerminalCursor() if ( isInsideTerminal(x, y) ) { - setTermXY (x,y); + setTermXY (x, y); showCursor(); return true; } @@ -2694,7 +2697,7 @@ bool FVTerm::isInsideTerminal (int x, int y) // Check whether the coordinates are within the virtual terminal FRect term_geometry (0, 0, getColumnNumber(), getLineNumber()); - if ( term_geometry.contains(x,y) ) + if ( term_geometry.contains(x, y) ) return true; else return false; @@ -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); } diff --git a/src/fvterm.h b/src/fvterm.h index 6db8c17b..13dde6e8 100644 --- a/src/fvterm.h +++ b/src/fvterm.h @@ -46,376 +46,376 @@ class FWidget; class FVTerm : public FObject, public FTerm { - public: - // Typedefs and Enumeration - typedef struct - { - uInt xmin; // X-position with the first change - uInt xmax; // X-position with the last change - uInt trans_count; // Number of transparent characters - } line_changes; + public: + // Typedefs and Enumeration + typedef struct + { + uInt xmin; // X-position with the first change + uInt xmax; // X-position with the last change + uInt trans_count; // Number of transparent characters + } line_changes; - typedef FOptiAttr::char_data char_data; - typedef void (FVTerm::*FPreprocessingHandler)(); + typedef FOptiAttr::char_data char_data; + typedef void (FVTerm::*FPreprocessingHandler)(); - struct vterm_preprocessing - { - FVTerm* instance; - FPreprocessingHandler handler; - }; + struct vterm_preprocessing + { + FVTerm* instance; + FPreprocessingHandler handler; + }; - typedef std::vector FPreprocessing; + typedef std::vector FPreprocessing; - // define virtual terminal character properties - struct term_area - { - public: - term_area() - : offset_left (0) - , offset_top (0) - , width (-1) - , height (-1) - , right_shadow (0) - , bottom_shadow (0) - , cursor_x (0) - , cursor_y (0) - , input_cursor_x (-1) - , input_cursor_y (-1) - , widget() - , preprocessing_call() - , changes (0) - , text (0) - , input_cursor_visible (false) - , has_changes (false) - , visible (false) - { } + // define virtual terminal character properties + struct term_area + { + public: + term_area() + : offset_left (0) + , offset_top (0) + , width (-1) + , height (-1) + , right_shadow (0) + , bottom_shadow (0) + , cursor_x (0) + , cursor_y (0) + , input_cursor_x (-1) + , input_cursor_y (-1) + , widget() + , preprocessing_call() + , changes (0) + , text (0) + , input_cursor_visible (false) + , has_changes (false) + , visible (false) + { } - ~term_area() - { } + ~term_area() + { } - int offset_left; // Distance from left terminal side - int offset_top; // Distance from top of the terminal - int width; // Window width - int height; // Window height - int right_shadow; // Right window shadow - int bottom_shadow; // Bottom window shadow - int cursor_x; // X-position for the next write operation - int cursor_y; // Y-position for the next write operation - int input_cursor_x; // X-position input cursor - int input_cursor_y; // Y-position input cursor - FWidget* widget; // Widget that owns this term_area - FPreprocessing preprocessing_call; - line_changes* changes; - char_data* text; // Text data for the output - bool input_cursor_visible; - bool has_changes; - bool visible; + int offset_left; // Distance from left terminal side + int offset_top; // Distance from top of the terminal + int width; // Window width + int height; // Window height + int right_shadow; // Right window shadow + int bottom_shadow; // Bottom window shadow + int cursor_x; // X-position for the next write operation + int cursor_y; // Y-position for the next write operation + int input_cursor_x; // X-position input cursor + int input_cursor_y; // Y-position input cursor + FWidget* widget; // Widget that owns this term_area + FPreprocessing preprocessing_call; + line_changes* changes; + char_data* text; // Text data for the output + bool input_cursor_visible; + bool has_changes; + bool visible; - private: - // Disable copy constructor - term_area (const term_area&); - // Disable assignment operator (=) - term_area& operator = (const term_area&); - }; + private: + // Disable copy constructor + term_area (const term_area&); + // Disable assignment operator (=) + term_area& operator = (const term_area&); + }; - enum covered_state - { - non_covered, - half_covered, - fully_covered - }; + enum covered_state + { + non_covered, + half_covered, + fully_covered + }; - // Constructor - explicit FVTerm (FVTerm* = 0, bool = false); + // Constructor + explicit FVTerm (FVTerm* = 0, bool = false); - // Destructor - ~FVTerm(); + // Destructor + ~FVTerm(); - // Overloaded operators - template FVTerm& operator << (const type&); - FVTerm& operator << (const std::vector&); + // Overloaded operators + template FVTerm& operator << (const type&); + FVTerm& operator << (const std::vector&); - // Accessors - virtual const char* getClassName() const; - static short getTermForegroundColor(); - static short getTermBackgroundColor(); - term_area* getVWin() const; - FPoint getPrintCursor(); - static char_data getAttribute(); + // Accessors + virtual const char* getClassName() const; + static short getTermForegroundColor(); + static short getTermBackgroundColor(); + term_area* getVWin() const; + FPoint getPrintCursor(); + static char_data getAttribute(); - // Mutators - static void setTermXY (register int, register int); - static bool hideCursor (bool); - static bool hideCursor(); - static bool showCursor(); - void setPrintCursor (const FPoint&); - void setPrintCursor (register int, register int); - void setColor (short, short); - static void setNormal(); + // Mutators + static void setTermXY (register int, register int); + static bool hideCursor (bool); + static bool hideCursor(); + static bool showCursor(); + void setPrintCursor (const FPoint&); + void setPrintCursor (register int, register int); + void setColor (short, short); + static void setNormal(); - static bool setBold (register bool); - static bool setBold(); - static bool unsetBold(); + static bool setBold (register bool); + static bool setBold(); + static bool unsetBold(); - static bool setDim (register bool); - static bool setDim(); - static bool unsetDim(); + static bool setDim (register bool); + static bool setDim(); + static bool unsetDim(); - static bool setItalic (register bool); - static bool setItalic(); - static bool unsetItalic(); + static bool setItalic (register bool); + static bool setItalic(); + static bool unsetItalic(); - static bool setUnderline (register bool); - static bool setUnderline(); - static bool unsetUnderline(); + static bool setUnderline (register bool); + static bool setUnderline(); + static bool unsetUnderline(); - static bool setBlink (register bool); - static bool setBlink(); - static bool unsetBlink(); + static bool setBlink (register bool); + static bool setBlink(); + static bool unsetBlink(); - static bool setReverse (register bool); - static bool setReverse(); - static bool unsetReverse(); + static bool setReverse (register bool); + static bool setReverse(); + static bool unsetReverse(); - static bool setStandout (register bool); - static bool setStandout(); - static bool unsetStandout(); + static bool setStandout (register bool); + static bool setStandout(); + static bool unsetStandout(); - static bool setInvisible (register bool); - static bool setInvisible(); - static bool unsetInvisible(); + static bool setInvisible (register bool); + static bool setInvisible(); + static bool unsetInvisible(); - static bool setProtected (register bool); - static bool setProtected(); - static bool unsetProtected(); + static bool setProtected (register bool); + static bool setProtected(); + static bool unsetProtected(); - static bool setCrossedOut (register bool); - static bool setCrossedOut(); - static bool unsetCrossedOut(); + static bool setCrossedOut (register bool); + static bool setCrossedOut(); + static bool unsetCrossedOut(); - static bool setDoubleUnderline (register bool); - static bool setDoubleUnderline(); - static bool unsetDoubleUnderline(); + static bool setDoubleUnderline (register bool); + static bool setDoubleUnderline(); + static bool unsetDoubleUnderline(); - static bool setAltCharset (register bool); - static bool setAltCharset(); - static bool unsetAltCharset(); + static bool setAltCharset (register bool); + static bool setAltCharset(); + static bool unsetAltCharset(); - static bool setPCcharset (register bool); - static bool setPCcharset(); - static bool unsetPCcharset(); + static bool setPCcharset (register bool); + static bool setPCcharset(); + static bool unsetPCcharset(); - static bool setTransparent (register bool); - static bool setTransparent(); - static bool unsetTransparent(); + static bool setTransparent (register bool); + static bool setTransparent(); + static bool unsetTransparent(); - static bool setTransShadow (register bool); - static bool setTransShadow(); - static bool unsetTransShadow(); + static bool setTransShadow (register bool); + static bool setTransShadow(); + static bool unsetTransShadow(); - static bool setInheritBackground (register bool); - static bool setInheritBackground(); - static bool unsetInheritBackground(); + static bool setInheritBackground (register bool); + static bool setInheritBackground(); + static bool unsetInheritBackground(); - // Inquiries - static bool isCursorHidden(); - static bool isBold(); - static bool isDim(); - static bool isItalic(); - static bool isUnderline(); - static bool isBlink(); - static bool isReverse(); - static bool isStandout(); - static bool isInvisible(); - static bool isProtected(); - static bool isCrossedOut(); - static bool isDoubleUnderline(); - static bool isAltCharset(); - static bool isPCcharset(); - static bool isTransparent(); - static bool isTransShadow(); - static bool isInheritBackground(); + // Inquiries + static bool isCursorHidden(); + static bool isBold(); + static bool isDim(); + static bool isItalic(); + static bool isUnderline(); + static bool isBlink(); + static bool isReverse(); + static bool isStandout(); + static bool isInvisible(); + static bool isProtected(); + static bool isCrossedOut(); + static bool isDoubleUnderline(); + static bool isAltCharset(); + static bool isPCcharset(); + static bool isTransparent(); + static bool isTransShadow(); + static bool isInheritBackground(); - // Methods - virtual void clearArea (int = ' '); - void createVTerm (const FRect&); - void createVTerm (int, int); - static void resizeVTerm (const FRect&); - static void resizeVTerm (int, int); - static void putVTerm(); - static void updateTerminal (bool); - static void updateTerminal(); - void addPreprocessingHandler ( FVTerm* - , FPreprocessingHandler ); - void delPreprocessingHandler (FVTerm*); + // Methods + virtual void clearArea (int = ' '); + void createVTerm (const FRect&); + void createVTerm (int, int); + static void resizeVTerm (const FRect&); + static void resizeVTerm (int, int); + static void putVTerm(); + static void updateTerminal (bool); + static void updateTerminal(); + void addPreprocessingHandler ( FVTerm* + , FPreprocessingHandler ); + void delPreprocessingHandler (FVTerm*); - int printf (const wchar_t*, ...); - int printf (const char*, ...) - #if defined(__clang__) - __attribute__((__format__ (__printf__, 2, 3))) - #elif defined(__GNUC__) - __attribute__ ((format (printf, 2, 3))) - #endif - ; - int print (const std::wstring&); - int print (term_area*, const std::wstring&); - int print (const wchar_t*); - int print (term_area*, const wchar_t*); - int print (const char*); - int print (term_area*, const char*); - int print (const std::string&); - int print (term_area*, const std::string&); - int print (const FString&); - int print (term_area*, const FString&); - int print (const std::vector&); - int print (term_area*, const std::vector&); - int print (int); - int print (term_area*, int); - FVTerm& print(); + int printf (const wchar_t*, ...); + int printf (const char*, ...) + #if defined(__clang__) + __attribute__((__format__ (__printf__, 2, 3))) + #elif defined(__GNUC__) + __attribute__ ((format (printf, 2, 3))) + #endif + ; + int print (const std::wstring&); + int print (term_area*, const std::wstring&); + int print (const wchar_t*); + int print (term_area*, const wchar_t*); + int print (const char*); + int print (term_area*, const char*); + int print (const std::string&); + int print (term_area*, const std::string&); + int print (const FString&); + int print (term_area*, const FString&); + int print (const std::vector&); + int print (term_area*, const std::vector&); + int print (int); + int print (term_area*, int); + FVTerm& print(); - protected: - // Enumeration - enum character_type - { - overlapped_character, - covered_character - }; + protected: + // Enumeration + enum character_type + { + overlapped_character, + covered_character + }; - // Accessor - virtual term_area* getPrintArea(); + // Accessor + virtual term_area* getPrintArea(); - // Inquiries - bool hasPrintArea() const; - bool hasChildPrintArea() const; - bool isChildPrintArea() const; - bool isVirtualWindow() const; + // Inquiries + bool hasPrintArea() const; + bool hasChildPrintArea() const; + bool isChildPrintArea() const; + bool isVirtualWindow() const; - // Mutator - static void setInsertCursorStyle (bool on); - static void setInsertCursorStyle(); - static void unsetInsertCursorStyle(); + // Mutator + static void setInsertCursorStyle (bool on); + static void setInsertCursorStyle(); + static void unsetInsertCursorStyle(); - // Methods - void createArea ( const FRect& - , const FPoint& - , term_area*& ); + // Methods + void createArea ( const FRect& + , const FPoint& + , term_area*& ); - void createArea ( int, int, int, int - , int, int - , term_area*& ); + void createArea ( int, int, int, int + , int, int + , term_area*& ); - static void resizeArea ( const FRect& - , const FPoint& + static void resizeArea ( const FRect& + , const FPoint& + , term_area* ); + + static void resizeArea ( int, int, int, int + , int, int + , term_area* ); + + static void removeArea (term_area*&); + static void restoreVTerm (const FRect&); + static void restoreVTerm (int, int, int, int); + + static covered_state isCovered ( const FPoint& , term_area* ); - static void resizeArea ( int, int, int, int - , int, int + static covered_state isCovered ( int, int , term_area* ); - static void removeArea (term_area*&); - static void restoreVTerm (const FRect&); - static void restoreVTerm (int, int, int, int); + static void updateVTerm(); + static void updateVTerm (term_area*); + static bool updateVTermCursor (term_area*); + static bool isInsideArea (int, int, term_area*); - static covered_state isCovered ( const FPoint& - , term_area* ); + static void setAreaCursor ( const FPoint& + , bool, term_area* ); - static covered_state isCovered ( int, int - , term_area* ); + static void setAreaCursor ( int, int + , bool, term_area*); - static void updateVTerm(); - static void updateVTerm (term_area*); - static bool updateVTermCursor (term_area*); - static bool isInsideArea (int, int, term_area*); + static void getArea (const FPoint&, term_area*); + static void getArea (int, int, term_area*); + static void getArea (const FRect&, term_area*); + static void getArea (int, int, int, int, term_area*); + static void putArea (const FPoint&, term_area*); + static void putArea (int, int, term_area*); + static void scrollAreaForward (term_area*); + static void scrollAreaReverse (term_area*); + static void clearArea (term_area*, int = ' '); - static void setAreaCursor ( const FPoint& - , bool, term_area* ); + static char_data getCharacter ( character_type + , const FPoint& + , FVTerm* ); - static void setAreaCursor ( int, int - , bool, term_area*); + static char_data getCharacter ( character_type + , int + , int, FVTerm* ); - static void getArea (const FPoint&, term_area*); - static void getArea (int, int, term_area*); - static void getArea (const FRect&, term_area*); - static void getArea (int, int, int, int, term_area*); - static void putArea (const FPoint&, term_area*); - static void putArea (int, int, term_area*); - static void scrollAreaForward (term_area*); - static void scrollAreaReverse (term_area*); - static void clearArea (term_area*, int = ' '); + static char_data getCoveredCharacter (const FPoint&, FVTerm*); + static char_data getCoveredCharacter (int, int, FVTerm*); + static char_data getOverlappedCharacter (const FPoint&, FVTerm*); + static char_data getOverlappedCharacter (int, int, FVTerm*); + static void processTerminalUpdate(); + static void startTerminalUpdate(); + static void finishTerminalUpdate(); + static void flush_out(); - static char_data getCharacter ( character_type - , const FPoint& - , FVTerm* ); + // Data Members + static term_area* vterm; // virtual terminal + static term_area* vdesktop; // virtual desktop + static term_area* active_area; // active area + term_area* print_area; // print area for this object + term_area* child_print_area; // print area for children + term_area* vwin; // virtual window - static char_data getCharacter ( character_type - , int - , int, FVTerm* ); + private: + // Typedef + typedef FTermcap::tcap_map termcap_map; - static char_data getCoveredCharacter (const FPoint&, FVTerm*); - static char_data getCoveredCharacter (int, int, FVTerm*); - static char_data getOverlappedCharacter (const FPoint&, FVTerm*); - static char_data getOverlappedCharacter (int, int, FVTerm*); - static void processTerminalUpdate(); - static void startTerminalUpdate(); - static void finishTerminalUpdate(); - static void flush_out(); + // Constants + static const uInt TERMINAL_OUTPUT_BUFFER_SIZE = 32768; + // Buffer size for character output on the terminal - // Data Members - static term_area* vterm; // virtual terminal - static term_area* vdesktop; // virtual desktop - static term_area* active_area; // active area - term_area* print_area; // print area for this object - term_area* child_print_area; // print area for children - term_area* vwin; // virtual window + // Disable copy constructor + FVTerm (const FVTerm&); - private: - // Typedef - typedef FTermcap::tcap_map termcap_map; + // Disable assignment operator (=) + FVTerm& operator = (const FVTerm&); - // Constants - static const uInt TERMINAL_OUTPUT_BUFFER_SIZE = 32768; - // Buffer size for character output on the terminal + // Mutators + void setPrintArea (term_area*); - // Disable copy constructor - FVTerm (const FVTerm&); + // Methods + void init(); + void finish(); + static bool clearTerm (int = ' '); + static void updateTerminalLine (uInt); + static bool updateTerminalCursor(); + static bool isInsideTerminal (int, int); + static void markAsPrinted (uInt, uInt); + static void markAsPrinted (uInt, uInt, uInt); + static void newFontChanges (char_data*&); + static void charsetChanges (char_data*&); + static void appendCharacter (char_data*&); + static void appendChar (char_data*&); + static void appendAttributes (char_data*&); + static int appendLowerRight (char_data*&); + static void appendOutputBuffer (const std::string&); + static void appendOutputBuffer (const char*&); + static int appendOutputBuffer (int); - // Disable assignment operator (=) - FVTerm& operator = (const FVTerm&); - - // Mutators - void setPrintArea (term_area*); - - // Methods - void init(); - void finish(); - static bool clearTerm (int = ' '); - static void updateTerminalLine (uInt); - static bool updateTerminalCursor(); - static bool isInsideTerminal (int, int); - static void markAsPrinted (uInt, uInt); - static void markAsPrinted (uInt, uInt, uInt); - static void newFontChanges (char_data*&); - static void charsetChanges (char_data*&); - static void appendCharacter (char_data*&); - 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 int appendOutputBuffer (int); - - // Data Members - static std::queue* output_buffer; - static char_data term_attribute; - static char_data next_attribute; - static FPoint* term_pos; // terminal cursor position - static termcap_map* tcap; - static bool hidden_cursor; - static bool terminal_update_complete; - static bool terminal_update_pending; - static bool force_terminal_update; - static bool stop_terminal_updates; - static int skipped_terminal_update; + // Data Members + static std::queue* output_buffer; + static char_data term_attribute; + static char_data next_attribute; + static FPoint* term_pos; // terminal cursor position + static termcap_map* tcap; + static bool hidden_cursor; + static bool terminal_update_complete; + static bool terminal_update_pending; + static bool force_terminal_update; + static bool stop_terminal_updates; + static int skipped_terminal_update; }; #pragma pack(pop) diff --git a/src/fwidget.cpp b/src/fwidget.cpp index ab2ff43f..e8ac7fe3 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -1,6 +1,8 @@ // File: fwidget.cpp // Provides: class FWidget +#include + #include "fapplication.h" #include "fmenubar.h" #include "fstatusbar.h" @@ -44,19 +46,19 @@ FWidget::FWidget (FWidget* parent, bool disable_alt_screen) , focus(false) , focusable(true) , visible_cursor(true) - , widget_cursor_position(-1,-1) + , widget_cursor_position(-1, -1) , size_hints() , double_flatline_mask() , padding() , ignore_padding(false) - , wsize(1,1,1,1) - , adjust_wsize(1,1,1,1) + , wsize(1, 1, 1, 1) + , adjust_wsize(1, 1, 1, 1) , adjust_wsize_term() , adjust_wsize_shadow() , adjust_wsize_term_shadow() , offset() , client_offset() - , wshadow(0,0) + , wshadow(0, 0) , foreground_color(fc::Default) , background_color(fc::Default) , statusbar_message() @@ -263,7 +265,6 @@ FPoint FWidget::getPrintPos() int cy = cur.getY(); return FPoint ( cx - offset.getX1() - getX() + 1 , cy - offset.getY1() - getY() + 1 ); - } //---------------------------------------------------------------------- @@ -450,8 +451,8 @@ void FWidget::setPos (int x, int y, bool adjust) y = 1; } - wsize.setPos(x,y); - adjust_wsize.setPos(x,y); + wsize.setPos(x, y); + adjust_wsize.setPos(x, y); if ( adjust ) adjustSize(); @@ -710,7 +711,7 @@ bool FWidget::setCursorPos (register int x, register int y) { // sets the input cursor position - widget_cursor_position.setPoint(x,y); + widget_cursor_position.setPoint(x, y); if ( (flags & fc::focus) == 0 || isWindowWidget() ) return false; @@ -857,7 +858,7 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y) if ( widget->isEnabled() && widget->isVisible() && ! widget->isWindowWidget() - && widget->getTermGeometry().contains(x,y) ) + && widget->getTermGeometry().contains(x, y) ) { FWidget* child = childWidgetAt(widget, x, y); return (child != 0) ? child : widget; @@ -1405,8 +1406,8 @@ void FWidget::detectTermSize() //---------------------------------------------------------------------- void FWidget::move (int dx, int dy) { - wsize.move(dx,dy); - adjust_wsize.move(dx,dy); + wsize.move(dx, dy); + adjust_wsize.move(dx, dy); } //---------------------------------------------------------------------- @@ -1482,8 +1483,8 @@ void FWidget::drawShadow() else if ( FWidget* p = getParentWidget() ) setColor (wc.shadow_fg, p->getBackgroundColor()); - block = fc::FullBlock; // █ - print (fc::LowerHalfBlock); // ▄ + block = fc::FullBlock; // █ + print (fc::LowerHalfBlock); // ▄ if ( isWindowWidget() ) unsetInheritBackground(); @@ -1491,7 +1492,7 @@ void FWidget::drawShadow() for (int i = 1; i < getHeight(); i++) { setPrintPos (x2 + 1, y1 + i); - print (block); // █ + print (block); // █ } setPrintPos (x1 + 1, y2 + 1); @@ -1500,7 +1501,7 @@ void FWidget::drawShadow() setInheritBackground(); for (int i = 1; i <= getWidth(); i++) - print (fc::UpperHalfBlock); // ▀ + print (fc::UpperHalfBlock); // ▀ if ( isWindowWidget() ) unsetInheritBackground(); @@ -1542,7 +1543,7 @@ void FWidget::clearShadow() setPrintPos (x1 + 1, y2 + 1); for (int i = 1; i <= getWidth(); i++) - print (' '); // clear ▀ + print (' '); // clear ▀ } if ( isWindowWidget() ) @@ -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); } } @@ -1697,61 +1706,61 @@ void FWidget::drawBorder (int x1, int y1, int x2, int y2) if ( isNewFont() ) { setPrintPos (x1, y1); - print (fc::NF_border_corner_middle_upper_left); // ┌ + print (fc::NF_border_corner_middle_upper_left); // ┌ for (int x = x1 + 1; x < x2; x++) - print (fc::BoxDrawingsHorizontal); // ─ + print (fc::BoxDrawingsHorizontal); // ─ - print (fc::NF_border_corner_middle_upper_right); // ┐ + print (fc::NF_border_corner_middle_upper_right); // ┐ for (int y = y1 + 1; y <= y2; y++) { setPrintPos (x1, y); - print (fc::NF_border_line_left); // border left ⎸ + print (fc::NF_border_line_left); // border left ⎸ setPrintPos (x2, y); - print (fc::NF_rev_border_line_right); // border right⎹ + print (fc::NF_rev_border_line_right); // border right⎹ } setPrintPos (x1, y2); - print (fc::NF_border_corner_middle_lower_left); // └ + print (fc::NF_border_corner_middle_lower_left); // └ for (int x = x1 + 1; x < x2; x++) - print (fc::BoxDrawingsHorizontal); // ─ + print (fc::BoxDrawingsHorizontal); // ─ - print (fc::NF_border_corner_middle_lower_right); // ┘ + print (fc::NF_border_corner_middle_lower_right); // ┘ } else { setPrintPos (x1, y1); - print (fc::BoxDrawingsDownAndRight); // ┌ + print (fc::BoxDrawingsDownAndRight); // ┌ for (int x = x1 + 1; x < x2; x++) - print (fc::BoxDrawingsHorizontal); // ─ + print (fc::BoxDrawingsHorizontal); // ─ - print (fc::BoxDrawingsDownAndLeft); // ┐ + print (fc::BoxDrawingsDownAndLeft); // ┐ for (int y = y1 + 1; y < y2; y++) { setPrintPos (x1, y); - print (fc::BoxDrawingsVertical); // │ + print (fc::BoxDrawingsVertical); // │ setPrintPos (x2, y); - print (fc::BoxDrawingsVertical); // │ + print (fc::BoxDrawingsVertical); // │ } setPrintPos (x1, y2); - print (fc::BoxDrawingsUpAndRight); // └ + print (fc::BoxDrawingsUpAndRight); // └ for (int x = x1 + 1; x < x2; x++) - print (fc::BoxDrawingsHorizontal); // ─ + print (fc::BoxDrawingsHorizontal); // ─ - print (fc::BoxDrawingsUpAndLeft); // ┘ + print (fc::BoxDrawingsUpAndLeft); // ┘ for (int x = x1 + 1; x < x2; x++) { setPrintPos (x, y1); - print (fc::BoxDrawingsHorizontal); // ─ + print (fc::BoxDrawingsHorizontal); // ─ setPrintPos (x, y2); - print (fc::BoxDrawingsHorizontal); // ─ + print (fc::BoxDrawingsHorizontal); // ─ } } } @@ -2431,7 +2440,7 @@ void FWidget::setColorTheme() wc.tooltip_fg = fc::Black; wc.tooltip_bg = fc::Yellow; wc.shadow_fg = fc::Black; - wc.shadow_bg = fc::LightGray; // only for transparent shadow + wc.shadow_bg = fc::LightGray; // only for transparent shadow wc.current_element_focus_fg = fc::White; wc.current_element_focus_bg = fc::Blue; wc.current_element_fg = fc::LightGray; @@ -2521,7 +2530,7 @@ void FWidget::setColorTheme() wc.tooltip_fg = fc::LightGray; wc.tooltip_bg = fc::Cyan; wc.shadow_fg = fc::Black; - wc.shadow_bg = fc::LightGray; // only for transparent shadow + wc.shadow_bg = fc::LightGray; // only for transparent shadow wc.current_element_focus_fg = fc::LightGray; wc.current_element_focus_bg = fc::Red; wc.current_element_fg = fc::LightGray; diff --git a/src/fwidget.h b/src/fwidget.h index b8057752..eec1d35f 100644 --- a/src/fwidget.h +++ b/src/fwidget.h @@ -71,6 +71,8 @@ #ifndef FWIDGET_H #define FWIDGET_H +#include + #include "fvterm.h" @@ -95,448 +97,448 @@ class FMenuBar; class FWidget : public FVTerm { - public: - // Using-declaration - using FVTerm::setColor; + public: + // Using-declaration + using FVTerm::setColor; - struct accelerator - { - int key; - FWidget* object; - }; + struct accelerator + { + int key; + FWidget* object; + }; - // Typedefs - typedef std::vector widgetList; - typedef void* data_ptr; - typedef void (*FCallback)(FWidget*, data_ptr); - typedef void (FWidget::*FMemberCallback)(FWidget*, data_ptr); - typedef std::vector Accelerators; + // Typedefs + typedef std::vector widgetList; + typedef void* data_ptr; + typedef void (*FCallback)(FWidget*, data_ptr); + typedef void (FWidget::*FMemberCallback)(FWidget*, data_ptr); + typedef std::vector Accelerators; - // Constructor - explicit FWidget (FWidget* = 0, bool = false); + // Constructor + explicit FWidget (FWidget* = 0, bool = false); - // Destructor - ~FWidget(); + // Destructor + ~FWidget(); - // Accessors - const char* getClassName() const; - FWidget* getRootWidget() const; - FWidget* getParentWidget() const; - static FWidget* getMainWidget(); - virtual FWidget* getFocusWidget() const; - virtual FWidget* getFirstFocusableWidget (FObjectList); - virtual FWidget* getLastFocusableWidget (FObjectList); - static FWidget* getClickedWidget(); - static FWidget* getMoveSizeWidget(); - static FWidget* getOpenMenu(); - static FMenuBar* getMenuBar(); - static FStatusBar* getStatusBar(); - FString getStatusbarMessage() const; - short getForegroundColor() const; // get the primary - short getBackgroundColor() const; // widget colors - int getX() const; // positioning - int getY() const; - const FPoint getPos() const; - int getTermX() const; - int getTermY() const; - const FPoint getTermPos() const; - int getWidth() const; - int getHeight() const; - int getTopPadding() const; - int getLeftPadding() const; - int getBottomPadding() const; - int getRightPadding() const; - int getClientWidth() const; - int getClientHeight() const; - int getMaxWidth() const; - int getMaxHeight() const; - const FPoint& getShadow() const; - const FRect& getGeometry() const; - const FRect& getGeometryWithShadow(); - const FRect& getTermGeometry(); - const FRect& getTermGeometryWithShadow(); - int getFlags() const; - FPoint getCursorPos(); - FPoint getPrintPos(); - std::vector& doubleFlatLine_ref (fc::sides); + // Accessors + const char* getClassName() const; + FWidget* getRootWidget() const; + FWidget* getParentWidget() const; + static FWidget* getMainWidget(); + virtual FWidget* getFocusWidget() const; + virtual FWidget* getFirstFocusableWidget (FObjectList); + virtual FWidget* getLastFocusableWidget (FObjectList); + static FWidget* getClickedWidget(); + static FWidget* getMoveSizeWidget(); + static FWidget* getOpenMenu(); + static FMenuBar* getMenuBar(); + static FStatusBar* getStatusBar(); + FString getStatusbarMessage() const; + short getForegroundColor() const; // get the primary + short getBackgroundColor() const; // widget colors + int getX() const; // positioning + int getY() const; + const FPoint getPos() const; + int getTermX() const; + int getTermY() const; + const FPoint getTermPos() const; + int getWidth() const; + int getHeight() const; + int getTopPadding() const; + int getLeftPadding() const; + int getBottomPadding() const; + int getRightPadding() const; + int getClientWidth() const; + int getClientHeight() const; + int getMaxWidth() const; + int getMaxHeight() const; + const FPoint& getShadow() const; + const FRect& getGeometry() const; + const FRect& getGeometryWithShadow(); + const FRect& getTermGeometry(); + const FRect& getTermGeometryWithShadow(); + int getFlags() const; + FPoint getCursorPos(); + FPoint getPrintPos(); + std::vector& doubleFlatLine_ref (fc::sides); - // Mutators - static void setMainWidget (FWidget*); - virtual void setFocusWidget (FWidget*); - static void setClickedWidget (FWidget*); - static void setMoveSizeWidget (FWidget*); - static void setOpenMenu (FWidget*); - virtual void setStatusbarMessage (const FString&); - bool setVisible(); - virtual bool setEnable (bool); - virtual bool setEnable(); - virtual bool unsetEnable(); - virtual bool setDisable(); - virtual bool setVisibleCursor (bool); // input cursor visibility - virtual bool setVisibleCursor(); // for the widget - virtual bool unsetVisibleCursor(); - virtual bool setFocus (bool); - virtual bool setFocus(); - virtual bool unsetFocus(); - void setFocusable(); - void unsetFocusable(); - bool ignorePadding (bool); // ignore padding from - bool ignorePadding(); // the parent widget - bool acceptPadding(); - void setForegroundColor (short); - void setBackgroundColor (short); - void setColor(); - virtual void setX (int, bool = true); // positioning - virtual void setY (int, bool = true); - virtual void setPos (const FPoint&, bool = true); - virtual void setPos (int, int, bool = true); - virtual void setWidth (int, bool = true); - virtual void setHeight (int, bool = true); - virtual void setSize (int, int, bool = true); - void setTopPadding (int, bool = true); - void setLeftPadding (int, bool = true); - void setBottomPadding (int, bool = true); - void setRightPadding (int, bool = true); - void setParentOffset(); - void setTermOffset(); - void setTermOffsetWithPadding(); - void setTermSize (int, int); - virtual void setGeometry (const FRect&, bool = true); - virtual void setGeometry (int, int, int, int, bool = true); - virtual void setShadowSize (int, int); - void setMinimumWidth (int); - void setMinimumHeight (int); - void setMinimumSize (int, int); - void setMaximumWidth (int); - void setMaximumHeight (int); - void setMaximumSize (int, int); - void setFixedSize (int, int); - bool setCursorPos (const FPoint&); - bool setCursorPos (register int, register int); - void unsetCursorPos(); - void setPrintPos (const FPoint&); - void setPrintPos (register int, register int); - void setDoubleFlatLine (fc::sides, bool = true); - void unsetDoubleFlatLine (fc::sides); - void setDoubleFlatLine (fc::sides, int, bool = true); - void unsetDoubleFlatLine (fc::sides, int); + // Mutators + static void setMainWidget (FWidget*); + virtual void setFocusWidget (FWidget*); + static void setClickedWidget (FWidget*); + static void setMoveSizeWidget (FWidget*); + static void setOpenMenu (FWidget*); + virtual void setStatusbarMessage (const FString&); + bool setVisible(); + virtual bool setEnable (bool); + virtual bool setEnable(); + virtual bool unsetEnable(); + virtual bool setDisable(); + virtual bool setVisibleCursor (bool); // input cursor visibility + virtual bool setVisibleCursor(); // for the widget + virtual bool unsetVisibleCursor(); + virtual bool setFocus (bool); + virtual bool setFocus(); + virtual bool unsetFocus(); + void setFocusable(); + void unsetFocusable(); + bool ignorePadding (bool); // ignore padding from + bool ignorePadding(); // the parent widget + bool acceptPadding(); + void setForegroundColor (short); + void setBackgroundColor (short); + void setColor(); + virtual void setX (int, bool = true); // positioning + virtual void setY (int, bool = true); + virtual void setPos (const FPoint&, bool = true); + virtual void setPos (int, int, bool = true); + virtual void setWidth (int, bool = true); + virtual void setHeight (int, bool = true); + virtual void setSize (int, int, bool = true); + void setTopPadding (int, bool = true); + void setLeftPadding (int, bool = true); + void setBottomPadding (int, bool = true); + void setRightPadding (int, bool = true); + void setParentOffset(); + void setTermOffset(); + void setTermOffsetWithPadding(); + void setTermSize (int, int); + virtual void setGeometry (const FRect&, bool = true); + virtual void setGeometry (int, int, int, int, bool = true); + virtual void setShadowSize (int, int); + void setMinimumWidth (int); + void setMinimumHeight (int); + void setMinimumSize (int, int); + void setMaximumWidth (int); + void setMaximumHeight (int); + void setMaximumSize (int, int); + void setFixedSize (int, int); + bool setCursorPos (const FPoint&); + bool setCursorPos (register int, register int); + void unsetCursorPos(); + void setPrintPos (const FPoint&); + void setPrintPos (register int, register int); + void setDoubleFlatLine (fc::sides, bool = true); + void unsetDoubleFlatLine (fc::sides); + void setDoubleFlatLine (fc::sides, int, bool = true); + void unsetDoubleFlatLine (fc::sides, int); - // Inquiries - bool isRootWidget() const; - bool isWindowWidget() const; - bool isDialogWidget() const; - bool isMenuWidget() const; - bool isVisible() const; - bool isShown() const; - bool isEnabled() const; - bool hasVisibleCursor() const; - bool hasFocus() const; - bool acceptFocus() const; // is focusable - bool isPaddingIgnored(); + // Inquiries + bool isRootWidget() const; + bool isWindowWidget() const; + bool isDialogWidget() const; + bool isMenuWidget() const; + bool isVisible() const; + bool isShown() const; + bool isEnabled() const; + bool hasVisibleCursor() const; + bool hasFocus() const; + bool acceptFocus() const; // is focusable + bool isPaddingIgnored(); - // Methods - static FWidget* childWidgetAt (FWidget*, const FPoint&); - static FWidget* childWidgetAt (FWidget*, int, int); - int numOfFocusableChildren(); - virtual bool close(); - void clearStatusbarMessage(); - void addCallback ( const FString& - , FCallback - , data_ptr = null ); - void addCallback ( const FString& - , FWidget* - , FMemberCallback - , data_ptr = null ); - void delCallback (FCallback); - void delCallback (FWidget*); - void delCallbacks(); - void emitCallback (const FString&); - void addAccelerator (int); - virtual void addAccelerator (int, FWidget*); - void delAccelerator (); - virtual void delAccelerator (FWidget*); - virtual void redraw(); - virtual void resize(); - virtual void show(); - virtual void hide(); - virtual bool focusFirstChild(); // widget focusing - virtual bool focusLastChild(); - FPoint termToWidgetPos (const FPoint&); - void detectTermSize(); - virtual void move (const FPoint&); - virtual void move (int, int); - void drawShadow(); - void clearShadow(); - void drawFlatBorder(); - void clearFlatBorder(); - virtual void drawBorder (int, int, int, int); - virtual void drawBorder(); - static void quit(); + // Methods + static FWidget* childWidgetAt (FWidget*, const FPoint&); + static FWidget* childWidgetAt (FWidget*, int, int); + int numOfFocusableChildren(); + virtual bool close(); + void clearStatusbarMessage(); + void addCallback ( const FString& + , FCallback + , data_ptr = null ); + void addCallback ( const FString& + , FWidget* + , FMemberCallback + , data_ptr = null ); + void delCallback (FCallback); + void delCallback (FWidget*); + void delCallbacks(); + void emitCallback (const FString&); + void addAccelerator (int); + virtual void addAccelerator (int, FWidget*); + void delAccelerator (); + virtual void delAccelerator (FWidget*); + virtual void redraw(); + virtual void resize(); + virtual void show(); + virtual void hide(); + virtual bool focusFirstChild(); // widget focusing + virtual bool focusLastChild(); + FPoint termToWidgetPos (const FPoint&); + void detectTermSize(); + virtual void move (const FPoint&); + virtual void move (int, int); + void drawShadow(); + void clearShadow(); + void drawFlatBorder(); + void clearFlatBorder(); + virtual void drawBorder (int, int, int, int); + virtual void drawBorder(); + static void quit(); - // Data Members - static widgetList* window_list; - Accelerators* accelerator_list; + // Data Members + static widgetList* window_list; + Accelerators* accelerator_list; - protected: - struct callback_data - { - FString cb_signal; - FCallback cb_handler; - data_ptr data; - }; + protected: + struct callback_data + { + FString cb_signal; + FCallback cb_handler; + data_ptr data; + }; - struct member_callback_data - { - FString cb_signal; - FWidget* cb_instance; - FMemberCallback cb_handler; - data_ptr data; - }; + struct member_callback_data + { + FString cb_signal; + FWidget* cb_instance; + FMemberCallback cb_handler; + data_ptr data; + }; - // Typedefs - typedef std::vector CallbackObjects; - typedef std::vector MemberCallbackObjects; + // Typedefs + typedef std::vector CallbackObjects; + typedef std::vector MemberCallbackObjects; - // Mutators - virtual void setStatusBar (FStatusBar*); - virtual void setMenuBar (FMenuBar*); + // Mutators + virtual void setStatusBar (FStatusBar*); + virtual void setMenuBar (FMenuBar*); - // Methods - virtual void adjustSize(); - void adjustSizeGlobal(); - virtual bool focusNextChild(); // Change child - virtual bool focusPrevChild(); // focus + // Methods + virtual void adjustSize(); + void adjustSizeGlobal(); + virtual bool focusNextChild(); // Change child + virtual bool focusPrevChild(); // focus - // Event handlers - bool event (FEvent*); - virtual void onKeyPress (FKeyEvent*); - virtual void onKeyUp (FKeyEvent*); - virtual void onKeyDown (FKeyEvent*); - virtual void onMouseDown (FMouseEvent*); - virtual void onMouseUp (FMouseEvent*); - virtual void onMouseDoubleClick (FMouseEvent*); - virtual void onWheel (FWheelEvent*); - virtual void onMouseMove (FMouseEvent*); - virtual void onFocusIn (FFocusEvent*); - virtual void onFocusOut (FFocusEvent*); - virtual void onChildFocusIn (FFocusEvent*); - virtual void onChildFocusOut (FFocusEvent*); - virtual void onAccel (FAccelEvent*); - virtual void onResize (FResizeEvent*); - virtual void onShow (FShowEvent*); - virtual void onHide (FHideEvent*); - virtual void onClose (FCloseEvent*); + // Event handlers + bool event (FEvent*); + virtual void onKeyPress (FKeyEvent*); + virtual void onKeyUp (FKeyEvent*); + virtual void onKeyDown (FKeyEvent*); + virtual void onMouseDown (FMouseEvent*); + virtual void onMouseUp (FMouseEvent*); + virtual void onMouseDoubleClick (FMouseEvent*); + virtual void onWheel (FWheelEvent*); + virtual void onMouseMove (FMouseEvent*); + virtual void onFocusIn (FFocusEvent*); + virtual void onFocusOut (FFocusEvent*); + virtual void onChildFocusIn (FFocusEvent*); + virtual void onChildFocusOut (FFocusEvent*); + virtual void onAccel (FAccelEvent*); + virtual void onResize (FResizeEvent*); + virtual void onShow (FShowEvent*); + virtual void onHide (FHideEvent*); + virtual void onClose (FCloseEvent*); - // Data Members - static struct widget_colors - { - short term_fg; - short term_bg; - short list_fg; - short list_bg; - short selected_list_fg; - short selected_list_bg; - short current_element_focus_fg; - short current_element_focus_bg; - short current_element_fg; - short current_element_bg; - short current_inc_search_element_fg; - short selected_current_element_focus_fg; - short selected_current_element_focus_bg; - short selected_current_element_fg; - short selected_current_element_bg; - short label_fg; - short label_bg; - short label_inactive_fg; - short label_inactive_bg; - short label_hotkey_fg; - short label_hotkey_bg; - short label_emphasis_fg; - short label_ellipsis_fg; - short inputfield_active_focus_fg; - short inputfield_active_focus_bg; - short inputfield_active_fg; - short inputfield_active_bg; - short inputfield_inactive_fg; - short inputfield_inactive_bg; - short dialog_fg; - short dialog_resize_fg; - short dialog_emphasis_fg; - short dialog_bg; - short error_box_fg; - short error_box_emphasis_fg; - short error_box_bg; - short tooltip_fg; - short tooltip_bg; - short shadow_fg; - short shadow_bg; - short toggle_button_active_focus_fg; - short toggle_button_active_focus_bg; - short toggle_button_active_fg; - short toggle_button_active_bg; - short toggle_button_inactive_fg; - short toggle_button_inactive_bg; - short button_active_focus_fg; - short button_active_focus_bg; - short button_active_fg; - short button_active_bg; - short button_inactive_fg; - short button_inactive_bg; - short button_hotkey_fg; - short titlebar_active_fg; - short titlebar_active_bg; - short titlebar_inactive_fg; - short titlebar_inactive_bg; - short titlebar_button_fg; - short titlebar_button_bg; - short titlebar_button_focus_fg; - short titlebar_button_focus_bg; - short menu_active_focus_fg; - short menu_active_focus_bg; - short menu_active_fg; - short menu_active_bg; - short menu_inactive_fg; - short menu_inactive_bg; - short menu_hotkey_fg; - short menu_hotkey_bg; - short statusbar_fg; - short statusbar_bg; - short statusbar_hotkey_fg; - short statusbar_hotkey_bg; - short statusbar_separator_fg; - short statusbar_active_fg; - short statusbar_active_bg; - short statusbar_active_hotkey_fg; - short statusbar_active_hotkey_bg; - short scrollbar_fg; - short scrollbar_bg; - short scrollbar_button_fg; - short scrollbar_button_bg; - short progressbar_fg; - short progressbar_bg; - } wc; - // widget_colors wc; + // Data Members + static struct widget_colors + { + short term_fg; + short term_bg; + short list_fg; + short list_bg; + short selected_list_fg; + short selected_list_bg; + short current_element_focus_fg; + short current_element_focus_bg; + short current_element_fg; + short current_element_bg; + short current_inc_search_element_fg; + short selected_current_element_focus_fg; + short selected_current_element_focus_bg; + short selected_current_element_fg; + short selected_current_element_bg; + short label_fg; + short label_bg; + short label_inactive_fg; + short label_inactive_bg; + short label_hotkey_fg; + short label_hotkey_bg; + short label_emphasis_fg; + short label_ellipsis_fg; + short inputfield_active_focus_fg; + short inputfield_active_focus_bg; + short inputfield_active_fg; + short inputfield_active_bg; + short inputfield_inactive_fg; + short inputfield_inactive_bg; + short dialog_fg; + short dialog_resize_fg; + short dialog_emphasis_fg; + short dialog_bg; + short error_box_fg; + short error_box_emphasis_fg; + short error_box_bg; + short tooltip_fg; + short tooltip_bg; + short shadow_fg; + short shadow_bg; + short toggle_button_active_focus_fg; + short toggle_button_active_focus_bg; + short toggle_button_active_fg; + short toggle_button_active_bg; + short toggle_button_inactive_fg; + short toggle_button_inactive_bg; + short button_active_focus_fg; + short button_active_focus_bg; + short button_active_fg; + short button_active_bg; + short button_inactive_fg; + short button_inactive_bg; + short button_hotkey_fg; + short titlebar_active_fg; + short titlebar_active_bg; + short titlebar_inactive_fg; + short titlebar_inactive_bg; + short titlebar_button_fg; + short titlebar_button_bg; + short titlebar_button_focus_fg; + short titlebar_button_focus_bg; + short menu_active_focus_fg; + short menu_active_focus_bg; + short menu_active_fg; + short menu_active_bg; + short menu_inactive_fg; + short menu_inactive_bg; + short menu_hotkey_fg; + short menu_hotkey_bg; + short statusbar_fg; + short statusbar_bg; + short statusbar_hotkey_fg; + short statusbar_hotkey_bg; + short statusbar_separator_fg; + short statusbar_active_fg; + short statusbar_active_bg; + short statusbar_active_hotkey_fg; + short statusbar_active_hotkey_bg; + short scrollbar_fg; + short scrollbar_bg; + short scrollbar_button_fg; + short scrollbar_button_bg; + short progressbar_fg; + short progressbar_bg; + } wc; + // widget_colors wc; - int flags; - static uInt modal_dialogs; - static widgetList* dialog_list; - static widgetList* always_on_top_list; - static widgetList* close_widget; - CallbackObjects callback_objects; - MemberCallbackObjects member_callback_objects; + int flags; + static uInt modal_dialogs; + static widgetList* dialog_list; + static widgetList* always_on_top_list; + static widgetList* close_widget; + CallbackObjects callback_objects; + MemberCallbackObjects member_callback_objects; - private: - // Disable copy constructor - FWidget (const FWidget&); + private: + // Disable copy constructor + FWidget (const FWidget&); - // Disable assignment operator (=) - FWidget& operator = (const FWidget&); + // Disable assignment operator (=) + FWidget& operator = (const FWidget&); - // Methods - void init(); - void finish(); - void insufficientSpaceAdjust(); - void processDestroy(); - virtual void draw(); - static void setColorTheme(); + // Methods + void init(); + void finish(); + void insufficientSpaceAdjust(); + void processDestroy(); + virtual void draw(); + static void setColorTheme(); - // Data Members - bool enable; - bool visible; - bool shown; - bool focus; - bool focusable; - bool visible_cursor; - FPoint widget_cursor_position; + // Data Members + bool enable; + bool visible; + bool shown; + bool focus; + bool focusable; + bool visible_cursor; + FPoint widget_cursor_position; - struct widget_size_hints - { - widget_size_hints() - : min_width (INT_MIN) - , min_height (INT_MIN) - , max_width (INT_MAX) - , max_height (INT_MAX) - { } + struct widget_size_hints + { + widget_size_hints() + : min_width (INT_MIN) + , min_height (INT_MIN) + , max_width (INT_MAX) + , max_height (INT_MAX) + { } - ~widget_size_hints() - { } + ~widget_size_hints() + { } - void setMinimum (int w, int h) - { - min_width = w; - min_height = h; - } + void setMinimum (int w, int h) + { + min_width = w; + min_height = h; + } - void setMaximum (int w, int h) - { - max_width = w; - max_height = h; - } + void setMaximum (int w, int h) + { + max_width = w; + max_height = h; + } - int min_width; - int min_height; - int max_width; - int max_height; - } size_hints; + int min_width; + int min_height; + int max_width; + int max_height; + } size_hints; - struct dbl_line_mask - { - dbl_line_mask() : top(), right(), bottom(), left() - { } + struct dbl_line_mask + { + dbl_line_mask() : top(), right(), bottom(), left() + { } - ~dbl_line_mask() - { } + ~dbl_line_mask() + { } - std::vector top; - std::vector right; - std::vector bottom; - std::vector left; - } double_flatline_mask; + std::vector top; + std::vector right; + std::vector bottom; + std::vector left; + } double_flatline_mask; - struct widget_padding - { - widget_padding() : top(0), left(0), bottom(0), right(0) - { } + struct widget_padding + { + widget_padding() : top(0), left(0), bottom(0), right(0) + { } - ~widget_padding() - { } + ~widget_padding() + { } - int top; - int left; - int bottom; - int right; - } padding; + int top; + int left; + int bottom; + int right; + } padding; - bool ignore_padding; + bool ignore_padding; - // widget size - FRect wsize; - FRect adjust_wsize; - FRect adjust_wsize_term; - FRect adjust_wsize_shadow; - FRect adjust_wsize_term_shadow; - // widget offset - FRect offset; - // offset of the widget client area - FRect client_offset; - // widget shadow size (on the right and bottom side) - FPoint wshadow; + // widget size + FRect wsize; + FRect adjust_wsize; + FRect adjust_wsize_term; + FRect adjust_wsize_shadow; + FRect adjust_wsize_term_shadow; + // widget offset + FRect offset; + // offset of the widget client area + FRect client_offset; + // widget shadow size (on the right and bottom side) + FPoint wshadow; - // default widget foreground and background color - short foreground_color; - short background_color; + // default widget foreground and background color + short foreground_color; + short background_color; - FString statusbar_message; - static FStatusBar* statusbar; - static FMenuBar* menubar; - static FWidget* show_root_widget; - static FWidget* redraw_root_widget; - static bool init_desktop; - static bool hideable; + FString statusbar_message; + static FStatusBar* statusbar; + static FMenuBar* menubar; + static FWidget* show_root_widget; + static FWidget* redraw_root_widget; + static bool init_desktop; + static bool hideable; - // Friend class - friend class FToggleButton; - friend class FScrollView; + // Friend class + friend class FToggleButton; + friend class FScrollView; }; #pragma pack(pop) @@ -804,7 +806,7 @@ inline bool FWidget::setCursorPos (const FPoint& pos) //---------------------------------------------------------------------- inline void FWidget::unsetCursorPos() -{ setCursorPos(-1,-1); } +{ setCursorPos(-1, -1); } //---------------------------------------------------------------------- inline void FWidget::setPrintPos (const FPoint& pos) diff --git a/src/fwindow.cpp b/src/fwindow.cpp index b6d08754..395f2440 100644 --- a/src/fwindow.cpp +++ b/src/fwindow.cpp @@ -25,7 +25,7 @@ FWindow::FWindow(FWidget* parent) { setWindowWidget(); FRect geometry = getTermGeometry(); - geometry.move(-1,-1); + geometry.move(-1, -1); createArea (geometry, getShadow(), vwin); addWindow (this); } @@ -261,12 +261,12 @@ void FWindow::drawBorder() int y2 = 1 + getHeight() - 1; setPrintPos (x1, y1); - print (fc::NF_border_corner_upper_left); // ⎡ + print (fc::NF_border_corner_upper_left); // ⎡ for (int x = x1 + 1; x < x2; x++) - print (fc::NF_border_line_upper); // ¯ + print (fc::NF_border_line_upper); // ¯ - print (fc::NF_rev_border_corner_upper_right); // ⎤ + print (fc::NF_rev_border_corner_upper_right); // ⎤ for (int y = y1 + 1; y < y2; y++) { @@ -282,7 +282,7 @@ void FWindow::drawBorder() // lower left corner border ⎣ print (fc::NF_border_corner_lower_left); - for (int x = 2; x < getWidth(); x++) // low line _ + for (int x = 2; x < getWidth(); x++) // low line _ print (fc::NF_border_line_bottom); setPrintPos (x2, y2); @@ -358,7 +358,7 @@ void FWindow::setWidth (int w, bool adjust) if ( isVirtualWindow() && getWidth() != old_width ) { FRect geometry = getTermGeometry(); - geometry.move(-1,-1); + geometry.move(-1, -1); resizeArea (geometry, getShadow(), vwin); } } @@ -372,7 +372,7 @@ void FWindow::setHeight (int h, bool adjust) if ( isVirtualWindow() && getHeight() != old_height ) { FRect geometry = getTermGeometry(); - geometry.move(-1,-1); + geometry.move(-1, -1); resizeArea (geometry, getShadow(), vwin); } } @@ -384,10 +384,11 @@ 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); + geometry.move(-1, -1); 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 ) { FRect geometry = getTermGeometry(); - geometry.move(-1,-1); + geometry.move(-1, -1); resizeArea (geometry, getShadow(), vwin); } 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) { - FWidget::move (dx,dy); + FWidget::move (dx, dy); if ( isVirtualWindow() ) { @@ -456,12 +457,11 @@ FWindow* FWindow::getWindowWidgetAt (int x, int y) FWindow* w = static_cast(*iter); if ( ! w->isWindowHidden() - && w->getTermGeometry().contains(x,y) ) + && w->getTermGeometry().contains(x, y) ) return w; } } while ( iter != begin ); - } return 0; @@ -779,10 +779,11 @@ 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); + geometry.move(-1, -1); resizeArea (geometry, getShadow(), vwin); } } diff --git a/test/calculator.cpp b/test/calculator.cpp index 4fd46106..16a06c6e 100644 --- a/test/calculator.cpp +++ b/test/calculator.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "fapplication.h" @@ -25,19 +26,19 @@ const lDouble PI = 3.141592653589793238L; class Button : public FButton { - public: - // Constructor - explicit Button (FWidget* = 0); + public: + // Constructor + explicit Button (FWidget* = 0); - // Method - void setChecked(bool); + // Method + void setChecked(bool); - // Event handler - void onKeyPress (FKeyEvent*); + // Event handler + void onKeyPress (FKeyEvent*); - private: - // Data Member - bool checked; + private: + // Data Member + bool checked; }; #pragma pack(pop) @@ -93,93 +94,93 @@ void Button::onKeyPress (FKeyEvent* ev) class Calc : public FDialog { - public: - // Constructor - explicit Calc (FWidget* parent=0); + public: + // Constructor + explicit Calc (FWidget* parent=0); - // Destructor - ~Calc(); + // Destructor + ~Calc(); - // Event handlers - void onKeyPress (FKeyEvent*); - void onAccel (FAccelEvent*); - void onClose (FCloseEvent*); + // Event handlers + void onKeyPress (FKeyEvent*); + void onAccel (FAccelEvent*); + void onClose (FCloseEvent*); - // Callback method - void cb_buttonClicked (FWidget*, data_ptr); + // Callback method + void cb_buttonClicked (FWidget*, data_ptr); - private: - // Methods - void drawDispay(); - virtual void draw(); - bool isDataEntryKey(int); - bool isOperatorKey(int); - void setDisplay (lDouble); - void setInfixOperator(char); - void clearInfixOperator(); - void calcInfixOperator(); - void adjustSize(); + private: + // Methods + void drawDispay(); + virtual void draw(); + bool isDataEntryKey(int); + bool isOperatorKey(int); + void setDisplay (lDouble); + void setInfixOperator(char); + void clearInfixOperator(); + void calcInfixOperator(); + void adjustSize(); - // Data Members - bool error; - bool arcus_mode; - bool hyperbolic_mode; + // Data Members + bool error; + bool arcus_mode; + bool hyperbolic_mode; - enum button - { - Sine, - Cosine, - Tangent, - Reciprocal, - On, - Natural_logarithm, - Powers_of_e, - Power, - Square_root, - Divide, - Common_logarithm, - Powers_of_ten, - Parenthese_l, - Parenthese_r, - Multiply, - Hyperbolic, - Seven, - Eight, - Nine, - Subtract, - Arcus, - Four, - Five, - Six, - Add, - Pi, - One, - Two, - Three, - Percent, - Zero, - Decimal_point, - Change_sign, - Equals, - NUM_OF_BUTTONS - }; + enum button + { + Sine, + Cosine, + Tangent, + Reciprocal, + On, + Natural_logarithm, + Powers_of_e, + Power, + Square_root, + Divide, + Common_logarithm, + Powers_of_ten, + Parenthese_l, + Parenthese_r, + Multiply, + Hyperbolic, + Seven, + Eight, + Nine, + Subtract, + Arcus, + Four, + Five, + Six, + Add, + Pi, + One, + Two, + Three, + Percent, + Zero, + Decimal_point, + Change_sign, + Equals, + NUM_OF_BUTTONS + }; - lDouble a, b; - uInt max_char; - int last_key; - char infix_operator; - char last_infix_operator; - FString input; - int button_no[Calc::NUM_OF_BUTTONS]; + lDouble a, b; + uInt max_char; + int last_key; + char infix_operator; + char last_infix_operator; + FString input; + int button_no[Calc::NUM_OF_BUTTONS]; - struct stack_data - { - lDouble term; - char infix_operator; - }; + struct stack_data + { + lDouble term; + char infix_operator; + }; - std::stack bracket_stack; - std::map calculator_buttons; + std::stack bracket_stack; + std::map calculator_buttons; }; #pragma pack(pop) @@ -277,10 +278,9 @@ Calc::Calc (FWidget* parent) ); calculator_buttons[button(key)] = btn; - } - calculator_buttons[On]->addAccelerator(fc::Fkey_dc); // del key + calculator_buttons[On]->addAccelerator(fc::Fkey_dc); // del key calculator_buttons[On]->setFocus(); calculator_buttons[Pi]->addAccelerator('p'); calculator_buttons[Power]->addAccelerator('^'); @@ -329,7 +329,7 @@ void Calc::drawDispay() if ( isMonochron() ) setReverse(false); - setPrintPos (3,3); + setPrintPos (3, 3); print(display); print(L' '); setColor(wc.dialog_fg, wc.dialog_bg); @@ -339,16 +339,16 @@ void Calc::drawDispay() if ( isNewFont() ) { - FString bottom_line(33, wchar_t(fc::NF_border_line_bottom)); - setPrintPos (3,2); + FString bottom_line (33, wchar_t(fc::NF_border_line_bottom)); + setPrintPos (3, 2); print (bottom_line); - setPrintPos (2,3); + setPrintPos (2, 3); print (wchar_t(fc::NF_rev_border_line_right)); - setPrintPos (36,3); + setPrintPos (36, 3); 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_line_2(2, wchar_t(fc::NF_border_line_upper)); - setPrintPos (3,4); + 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)); + setPrintPos (3, 4); print ( 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(35, wchar_t(fc::BoxDrawingsHorizontal)) + FString(wchar_t(fc::BoxDrawingsVerticalAndLeft)); - setPrintPos (1,4); + setPrintPos (1, 4); print(separator); } } @@ -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::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 @@ -775,7 +771,7 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data) break; case Powers_of_ten: // 10ˣ - *x = std::pow(10,*x); + *x = std::pow(10, *x); if ( errno == EDOM || errno == ERANGE ) error = true; @@ -972,7 +968,7 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data) default: break; - } // end of switch + } // end of switch if ( ! input.isEmpty() ) { diff --git a/test/choice.cpp b/test/choice.cpp index 88c234f8..dcfdd9ca 100644 --- a/test/choice.cpp +++ b/test/choice.cpp @@ -26,7 +26,7 @@ void cb_quit (FWidget*, FWidget::data_ptr data) //---------------------------------------------------------------------- int main (int argc, char* argv[]) { - int x,y,w,h; + int x, y, w, h; FString label_text = "no OS"; // Create the application object diff --git a/test/keyboard.cpp b/test/keyboard.cpp index caa6ce42..a7df453d 100644 --- a/test/keyboard.cpp +++ b/test/keyboard.cpp @@ -8,16 +8,16 @@ class keyboard : public FWidget { - public: - // Constructor - explicit keyboard (FWidget* = 0); + public: + // Constructor + explicit keyboard (FWidget* = 0); - protected: - // Event handlers - void onKeyPress (FKeyEvent*); - void onAccel (FAccelEvent*); + protected: + // Event handlers + void onKeyPress (FKeyEvent*); + void onAccel (FAccelEvent*); - void draw(); + void draw(); }; //---------------------------------------------------------------------- @@ -58,7 +58,7 @@ void keyboard::onAccel (FAccelEvent* ev) //---------------------------------------------------------------------- void keyboard::draw() { - setPrintPos (1,1); + setPrintPos (1, 1); print() << "---------------\n" << "Press Q to quit\n" << "---------------\n"; diff --git a/test/listbox.cpp b/test/listbox.cpp index 9a44a464..15785900 100644 --- a/test/listbox.cpp +++ b/test/listbox.cpp @@ -1,6 +1,8 @@ // File: listbox.cpp #include +#include +#include #include #include "fapplication.h" @@ -49,26 +51,26 @@ FString& mapToString (std::map::const_iterator iter) class Listbox : public FDialog { - public: - // Constructor - explicit Listbox (FWidget* = 0); - // Destructor - ~Listbox(); + public: + // Constructor + explicit Listbox (FWidget* = 0); + // Destructor + ~Listbox(); - private: - // Disable copy constructor - Listbox (const Listbox&); - // Disable assignment operator (=) - Listbox& operator = (const Listbox&); + private: + // Disable copy constructor + Listbox (const Listbox&); + // Disable assignment operator (=) + Listbox& operator = (const Listbox&); - // Event handlers - void onClose (FCloseEvent*); + // Event handlers + void onClose (FCloseEvent*); - // Callback method - void cb_exitApp (FWidget*, data_ptr); + // Callback method + void cb_exitApp (FWidget*, data_ptr); - // Data Member - std::list* double_list; + // Data Member + std::list* double_list; }; #pragma pack(pop) @@ -134,7 +136,7 @@ Listbox::Listbox (FWidget* parent) } //---------------------------------------------------------------------- -Listbox::~Listbox() +Listbox::~Listbox() // destructor { delete temp_str; delete double_list; diff --git a/test/listview.cpp b/test/listview.cpp index 69da9ef7..fb6da530 100644 --- a/test/listview.cpp +++ b/test/listview.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include #include "fapplication.h" #include "fdialog.h" @@ -18,24 +20,24 @@ class Listview : public FDialog { - public: - // Constructor - explicit Listview (FWidget* = 0); - // Destructor - ~Listview(); + public: + // Constructor + explicit Listview (FWidget* = 0); + // Destructor + ~Listview(); - private: - // Disable copy constructor - Listview (const Listview&); - // Disable assignment operator (=) - Listview& operator = (const Listview&); + private: + // Disable copy constructor + Listview (const Listview&); + // Disable assignment operator (=) + Listview& operator = (const Listview&); - // Event handlers - void onClose (FCloseEvent*); + // Event handlers + void onClose (FCloseEvent*); - // Callback methods - void cb_exitApp (FWidget*, data_ptr); - void cb_showInMessagebox (FWidget*, data_ptr); + // Callback methods + void cb_exitApp (FWidget*, data_ptr); + void cb_showInMessagebox (FWidget*, data_ptr); }; #pragma pack(pop) @@ -133,7 +135,7 @@ Listview::Listview (FWidget* parent) } //---------------------------------------------------------------------- -Listview::~Listview() +Listview::~Listview() // destructor { } //---------------------------------------------------------------------- diff --git a/test/mandelbrot.cpp b/test/mandelbrot.cpp index be241e95..c3fd1ca1 100644 --- a/test/mandelbrot.cpp +++ b/test/mandelbrot.cpp @@ -13,21 +13,21 @@ class Mandelbrot : public FDialog { - public: - // Constructor - explicit Mandelbrot (FWidget* = 0); + public: + // Constructor + explicit Mandelbrot (FWidget* = 0); - // Destructor - ~Mandelbrot(); + // Destructor + ~Mandelbrot(); - // Event handlers - void onAccel (FAccelEvent*); - void onClose (FCloseEvent*); + // Event handlers + void onAccel (FAccelEvent*); + void onClose (FCloseEvent*); - private: - // Methods - virtual void draw(); - void adjustSize(); + private: + // Methods + virtual void draw(); + void adjustSize(); }; #pragma pack(pop) diff --git a/test/menu.cpp b/test/menu.cpp index e19d3a17..3e76e921 100644 --- a/test/menu.cpp +++ b/test/menu.cpp @@ -20,30 +20,30 @@ class Menu : public FDialog { - public: - // Constructor - explicit Menu (FWidget* = 0); + public: + // Constructor + explicit Menu (FWidget* = 0); - // Destructor - ~Menu(); + // Destructor + ~Menu(); - private: - // Disable copy constructor - Menu (const Menu&); + private: + // Disable copy constructor + Menu (const Menu&); - // Disable assignment operator (=) - Menu& operator = (const Menu&); + // Disable assignment operator (=) + Menu& operator = (const Menu&); - // Methods - void defaultCallback (FMenuList*); - void adjustSize(); + // Methods + void defaultCallback (FMenuList*); + void adjustSize(); - // Event handler - void onClose (FCloseEvent*); + // Event handler + void onClose (FCloseEvent*); - // Callback methods - void cb_message (FWidget*, data_ptr); - void cb_exitApp (FWidget*, data_ptr); + // Callback methods + void cb_message (FWidget*, data_ptr); + void cb_exitApp (FWidget*, data_ptr); }; #pragma pack(pop) @@ -68,28 +68,28 @@ Menu::Menu (FWidget* parent) // "File" menu items FMenuItem* New = new FMenuItem ("&New", File); - New->addAccelerator (fc::Fckey_n); // Ctrl + N + New->addAccelerator (fc::Fckey_n); // Ctrl + N New->setStatusbarMessage ("Create a new file"); FMenuItem* Open = new FMenuItem ("&Open...", File); - Open->addAccelerator (fc::Fckey_o); // Ctrl + O + Open->addAccelerator (fc::Fckey_o); // Ctrl + O Open->setStatusbarMessage ("Locate and open a text file"); FMenuItem* Save = new FMenuItem ("&Save", File); - Save->addAccelerator (fc::Fckey_s); // Ctrl + S + Save->addAccelerator (fc::Fckey_s); // Ctrl + S Save->setStatusbarMessage ("Save the file"); FMenuItem* SaveAs = new FMenuItem ("&Save as...", File); SaveAs->setStatusbarMessage ("Save the current file under a different name"); FMenuItem* Close = new FMenuItem ("&Close", File); - Close->addAccelerator (fc::Fckey_w); // Ctrl + W + Close->addAccelerator (fc::Fckey_w); // Ctrl + W Close->setStatusbarMessage ("Close the current file"); FMenuItem* Line1 = new FMenuItem (File); Line1->setSeparator(); FMenuItem* Print = new FMenuItem ("&Print", File); - Print->addAccelerator (fc::Fckey_p); // Ctrl + P + Print->addAccelerator (fc::Fckey_p); // Ctrl + P Print->setStatusbarMessage ("Print the current file"); FMenuItem* Line2 = new FMenuItem (File); Line2->setSeparator(); FMenuItem* Quit = new FMenuItem ("&Quit", File); - Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X + Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X Quit->setStatusbarMessage ("Exit the program"); // "Edit" menu items @@ -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); @@ -184,19 +185,19 @@ Menu::Menu (FWidget* parent) // Headline labels FLabel* Headline1 = new FLabel(" Key ", this); Headline1->ignorePadding(); - Headline1->setGeometry(3,2,5,1); + Headline1->setGeometry(3, 2, 5, 1); Headline1->setEmphasis(); FLabel* Headline2 = new FLabel(" Function ", this); Headline2->ignorePadding(); - Headline2->setGeometry(19,2,10,1); + Headline2->setGeometry(19, 2, 10, 1); Headline2->setEmphasis(); // Info label FLabel* Info = new FLabel(" Activate menu bar\n" "+ Activate menu bar\n" "+ Exit", this); - Info->setGeometry(2,1,36,3); + Info->setGeometry(2, 1, 36, 3); } //---------------------------------------------------------------------- diff --git a/test/mouse.cpp b/test/mouse.cpp index 0132dc05..0d06ff14 100644 --- a/test/mouse.cpp +++ b/test/mouse.cpp @@ -15,32 +15,32 @@ class ColorChooser : public FWidget { - public: - // Constructor - explicit ColorChooser (FWidget* = 0); + public: + // Constructor + explicit ColorChooser (FWidget* = 0); - // Destructor - ~ColorChooser(); + // Destructor + ~ColorChooser(); - // Accessors - short getForeground(); - short getBackground(); + // Accessors + short getForeground(); + short getBackground(); - private: - // Disable copy constructor - ColorChooser (const ColorChooser&); - // Disable assignment operator (=) - ColorChooser& operator = (const ColorChooser&); + private: + // Disable copy constructor + ColorChooser (const ColorChooser&); + // Disable assignment operator (=) + ColorChooser& operator = (const ColorChooser&); - // Method - void draw(); + // Method + void draw(); - // Event handler - void onMouseDown (FMouseEvent*); + // Event handler + void onMouseDown (FMouseEvent*); - // Data Members - short fg_color; - short bg_color; + // Data Members + short fg_color; + short bg_color; }; #pragma pack(pop) @@ -150,36 +150,36 @@ inline short ColorChooser::getBackground() class Brushes : public FWidget { - public: - // Constructor - explicit Brushes (FWidget* = 0); + public: + // Constructor + explicit Brushes (FWidget* = 0); - // Destructor - ~Brushes(); + // Destructor + ~Brushes(); - // Accessor - wchar_t getBrush(); + // Accessor + wchar_t getBrush(); - // Mutators - void setForeground (short); - void setBackground (short); + // Mutators + void setForeground (short); + void setBackground (short); - private: - // Disable copy constructor - Brushes (const Brushes&); - // Disable assignment operator (=) - Brushes& operator = (const Brushes&); + private: + // Disable copy constructor + Brushes (const Brushes&); + // Disable assignment operator (=) + Brushes& operator = (const Brushes&); - // Method - void draw(); + // Method + void draw(); - // Event handler - void onMouseDown (FMouseEvent*); + // Event handler + void onMouseDown (FMouseEvent*); - // Data Members - wchar_t brush; - short fg_color; - short bg_color; + // Data Members + wchar_t brush; + short fg_color; + short bg_color; }; #pragma pack(pop) @@ -285,46 +285,46 @@ inline void Brushes::setBackground (short color) class MouseDraw : public FDialog { - public: - // Using-declaration - using FWidget::setGeometry; + public: + // Using-declaration + using FWidget::setGeometry; - // Constructor - explicit MouseDraw (FWidget* = 0); + // Constructor + explicit MouseDraw (FWidget* = 0); - // Destructor - ~MouseDraw(); + // Destructor + ~MouseDraw(); - // Methods - void setGeometry (int, int, int, int, bool = true); + // Methods + void setGeometry (int, int, int, int, bool = true); - // Event handlers - void onAccel (FAccelEvent*); - void onClose (FCloseEvent*); + // Event handlers + void onAccel (FAccelEvent*); + void onClose (FCloseEvent*); - private: - // Disable copy constructor - MouseDraw (const MouseDraw&); - // Disable assignment operator (=) - MouseDraw& operator = (const MouseDraw&); + private: + // Disable copy constructor + MouseDraw (const MouseDraw&); + // Disable assignment operator (=) + MouseDraw& operator = (const MouseDraw&); - // Methods - virtual void draw(); - void drawBrush (int, int, bool = false); - void drawCanvas(); - void adjustSize(); + // Methods + virtual void draw(); + void drawBrush (int, int, bool = false); + void drawCanvas(); + void adjustSize(); - // Event handler - void onMouseDown (FMouseEvent*); - void onMouseMove (FMouseEvent*); + // Event handler + void onMouseDown (FMouseEvent*); + void onMouseMove (FMouseEvent*); - // Callback methods - void cb_colorChanged (FWidget*, data_ptr); + // Callback methods + void cb_colorChanged (FWidget*, data_ptr); - // Data Members - term_area* canvas; - ColorChooser* c_chooser; - Brushes* brush; + // Data Members + term_area* canvas; + ColorChooser* c_chooser; + Brushes* brush; }; #pragma pack(pop) @@ -337,7 +337,7 @@ MouseDraw::MouseDraw (FWidget* parent) { setText ("Drawing with the mouse"); c_chooser = new ColorChooser(this); - c_chooser->setPos (1,1); + c_chooser->setPos (1, 1); c_chooser->addCallback ( "clicked", @@ -345,7 +345,7 @@ MouseDraw::MouseDraw (FWidget* parent) ); brush = new Brushes(this); - brush->setPos (1,12); + brush->setPos (1, 12); FPoint no_shadow(0,0); FRect scroll_geometry(0, 0, 1, 1); @@ -459,8 +459,8 @@ void MouseDraw::drawCanvas() for (int y = 0; y < y_end; y++) // line loop { - char_data* cc; // canvas character - char_data* wc; // window character + char_data* cc; // canvas character + char_data* wc; // window character cc = &canvas->text[y * x_end]; wc = &print_area->text[(ay + y) * w_line_len + ax]; std::memcpy (wc, cc, sizeof(char_data) * unsigned(x_end)); diff --git a/test/opti-move.cpp b/test/opti-move.cpp index 3a7a12a5..f2776962 100644 --- a/test/opti-move.cpp +++ b/test/opti-move.cpp @@ -1,6 +1,8 @@ // File: opti-move.cpp #include +#include + #include "fapplication.h" #include "fvterm.h" diff --git a/test/scrollview.cpp b/test/scrollview.cpp index f91e2ca7..42442304 100644 --- a/test/scrollview.cpp +++ b/test/scrollview.cpp @@ -16,36 +16,36 @@ class scrollview : public FScrollView { - public: - // Constructor - explicit scrollview (FWidget* = 0); + public: + // Constructor + explicit scrollview (FWidget* = 0); - // Destructor - ~scrollview (); + // Destructor + ~scrollview (); - // Mutator - void setScrollSize (int, int); + // Mutator + void setScrollSize (int, int); - private: - // Disable copy constructor - scrollview (const scrollview&); - // Disable assignment operator (=) - scrollview& operator = (const scrollview&); + private: + // Disable copy constructor + scrollview (const scrollview&); + // Disable assignment operator (=) + scrollview& operator = (const scrollview&); - // Method - void draw(); + // Method + void draw(); - // Callback methods - void cb_go_east (FWidget*, data_ptr); - void cb_go_south (FWidget*, data_ptr); - void cb_go_west (FWidget*, data_ptr); - void cb_go_north (FWidget*, data_ptr); + // Callback methods + void cb_go_east (FWidget*, data_ptr); + void cb_go_south (FWidget*, data_ptr); + void cb_go_west (FWidget*, data_ptr); + void cb_go_north (FWidget*, data_ptr); - // Data Members - FButton* go_east; - FButton* go_south; - FButton* go_west; - FButton* go_north; + // Data Members + FButton* go_east; + FButton* go_south; + FButton* go_west; + FButton* go_north; }; #pragma pack(pop) @@ -176,18 +176,18 @@ void scrollview::cb_go_north (FWidget*, data_ptr) class scrollviewdemo : public FDialog { - public: - // Constructor - explicit scrollviewdemo (FWidget* = 0); + public: + // Constructor + explicit scrollviewdemo (FWidget* = 0); - // Destructor - ~scrollviewdemo (); + // Destructor + ~scrollviewdemo (); - // Event handler - void onClose (FCloseEvent*); + // Event handler + void onClose (FCloseEvent*); - // Callback method - void cb_quit (FWidget* = 0, data_ptr = 0); + // Callback method + void cb_quit (FWidget* = 0, data_ptr = 0); }; #pragma pack(pop) diff --git a/test/string-operations.cpp b/test/string-operations.cpp index dca7d116..ae69678b 100644 --- a/test/string-operations.cpp +++ b/test/string-operations.cpp @@ -1,12 +1,14 @@ // File: string-operations.cpp -#include -#include - #include #include #include +#include +#include +#include +#include + #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(L"wchar_t*"); + const FString& add3 = FString("FString + ") + + const_cast(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*"); + const FString& add5 = FString("FString + ") + + const_cast("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*") + FString(" + FString"); + const FString& add10 = const_cast("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(L"wchar_t*") + FString(" + FString"); + const FString& add12 = const_cast(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 ==, <=, <, >=, >, != @@ -268,7 +278,7 @@ int main (int, char**) // Test: extract a substring of 27 characters from position 12 std::cout << " mid: \"" - << alphabet.mid(13,27) << "\"" << std::endl; + << alphabet.mid(13, 27) << "\"" << std::endl; // Test: 11 characters from the right of the string std::cout << " right: \"" @@ -288,12 +298,12 @@ int main (int, char**) } // Test: get character access at a specified index position - FString index(5); // string with five characters + FString index(5); // string with five characters index = "index"; try { - index[0] = L'I'; // write a wide character at position 0 + index[0] = L'I'; // write a wide character at position 0 printf ( " index: [0] = %c ; [4] = %c\n" , char(index[0]) , char(index[4]) ); @@ -327,7 +337,7 @@ int main (int, char**) // Test: remove 2 characters at position 7 FString remove_std = "A fast remove"; std::cout << " remove: " - << remove_std.remove(7,2) << std::endl; + << remove_std.remove(7, 2) << std::endl; // Test: includes a substring (positive test) FString include_std = "string"; diff --git a/test/term-attributes.cpp b/test/term-attributes.cpp index 85bad0bf..cdebe09b 100644 --- a/test/term-attributes.cpp +++ b/test/term-attributes.cpp @@ -14,38 +14,37 @@ class AttribDlg : public FDialog { - public: - // Constructor - explicit AttribDlg (FWidget* = 0); + public: + // Constructor + explicit AttribDlg (FWidget* = 0); - // Destructor - ~AttribDlg(); + // Destructor + ~AttribDlg(); - // Event handlers - void onAccel (FAccelEvent*); - void onWheel (FWheelEvent*); - void onClose (FCloseEvent*); + // Event handlers + void onAccel (FAccelEvent*); + void onWheel (FWheelEvent*); + void onClose (FCloseEvent*); - // Callback methods - void cb_next (FWidget* = 0, data_ptr = 0); - void cb_back (FWidget* = 0, data_ptr = 0); + // Callback methods + void cb_next (FWidget* = 0, data_ptr = 0); + void cb_back (FWidget* = 0, data_ptr = 0); - // Data Members - short bgcolor; + // Data Members + short bgcolor; - private: - // Disable copy constructor - AttribDlg (const AttribDlg&); - // Disable assignment operator (=) - AttribDlg& operator = (const AttribDlg&); + private: + // Disable copy constructor + AttribDlg (const AttribDlg&); + // Disable assignment operator (=) + AttribDlg& operator = (const AttribDlg&); - // Method - void adjustSize(); - - // Data Members - FButton* next_button; - FButton* back_button; + // Method + void adjustSize(); + // Data Members + FButton* next_button; + FButton* back_button; }; #pragma pack(pop) @@ -176,38 +175,38 @@ void AttribDlg::adjustSize() class AttribDemo : public FWidget { - public: - // Constructor - explicit AttribDemo (FWidget* = 0); + public: + // Constructor + explicit AttribDemo (FWidget* = 0); - // Destructor - ~AttribDemo() - { } + // Destructor + ~AttribDemo() + { } - // Event handler - void onWheel (FWheelEvent* ev) - { - AttribDlg* p = dynamic_cast(getParentWidget()); + // Event handler + void onWheel (FWheelEvent* ev) + { + AttribDlg* p = static_cast(getParentWidget()); - if ( p ) - p->onWheel(ev); - } + if ( p ) + p->onWheel(ev); + } - private: - // Methods - void printColorLine(); - void printAltCharset(); - void draw(); + private: + // Methods + void printColorLine(); + void printAltCharset(); + void draw(); - // Data Member - int colors; + // Data Member + int colors; }; #pragma pack(pop) //---------------------------------------------------------------------- AttribDemo::AttribDemo (FWidget* parent) - : FWidget(parent) - , colors(getMaxColor()) + : FWidget(parent) + , colors(getMaxColor()) { if ( isMonochron() ) colors = 1; @@ -402,7 +401,7 @@ int main (int argc, char* argv[]) dialog->setShadow(); AttribDemo* demo = new AttribDemo(dialog); - demo->setGeometry (1,1,67,19); + demo->setGeometry (1, 1, 67, 19); app.setMainWidget(dialog); dialog->show(); diff --git a/test/termcap.cpp b/test/termcap.cpp index 793bd578..703b5ac9 100644 --- a/test/termcap.cpp +++ b/test/termcap.cpp @@ -1,7 +1,9 @@ -// File: opti-move.cpp +// File: termcap.cpp #include #include +#include + #include "fapplication.h" #include "ftermcap.h" #include "fvterm.h" diff --git a/test/timer.cpp b/test/timer.cpp index 3dea44d5..d595711b 100644 --- a/test/timer.cpp +++ b/test/timer.cpp @@ -8,17 +8,17 @@ class timer : public FWidget { - public: - // Constructor - explicit timer (FWidget* = 0); + public: + // Constructor + explicit timer (FWidget* = 0); - protected: - // Method - void draw(); + protected: + // Method + void draw(); - // Event handlers - void onTimer (FTimerEvent*); - void onAccel (FAccelEvent*); + // Event handlers + void onTimer (FTimerEvent*); + void onAccel (FAccelEvent*); }; //---------------------------------------------------------------------- diff --git a/test/transparent.cpp b/test/transparent.cpp index cafa017c..8a97d84c 100644 --- a/test/transparent.cpp +++ b/test/transparent.cpp @@ -17,37 +17,37 @@ class Transparent : public FDialog { - public: - // Typedef and Enumeration - typedef enum ttype - { - transparent = 0, - shadow = 1, - inherit_background = 2 - } trans_type; + public: + // Typedef and Enumeration + typedef enum ttype + { + transparent = 0, + shadow = 1, + inherit_background = 2 + } trans_type; - public: - // Constructor - explicit Transparent (FWidget* = 0, trans_type = transparent); + public: + // Constructor + explicit Transparent (FWidget* = 0, trans_type = transparent); - // Destructor - ~Transparent(); + // Destructor + ~Transparent(); - private: - // Disable copy constructor - Transparent (const Transparent&); + private: + // Disable copy constructor + Transparent (const Transparent&); - // Disable assignment operator (=) - Transparent& operator = (const Transparent&); + // Disable assignment operator (=) + Transparent& operator = (const Transparent&); - // Method - void draw(); + // Method + void draw(); - // Event handlers - void onKeyPress (FKeyEvent* ev); + // Event handlers + void onKeyPress (FKeyEvent* ev); - // Data Members - trans_type type; + // Data Members + trans_type type; }; #pragma pack(pop) @@ -134,41 +134,41 @@ void Transparent::onKeyPress (FKeyEvent* ev) class MainWindow : public FDialog { - private: - FString line1; - FString line2; + private: + FString line1; + FString line2; - private: - // Disable copy constructor - MainWindow (const MainWindow&); - // Disable assignment operator (=) - MainWindow& operator = (const MainWindow&); + private: + // Disable copy constructor + MainWindow (const MainWindow&); + // Disable assignment operator (=) + MainWindow& operator = (const MainWindow&); - void draw(); + void draw(); - // Event handlers - void onClose (FCloseEvent*); - void onShow (FShowEvent*); - void onTimer (FTimerEvent*); - void onKeyPress (FKeyEvent* ev) - { - if ( ! ev ) - return; + // Event handlers + void onClose (FCloseEvent*); + void onShow (FShowEvent*); + void onTimer (FTimerEvent*); + void onKeyPress (FKeyEvent* ev) + { + if ( ! ev ) + return; - if ( ev->key() == 'q' ) - { - close(); - ev->accept(); - } - else - FDialog::onKeyPress(ev); - } + if ( ev->key() == 'q' ) + { + close(); + ev->accept(); + } + else + FDialog::onKeyPress(ev); + } - public: - // Constructor - explicit MainWindow (FWidget* = 0); - // Destructor - ~MainWindow(); + public: + // Constructor + explicit MainWindow (FWidget* = 0); + // Destructor + ~MainWindow(); }; #pragma pack(pop) @@ -218,9 +218,9 @@ void MainWindow::draw() setReverse(true); setColor(); - setPrintPos (2,4); + setPrintPos (2, 4); print(line1); - setPrintPos (2,5); + setPrintPos (2, 5); print(line2); if ( isMonochron() ) diff --git a/test/treeview.cpp b/test/treeview.cpp index 45d3c8de..f7a74b0b 100644 --- a/test/treeview.cpp +++ b/test/treeview.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include #include "fapplication.h" #include "fdialog.h" @@ -18,23 +20,23 @@ class Treeview : public FDialog { - public: - // Constructor - explicit Treeview (FWidget* = 0); - // Destructor - ~Treeview(); + public: + // Constructor + explicit Treeview (FWidget* = 0); + // Destructor + ~Treeview(); - private: - // Disable copy constructor - Treeview (const Treeview&); - // Disable assignment operator (=) - Treeview& operator = (const Treeview&); + private: + // Disable copy constructor + Treeview (const Treeview&); + // Disable assignment operator (=) + Treeview& operator = (const Treeview&); - // Event handlers - void onClose (FCloseEvent*); + // Event handlers + void onClose (FCloseEvent*); - // Callback methods - void cb_exitApp (FWidget*, data_ptr); + // Callback methods + void cb_exitApp (FWidget*, data_ptr); }; #pragma pack(pop) @@ -92,7 +94,7 @@ Treeview::Treeview (FWidget* parent) } //---------------------------------------------------------------------- -Treeview::~Treeview() +Treeview::~Treeview() // destructor { } //---------------------------------------------------------------------- diff --git a/test/ui.cpp b/test/ui.cpp index 64e5d116..e91b08fc 100644 --- a/test/ui.cpp +++ b/test/ui.cpp @@ -1,7 +1,8 @@ // File: ui.cpp -#include #include +#include +#include #include "final.h" @@ -15,32 +16,32 @@ class ProgressDialog : public FDialog { - public: - // Constructor - explicit ProgressDialog (FWidget* = 0); - // Destructor - ~ProgressDialog(); + public: + // Constructor + explicit ProgressDialog (FWidget* = 0); + // Destructor + ~ProgressDialog(); - private: - // Disable copy constructor - ProgressDialog (const ProgressDialog&); - // Disable assignment operator (=) - ProgressDialog& operator = (const ProgressDialog&); + private: + // Disable copy constructor + ProgressDialog (const ProgressDialog&); + // Disable assignment operator (=) + ProgressDialog& operator = (const ProgressDialog&); - // Event handlers - void onShow (FShowEvent*); - void onTimer (FTimerEvent*); + // Event handlers + void onShow (FShowEvent*); + void onTimer (FTimerEvent*); - // Callback methods - void cb_reset_bar (FWidget*, data_ptr); - void cb_more_bar (FWidget*, data_ptr); - void cb_exit_bar (FWidget*, data_ptr); + // Callback methods + void cb_reset_bar (FWidget*, data_ptr); + void cb_more_bar (FWidget*, data_ptr); + void cb_exit_bar (FWidget*, data_ptr); - // Data Members - FProgressbar* progressBar; - FButton* reset; - FButton* more; - FButton* quit; + // Data Members + FProgressbar* progressBar; + FButton* reset; + FButton* more; + FButton* quit; }; #pragma pack(pop) @@ -97,7 +98,7 @@ ProgressDialog::ProgressDialog (FWidget* parent) } //---------------------------------------------------------------------- -ProgressDialog::~ProgressDialog() +ProgressDialog::~ProgressDialog() // destructor { delOwnTimer(); delCallback(quit); @@ -170,24 +171,24 @@ void ProgressDialog::cb_exit_bar (FWidget*, data_ptr) class TextWindow : public FDialog { - public: - // Constructor - explicit TextWindow (FWidget* = 0); - // Destructor - ~TextWindow(); + public: + // Constructor + explicit TextWindow (FWidget* = 0); + // Destructor + ~TextWindow(); - void append (const FString&); + void append (const FString&); - private: - // Disable copy constructor - TextWindow (const TextWindow&); - // Disable assignment operator (=) - TextWindow& operator = (const TextWindow&); + private: + // Disable copy constructor + TextWindow (const TextWindow&); + // Disable assignment operator (=) + TextWindow& operator = (const TextWindow&); - void adjustSize(); + void adjustSize(); - // Data Members - FTextView* scrollText; + // Data Members + FTextView* scrollText; }; #pragma pack(pop) @@ -212,7 +213,7 @@ TextWindow::TextWindow (FWidget* parent) } //---------------------------------------------------------------------- -TextWindow::~TextWindow() +TextWindow::~TextWindow() // destructor { } //---------------------------------------------------------------------- @@ -238,46 +239,46 @@ void TextWindow::adjustSize() class MyDialog : public FDialog { - public: - // Constructor - explicit MyDialog (FWidget* = 0); - // Destructor - ~MyDialog(); + public: + // Constructor + explicit MyDialog (FWidget* = 0); + // Destructor + ~MyDialog(); - private: - // Disable copy constructor - MyDialog (const MyDialog&); - // Disable assignment operator (=) - MyDialog& operator = (const MyDialog&); + private: + // Disable copy constructor + MyDialog (const MyDialog&); + // Disable assignment operator (=) + MyDialog& operator = (const MyDialog&); - // Method - void adjustSize(); + // Method + void adjustSize(); - // Event handlers - void onClose (FCloseEvent*); + // Event handlers + void onClose (FCloseEvent*); - // Callback methods - void cb_noFunctionMsg (FWidget*, data_ptr); - void cb_about (FWidget*, data_ptr); - void cb_terminfo (FWidget*, data_ptr); - void cb_drives (FWidget*, data_ptr); - void cb_cutClipboard (FWidget*, data_ptr); - void cb_copyClipboard (FWidget*, data_ptr); - void cb_pasteClipboard (FWidget*, data_ptr); - void cb_clearInput (FWidget*, data_ptr); - void cb_input2buttonText (FWidget*, data_ptr); - void cb_setTitlebar (FWidget*, data_ptr); - void cb_ProgressBar (FWidget*, data_ptr); - void cb_updateNumber (FWidget*, data_ptr); - void cb_activateButton (FWidget*, data_ptr); - void cb_view (FWidget*, data_ptr); - void cb_setInput (FWidget*, data_ptr); - void cb_exitApp (FWidget*, data_ptr); + // Callback methods + void cb_noFunctionMsg (FWidget*, data_ptr); + void cb_about (FWidget*, data_ptr); + void cb_terminfo (FWidget*, data_ptr); + void cb_drives (FWidget*, data_ptr); + void cb_cutClipboard (FWidget*, data_ptr); + void cb_copyClipboard (FWidget*, data_ptr); + void cb_pasteClipboard (FWidget*, data_ptr); + void cb_clearInput (FWidget*, data_ptr); + void cb_input2buttonText (FWidget*, data_ptr); + void cb_setTitlebar (FWidget*, data_ptr); + void cb_ProgressBar (FWidget*, data_ptr); + void cb_updateNumber (FWidget*, data_ptr); + void cb_activateButton (FWidget*, data_ptr); + void cb_view (FWidget*, data_ptr); + void cb_setInput (FWidget*, data_ptr); + void cb_exitApp (FWidget*, data_ptr); - // Data Members - FLineEdit* myLineEdit; - FListBox* myList; - FString clipboard; + // Data Members + FLineEdit* myLineEdit; + FListBox* myList; + FString clipboard; }; #pragma pack(pop) @@ -308,7 +309,7 @@ MyDialog::MyDialog (FWidget* parent) // "File" menu items FMenuItem* Open = new FMenuItem ("&Open...", File); - Open->addAccelerator (fc::Fckey_o); // Ctrl + O + Open->addAccelerator (fc::Fckey_o); // Ctrl + O Open->setStatusbarMessage ("Locate and open a text file"); FMenu* Recent = new FMenu ("&System files", File); Recent->setStatusbarMessage ("View text file"); @@ -316,7 +317,7 @@ MyDialog::MyDialog (FWidget* parent) FMenuItem* Line1 = new FMenuItem (File); Line1->setSeparator(); FMenuItem* Quit = new FMenuItem ("&Quit", File); - Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X + Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X Quit->setStatusbarMessage ("Exit the program"); // "Recent" menu items @@ -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(File1) + static_cast(File1) ); File2->addCallback ( "clicked", F_METHOD_CALLBACK (this, &MyDialog::cb_view), - dynamic_cast(File2) + static_cast(File2) ); File3->addCallback ( "clicked", F_METHOD_CALLBACK (this, &MyDialog::cb_view), - dynamic_cast(File3) + static_cast(File3) ); // Buttons @@ -563,7 +565,7 @@ MyDialog::MyDialog (FWidget* parent) ( "clicked", F_METHOD_CALLBACK (this, &MyDialog::cb_input2buttonText), - dynamic_cast(myLineEdit) + static_cast(myLineEdit) ); MyButton5->addCallback @@ -588,21 +590,21 @@ MyDialog::MyDialog (FWidget* parent) ( "toggled", F_METHOD_CALLBACK (this, &MyDialog::cb_activateButton), - dynamic_cast(MyButton5) + static_cast(MyButton5) ); myList->addCallback ( "clicked", F_METHOD_CALLBACK (this, &MyDialog::cb_setInput), - dynamic_cast(myLineEdit) + static_cast(myLineEdit) ); myList->addCallback ( "row-selected", F_METHOD_CALLBACK (this, &MyDialog::cb_updateNumber), - dynamic_cast(tagged_count) + static_cast(tagged_count) ); key_F1->addCallback @@ -625,7 +627,7 @@ MyDialog::MyDialog (FWidget* parent) } //---------------------------------------------------------------------- -MyDialog::~MyDialog() +MyDialog::~MyDialog() // destructor { } //---------------------------------------------------------------------- diff --git a/test/watch.cpp b/test/watch.cpp index 9bdcb2a0..db4623ac 100644 --- a/test/watch.cpp +++ b/test/watch.cpp @@ -17,42 +17,42 @@ class watch : public FDialog { - public: - // Constructor - explicit watch (FWidget* = 0); + public: + // Constructor + explicit watch (FWidget* = 0); - // Destructor - ~watch(); + // Destructor + ~watch(); - // Method - void printTime(); + // Method + void printTime(); - // Event handlers - void onTimer (FTimerEvent*); - void onClose (FCloseEvent*); + // Event handlers + void onTimer (FTimerEvent*); + void onClose (FCloseEvent*); - // Callback methods - void cb_clock (FWidget*, data_ptr); - void cb_seconds (FWidget*, data_ptr); - void cb_exitApp (FWidget*, data_ptr); + // Callback methods + void cb_clock (FWidget*, data_ptr); + void cb_seconds (FWidget*, data_ptr); + void cb_exitApp (FWidget*, data_ptr); - protected: - // Method - void adjustSize(); + protected: + // Method + void adjustSize(); - private: - // Disable copy constructor - watch (const watch&); + private: + // Disable copy constructor + watch (const watch&); - // Disable assignment operator (=) - watch& operator = (const watch&); + // Disable assignment operator (=) + watch& operator = (const watch&); - // Data Members - bool sec; - FLabel* time_label; - FLabel* time_str; - FSwitch* clock_sw; - FSwitch* seconds_sw; + // Data Members + bool sec; + FLabel* time_label; + FLabel* time_str; + FSwitch* clock_sw; + FSwitch* seconds_sw; }; #pragma pack(pop) @@ -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(); diff --git a/test/windows.cpp b/test/windows.cpp index 566dcf50..45a61c89 100644 --- a/test/windows.cpp +++ b/test/windows.cpp @@ -1,5 +1,7 @@ // File: windows.cpp +#include + #include "fapplication.h" #include "fdialog.h" #include "fdialoglistmenu.h" @@ -19,33 +21,33 @@ class smallWindow : public FDialog { - public: - // Constructor - explicit smallWindow (FWidget* = 0); + public: + // Constructor + explicit smallWindow (FWidget* = 0); - // Destructor - ~smallWindow(); + // Destructor + ~smallWindow(); - private: - // Disable copy constructor - smallWindow (const smallWindow&); + private: + // Disable copy constructor + smallWindow (const smallWindow&); - // Disable assignment operator (=) - smallWindow& operator = (const smallWindow&); + // Disable assignment operator (=) + smallWindow& operator = (const smallWindow&); - // Method - void adjustSize(); + // Method + void adjustSize(); - // Event handlers - void onShow (FShowEvent*); - void onTimer (FTimerEvent*); + // Event handlers + void onShow (FShowEvent*); + void onTimer (FTimerEvent*); - // Data Members - FLabel* left_arrow; - FLabel* right_arrow; - FLabel* top_left_label; - FLabel* top_right_label; - FLabel* bottom_label; + // Data Members + FLabel* left_arrow; + FLabel* right_arrow; + FLabel* top_left_label; + FLabel* top_right_label; + FLabel* bottom_label; }; #pragma pack(pop) @@ -157,46 +159,46 @@ void smallWindow::onTimer (FTimerEvent*) class Window : public FDialog { - public: - // Constructor - explicit Window (FWidget* = 0); + public: + // Constructor + explicit Window (FWidget* = 0); - // Destructor - ~Window(); + // Destructor + ~Window(); - private: - // Typedef - typedef struct - { - bool is_open; - FString* title; - FDialog* dgl; - } - win_data; + private: + // Typedef + typedef struct + { + bool is_open; + FString* title; + FDialog* dgl; + } + win_data; - // Disable copy constructor - Window (const Window&); + // Disable copy constructor + Window (const Window&); - // Disable assignment operator (=) - Window& operator = (const Window&); + // Disable assignment operator (=) + Window& operator = (const Window&); - // Method - void activateWindow (FDialog*); - void adjustSize(); + // Method + void activateWindow (FDialog*); + void adjustSize(); - // Event handlers - void onClose (FCloseEvent*); + // Event handlers + void onClose (FCloseEvent*); - // Callback methods - void cb_createWindows (FWidget*, data_ptr); - void cb_closeWindows (FWidget*, data_ptr); - void cb_next (FWidget*, data_ptr); - void cb_previous (FWidget*, data_ptr); - void cb_exitApp (FWidget*, data_ptr); - void cb_destroyWindow (FWidget*, data_ptr); + // Callback methods + void cb_createWindows (FWidget*, data_ptr); + void cb_closeWindows (FWidget*, data_ptr); + void cb_next (FWidget*, data_ptr); + void cb_previous (FWidget*, data_ptr); + void cb_exitApp (FWidget*, data_ptr); + void cb_destroyWindow (FWidget*, data_ptr); - // Data Members - std::vector windows; + // Data Members + std::vector windows; }; #pragma pack(pop) @@ -230,18 +232,18 @@ Window::Window (FWidget* parent) Line1->setSeparator(); FMenuItem* Next = new FMenuItem ("Ne&xt window", File); - Next->addAccelerator (fc::Fmkey_npage); // Meta/Alt + PgDn + Next->addAccelerator (fc::Fmkey_npage); // Meta/Alt + PgDn Next->setStatusbarMessage ("Switch to the next window"); FMenuItem* Previous = new FMenuItem ("&Previous window", File); - Previous->addAccelerator (fc::Fmkey_ppage); // Meta/Alt + PgUp + Previous->addAccelerator (fc::Fmkey_ppage); // Meta/Alt + PgUp Previous->setStatusbarMessage ("Switch to the previous window"); FMenuItem* Line2 = new FMenuItem (File); Line2->setSeparator(); FMenuItem* Quit = new FMenuItem ("&Quit", File); - Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X + Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X Quit->setStatusbarMessage ("Exit the program"); // Statusbar at the bottom @@ -353,7 +355,7 @@ void Window::activateWindow (FDialog* win) //---------------------------------------------------------------------- void Window::adjustSize() { - int w,h,X,Y,dx,dy; + int w, h, X, Y, dx, dy; std::vector::const_iterator iter, begin; w = getRootWidget()->getWidth(); h = getRootWidget()->getHeight(); @@ -372,7 +374,7 @@ void Window::adjustSize() { if ( (*iter)->is_open ) { - int x,y,n; + int x, y, n; n = int(std::distance(begin, iter)); x = dx + 5 + (n % 3) * 25 + 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) { - int w,h,dx,dy; + int w, h, dx, dy; std::vector::const_iterator iter, begin; iter = begin = windows.begin(); w = getRootWidget()->getWidth();