diff --git a/examples/calculator.cpp b/examples/calculator.cpp index c0f6fae2..6b059868 100644 --- a/examples/calculator.cpp +++ b/examples/calculator.cpp @@ -30,7 +30,7 @@ #include -const lDouble PI = 3.141592653589793238L; +constexpr lDouble PI = 3.141592653589793238L; //---------------------------------------------------------------------- diff --git a/examples/checklist.cpp b/examples/checklist.cpp index db41c5d7..1ee56939 100644 --- a/examples/checklist.cpp +++ b/examples/checklist.cpp @@ -125,7 +125,7 @@ void CheckList::populate() { "Lemons", "Low" } }; - const int lastItem = int(sizeof(list) / sizeof(list[0])) - 1; + constexpr int lastItem = int(sizeof(list) / sizeof(list[0])) - 1; for (int i = 0; i <= lastItem; i++) { diff --git a/examples/listbox.cpp b/examples/listbox.cpp index 88e1f747..ddfb5c31 100644 --- a/examples/listbox.cpp +++ b/examples/listbox.cpp @@ -27,40 +27,41 @@ #include +using namespace finalcut; // Global application object -static std::shared_ptr temp_str { nullptr }; +static std::shared_ptr temp_str { nullptr }; // Function prototypes -void doubleToItem ( finalcut::FListBoxItem& - , finalcut::FWidget::data_ptr container +void doubleToItem ( FListBoxItem& + , FWidget::data_ptr container , int index); -finalcut::FString& doubleToString (std::list::const_iterator iter); -finalcut::FString& mapToString ( std::map::const_iterator iter ); +FString& doubleToString (std::list::const_iterator iter); +FString& mapToString ( std::map::const_iterator iter ); // Lazy conversion import function -void doubleToItem ( finalcut::FListBoxItem& item - , finalcut::FWidget::data_ptr container, int index) +void doubleToItem ( FListBoxItem& item + , FWidget::data_ptr container, int index) { typedef std::list* double_list_ptr; double_list_ptr dbllist = static_cast(container); std::list::iterator iter = dbllist->begin(); std::advance (iter, index); - item.setText (finalcut::FString() << *iter); - item.setData (finalcut::FWidget::data_ptr(&(*iter))); + item.setText (FString() << *iter); + item.setData (FWidget::data_ptr(&(*iter))); } // Import converter functions -finalcut::FString& doubleToString (std::list::const_iterator iter) +FString& doubleToString (std::list::const_iterator iter) { return temp_str->setNumber(*iter); } -finalcut::FString& mapToString ( std::map::const_iterator iter ) +FString& mapToString ( std::map::const_iterator iter ) { return *temp_str = iter->first + ": " + iter->second; } @@ -73,7 +74,7 @@ finalcut::FString& mapToString ( std::map double_list{}; - finalcut::FListBox list1{this}; - finalcut::FListBox list2{this}; - finalcut::FListBox list3{this}; - finalcut::FButton Quit{this}; + FListBox list1{this}; + FListBox list2{this}; + FListBox list3{this}; + FButton Quit{this}; }; #pragma pack(pop) //---------------------------------------------------------------------- -Listbox::Listbox (finalcut::FWidget* parent) - : finalcut::FDialog(parent) +Listbox::Listbox (FWidget* parent) + : FDialog(parent) { - temp_str = std::make_shared(); + temp_str = std::make_shared(); // listbox 1 //---------- @@ -113,7 +114,7 @@ Listbox::Listbox (finalcut::FWidget* parent) list1.setText ("FListBoxItem"); for (int i = 1; i < 30; i++) - list1.insert (L"----- " + (finalcut::FString() << i) + L" -----"); + list1.insert (L"----- " + (FString() << i) + L" -----"); // listbox 2 //---------- @@ -135,7 +136,7 @@ Listbox::Listbox (finalcut::FWidget* parent) // listbox 3 //---------- - std::map TLD; + std::map TLD; TLD["com"] = "Commercial"; TLD["org"] = "Organization"; TLD["net"] = "Network"; @@ -154,7 +155,7 @@ Listbox::Listbox (finalcut::FWidget* parent) Quit.addCallback ( "clicked", - F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp) + F_METHOD_CALLBACK (this, &FApplication::cb_exitApp) ); } @@ -163,9 +164,9 @@ Listbox::~Listbox() // destructor { } //---------------------------------------------------------------------- -void Listbox::onClose (finalcut::FCloseEvent* ev) +void Listbox::onClose (FCloseEvent* ev) { - finalcut::FApplication::closeConfirmationDialog (this, ev); + FApplication::closeConfirmationDialog (this, ev); } @@ -176,7 +177,7 @@ void Listbox::onClose (finalcut::FCloseEvent* ev) int main (int argc, char* argv[]) { // Create the application object - finalcut::FApplication app(argc, argv); + FApplication app(argc, argv); // Create main dialog object Listbox d(&app); diff --git a/examples/listview.cpp b/examples/listview.cpp index 39571d37..e1f16598 100644 --- a/examples/listview.cpp +++ b/examples/listview.cpp @@ -173,7 +173,7 @@ void Listview::populate() { "Zurich", "Mostly Cloudy", "23°C", "44%", "1023.7 mb" } }; - const int lastItem = int(sizeof(weather) / sizeof(weather[0])) - 1; + constexpr int lastItem = int(sizeof(weather) / sizeof(weather[0])) - 1; for (int i = 0; i <= lastItem; i++) { diff --git a/examples/ui.cpp b/examples/ui.cpp index 2c5cefe0..2f710f6d 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -774,8 +774,8 @@ void MyDialog::cb_noFunctionMsg (finalcut::FWidget* widget, data_ptr) //---------------------------------------------------------------------- void MyDialog::cb_about (finalcut::FWidget*, data_ptr) { - const char libver[] = F_VERSION; - finalcut::FString line(2, finalcut::fc::BoxDrawingsHorizontal); + constexpr char libver[] = F_VERSION; + const finalcut::FString line(2, finalcut::fc::BoxDrawingsHorizontal); finalcut::FMessageBox info ( "About" , line + L" The Final Cut " + line + "\n\n" @@ -999,10 +999,10 @@ void MyDialog::cb_setInput (finalcut::FWidget* widget, data_ptr data) int main (int argc, char* argv[]) { - finalcut::FString ver = F_VERSION; // Library version - finalcut::FString title = "The FINAL CUT " - + ver - + " (C) 2018 by Markus Gans"; + const finalcut::FString ver = F_VERSION; // Library version + const finalcut::FString title = "The FINAL CUT " + + ver + + " (C) 2018 by Markus Gans"; // Create the application object app finalcut::FApplication app(argc, argv); diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 04d928eb..51223d6d 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -67,8 +67,10 @@ FApplication::FApplication ( const int& _argc , app_argc{_argc} , app_argv{_argv} { - assert ( ! app_object - && "FApplication: There should be only one application object" ); + if ( app_object ) + throw std::runtime_error( "FApplication: There should be " + "only one application object" ); + app_object = this; if ( ! (_argc && _argv) ) @@ -773,7 +775,7 @@ FWidget*& FApplication::determineClickedWidget() && ! mouse->isWheelDown() ) return clicked; - const FPoint& mouse_position = mouse->getPos(); + const auto& mouse_position = mouse->getPos(); // Determine the window object on the current click position auto window = FWindow::getWindowWidgetAt (mouse_position); @@ -817,7 +819,7 @@ void FApplication::closeOpenMenu() if ( mouse ) { - const FPoint& mouse_position = mouse->getPos(); + const auto& mouse_position = mouse->getPos(); if ( menu->containsMenuStructure(mouse_position) ) return; @@ -867,7 +869,7 @@ void FApplication::unselectMenubarItems() if ( ! mouse ) return; - const FPoint& mouse_position = mouse->getPos(); + const auto& mouse_position = mouse->getPos(); if ( ! menu_bar->getTermGeometry().contains(mouse_position) ) { @@ -900,8 +902,7 @@ void FApplication::sendMouseEvent() if ( ! mouse ) return; - FPoint widgetMousePos; - const FPoint& mouse_position = mouse->getPos(); + const auto& mouse_position = mouse->getPos(); int key_state = 0; if ( mouse->isShiftKeyPressed() ) @@ -913,7 +914,7 @@ void FApplication::sendMouseEvent() if ( mouse->isMetaKeyPressed() ) key_state |= fc::MetaButton; - widgetMousePos = clicked->termToWidgetPos(mouse_position); + auto widgetMousePos = clicked->termToWidgetPos(mouse_position); if ( mouse->isMoved() ) { diff --git a/src/fbutton.cpp b/src/fbutton.cpp index a9b3d650..e4a17326 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -149,8 +149,8 @@ bool FButton::setFocus (bool enable) { if ( getStatusBar() ) { - const FString& msg = getStatusbarMessage(); - const FString& curMsg = getStatusBar()->getMessage(); + const auto& msg = getStatusbarMessage(); + const auto& curMsg = getStatusBar()->getMessage(); if ( curMsg != msg ) getStatusBar()->setMessage(msg); @@ -747,8 +747,8 @@ void FButton::updateStatusBar() if ( ! flags.focus || ! getStatusBar() ) return; - const FString& msg = getStatusbarMessage(); - const FString& curMsg = getStatusBar()->getMessage(); + const auto& msg = getStatusbarMessage(); + const auto& curMsg = getStatusBar()->getMessage(); if ( curMsg != msg ) { diff --git a/src/fdialog.cpp b/src/fdialog.cpp index fbb14cfb..6be9436f 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -194,7 +194,7 @@ void FDialog::setPos (int x, int y, bool) , dy = getY() - y , old_x = getTermX() , old_y = getTermY(); - const FPoint& shadow = getShadow(); + const auto& shadow = getShadow(); rsw = shadow.getX(); // right shadow width; bsh = shadow.getY(); // bottom shadow height old_geometry = getTermGeometryWithShadow(); @@ -304,7 +304,7 @@ void FDialog::setSize (std::size_t w, std::size_t h, bool adjust) , old_height = int(getHeight()) , dw = old_width - int(w) , dh = old_height - int(h); - const FPoint& shadow = getShadow(); + const auto& shadow = getShadow(); int rsw = shadow.getX(); // right shadow width; int bsh = shadow.getY(); // bottom shadow height @@ -1357,7 +1357,7 @@ void FDialog::pressZoomButton (mouseStates& ms) //---------------------------------------------------------------------- inline bool FDialog::isMouseOverMenu (const FPoint& termpos) { - const FRect& menu_geometry = dialog_menu->getTermGeometry(); + const auto& menu_geometry = dialog_menu->getTermGeometry(); if ( dialog_menu->getCount() > 0 && menu_geometry.contains(termpos) ) return true; @@ -1375,8 +1375,8 @@ inline void FDialog::passEventToSubMenu ( mouseStates& ms || ! dialog_menu->isShown() ) return; - const FPoint& g = ms.termPos; - const FPoint& p = dialog_menu->termToWidgetPos(g); + const auto& g = ms.termPos; + const auto& p = dialog_menu->termToWidgetPos(g); int b = ev->getButton(); try diff --git a/src/ffiledialog.cpp b/src/ffiledialog.cpp index d7e03365..48c5d55c 100644 --- a/src/ffiledialog.cpp +++ b/src/ffiledialog.cpp @@ -330,8 +330,8 @@ void FFileDialog::adjustSize() //---------------------------------------------------------------------- void FFileDialog::init() { - static const std::size_t w = 42; - static const std::size_t h = 15; + static constexpr std::size_t w = 42; + static constexpr std::size_t h = 15; int x, y; setGeometry(1, 1, w, h, false); @@ -725,7 +725,7 @@ int FFileDialog::changeDir (const FString& dirname) //---------------------------------------------------------------------- void FFileDialog::printPath (const FString& txt) { - const FString& path = txt; + const auto& path = txt; const uInt max_width = uInt(filebrowser.getWidth()) - 4; if ( path.getLength() > max_width ) @@ -775,7 +775,7 @@ void FFileDialog::cb_processActivate (FWidget*, data_ptr) if ( ! dir_entries.empty() ) { - const FString& input = filename.getText().trim(); + const auto& input = filename.getText().trim(); for (auto&& entry : dir_entries) { @@ -803,7 +803,7 @@ void FFileDialog::cb_processRowChanged (FWidget*, data_ptr) if ( n == 0 ) return; - const FString& name = dir_entries[n - 1].name; + const auto& name = dir_entries[n - 1].name; if ( dir_entries[n - 1].directory ) filename.setText( name + '/' ); diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index dbc0ebb1..270c4694 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -354,7 +354,7 @@ bool FKeyboard::isKeypressTimeout() FKey FKeyboard::UTF8decode (const char utf8[]) { FKey ucs = 0; // Universal coded character - const std::size_t max = 4; + constexpr std::size_t max = 4; std::size_t len = std::strlen(utf8); if ( len > max ) diff --git a/src/flabel.cpp b/src/flabel.cpp index 40466feb..6c19272f 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -272,8 +272,8 @@ void FLabel::onMouseDown (FMouseEvent* ev) if ( auto parent = getParentWidget() ) { int b = ev->getButton(); - const FPoint& tp = ev->getTermPos(); - const FPoint& p = parent->termToWidgetPos(tp); + const auto& tp = ev->getTermPos(); + const auto& p = parent->termToWidgetPos(tp); try { diff --git a/src/flineedit.cpp b/src/flineedit.cpp index c0003c33..94974ac9 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -199,8 +199,8 @@ bool FLineEdit::setFocus (bool enable) if ( getStatusBar() ) { - const FString& msg = getStatusbarMessage(); - const FString& curMsg = getStatusBar()->getMessage(); + const auto& msg = getStatusbarMessage(); + const auto& curMsg = getStatusBar()->getMessage(); if ( curMsg != msg ) getStatusBar()->setMessage(msg); @@ -690,8 +690,8 @@ void FLineEdit::draw() if ( flags.focus && getStatusBar() ) { - const FString& msg = getStatusbarMessage(); - const FString& curMsg = getStatusBar()->getMessage(); + const auto& msg = getStatusbarMessage(); + const auto& curMsg = getStatusBar()->getMessage(); if ( curMsg != msg ) { diff --git a/src/flistbox.cpp b/src/flistbox.cpp index f7cbb87d..34778dac 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -188,8 +188,8 @@ bool FListBox::setFocus (bool enable) { if ( getStatusBar() ) { - const FString& msg = getStatusbarMessage(); - const FString& curMsg = getStatusBar()->getMessage(); + const auto& msg = getStatusbarMessage(); + const auto& curMsg = getStatusBar()->getMessage(); if ( curMsg != msg ) getStatusBar()->setMessage(msg); @@ -894,8 +894,8 @@ void FListBox::draw() if ( flags.focus && getStatusBar() ) { - const FString& msg = getStatusbarMessage(); - const FString& curMsg = getStatusBar()->getMessage(); + const auto& msg = getStatusbarMessage(); + const auto& curMsg = getStatusBar()->getMessage(); if ( curMsg != msg ) { @@ -1510,7 +1510,7 @@ void FListBox::nextListItem (int distance) //---------------------------------------------------------------------- void FListBox::scrollToX (int val) { - static const std::size_t padding_space = 2; // 1 leading + 1 trailing space + static constexpr std::size_t padding_space = 2; // 1 leading + 1 trailing space std::size_t xoffset_end = max_line_width - getClientWidth() + padding_space; if ( xoffset == val ) @@ -1567,7 +1567,7 @@ void FListBox::scrollLeft (int distance) //---------------------------------------------------------------------- void FListBox::scrollRight (int distance) { - static const std::size_t padding_space = 2; // 1 leading + 1 trailing space + static constexpr std::size_t padding_space = 2; // 1 leading + 1 trailing space std::size_t xoffset_end = max_line_width - getClientWidth() + padding_space; xoffset += distance; @@ -1915,7 +1915,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 trailing space + static constexpr int padding_space = 2; // 1 leading space + 1 trailing space FScrollbar::sType scrollType; int distance = 1 , pagesize = 4 diff --git a/src/flistview.cpp b/src/flistview.cpp index 79e54b85..9678f5ce 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -1505,8 +1505,8 @@ void FListView::draw() if ( flags.focus && getStatusBar() ) { - const FString& msg = getStatusbarMessage(); - const FString& curMsg = getStatusBar()->getMessage(); + const auto& msg = getStatusbarMessage(); + const auto& curMsg = getStatusBar()->getMessage(); if ( curMsg != msg ) { @@ -1535,7 +1535,7 @@ void FListView::drawHeadlines() while ( iter != header.end() ) { - const FString& text = iter->name; + const auto& text = iter->name; if ( text.isNull() || text.isEmpty() ) { @@ -1632,11 +1632,11 @@ void FListView::drawListLine ( const FListViewItem* item { for (std::size_t col = 0; col < item->column_list.size(); ) { - static const std::size_t leading_space = 1; - static const std::size_t checkbox_space = 4; - static const std::size_t ellipsis_length = 2; + static constexpr std::size_t leading_space = 1; + static constexpr std::size_t checkbox_space = 4; + static constexpr std::size_t ellipsis_length = 2; - const FString& text = item->column_list[col]; + const auto& text = item->column_list[col]; std::size_t width = std::size_t(header[col].width); std::size_t txt_length = text.getLength(); // Increment the value of i for the column position @@ -1819,8 +1819,8 @@ inline void FListView::drawHeaderBorder (std::size_t length) void FListView::drawHeadlineLabel (headerItems::const_iterator& iter) { // Print lable text - static const std::size_t leading_space = 1; - const FString& text = iter->name; + static constexpr std::size_t leading_space = 1; + const auto& text = iter->name; FString txt = " " + text; std::size_t width = std::size_t(iter->width); std::size_t txt_length = txt.getLength(); @@ -1867,7 +1867,7 @@ void FListView::drawColumnEllipsis ( headerItems::const_iterator& iter , const FString& text ) { // Print lable ellipsis - static const int ellipsis_length = 2; + static constexpr int ellipsis_length = 2; int width = iter->width; headerline << ' '; @@ -1902,7 +1902,7 @@ void FListView::updateDrawing (bool draw_vbar, bool draw_hbar) //---------------------------------------------------------------------- std::size_t FListView::determineLineWidth (FListViewItem* item) { - static const std::size_t padding_space = 1; + static constexpr std::size_t padding_space = 1; std::size_t line_width = padding_space; // leading space uInt column_idx = 0; uInt entries = uInt(item->column_list.size()); @@ -2007,7 +2007,7 @@ void FListView::mouseHeaderClicked() while ( iter != header.end() ) { - static const int leading_space = 1; + static constexpr int leading_space = 1; bool has_sort_indicator = bool( column == sort_column ); int click_width = int(iter->name.getLength()); diff --git a/src/fmenu.cpp b/src/fmenu.cpp index cb857bf2..95411f58 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -93,7 +93,7 @@ void FMenu::hide() return; FWindow::hide(); - const FRect& t_geometry = getTermGeometryWithShadow(); + const auto& t_geometry = getTermGeometryWithShadow(); restoreVTerm (t_geometry); updateTerminal(); flush_out(); @@ -392,7 +392,7 @@ bool FMenu::isMouseOverSubMenu (const FPoint& termpos) { if ( opened_sub_menu ) { - const FRect& submenu_geometry = opened_sub_menu->getTermGeometry(); + const auto& submenu_geometry = opened_sub_menu->getTermGeometry(); if ( submenu_geometry.contains(termpos) ) return true; @@ -404,7 +404,7 @@ bool FMenu::isMouseOverSubMenu (const FPoint& termpos) //---------------------------------------------------------------------- bool FMenu::isMouseOverSuperMenu (const FPoint& termpos) { - auto smenu = superMenuAt (termpos); + const auto smenu = superMenuAt (termpos); if ( smenu ) return true; @@ -893,8 +893,8 @@ void FMenu::mouseMoveOverBorder (mouseStates& ms) if ( getStatusBar() ) { - const FString& msg = getStatusbarMessage(); - const FString& curMsg = getStatusBar()->getMessage(); + const auto& msg = getStatusbarMessage(); + const auto& curMsg = getStatusBar()->getMessage(); if ( curMsg != msg ) { @@ -912,8 +912,8 @@ void FMenu::passEventToSubMenu (FMouseEvent*& ev) { // Mouse event handover to sub-menu - const FPoint& t = ev->getTermPos(); - const FPoint& p = opened_sub_menu->termToWidgetPos(t); + const auto& t = ev->getTermPos(); + const auto& p = opened_sub_menu->termToWidgetPos(t); int b = ev->getButton(); try @@ -936,8 +936,8 @@ void FMenu::passEventToSuperMenu (FMouseEvent*& ev) // Mouse event handover to super-menu const auto& smenu = superMenuAt (ev->getTermPos()); - const FPoint& t = ev->getTermPos(); - const FPoint& p = smenu->termToWidgetPos(t); + const auto& t = ev->getTermPos(); + const auto& p = smenu->termToWidgetPos(t); int b = ev->getButton(); try @@ -960,8 +960,8 @@ void FMenu::passEventToMenuBar (FMouseEvent*& ev) // Mouse event handover to the menu bar const auto& menu_bar = getMenuBar(); - const FPoint& t = ev->getTermPos(); - const FPoint& p = menu_bar->termToWidgetPos(t); + const auto& t = ev->getTermPos(); + const auto& p = menu_bar->termToWidgetPos(t); int b = ev->getButton(); try diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index d7d48da4..6b7fd56a 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -982,8 +982,8 @@ void FMenuBar::passEventToMenu (FMouseEvent*& ev) if ( menu->getCount() > 0 && menu_geometry.contains(ev->getTermPos()) ) { - const FPoint& t = ev->getTermPos(); - const FPoint& p = menu->termToWidgetPos(t); + const auto& t = ev->getTermPos(); + const auto& p = menu->termToWidgetPos(t); int b = ev->getButton(); try diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index 1af5d98b..5486d1ac 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -147,8 +147,8 @@ bool FMenuItem::setFocus (bool enable) if ( getStatusBar() ) { - const FString& msg = getStatusbarMessage(); - const FString& curMsg = getStatusBar()->getMessage(); + const auto& msg = getStatusbarMessage(); + const auto& curMsg = getStatusBar()->getMessage(); if ( curMsg != msg ) getStatusBar()->setMessage(msg); @@ -633,7 +633,7 @@ void FMenuItem::createDialogList (FMenu* winmenu) FMenuItem* win_item; uInt32 n = uInt32(std::distance(first, iter)); // get the dialog title - const FString& name = win->getText(); + const auto& name = win->getText(); try { @@ -680,8 +680,8 @@ void FMenuItem::passMouseEvent ( T widget, FMouseEvent* ev if ( ! widget ) return; - const FPoint& t = ev->getTermPos(); - const FPoint& p2 = widget->termToWidgetPos(t); + const auto& t = ev->getTermPos(); + const auto& p2 = widget->termToWidgetPos(t); int b = ev->getButton(); std::shared_ptr _ev; diff --git a/src/fmessagebox.cpp b/src/fmessagebox.cpp index 44db0fd7..7aa96dcc 100644 --- a/src/fmessagebox.cpp +++ b/src/fmessagebox.cpp @@ -160,61 +160,6 @@ void FMessageBox::setText (const FString& txt) adjustButtons(); } -//---------------------------------------------------------------------- -int FMessageBox::info ( FWidget* parent - , const FString& caption - , const FString& message - , int button0 - , int button1 - , int button2 ) -{ - int reply; - FMessageBox mbox ( caption, message - , button0, button1, button2 - , parent ); - reply = mbox.exec(); - return reply; -} - -//---------------------------------------------------------------------- -int FMessageBox::info ( FWidget* parent - , const FString& caption - , int num - , int button0 - , int button1 - , int button2 ) -{ - int reply; - FMessageBox mbox ( caption - , FString() << num - , button0, button1, button2 - , parent ); - reply = mbox.exec(); - return reply; -} - -//---------------------------------------------------------------------- -int FMessageBox::error ( FWidget* parent - , const FString& message - , int button0 - , int button1 - , int button2 ) -{ - int reply; - const FString& caption = "Error message"; - FMessageBox mbox ( caption, message - , button0, button1, button2 - , parent ); - mbox.beep(); - mbox.setHeadline("Warning:"); - mbox.setCenterText(); - mbox.setForegroundColor(mbox.wc.error_box_fg); - mbox.setBackgroundColor(mbox.wc.error_box_bg); - mbox.emphasis_color = mbox.wc.error_box_emphasis_fg; - reply = mbox.exec(); - return reply; -} - // protected methods of FMessageBox //---------------------------------------------------------------------- @@ -471,7 +416,7 @@ void FMessageBox::resizeButtons() //---------------------------------------------------------------------- void FMessageBox::adjustButtons() { - static const std::size_t gap = 4; + static constexpr std::size_t gap = 4; std::size_t btn_width = 0; for (std::size_t n = 0; n < num_buttons; n++) diff --git a/src/fmouse.cpp b/src/fmouse.cpp index 52fde345..2f348ce5 100644 --- a/src/fmouse.cpp +++ b/src/fmouse.cpp @@ -497,7 +497,7 @@ void FMouseX11::setRawData (FKeyboard::keybuffer& fifo_buf) { // Import the X11 xterm mouse protocol (SGR-Mode) raw mouse data - static const std::size_t len = 6; + static constexpr std::size_t len = 6; std::size_t fifo_buf_size = sizeof(fifo_buf); std::size_t n; x11_mouse[0] = fifo_buf[3]; @@ -523,7 +523,7 @@ void FMouseX11::processEvent (struct timeval* time) { // Parse and interpret the X11 xterm mouse string - const FPoint& mouse_position = getPos(); + const auto& mouse_position = getPos(); uChar x, y; int btn; @@ -586,7 +586,7 @@ void FMouseX11::setButtonState (int btn, struct timeval* time) { // Get the x11 mouse button state - const FPoint& mouse_position = getPos(); + const auto& mouse_position = getPos(); switch ( btn ) { @@ -713,7 +713,7 @@ void FMouseSGR::setRawData (FKeyboard::keybuffer& fifo_buf) //---------------------------------------------------------------------- void FMouseSGR::processEvent (struct timeval* time) { - const FPoint& mouse_position = getPos(); + const auto& mouse_position = getPos(); char* p; int btn; short x, y; @@ -821,7 +821,7 @@ void FMouseSGR::setPressedButtonState (int btn, struct timeval* time) { // Gets the extended x11 mouse mode (SGR) status for pressed buttons - const FPoint& mouse_position = getPos(); + const auto& mouse_position = getPos(); switch ( btn ) { @@ -954,7 +954,7 @@ void FMouseUrxvt::processEvent (struct timeval* time) { // Parse and interpret the X11 xterm mouse string (Urxvt-Mode) - const FPoint& mouse_position = getPos(); + const auto& mouse_position = getPos(); char* p; bool x_neg; bool y_neg; @@ -1088,7 +1088,7 @@ void FMouseUrxvt::setButtonState (int btn, struct timeval* time) { // Get the urxvt mouse button state - const FPoint& mouse_position = getPos(); + const auto& mouse_position = getPos(); switch ( btn ) { diff --git a/src/foptimove.cpp b/src/foptimove.cpp index 3213f8ad..e263dc02 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -537,7 +537,7 @@ void FOptiMove::calculateCharDuration() { if ( baudrate != 0 ) { - static const int baudbyte = 9; // = 7 bit + 1 parity + 1 stop + static constexpr int baudbyte = 9; // = 7 bit + 1 parity + 1 stop char_duration = (baudbyte * 1000 * 10) / (baudrate > 0 ? baudrate : 9600); // milliseconds diff --git a/src/fstring.cpp b/src/fstring.cpp index 108aa68f..615a1354 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -422,7 +422,7 @@ std::size_t FString::getUTF8length() const //---------------------------------------------------------------------- FString& FString::sprintf (const FString format, ...) { - static const int BUFSIZE = 4096; + static constexpr int BUFSIZE = 4096; wchar_t buffer[BUFSIZE]; va_list args; diff --git a/src/fterm.cpp b/src/fterm.cpp index 96067634..4d86d4b4 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -278,7 +278,7 @@ bool FTerm::setOldFont() if ( isXTerminal() || isScreenTerm() || isUrxvtTerminal() || FTermcap::osc_support ) { - const FString& font = data->getXtermFont(); + const auto& font = data->getXtermFont(); if ( font.getLength() > 2 ) { @@ -418,7 +418,7 @@ char* FTerm::enableCursor() { // Returns the cursor enable string - static const std::size_t SIZE = 32; + static constexpr std::size_t SIZE = 32; static char enable_str[SIZE] = { }; const auto& vs = TCAP(fc::t_cursor_visible); const auto& ve = TCAP(fc::t_cursor_normal); @@ -1405,8 +1405,8 @@ void FTerm::init_captureFontAndTitle() // Save the used xterm font and window title xterm->captureFontAndTitle(); - const FString* font = xterm->getFont(); - const FString* title = xterm->getTitle(); + const auto font = xterm->getFont(); + const auto title = xterm->getTitle(); if ( font ) data->setXtermFont(*font); @@ -1904,7 +1904,7 @@ void FTerm::finish() { // Set default signal handler - const FString& title = data->getXtermTitle(); + const auto& title = data->getXtermTitle(); resetSignalHandler(); if ( title && isXTerminal() && ! isRxvtTerminal() ) diff --git a/src/ftermbuffer.cpp b/src/ftermbuffer.cpp index 938ef082..b68e9552 100644 --- a/src/ftermbuffer.cpp +++ b/src/ftermbuffer.cpp @@ -38,7 +38,7 @@ FTermBuffer::~FTermBuffer() // destructor //---------------------------------------------------------------------- int FTermBuffer::writef (const FString format, ...) { - static const int BUFSIZE = 4096; + static constexpr int BUFSIZE = 4096; wchar_t buffer[BUFSIZE]; va_list args; diff --git a/src/ftermcap.cpp b/src/ftermcap.cpp index 7536fda7..8bc332e6 100644 --- a/src/ftermcap.cpp +++ b/src/ftermcap.cpp @@ -81,8 +81,8 @@ void FTermcap::init() void FTermcap::termcap() { std::vector terminals; - static const int success = 1; - static const int uninitialized = -2; + static constexpr int success = 1; + static constexpr int uninitialized = -2; static char term_buffer[2048]; static char string_buf[2048]; char* buffer = string_buf; @@ -128,9 +128,9 @@ void FTermcap::termcap() //---------------------------------------------------------------------- void FTermcap::termcapError (int status) { - static const int no_entry = 0; - static const int db_not_found = -1; - static const int uninitialized = -2; + static constexpr int no_entry = 0; + static constexpr int db_not_found = -1; + static constexpr int uninitialized = -2; if ( status == no_entry || status == uninitialized ) { diff --git a/src/ftermcapquirks.cpp b/src/ftermcapquirks.cpp index ea502b67..b0ad5c57 100644 --- a/src/ftermcapquirks.cpp +++ b/src/ftermcapquirks.cpp @@ -503,7 +503,7 @@ void FTermcapQuirks::screen() //---------------------------------------------------------------------- void FTermcapQuirks::general() { - static const int not_available = -1; + static constexpr int not_available = -1; if ( FTermcap::tabstop == not_available ) FTermcap::tabstop = 8; diff --git a/src/ftermfreebsd.cpp b/src/ftermfreebsd.cpp index 151ed503..2d0e902f 100644 --- a/src/ftermfreebsd.cpp +++ b/src/ftermfreebsd.cpp @@ -144,7 +144,7 @@ bool FTermFreeBSD::saveFreeBSDAltKey() { // Saving the current mapping for the alt key - static const int left_alt = 0x38; + static constexpr int left_alt = 0x38; int ret; keymap_t keymap; @@ -163,7 +163,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key) { // Remapping the alt key - static const int left_alt = 0x38; + static constexpr int left_alt = 0x38; int ret; keymap_t keymap; diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index f4ab91bc..8c6d5aeb 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -515,7 +515,7 @@ int FTermLinux::getFramebuffer_bpp() //---------------------------------------------------------------------- bool FTermLinux::getScreenFont() { - static const std::size_t data_size = 4 * 32 * 512; + static constexpr std::size_t data_size = 4 * 32 * 512; struct console_font_op font; int fd_tty = FTerm::getTTYFileDescriptor(); @@ -737,7 +737,7 @@ inline uInt16 FTermLinux::getInputStatusRegisterOne() // Gets the VGA input-status-register-1 // Miscellaneous output (read port) - static const uInt16 misc_read = 0x3cc; + static constexpr uInt16 misc_read = 0x3cc; const uInt16 io_base = ( inb(misc_read) & 0x01 ) ? 0x3d0 : 0x3b0; // 0x3ba : Input status 1 MDA (read port) // 0x3da : Input status 1 CGA (read port) @@ -751,9 +751,9 @@ uChar FTermLinux::readAttributeController (uChar index) uChar res; // Attribute controller (write port) - static const uInt16 attrib_cntlr_write = 0x3c0; + static constexpr uInt16 attrib_cntlr_write = 0x3c0; // Attribute controller (read port) - static const uInt16 attrib_cntlr_read = 0x3c1; + static constexpr uInt16 attrib_cntlr_read = 0x3c1; const uInt16 input_status_1 = getInputStatusRegisterOne(); inb (input_status_1); // switch to index mode @@ -773,7 +773,7 @@ void FTermLinux::writeAttributeController (uChar index, uChar data) // Writes a byte from the attribute controller from a given index // Attribute controller (write port) - static const uInt16 attrib_cntlr_write = 0x3c0; + static constexpr uInt16 attrib_cntlr_write = 0x3c0; const uInt16 input_status_1 = getInputStatusRegisterOne(); inb (input_status_1); // switch to index mode @@ -790,7 +790,7 @@ void FTermLinux::writeAttributeController (uChar index, uChar data) inline uChar FTermLinux::getAttributeMode() { // Gets the attribute mode value from the vga attribute controller - static const uChar attrib_mode = 0x10; + static constexpr uChar attrib_mode = 0x10; return readAttributeController(attrib_mode); } @@ -798,7 +798,7 @@ inline uChar FTermLinux::getAttributeMode() inline void FTermLinux::setAttributeMode (uChar data) { // Sets the attribute mode value from the vga attribute controller - static const uChar attrib_mode = 0x10; + static constexpr uChar attrib_mode = 0x10; writeAttributeController (attrib_mode, data); } diff --git a/src/ftermopenbsd.cpp b/src/ftermopenbsd.cpp index b4d038de..413c7b24 100644 --- a/src/ftermopenbsd.cpp +++ b/src/ftermopenbsd.cpp @@ -107,7 +107,7 @@ bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding) //---------------------------------------------------------------------- bool FTermOpenBSD::setBSDConsoleMetaEsc() { - static const kbd_t meta_esc = 0x20; // generate ESC prefix on ALT-key + static constexpr kbd_t meta_esc = 0x20; // generate ESC prefix on ALT-key return setBSDConsoleEncoding (bsd_keyboard_encoding | meta_esc); } diff --git a/src/ftextview.cpp b/src/ftextview.cpp index fbf0d2ec..3194f957 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -414,8 +414,8 @@ void FTextView::onMouseDown (FMouseEvent* ev) && ! dialog->isZoomed() ) { int b = ev->getButton(); - const FPoint& tp = ev->getTermPos(); - const FPoint& p = parent->termToWidgetPos(tp); + const auto& tp = ev->getTermPos(); + const auto& p = parent->termToWidgetPos(tp); parent->setFocus(); try @@ -443,8 +443,8 @@ void FTextView::onMouseUp (FMouseEvent* ev) if ( dialog->isResizeable() && ! dialog->isZoomed() ) { int b = ev->getButton(); - const FPoint& tp = ev->getTermPos(); - const FPoint& p = parent->termToWidgetPos(tp); + const auto& tp = ev->getTermPos(); + const auto& p = parent->termToWidgetPos(tp); parent->setFocus(); try @@ -479,8 +479,8 @@ void FTextView::onMouseMove (FMouseEvent* ev) if ( dialog->isResizeable() && ! dialog->isZoomed() ) { int b = ev->getButton(); - const FPoint& tp = ev->getTermPos(); - const FPoint& p = parent->termToWidgetPos(tp); + const auto& tp = ev->getTermPos(); + const auto& p = parent->termToWidgetPos(tp); parent->setFocus(); try @@ -695,8 +695,8 @@ void FTextView::draw() if ( hasFocus() && getStatusBar() ) { - const FString& msg = getStatusbarMessage(); - const FString& curMsg = getStatusBar()->getMessage(); + const auto& msg = getStatusbarMessage(); + const auto& curMsg = getStatusBar()->getMessage(); if ( curMsg != msg ) { diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index 18bc8786..6a9246b8 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -149,8 +149,8 @@ bool FToggleButton::setFocus (bool enable) if ( getStatusBar() ) { - const FString& msg = getStatusbarMessage(); - const FString& curMsg = getStatusBar()->getMessage(); + const auto& msg = getStatusbarMessage(); + const auto& curMsg = getStatusBar()->getMessage(); if ( curMsg != msg ) getStatusBar()->setMessage(msg); @@ -447,8 +447,8 @@ void FToggleButton::draw() { if ( flags.focus && getStatusBar() ) { - const FString& msg = getStatusbarMessage(); - const FString& curMsg = getStatusBar()->getMessage(); + const auto& msg = getStatusbarMessage(); + const auto& curMsg = getStatusBar()->getMessage(); if ( curMsg != msg ) { diff --git a/src/fvterm.cpp b/src/fvterm.cpp index ac50d8a0..fcb4237c 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -303,7 +303,7 @@ void FVTerm::delPreprocessingHandler (FVTerm* instance) //---------------------------------------------------------------------- int FVTerm::printf (const FString format, ...) { - static const int BUFSIZE = 4096; + static constexpr int BUFSIZE = 4096; wchar_t buffer[BUFSIZE]; va_list args; @@ -1872,7 +1872,7 @@ FVTerm::charData FVTerm::getOverlappedCharacter ( int x void FVTerm::processTerminalUpdate() { // Retains terminal updates if there are unprocessed inputs - static const int max_skip = 8; + static constexpr int max_skip = 8; if ( ! terminal_update_pending ) return; diff --git a/src/fwidget.cpp b/src/fwidget.cpp index c768567b..a04c3663 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -69,9 +69,9 @@ FWidget::FWidget (FWidget* parent, bool disable_alt_screen) if ( ! parent ) { - assert ( ! rootObject - && "FTerm: There should be only one root object" ); - + if ( rootObject ) + throw std::runtime_error( "FWidget: No parent defined! " + "There should be only one root object" ); rootObject = this; show_root_widget = nullptr; redraw_root_widget = nullptr; diff --git a/src/fwindow.cpp b/src/fwindow.cpp index fc437d14..bfe7b2b9 100644 --- a/src/fwindow.cpp +++ b/src/fwindow.cpp @@ -67,7 +67,7 @@ FWindow::~FWindow() // destructor if ( ! fapp->isQuit() ) { - const FRect& t_geometry = getTermGeometryWithShadow(); + const auto& t_geometry = getTermGeometryWithShadow(); restoreVTerm (t_geometry); } diff --git a/src/include/final/fapplication.h b/src/include/final/fapplication.h index 6c2cced0..62e955ea 100644 --- a/src/include/final/fapplication.h +++ b/src/include/final/fapplication.h @@ -132,9 +132,6 @@ class FApplication : public FWidget typedef std::deque eventQueue; typedef std::shared_ptr eventQueuePtr; - // Constants - static const int NEED_MORE_DATA = -1; // parseKeyString return value - // Methods void init (long, long); void cmd_options (const int&, char*[]); diff --git a/src/include/final/fbutton.h b/src/include/final/fbutton.h index 9862d644..82bb3255 100644 --- a/src/include/final/fbutton.h +++ b/src/include/final/fbutton.h @@ -137,7 +137,7 @@ class FButton : public FWidget private: // Constants - static const std::size_t NOT_SET = static_cast(-1); + static constexpr std::size_t NOT_SET = static_cast(-1); // Methods void init(); diff --git a/src/include/final/fbuttongroup.h b/src/include/final/fbuttongroup.h index 08a572b6..95b1f0c5 100644 --- a/src/include/final/fbuttongroup.h +++ b/src/include/final/fbuttongroup.h @@ -132,7 +132,7 @@ class FButtonGroup : public FScrollView private: // Constants - static const std::size_t NOT_SET = static_cast(-1); + static constexpr std::size_t NOT_SET = static_cast(-1); // Inquiries bool isRadioButton (FToggleButton*) const; diff --git a/src/include/final/fcharmap.h b/src/include/final/fcharmap.h index d203e853..e4cdb92f 100644 --- a/src/include/final/fcharmap.h +++ b/src/include/final/fcharmap.h @@ -326,8 +326,8 @@ static uInt cp437_to_ucs[][2] = {0xff, 0x00a0} // no-break space }; -const uInt lastCP437Item = uInt ( sizeof(cp437_to_ucs) - / sizeof(cp437_to_ucs[0]) ) - 1; +constexpr uInt lastCP437Item = uInt ( sizeof(cp437_to_ucs) + / sizeof(cp437_to_ucs[0]) ) - 1; } // namespace fc } // namespace finalcut diff --git a/src/include/final/fdialog.h b/src/include/final/fdialog.h index 86e74c8b..8190c61d 100644 --- a/src/include/final/fdialog.h +++ b/src/include/final/fdialog.h @@ -172,8 +172,8 @@ class FDialog : public FWindow } mouseStates; // Constant - static const std::size_t MENU_BTN = 3; - static const bool PRINT_WIN_NUMBER = false; // Only for debug + static constexpr std::size_t MENU_BTN = 3; + static constexpr bool PRINT_WIN_NUMBER = false; // Only for debug // Using-declaration using FWidget::drawBorder; diff --git a/src/include/final/fkeyboard.h b/src/include/final/fkeyboard.h index 2f5447d0..0cb03077 100644 --- a/src/include/final/fkeyboard.h +++ b/src/include/final/fkeyboard.h @@ -85,7 +85,7 @@ class FKeyboard { public: // Constants - static const std::size_t FIFO_BUF_SIZE{512}; + static constexpr std::size_t FIFO_BUF_SIZE{512}; // Typedef typedef char keybuffer[FIFO_BUF_SIZE]; @@ -138,8 +138,8 @@ class FKeyboard private: // Constants - static const std::size_t READ_BUF_SIZE{1024}; - static const FKey NOT_SET = static_cast(-1); + static constexpr std::size_t READ_BUF_SIZE{1024}; + static constexpr FKey NOT_SET = static_cast(-1); // Accessors FKey getMouseProtocolKey(); diff --git a/src/include/final/flabel.h b/src/include/final/flabel.h index 05d97d70..0be75abc 100644 --- a/src/include/final/flabel.h +++ b/src/include/final/flabel.h @@ -139,7 +139,7 @@ class FLabel : public FWidget private: // Constants - static const std::size_t NOT_SET = static_cast(-1); + static constexpr std::size_t NOT_SET = static_cast(-1); // Methods void init(); diff --git a/src/include/final/flistview.h b/src/include/final/flistview.h index 62ef82ba..78ee2a5a 100644 --- a/src/include/final/flistview.h +++ b/src/include/final/flistview.h @@ -361,7 +361,7 @@ class FListView : public FWidget typedef std::shared_ptr FScrollbarPtr; // Constants - static const int USE_MAX_SIZE = -1; + static constexpr int USE_MAX_SIZE = -1; // Methods void init(); diff --git a/src/include/final/fmenu.h b/src/include/final/fmenu.h index 6caced8e..01794232 100644 --- a/src/include/final/fmenu.h +++ b/src/include/final/fmenu.h @@ -131,7 +131,8 @@ class FMenu : public FWindow, public FMenuList private: // Constants - static const std::size_t NOT_SET = static_cast(-1); + static constexpr std::size_t NOT_SET = static_cast(-1); + static constexpr bool SELECT_ITEM = true; // Typedef typedef struct @@ -153,9 +154,6 @@ class FMenu : public FWindow, public FMenuList bool no_underline; } menuText; - // Constants - static const bool SELECT_ITEM = true; - // Accessors FWidget* getSuperMenu() const; diff --git a/src/include/final/fmenubar.h b/src/include/final/fmenubar.h index ad81f927..11466cd7 100644 --- a/src/include/final/fmenubar.h +++ b/src/include/final/fmenubar.h @@ -108,7 +108,7 @@ class FMenuBar : public FWindow, public FMenuList private: // Constants - static const std::size_t NOT_SET = static_cast(-1); + static constexpr std::size_t NOT_SET = static_cast(-1); // Typedef typedef struct diff --git a/src/include/final/fmessagebox.h b/src/include/final/fmessagebox.h index a31a838d..a87ad04f 100644 --- a/src/include/final/fmessagebox.h +++ b/src/include/final/fmessagebox.h @@ -121,22 +121,17 @@ class FMessageBox : public FDialog void setText (const FString&); // Methods + template static int info ( FWidget* , const FString& - , const FString& - , int = FMessageBox::Ok - , int = 0 - , int = 0 ); - - static int info ( FWidget* - , const FString& - , int + , const messageType& , int = FMessageBox::Ok , int = 0 , int = 0 ); + template static int error ( FWidget* - , const FString& + , const messageType& , int = FMessageBox::Ok , int = 0 , int = 0 ); @@ -207,6 +202,48 @@ inline bool FMessageBox::setCenterText() inline bool FMessageBox::unsetCenterText() { return setCenterText(false); } +//---------------------------------------------------------------------- +template +int FMessageBox::info ( FWidget* parent + , const FString& caption + , const messageType& message + , int button0 + , int button1 + , int button2 ) +{ + int reply; + FMessageBox mbox ( caption + , FString() << message + , button0, button1, button2 + , parent ); + reply = mbox.exec(); + return reply; +} + +//---------------------------------------------------------------------- +template +int FMessageBox::error ( FWidget* parent + , const messageType& message + , int button0 + , int button1 + , int button2 ) +{ + int reply; + const FString& caption = "Error message"; + FMessageBox mbox ( caption + , FString() << message + , button0, button1, button2 + , parent ); + mbox.beep(); + mbox.setHeadline("Warning:"); + mbox.setCenterText(); + mbox.setForegroundColor(mbox.wc.error_box_fg); + mbox.setBackgroundColor(mbox.wc.error_box_bg); + mbox.emphasis_color = mbox.wc.error_box_emphasis_fg; + reply = mbox.exec(); + return reply; +} + } // namespace finalcut #endif // FMESSAGEBOX_H diff --git a/src/include/final/fmouse.h b/src/include/final/fmouse.h index 11a1191d..5fdd9100 100644 --- a/src/include/final/fmouse.h +++ b/src/include/final/fmouse.h @@ -306,7 +306,7 @@ class FMouseX11 : public FMouse }; // Constant - static const std::size_t MOUSE_BUF_SIZE = 4; + static constexpr std::size_t MOUSE_BUF_SIZE = 4; // Method void setKeyState (int); @@ -368,7 +368,7 @@ class FMouseSGR : public FMouse }; // Constant - static const std::size_t MOUSE_BUF_SIZE = 13; + static constexpr std::size_t MOUSE_BUF_SIZE = 13; // Methods void setKeyState (int); @@ -432,7 +432,7 @@ class FMouseUrxvt : public FMouse }; // Constant - static const std::size_t MOUSE_BUF_SIZE = 13; + static constexpr std::size_t MOUSE_BUF_SIZE = 13; // Methods void setKeyState (int); diff --git a/src/include/final/foptimove.h b/src/include/final/foptimove.h index bc15615e..8379f7d9 100644 --- a/src/include/final/foptimove.h +++ b/src/include/final/foptimove.h @@ -169,7 +169,7 @@ class FOptiMove private: // Constant - static const std::size_t BUF_SIZE{512}; + static constexpr std::size_t BUF_SIZE{512}; // Typedef typedef struct @@ -180,9 +180,9 @@ class FOptiMove } capability; // Constants - static const int LONG_DURATION{INT_MAX}; + static constexpr int LONG_DURATION{INT_MAX}; // value for a long capability waiting time - static const int MOVE_LIMIT{7}; + static constexpr int MOVE_LIMIT{7}; // maximum character distance to avoid direct cursor addressing // Methods diff --git a/src/include/final/fprogressbar.h b/src/include/final/fprogressbar.h index 32edc56d..997b2680 100644 --- a/src/include/final/fprogressbar.h +++ b/src/include/final/fprogressbar.h @@ -96,7 +96,7 @@ class FProgressbar : public FWidget private: // Constants - static const std::size_t NOT_SET = static_cast(-1); + static constexpr std::size_t NOT_SET = static_cast(-1); // Methods virtual void draw(); diff --git a/src/include/final/fscrollview.h b/src/include/final/fscrollview.h index 78dc4f97..9e375ba3 100644 --- a/src/include/final/fscrollview.h +++ b/src/include/final/fscrollview.h @@ -156,8 +156,8 @@ class FScrollView : public FWidget typedef std::shared_ptr FScrollbarPtr; // Constants - static const int vertical_border_spacing = 2; - static const int horizontal_border_spacing = 2; + static constexpr int vertical_border_spacing = 2; + static constexpr int horizontal_border_spacing = 2; // Accessors FPoint getViewportCursorPos(); diff --git a/src/include/final/fstring.h b/src/include/final/fstring.h index 570a73c9..5d51911a 100644 --- a/src/include/final/fstring.h +++ b/src/include/final/fstring.h @@ -263,9 +263,9 @@ class FString private: // Constants - static const uInt FWDBUFFER = 15; - static const uInt INPBUFFER = 200; - static const uInt CHAR_SIZE = sizeof(wchar_t); // bytes per character + static constexpr uInt FWDBUFFER = 15; + static constexpr uInt INPBUFFER = 200; + static constexpr uInt CHAR_SIZE = sizeof(wchar_t); // bytes per character // Methods void initLength (std::size_t); diff --git a/src/include/final/ftogglebutton.h b/src/include/final/ftogglebutton.h index d3b4c18a..9515f9e2 100644 --- a/src/include/final/ftogglebutton.h +++ b/src/include/final/ftogglebutton.h @@ -150,7 +150,7 @@ class FToggleButton : public FWidget private: // Constants - static const std::size_t NOT_SET = static_cast(-1); + static constexpr std::size_t NOT_SET = static_cast(-1); // Mutator void setGroup (FButtonGroup*); diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index 0e3d3dbd..fbc1b29c 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -448,7 +448,7 @@ class FVTerm }; // Constants - static const uInt TERMINAL_OUTPUT_BUFFER_SIZE = 32768; + static constexpr uInt TERMINAL_OUTPUT_BUFFER_SIZE = 32768; // Buffer size for character output on the terminal // Mutators diff --git a/test/fstring-test.cpp b/test/fstring-test.cpp index e61722fe..9bb87eec 100644 --- a/test/fstring-test.cpp +++ b/test/fstring-test.cpp @@ -51,7 +51,6 @@ class FStringTest : public CPPUNIT_NS::TestFixture { public: FStringTest() - : s(0) { } void setUp(); @@ -91,7 +90,7 @@ class FStringTest : public CPPUNIT_NS::TestFixture void controlCodesTest(); private: - finalcut::FString* s; + finalcut::FString* s{0}; // Adds code needed to register the test suite CPPUNIT_TEST_SUITE (FStringTest); @@ -223,8 +222,8 @@ void FStringTest::initLengthTest() CPPUNIT_ASSERT ( s1.isNull() ); CPPUNIT_ASSERT ( s1.isEmpty() ); - const int x1 = 10; - const std::size_t x2 = 10; + constexpr int x1 = 10; + constexpr std::size_t x2 = 10; const finalcut::FString s2(x1); CPPUNIT_ASSERT ( s2.getLength() == 10 ); CPPUNIT_ASSERT ( s2.capacity() == 25 ); @@ -355,28 +354,28 @@ void FStringTest::assignmentTest() CPPUNIT_ASSERT ( s1.getLength() == 3 ); CPPUNIT_ASSERT ( s1.capacity() == 18 ); - const wchar_t s5[] = L"abc"; + constexpr wchar_t s5[] = L"abc"; s1 = s5; CPPUNIT_ASSERT ( s1 ); CPPUNIT_ASSERT ( s1 == L"abc" ); CPPUNIT_ASSERT ( s1.getLength() == 3 ); CPPUNIT_ASSERT ( s1.capacity() == 18 ); - const char s6[] = "def"; + constexpr char s6[] = "def"; s1 = s6; CPPUNIT_ASSERT ( s1 ); CPPUNIT_ASSERT ( s1 == L"def" ); CPPUNIT_ASSERT ( s1.getLength() == 3 ); CPPUNIT_ASSERT ( s1.capacity() == 18 ); - const wchar_t s7 = L'#'; + constexpr wchar_t s7 = L'#'; s1 = s7; CPPUNIT_ASSERT ( s1 ); CPPUNIT_ASSERT ( s1 == L"#" ); CPPUNIT_ASSERT ( s1.getLength() == 1 ); CPPUNIT_ASSERT ( s1.capacity() == 18 ); - const char s8 = '%'; + constexpr char s8 = '%'; s1 = s8; CPPUNIT_ASSERT ( s1 ); CPPUNIT_ASSERT ( s1 == L"%" ); @@ -418,13 +417,13 @@ void FStringTest::assignmentTest() s1.setString(L""); CPPUNIT_ASSERT ( ! s1.isNull() ); - const wchar_t* wc = 0; + constexpr wchar_t* wc = 0; s1.setString(wc); CPPUNIT_ASSERT ( s1.isEmpty() ); CPPUNIT_ASSERT ( s1.isNull() ); CPPUNIT_ASSERT ( ! s1 ); - const char* c = 0; + constexpr char* c = 0; s1.setString(c); CPPUNIT_ASSERT ( s1.isEmpty() ); CPPUNIT_ASSERT ( s1.isNull() ); @@ -509,20 +508,20 @@ void FStringTest::additionTest() const std::wstring& s3 = L"abc"; CPPUNIT_ASSERT ( s3 + finalcut::FString("def") == L"abcdef" ); - const wchar_t s4[] = L"abc"; + constexpr wchar_t s4[] = L"abc"; CPPUNIT_ASSERT ( s4 + finalcut::FString("def") == L"abcdef" ); const std::string& s5 = "abc"; CPPUNIT_ASSERT ( s5 + finalcut::FString("def") == L"abcdef" ); - const char s6[] = "abc"; + constexpr char s6[] = "abc"; CPPUNIT_ASSERT ( s6 + finalcut::FString("def") == L"abcdef" ); - const wchar_t c1 = L'a'; + constexpr wchar_t c1 = L'a'; CPPUNIT_ASSERT ( c1 + s3 == L"aabc" ); CPPUNIT_ASSERT ( c1 + finalcut::FString("def") == L"adef" ); - const char c2 = 'a'; + constexpr char c2 = 'a'; CPPUNIT_ASSERT ( c2 + s5 == "aabc" ); CPPUNIT_ASSERT ( c2 + finalcut::FString("def") == L"adef" ); } @@ -553,13 +552,13 @@ void FStringTest::equalTest() CPPUNIT_ASSERT ( ws1 == ws2 ); const finalcut::FString one_char('a'); - const char ch = 'a'; + constexpr char ch = 'a'; CPPUNIT_ASSERT ( one_char == ch ); CPPUNIT_ASSERT ( ch == one_char.c_str()[0] ); CPPUNIT_ASSERT ( one_char.getLength() == 1 ); CPPUNIT_ASSERT ( one_char.capacity() == 16 ); - const wchar_t wch = L'a'; + constexpr wchar_t wch = L'a'; CPPUNIT_ASSERT ( one_char == wch ); CPPUNIT_ASSERT ( wch == one_char.wc_str()[0] ); @@ -567,14 +566,14 @@ void FStringTest::equalTest() const finalcut::FString str2(L"abc"); CPPUNIT_ASSERT ( str == str2 ); - const char cstr[] = "abc"; + constexpr char cstr[] = "abc"; CPPUNIT_ASSERT ( str == cstr ); CPPUNIT_ASSERT ( str.getLength() == 3 ); CPPUNIT_ASSERT ( str.getUTF8length() == 3 ); CPPUNIT_ASSERT ( str.capacity() == 18 ); CPPUNIT_ASSERT ( strncmp(cstr, str.c_str(), 3) == 0 ); - const wchar_t wcstr[] = L"abc"; + constexpr wchar_t wcstr[] = L"abc"; CPPUNIT_ASSERT ( str == wcstr ); CPPUNIT_ASSERT ( wcsncmp(wcstr, str.wc_str(), 3) == 0 ); @@ -599,13 +598,13 @@ void FStringTest::equalTest() void FStringTest::notEqualTest() { const finalcut::FString one_char('@'); - const char ch = '!'; + constexpr char ch = '!'; CPPUNIT_ASSERT ( one_char != ch ); CPPUNIT_ASSERT ( ch != one_char.c_str()[0] ); CPPUNIT_ASSERT ( one_char.getLength() == 1 ); CPPUNIT_ASSERT ( one_char.capacity() == 16 ); - const wchar_t wch = L'_'; + constexpr wchar_t wch = L'_'; CPPUNIT_ASSERT ( one_char != wch ); CPPUNIT_ASSERT ( wch != one_char.wc_str()[0] ); @@ -613,7 +612,7 @@ void FStringTest::notEqualTest() const finalcut::FString s2 = L"АВС"; // cyrillic letters CPPUNIT_ASSERT ( s1 != s2 ); - const char cstr[] = "abc"; + constexpr char cstr[] = "abc"; CPPUNIT_ASSERT ( s1 != cstr ); CPPUNIT_ASSERT ( s1.getLength() == 3 ); CPPUNIT_ASSERT ( strlen(s1.c_str()) == 3 ); @@ -625,7 +624,7 @@ void FStringTest::notEqualTest() CPPUNIT_ASSERT ( s2.capacity() == 18 ); CPPUNIT_ASSERT ( strncmp(cstr, s1.c_str(), 3) != 0 ); - const wchar_t wcstr[] = L"abc"; + constexpr wchar_t wcstr[] = L"abc"; CPPUNIT_ASSERT ( s1 != wcstr ); CPPUNIT_ASSERT ( wcsncmp(wcstr, s1.wc_str(), 3) != 0 ); @@ -648,10 +647,10 @@ void FStringTest::notEqualTest() void FStringTest::lessEqualTest() { const finalcut::FString one_char('x'); - const char ch = 'z'; + constexpr char ch = 'z'; CPPUNIT_ASSERT ( one_char <= ch ); - const wchar_t wch = L'z'; + constexpr wchar_t wch = L'z'; CPPUNIT_ASSERT ( one_char <= wch ); const finalcut::FString s1 = L"xyz"; @@ -660,13 +659,13 @@ void FStringTest::lessEqualTest() CPPUNIT_ASSERT ( s1 <= s2 && s1 == s2 ); CPPUNIT_ASSERT ( s1 <= s3 && s1 != s3 ); - const char cstr1[] = "xyz"; - const char cstr2[] = "xzz"; + constexpr char cstr1[] = "xyz"; + constexpr char cstr2[] = "xzz"; CPPUNIT_ASSERT ( s1 <= cstr1 && s1 == cstr1 ); CPPUNIT_ASSERT ( s1 <= cstr2 && s1 != cstr2 ); - const wchar_t wcstr1[] = L"xyz"; - const wchar_t wcstr2[] = L"xzz"; + constexpr wchar_t wcstr1[] = L"xyz"; + constexpr wchar_t wcstr2[] = L"xzz"; CPPUNIT_ASSERT ( s1 <= wcstr1 && s1 == wcstr1 ); CPPUNIT_ASSERT ( s1 <= wcstr2 && s1 != wcstr2 ); @@ -693,20 +692,20 @@ void FStringTest::lessEqualTest() void FStringTest::lessTest() { const finalcut::FString one_char('x'); - const char ch = 'z'; + constexpr char ch = 'z'; CPPUNIT_ASSERT ( one_char < ch ); - const wchar_t wch = L'z'; + constexpr wchar_t wch = L'z'; CPPUNIT_ASSERT ( one_char < wch ); const finalcut::FString s1 = L"xyz"; const finalcut::FString s2 = L"xzz"; CPPUNIT_ASSERT ( s1 < s2 ); - const char cstr[] = "xzz"; + constexpr char cstr[] = "xzz"; CPPUNIT_ASSERT ( s1 < cstr ); - const wchar_t wcstr[] = L"xzz"; + constexpr wchar_t wcstr[] = L"xzz"; CPPUNIT_ASSERT ( s1 < wcstr ); const std::string st = "xzz"; @@ -726,10 +725,10 @@ void FStringTest::lessTest() void FStringTest::greaterEqualTest() { const finalcut::FString one_char('x'); - const char ch = 'x'; + constexpr char ch = 'x'; CPPUNIT_ASSERT ( one_char >= ch ); - const wchar_t wch = L'x'; + constexpr wchar_t wch = L'x'; CPPUNIT_ASSERT ( one_char >= wch ); const finalcut::FString s1 = L"xyz"; @@ -738,13 +737,13 @@ void FStringTest::greaterEqualTest() CPPUNIT_ASSERT ( s1 >= s2 && s1 == s2 ); CPPUNIT_ASSERT ( s1 >= s3 && s1 != s3 ); - const char cstr1[] = "xyz"; - const char cstr2[] = "xxz"; + constexpr char cstr1[] = "xyz"; + constexpr char cstr2[] = "xxz"; CPPUNIT_ASSERT ( s1 >= cstr1 && s1 == cstr1 ); CPPUNIT_ASSERT ( s1 >= cstr2 && s1 != cstr2 ); - const wchar_t wcstr1[] = L"xyz"; - const wchar_t wcstr2[] = L"xxz"; + constexpr wchar_t wcstr1[] = L"xyz"; + constexpr wchar_t wcstr2[] = L"xxz"; CPPUNIT_ASSERT ( s1 >= wcstr1 && s1 == wcstr1 ); CPPUNIT_ASSERT ( s1 >= wcstr2 && s1 != wcstr2 ); @@ -771,20 +770,20 @@ void FStringTest::greaterEqualTest() void FStringTest::greaterTest() { const finalcut::FString one_char('x'); - const char ch = 'w'; + constexpr char ch = 'w'; CPPUNIT_ASSERT ( one_char > ch ); - const wchar_t wch = L'w'; + constexpr wchar_t wch = L'w'; CPPUNIT_ASSERT ( one_char > wch ); const finalcut::FString s1 = L"xyz"; const finalcut::FString s2 = L"xww"; CPPUNIT_ASSERT ( s1 > s2 ); - const char cstr[] = "xww"; + constexpr char cstr[] = "xww"; CPPUNIT_ASSERT ( s1 > cstr ); - const wchar_t wcstr[] = L"xww"; + constexpr wchar_t wcstr[] = L"xww"; CPPUNIT_ASSERT ( s1 > wcstr ); const std::string st = "xww"; @@ -1036,11 +1035,11 @@ void FStringTest::formatTest() str2.sprintf (null_fstring, 0); CPPUNIT_ASSERT ( str2.isNull() ); - const wchar_t* null_wstring = 0; + constexpr wchar_t* null_wstring = 0; str2.sprintf (null_wstring, 0); CPPUNIT_ASSERT ( str2.isNull() ); - const char* null_string = 0; + constexpr char* null_string = 0; str2.sprintf (null_string, 0); CPPUNIT_ASSERT ( str2.isNull() ); @@ -1119,15 +1118,15 @@ void FStringTest::convertToNumberTest() //---------------------------------------------------------------------- void FStringTest::convertFromNumberTest() { - const sInt16 n1 = -1234; - const uInt16 n2 = 1234; - const int n3 = -12345; - const uInt n4 = 12345; - const long n5 = -12345678; - const uLong n6 = 12345678; - const float n7 = 1234.56f; - const double n8 = 1234.5678; - const lDouble n9 = 12345.67890L; + constexpr sInt16 n1 = -1234; + constexpr uInt16 n2 = 1234; + constexpr int n3 = -12345; + constexpr uInt n4 = 12345; + constexpr long n5 = -12345678; + constexpr uLong n6 = 12345678; + constexpr float n7 = 1234.56f; + constexpr double n8 = 1234.5678; + constexpr lDouble n9 = 12345.67890L; CPPUNIT_ASSERT ( finalcut::FString().setNumber(n1) == "-1234" ); CPPUNIT_ASSERT ( finalcut::FString().setNumber(n2) == "1234" ); CPPUNIT_ASSERT ( finalcut::FString().setNumber(n3) == "-12345" ); @@ -1371,7 +1370,7 @@ void FStringTest::insertTest() CPPUNIT_ASSERT ( str1.insert(str2, 3) == "ABCxyz" ); str1 = "ABC"; - const wchar_t str3[] = L"xyz"; + constexpr wchar_t str3[] = L"xyz"; CPPUNIT_ASSERT ( str1.insert(str3, 0) == "xyzABC" ); str1 = "ABC"; CPPUNIT_ASSERT ( str1.insert(str3, 1) == "AxyzBC" ); @@ -1381,7 +1380,7 @@ void FStringTest::insertTest() CPPUNIT_ASSERT ( str1.insert(str3, 3) == "ABCxyz" ); str1 = "ABC"; - const char str4[] = "xyz"; + constexpr char str4[] = "xyz"; CPPUNIT_ASSERT ( str1.insert(str4, 0) == "xyzABC" ); str1 = "ABC"; CPPUNIT_ASSERT ( str1.insert(str4, 1) == "AxyzBC" ); @@ -1391,7 +1390,7 @@ void FStringTest::insertTest() CPPUNIT_ASSERT ( str1.insert(str4, 3) == "ABCxyz" ); str1 = "ABC"; - const wchar_t wc = L'*'; + constexpr wchar_t wc = L'*'; CPPUNIT_ASSERT ( str1.insert(wc, 0) == "*ABC" ); str1 = "ABC"; CPPUNIT_ASSERT ( str1.insert(wc, 1) == "A*BC" ); @@ -1401,7 +1400,7 @@ void FStringTest::insertTest() CPPUNIT_ASSERT ( str1.insert(wc, 3) == "ABC*" ); str1 = "ABC"; - const char c = '*'; + constexpr char c = '*'; CPPUNIT_ASSERT ( str1.insert(c, 0) == "*ABC" ); str1 = "ABC"; CPPUNIT_ASSERT ( str1.insert(c, 1) == "A*BC" ); @@ -1414,22 +1413,22 @@ void FStringTest::insertTest() //---------------------------------------------------------------------- void FStringTest::replaceTest() { - const finalcut::FString str = "Look behind you, a three-headed monkey!"; - finalcut::FString s1 = str; - const finalcut::FString from1 = "three"; - const std::wstring from2 = L"three"; - const wchar_t from3[] = L"three"; - const std::string from4 = "three"; - const char from5[] = "three"; - const wchar_t from6 = L','; - const char from7 = ','; - const finalcut::FString to1 = L'3'; - const std::wstring to2 = L"3"; - const wchar_t to3[] = L"3"; - const std::string to4 = "3"; - const char to5[] = "3"; - const wchar_t to6 = '3'; - const char to7 = '3'; + const finalcut::FString str = "Look behind you, a three-headed monkey!"; + finalcut::FString s1 = str; + const finalcut::FString from1 = "three"; + const std::wstring from2 = L"three"; + constexpr wchar_t from3[] = L"three"; + const std::string from4 = "three"; + constexpr char from5[] = "three"; + constexpr wchar_t from6 = L','; + constexpr char from7 = ','; + const finalcut::FString to1 = L'3'; + const std::wstring to2 = L"3"; + constexpr wchar_t to3[] = L"3"; + const std::string to4 = "3"; + constexpr char to5[] = "3"; + constexpr wchar_t to6 = '3'; + constexpr char to7 = '3'; CPPUNIT_ASSERT ( s1.replace(from1, to1) == "Look behind you, a 3-headed monkey!" ); @@ -1664,18 +1663,18 @@ void FStringTest::includesTest() { const finalcut::FString str = "Look behind you, a three-headed monkey!"; const finalcut::FString empty1{}; - const wchar_t* empty2 = 0; - const char* empty3 = 0; - const finalcut::FString search1 = "you"; - const finalcut::FString search2 = "me"; - const wchar_t search3[] = L"you"; - const wchar_t search4[] = L"me"; - const char search5[] = "you"; - const char search6[] = "me"; - const wchar_t search7 = L'y'; - const wchar_t search8 = L'&'; - const char search9 = 'y'; - const char search10 = '&'; + constexpr wchar_t* empty2 = 0; + constexpr char* empty3 = 0; + const finalcut::FString search1 = "you"; + const finalcut::FString search2 = "me"; + constexpr wchar_t search3[] = L"you"; + constexpr wchar_t search4[] = L"me"; + constexpr char search5[] = "you"; + constexpr char search6[] = "me"; + constexpr wchar_t search7 = L'y'; + constexpr wchar_t search8 = L'&'; + constexpr char search9 = 'y'; + constexpr char search10 = '&'; CPPUNIT_ASSERT ( ! str.includes(static_cast(0)) ); CPPUNIT_ASSERT ( ! str.includes(empty1) ); diff --git a/test/ftermcapquirks-test.cpp b/test/ftermcapquirks-test.cpp index e7eeb775..ebbf99ef 100644 --- a/test/ftermcapquirks-test.cpp +++ b/test/ftermcapquirks-test.cpp @@ -228,7 +228,7 @@ void FTermcapQuirksTest::classNameTest() void FTermcapQuirksTest::generalTest() { finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); - const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; + constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); @@ -295,7 +295,7 @@ void FTermcapQuirksTest::generalTest() void FTermcapQuirksTest::xtermTest() { finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); - const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; + constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); @@ -328,7 +328,7 @@ void FTermcapQuirksTest::xtermTest() void FTermcapQuirksTest::freebsdTest() { finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); - const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; + constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); @@ -367,7 +367,7 @@ void FTermcapQuirksTest::freebsdTest() void FTermcapQuirksTest::cygwinTest() { finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); - const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; + constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); @@ -394,7 +394,7 @@ void FTermcapQuirksTest::cygwinTest() void FTermcapQuirksTest::linuxTest() { finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); - const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; + constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); @@ -468,7 +468,7 @@ void FTermcapQuirksTest::linuxTest() void FTermcapQuirksTest::rxvtTest() { finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); - const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; + constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); @@ -511,7 +511,7 @@ void FTermcapQuirksTest::rxvtTest() void FTermcapQuirksTest::vteTest() { finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); - const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; + constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); @@ -537,7 +537,7 @@ void FTermcapQuirksTest::vteTest() void FTermcapQuirksTest::puttyTest() { finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); - const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; + constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); @@ -629,7 +629,7 @@ void FTermcapQuirksTest::puttyTest() void FTermcapQuirksTest::teratermTest() { finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); - const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; + constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); @@ -661,7 +661,7 @@ void FTermcapQuirksTest::teratermTest() void FTermcapQuirksTest::sunTest() { finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); - const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; + constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); @@ -781,7 +781,7 @@ void FTermcapQuirksTest::sunTest() void FTermcapQuirksTest::screenTest() { finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); - const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; + constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); diff --git a/test/ftermdetection-test.cpp b/test/ftermdetection-test.cpp index 7ba5462f..1263f179 100644 --- a/test/ftermdetection-test.cpp +++ b/test/ftermdetection-test.cpp @@ -679,7 +679,6 @@ void FTermDetectionTest::urxvtTest() setenv ("TERM", "rxvt-unicode-256color", 1); setenv ("COLORTERM", "rxvt-xpm", 1); setenv ("COLORFGBG", "default;default;0", 1); - //unsetenv("COLORFGBG"); unsetenv("TERMCAP"); unsetenv("VTE_VERSION"); unsetenv("XTERM_VERSION"); @@ -2100,7 +2099,7 @@ void FTermDetectionTest::debugOutput() std::cout << std::endl << line << std::endl; // Command line - const char debug_command[] = "/bin/bash -c ' \ + constexpr char debug_command[] = "/bin/bash -c ' \ for i in DSR CURSOR_POS DECID DA DA1 SEC_DA ANSWERBACK \ TITLE COLOR16 COLOR88 COLOR256; \ do \ @@ -2258,7 +2257,7 @@ pid_t FTermDetectionTest::forkProcess() } else { - const int timeout = 150; // 1.5 seconds + constexpr int timeout = 150; // 1.5 seconds int i = 0; // Wait until the child process is ready for input