diff --git a/examples/menu.cpp b/examples/menu.cpp index a51759e9..68cd77bb 100644 --- a/examples/menu.cpp +++ b/examples/menu.cpp @@ -94,8 +94,8 @@ Menu::Menu (FWidget* parent) defaultCallback (Menubar); // Statusbar at the bottom - FStatusBar* statusbar = new FStatusBar (this); - statusbar->setMessage("Status bar message"); + FStatusBar* Statusbar = new FStatusBar (this); + Statusbar->setMessage("Status bar message"); // Headline labels FLabel* Headline1 = new FLabel(" Key ", this); diff --git a/examples/mouse.cpp b/examples/mouse.cpp index 60e4594d..ebd13e8e 100644 --- a/examples/mouse.cpp +++ b/examples/mouse.cpp @@ -481,11 +481,11 @@ void MouseDraw::drawCanvas() for (int y = 0; y < y_end; y++) // line loop { - charData* cc; // canvas character - charData* wc; // window character - cc = &canvas->text[y * x_end]; - wc = &print_area->text[(ay + y) * w_line_len + ax]; - std::memcpy (wc, cc, sizeof(charData) * unsigned(x_end)); + charData* canvaschar; // canvas character + charData* winchar; // window character + canvaschar = &canvas->text[y * x_end]; + winchar = &print_area->text[(ay + y) * w_line_len + ax]; + std::memcpy (winchar, canvaschar, sizeof(charData) * unsigned(x_end)); if ( short(print_area->changes[ay + y].xmin) > ax ) print_area->changes[ay + y].xmin = uInt(ax); diff --git a/examples/transparent.cpp b/examples/transparent.cpp index bc93df49..cdcc3b81 100644 --- a/examples/transparent.cpp +++ b/examples/transparent.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2016-2017 Markus Gans * +* Copyright 2016-2018 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -212,8 +212,8 @@ MainWindow::MainWindow (FWidget* parent) ibg->unsetTransparentShadow(); // Statusbar at the bottom - FStatusBar* statusbar = new FStatusBar (this); - statusbar->setMessage("Press Q to quit"); + FStatusBar* status_bar = new FStatusBar (this); + status_bar->setMessage("Press Q to quit"); addAccelerator('q'); unsetTransparentShadow(); diff --git a/examples/ui.cpp b/examples/ui.cpp index c755ddd0..6f455207 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -555,12 +555,12 @@ void MyDialog::initHelpMenuCallback() void MyDialog::initStatusBar() { // Statusbar at the bottom - FStatusBar* statusbar = new FStatusBar (this); + FStatusBar* Statusbar = new FStatusBar (this); // Statusbar keys - key_F1 = new FStatusKey (fc::Fkey_f1, "About", statusbar); - key_F2 = new FStatusKey (fc::Fkey_f2, "View", statusbar); - key_F3 = new FStatusKey (fc::Fkey_f3, "Quit", statusbar); + key_F1 = new FStatusKey (fc::Fkey_f1, "About", Statusbar); + key_F2 = new FStatusKey (fc::Fkey_f2, "View", Statusbar); + key_F3 = new FStatusKey (fc::Fkey_f3, "Quit", Statusbar); } //---------------------------------------------------------------------- diff --git a/examples/windows.cpp b/examples/windows.cpp index f5de2e6c..0c6cb4cb 100644 --- a/examples/windows.cpp +++ b/examples/windows.cpp @@ -229,7 +229,7 @@ Window::Window (FWidget* parent) FDialogListMenu* DglList; FString drop_down_symbol; FMenuBar* Menubar; - FStatusBar* statusbar; + FStatusBar* Statusbar; // Menu bar Menubar = new FMenuBar (this); @@ -250,8 +250,8 @@ Window::Window (FWidget* parent) createDialogButtons(); // Statusbar at the bottom - statusbar = new FStatusBar (this); - statusbar->setMessage("Status bar message"); + Statusbar = new FStatusBar (this); + Statusbar->setMessage("Status bar message"); // Generate data vector for the windows for (int n = 1; n <= 6; n++) diff --git a/include/final/fcolorpalette.h b/include/final/fcolorpalette.h index d6b338be..3c0bf64c 100644 --- a/include/final/fcolorpalette.h +++ b/include/final/fcolorpalette.h @@ -44,6 +44,9 @@ class FColorPalette { public: + // Destructor + virtual ~FColorPalette() = 0; + // Typedefs typedef void (*funcp)(short, int, int, int); diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 93dfa9f9..3ef372ec 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -869,12 +869,12 @@ void FApplication::unselectMenubarItems() if ( open_menu || (mouse && mouse->isMoved()) ) return; - FMenuBar* menubar = getMenuBar(); + FMenuBar* menu_bar = getMenuBar(); - if ( ! menubar ) + if ( ! menu_bar ) return; - if ( ! menubar->hasSelectedItem() ) + if ( ! menu_bar->hasSelectedItem() ) return; if ( ! mouse ) diff --git a/src/fmenu.cpp b/src/fmenu.cpp index de6ae73b..1bec754c 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -143,18 +143,18 @@ void FMenu::hide() //---------------------------------------------------------------------- void FMenu::onKeyPress (FKeyEvent* ev) { - FWidget* menubar; + FWidget* menu_bar; // looking for menu hotkey if ( hotkeyMenu(ev) ) return; // looking for menu bar hotkey - menubar = getMenuBar(); + menu_bar = getMenuBar(); - if ( menubar ) + if ( menu_bar ) { - FMenuBar* mbar = static_cast(menubar); + FMenuBar* mbar = static_cast(menu_bar); if ( mbar->hotkeyMenu(ev) ) return; @@ -1004,16 +1004,16 @@ void FMenu::passEventToMenuBar (FMouseEvent*& ev) { // Mouse event handover to the menu bar - FWidget* menubar = getMenuBar(); + FWidget* menu_bar = getMenuBar(); const FPoint& t = ev->getTermPos(); - const FPoint& p = menubar->termToWidgetPos(t); + const FPoint& p = menu_bar->termToWidgetPos(t); int b = ev->getButton(); try { FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p, t, b); - setClickedWidget(menubar); - FMenuBar* mbar = static_cast(menubar); + setClickedWidget(menu_bar); + FMenuBar* mbar = static_cast(menu_bar); mbar->mouse_down = true; mbar->onMouseMove(_ev); delete _ev; diff --git a/src/fmouse.cpp b/src/fmouse.cpp index ff9adb54..740f8206 100644 --- a/src/fmouse.cpp +++ b/src/fmouse.cpp @@ -519,22 +519,22 @@ void FMouseX11::processEvent (struct timeval* time) const FPoint& mouse_position = getPos(); uChar x, y; - int button; + int btn; x = uChar(x11_mouse[1] - 0x20); y = uChar(x11_mouse[2] - 0x20); - button = x11_mouse[0]; + btn = x11_mouse[0]; new_mouse_position.setPoint (x, y); // Fill bit field with 0 std::memset(&b_state, 0x00, sizeof(b_state)); - setKeyState (button); - setMoveState (mouse_position, button); - setButtonState (button & button_mask, time); + setKeyState (btn); + setMoveState (mouse_position, btn); + setButtonState (btn & button_mask, time); if ( new_mouse_position == mouse_position && ! isWheelUp() && ! isWheelDown() - && uChar(button) == x11_button_state ) + && uChar(btn) == x11_button_state ) { mouse_event_occurred = false; x11_mouse[0] = '\0'; // Delete already interpreted data @@ -544,7 +544,7 @@ void FMouseX11::processEvent (struct timeval* time) mouse_event_occurred = true; setPos (FPoint(x, y)); // Get the button state from string - x11_button_state = uChar(button); + x11_button_state = uChar(btn); // Delete already interpreted data x11_mouse[0] = '\0'; } @@ -552,23 +552,23 @@ void FMouseX11::processEvent (struct timeval* time) // private methods of FMouseX11 //---------------------------------------------------------------------- -void FMouseX11::setKeyState (int button) +void FMouseX11::setKeyState (int btn) { - if ( (button & key_shift) == key_shift ) + if ( (btn & key_shift) == key_shift ) b_state.shift_button = Pressed; - if ( (button & key_meta) == key_meta ) + if ( (btn & key_meta) == key_meta ) b_state.meta_button = Pressed; - if ( (button & key_ctrl) == key_ctrl ) + if ( (btn & key_ctrl) == key_ctrl ) b_state.control_button = Pressed; } //---------------------------------------------------------------------- -void FMouseX11::setMoveState (const FPoint& mouse_position, int button) +void FMouseX11::setMoveState (const FPoint& mouse_position, int btn) { - if ( (button & button_mask) >= button1_pressed_move - && (button & button_mask) <= button3_pressed_move + if ( (btn & button_mask) >= button1_pressed_move + && (btn & button_mask) <= button3_pressed_move && mouse_position != zero_point ) { b_state.mouse_moved = true; @@ -576,13 +576,13 @@ void FMouseX11::setMoveState (const FPoint& mouse_position, int button) } //---------------------------------------------------------------------- -void FMouseX11::setButtonState (int button, struct timeval* time) +void FMouseX11::setButtonState (int btn, struct timeval* time) { // Get the x11 mouse button state const FPoint& mouse_position = getPos(); - switch ( button ) + switch ( btn ) { case button1_pressed: case button1_pressed_move: @@ -723,12 +723,12 @@ void FMouseSGR::processEvent (struct timeval* time) { const FPoint& mouse_position = getPos(); register char* p; - int button; + int btn; short x, y; x = 0; y = 0; - button = 0; + btn = 0; // parse the SGR mouse string p = sgr_mouse; @@ -742,7 +742,7 @@ void FMouseSGR::processEvent (struct timeval* time) return; } - button = 10 * button + (*p - '0'); + btn = 10 * btn + (*p - '0'); p++; } @@ -773,18 +773,18 @@ void FMouseSGR::processEvent (struct timeval* time) new_mouse_position.setPoint (x, y); // Fill bit field with 0 std::memset(&b_state, 0x00, sizeof(b_state)); - setKeyState (button); - setMoveState (mouse_position, button); + setKeyState (btn); + setMoveState (mouse_position, btn); if ( *p == pressed ) - setPressedButtonState (button & button_mask, time); + setPressedButtonState (btn & button_mask, time); else // *p == released - setReleasedButtonState (button & button_mask); + setReleasedButtonState (btn & button_mask); if ( mouse_position == new_mouse_position && ! isWheelUp() && ! isWheelDown() - && sgr_button_state == uChar(((*p & 0x20) << 2) + button) ) + && sgr_button_state == uChar(((*p & 0x20) << 2) + btn) ) { mouse_event_occurred = false; sgr_mouse[0] = '\0'; // Delete already interpreted data @@ -794,30 +794,30 @@ void FMouseSGR::processEvent (struct timeval* time) mouse_event_occurred = true; setPos (FPoint(x, y)); // Get the button state from string - sgr_button_state = uChar(((*p & 0x20) << 2) + button); + sgr_button_state = uChar(((*p & 0x20) << 2) + btn); // Delete already interpreted data sgr_mouse[0] = '\0'; } // private methods of FMouseSGR //---------------------------------------------------------------------- -void FMouseSGR::setKeyState (int button) +void FMouseSGR::setKeyState (int btn) { - if ( (button & key_shift) == key_shift ) + if ( (btn & key_shift) == key_shift ) b_state.shift_button = true; - if ( (button & key_meta) == key_meta ) + if ( (btn & key_meta) == key_meta ) b_state.meta_button = true; - if ( (button & key_ctrl) == key_ctrl ) + if ( (btn & key_ctrl) == key_ctrl ) b_state.control_button = true; } //---------------------------------------------------------------------- -void FMouseSGR::setMoveState (const FPoint& mouse_position, int button) +void FMouseSGR::setMoveState (const FPoint& mouse_position, int btn) { - if ( (button & button_mask) >= button1_move - && (button & button_mask) <= button3_move + if ( (btn & button_mask) >= button1_move + && (btn & button_mask) <= button3_move && mouse_position != zero_point ) { b_state.mouse_moved = true; @@ -825,13 +825,13 @@ void FMouseSGR::setMoveState (const FPoint& mouse_position, int button) } //---------------------------------------------------------------------- -void FMouseSGR::setPressedButtonState (int button, struct timeval* time) +void FMouseSGR::setPressedButtonState (int btn, struct timeval* time) { // Gets the extended x11 mouse mode (SGR) status for pressed buttons const FPoint& mouse_position = getPos(); - switch ( button ) + switch ( btn ) { case button1: case button1_move: @@ -882,11 +882,11 @@ void FMouseSGR::setPressedButtonState (int button, struct timeval* time) } //---------------------------------------------------------------------- -void FMouseSGR::setReleasedButtonState (int button) +void FMouseSGR::setReleasedButtonState (int btn) { // Gets the extended x11 mouse mode (SGR) status for released buttons - switch ( button ) + switch ( btn ) { case button1: case button1_move: @@ -980,12 +980,12 @@ void FMouseUrxvt::processEvent (struct timeval* time) register char* p; register bool x_neg; register bool y_neg; - int button; + int btn; short x, y; x = 0; y = 0; - button = 0; + btn = 0; // Parse the Urxvt mouse string p = urxvt_mouse; @@ -1001,7 +1001,7 @@ void FMouseUrxvt::processEvent (struct timeval* time) return; } - button = 10 * button + (*p - '0'); + btn = 10 * btn + (*p - '0'); p++; } @@ -1058,14 +1058,14 @@ void FMouseUrxvt::processEvent (struct timeval* time) new_mouse_position.setPoint (x, y); // Fill bit field with 0 std::memset(&b_state, 0x00, sizeof(b_state)); - setKeyState (button); - setMoveState (mouse_position, button); - setButtonState (button & button_mask, time); + setKeyState (btn); + setMoveState (mouse_position, btn); + setButtonState (btn & button_mask, time); if ( mouse_position == new_mouse_position && ! isWheelUp() && ! isWheelDown() - && urxvt_button_state == uChar(button) ) + && urxvt_button_state == uChar(btn) ) { mouse_event_occurred = false; urxvt_mouse[0] = '\0'; // Delete already interpreted data @@ -1074,7 +1074,7 @@ void FMouseUrxvt::processEvent (struct timeval* time) mouse_event_occurred = true; setPos (FPoint(x, y)); - urxvt_button_state = uChar(button); + urxvt_button_state = uChar(btn); // Delete already interpreted data urxvt_mouse[0] = '\0'; } @@ -1082,23 +1082,23 @@ void FMouseUrxvt::processEvent (struct timeval* time) // private methods of FMouseUrxvt //---------------------------------------------------------------------- -void FMouseUrxvt::setKeyState (int button) +void FMouseUrxvt::setKeyState (int btn) { - if ( (button & key_shift) == key_shift ) + if ( (btn & key_shift) == key_shift ) b_state.shift_button = Pressed; - if ( (button & key_meta) == key_meta ) + if ( (btn & key_meta) == key_meta ) b_state.meta_button = Pressed; - if ( (button & key_ctrl) == key_ctrl ) + if ( (btn & key_ctrl) == key_ctrl ) b_state.control_button = Pressed; } //---------------------------------------------------------------------- -void FMouseUrxvt::setMoveState (const FPoint& mouse_position, int button) +void FMouseUrxvt::setMoveState (const FPoint& mouse_position, int btn) { - if ( (button & button_mask) >= button1_pressed_move - && (button & button_mask) <= button3_pressed_move + if ( (btn & button_mask) >= button1_pressed_move + && (btn & button_mask) <= button3_pressed_move && mouse_position != zero_point ) { b_state.mouse_moved = true; @@ -1106,13 +1106,13 @@ void FMouseUrxvt::setMoveState (const FPoint& mouse_position, int button) } //---------------------------------------------------------------------- -void FMouseUrxvt::setButtonState (int button, struct timeval* time) +void FMouseUrxvt::setButtonState (int btn, struct timeval* time) { // Get the urxvt mouse button state const FPoint& mouse_position = getPos(); - switch ( button ) + switch ( btn ) { case button1_pressed: case button1_pressed_move: diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index 25a6a7bd..18b7b7a3 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -332,9 +332,12 @@ char* FTermDetection::init_256colorTerminal() #if DEBUG if ( new_termtype ) + { std::strncpy ( termtype_256color , new_termtype - , std::strlen(new_termtype) + 1 ); + , sizeof(termtype_256color) ); + termtype_256color[sizeof(termtype_256color) - 1] = '\0'; + } #endif return new_termtype; @@ -472,7 +475,7 @@ const FString FTermDetection::getXTermColorName (int color) int stdin_no = FTermios::getStdIn(); char temp[512] = { }; - FTerm::putstringf (OSC "4;%d;?" BEL, color); // get color + std::fprintf (stdout, OSC "4;%d;?" BEL, color); // get color std::fflush(stdout); FD_ZERO(&ifds); @@ -534,9 +537,12 @@ char* FTermDetection::parseAnswerbackMsg (char current_termtype[]) #if DEBUG if ( new_termtype ) + { std::strncpy ( termtype_Answerback , new_termtype - , std::strlen(new_termtype) + 1 ); + , sizeof(termtype_Answerback) ); + termtype_Answerback[sizeof(termtype_Answerback) - 1] = '\0'; + } #endif return new_termtype; @@ -648,9 +654,10 @@ char* FTermDetection::parseSecDA (char current_termtype[]) #if DEBUG if ( new_termtype ) - std::strncpy ( termtype_SecDA - , new_termtype - , std::strlen(new_termtype) + 1 ); + { + std::strncpy (termtype_SecDA, new_termtype, sizeof(termtype_SecDA)); + termtype_SecDA[sizeof(termtype_SecDA) - 1] = '\0'; + } #endif return new_termtype; @@ -664,16 +671,13 @@ const FString FTermDetection::getSecDA() int a = 0 , b = 0 , c = 0 - , stdin_no = FTermios::getStdIn(); + , stdin_no = FTermios::getStdIn() + , stdout_no = FTermios::getStdOut(); fd_set ifds; struct timeval tv; // Get the secondary device attributes -#if defined(__CYGWIN__) - puts (SECDA); -#else - FTerm::putstring (SECDA); -#endif + write(stdout_no, SECDA, std::strlen(SECDA)); std::fflush(stdout); FD_ZERO(&ifds); diff --git a/src/fvterm.cpp b/src/fvterm.cpp index 665114ef..2a866696 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -2114,15 +2114,15 @@ void FVTerm::init() } //---------------------------------------------------------------------- -void FVTerm::init_characterLengths (FOptiMove* opti_move) +void FVTerm::init_characterLengths (FOptiMove* optimove) { - if ( opti_move ) + if ( optimove ) { - cursor_address_length = opti_move->getCursorAddressLength(); - erase_char_length = opti_move->getEraseCharsLength(); - repeat_char_length = opti_move->getRepeatCharLength(); - clr_bol_length = opti_move->getClrBolLength(); - clr_eol_length = opti_move->getClrEolLength(); + cursor_address_length = optimove->getCursorAddressLength(); + erase_char_length = optimove->getEraseCharsLength(); + repeat_char_length = optimove->getRepeatCharLength(); + clr_bol_length = optimove->getClrBolLength(); + clr_eol_length = optimove->getClrEolLength(); } else {