From d5ff257bcf3954b4c5a2fe4b06a45bf6a492bf5d Mon Sep 17 00:00:00 2001 From: Evan Teran Date: Fri, 10 Jan 2025 22:42:51 -0500 Subject: [PATCH 1/2] hard coding to c++17 standard! --- Interpreter/CMakeLists.txt | 2 +- Regex/CMakeLists.txt | 2 +- Settings/CMakeLists.txt | 2 +- Util/CMakeLists.txt | 2 +- client/CMakeLists.txt | 2 +- import/CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Interpreter/CMakeLists.txt b/Interpreter/CMakeLists.txt index b816ddad..b4c41d60 100644 --- a/Interpreter/CMakeLists.txt +++ b/Interpreter/CMakeLists.txt @@ -40,5 +40,5 @@ PRIVATE target_add_warnings(Interpreter) -set_property(TARGET Interpreter PROPERTY CXX_STANDARD ${TARGET_COMPILER_HIGHEST_STD_SUPPORTED}) +set_property(TARGET Interpreter PROPERTY CXX_STANDARD 17) set_property(TARGET Interpreter PROPERTY CXX_EXTENSIONS OFF) diff --git a/Regex/CMakeLists.txt b/Regex/CMakeLists.txt index 1902835d..4ccc5698 100644 --- a/Regex/CMakeLists.txt +++ b/Regex/CMakeLists.txt @@ -41,7 +41,7 @@ target_link_libraries(Regex PUBLIC target_add_warnings(Regex) -set_property(TARGET Regex PROPERTY CXX_STANDARD ${TARGET_COMPILER_HIGHEST_STD_SUPPORTED}) +set_property(TARGET Regex PROPERTY CXX_STANDARD 17) set_property(TARGET Regex PROPERTY CXX_EXTENSIONS OFF) if(NEDIT_BUILD_TESTS) diff --git a/Settings/CMakeLists.txt b/Settings/CMakeLists.txt index 81cf385a..fe393f78 100644 --- a/Settings/CMakeLists.txt +++ b/Settings/CMakeLists.txt @@ -25,7 +25,7 @@ PUBLIC target_add_warnings(Settings) -set_property(TARGET Settings PROPERTY CXX_STANDARD ${TARGET_COMPILER_HIGHEST_STD_SUPPORTED}) +set_property(TARGET Settings PROPERTY CXX_STANDARD 17) set_property(TARGET Settings PROPERTY CXX_EXTENSIONS OFF) diff --git a/Util/CMakeLists.txt b/Util/CMakeLists.txt index fd886403..858b0d05 100644 --- a/Util/CMakeLists.txt +++ b/Util/CMakeLists.txt @@ -116,7 +116,7 @@ PUBLIC target_add_warnings(Util) -set_property(TARGET Util PROPERTY CXX_STANDARD ${TARGET_COMPILER_HIGHEST_STD_SUPPORTED}) +set_property(TARGET Util PROPERTY CXX_STANDARD 17) set_property(TARGET Util PROPERTY CXX_EXTENSIONS OFF) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 14b6e627..9e67c621 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -21,7 +21,7 @@ target_link_libraries(nc-ng PUBLIC target_add_warnings(nc-ng) -set_property(TARGET nc-ng PROPERTY CXX_STANDARD ${TARGET_COMPILER_HIGHEST_STD_SUPPORTED}) +set_property(TARGET nc-ng PROPERTY CXX_STANDARD 17) set_property(TARGET nc-ng PROPERTY CXX_EXTENSIONS OFF) set_property(TARGET nc-ng PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") diff --git a/import/CMakeLists.txt b/import/CMakeLists.txt index 4bac76a4..4c115174 100644 --- a/import/CMakeLists.txt +++ b/import/CMakeLists.txt @@ -31,7 +31,7 @@ target_include_directories(nedit-import PRIVATE target_add_warnings(nedit-import) -set_property(TARGET nedit-import PROPERTY CXX_STANDARD ${TARGET_COMPILER_HIGHEST_STD_SUPPORTED}) +set_property(TARGET nedit-import PROPERTY CXX_STANDARD 17) set_property(TARGET nedit-import PROPERTY CXX_EXTENSIONS OFF) set_property(TARGET nedit-import PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d49865b0..dd5554e0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -272,7 +272,7 @@ PRIVATE yaml-cpp ) set_property(TARGET nedit-ng PROPERTY CXX_EXTENSIONS OFF) -set_property(TARGET nedit-ng PROPERTY CXX_STANDARD ${TARGET_COMPILER_HIGHEST_STD_SUPPORTED}) +set_property(TARGET nedit-ng PROPERTY CXX_STANDARD 17) set_property(TARGET nedit-ng PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") if(TARGET_COMPILER_MSVC) From 62164fae907dd56b7617c5cba17218eaca488934 Mon Sep 17 00:00:00 2001 From: Evan Teran Date: Fri, 10 Jan 2025 23:02:24 -0500 Subject: [PATCH 2/2] factoring out boost usage since we only needed it for std::variant and std::optional --- .github/workflows/build.yaml | 26 ---------- .travis.yml | 32 ------------ CMakeLists.txt | 6 +-- Interpreter/CMakeLists.txt | 10 ++-- Interpreter/DataValue.h | 36 +++++++------- README.md | 29 ++++++----- Regex/CMakeLists.txt | 8 ++- Regex/Decompile.h | 4 +- Regex/test/CMakeLists.txt | 10 +++- Settings/CMakeLists.txt | 10 ++-- Util/CMakeLists.txt | 11 +++-- Util/include/Util/FileSystem.h | 2 +- client/CMakeLists.txt | 11 +++-- client/nc.cpp | 6 +-- cmake/Modules/DetectCompiler.cmake | 18 ------- import/CMakeLists.txt | 12 +++-- libs/CMakeLists.txt | 4 +- libs/yaml-cpp-0.8.0/CMakeLists.txt | 10 ++-- src/CMakeLists.txt | 12 +++-- src/CallTip.h | 4 +- src/DialogDrawingStyles.cpp | 14 +++--- src/DialogDrawingStyles.h | 4 +- src/DialogFind.cpp | 6 +-- src/DialogFind.h | 4 +- src/DialogLanguageModes.cpp | 12 ++--- src/DialogLanguageModes.h | 4 +- src/DialogMacros.cpp | 10 ++-- src/DialogMacros.h | 4 +- src/DialogMultiReplace.cpp | 2 +- src/DialogReplace.cpp | 16 +++--- src/DialogReplace.h | 4 +- src/DialogShellMenu.cpp | 8 +-- src/DialogShellMenu.h | 4 +- src/DialogSyntaxPatterns.cpp | 16 +++--- src/DialogSyntaxPatterns.h | 4 +- src/DialogWindowBackgroundMenu.cpp | 10 ++-- src/DialogWindowBackgroundMenu.h | 4 +- src/DocumentWidget.cpp | 20 ++++---- src/DocumentWidget.h | 4 +- src/Highlight.cpp | 32 ++++++------ src/Highlight.h | 4 +- src/MainWindow.cpp | 20 ++++---- src/Preferences.cpp | 12 ++--- src/Rangeset.cpp | 8 +-- src/Rangeset.h | 6 +-- src/Search.cpp | 78 +++++++++++++++--------------- src/Search.h | 6 +-- src/TextArea.cpp | 36 +++++++------- src/TextArea.h | 8 +-- src/TextBuffer.h | 14 +++--- src/TextBuffer.tcc | 30 ++++++------ src/macro.cpp | 26 +++++----- src/userCmds.cpp | 10 ++-- 53 files changed, 324 insertions(+), 377 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3ade4e93..a81d1bd2 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -8,17 +8,10 @@ on: env: BUILD_TYPE: Release - BOOST_URL: 'https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_87_0.tar.gz' - BOOST_TGZ: 'boost_1_87_0.tar.gz' - BOOST_PATH: 'D:/boost_1_87_0' - jobs: build_ubuntu_20: runs-on: ubuntu-20.04 steps: - - name: Install Dependencies - run: sudo apt-get install -y libboost-dev - - name: Install Qt uses: jurplel/install-qt-action@v3 with: @@ -45,23 +38,6 @@ jobs: version: "5.12.8" setup-python: 'false' - - name: Cache Boost - id: cache-boost - uses: actions/cache@v4 - with: - path: ${{env.BOOST_PATH}} - key: win64-boost - - - name: Install Boost - if: steps.cache-boost.outputs.cache-hit != 'true' - run: | - Invoke-WebRequest ` - "${{ env.BOOST_URL }}" ` - -OutFile "${{ env.BOOST_TGZ }}" ` - -UserAgent "''" - tar xzf ${{ env.BOOST_TGZ }} -C D:/ - rm ${{ env.BOOST_TGZ }} - - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v2 @@ -73,8 +49,6 @@ jobs: - name: Configure run: | cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -G"Visual Studio 17 2022" - env: - BOOST_ROOT: "${{env.BOOST_PATH}}" - name: Build run: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7744408d..00000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -dist: bionic - -language: cpp - -cache: apt - -compiler: - - gcc - -env: - global: - - MAKEFLAGS="-j2" - -before_script: - - mkdir build && cd build && CXX=g++ cmake .. - -script: - - make - -os: - - linux - -addons: - apt: - packages: - - build-essential - - libboost-dev - - cmake - - qt5-default - - qtbase5-dev-tools - - qttools5-dev-tools - - qttools5-dev diff --git a/CMakeLists.txt b/CMakeLists.txt index 01690202..d83ec3f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,11 +27,11 @@ set(CPACK_RPM_PACKAGE_LICENSE "GPL-2") set(CPACK_RPM_PACKAGE_GROUP "Applications/Editors") # build requirements... -# set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase-devel, qt5-linguist, gcc, gcc-c++, boost-devel, cmake") +# set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase-devel, qt5-linguist, gcc, gcc-c++, cmake") set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase >= 5.6") set(CPACK_RPM_FILE_NAME RPM-DEFAULT) -set(CPACK_DEBIAN_PACKAGE_BUILD_DEPENDS "cmake (>= 3.0), qt5-default (>= 5.6), qtbase5-dev-tools (>= 5.6), qttools5-dev-tools (>= 5.6), qttools5-dev (>= 5.6), libboost-dev (>= 1.35), bison (>=3.0)") +set(CPACK_DEBIAN_PACKAGE_BUILD_DEPENDS "cmake (>= 3.0), qt5-default (>= 5.6), qtbase5-dev-tools (>= 5.6), qttools5-dev-tools (>= 5.6), qttools5-dev (>= 5.6), bison (>=3.0)") set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5core5a (>= 5.6), libqt5gui5 (>= 5.6), libqt5network5 (>= 5.6), libqt5printsupport5 (>= 5.6), libqt5widgets5 (>= 5.6), libqt5xml5 (>= 5.6)") set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CMAKE_PROJECT_HOMEPAGE_URL}) set(CPACK_DEBIAN_PACKAGE_SECTION "editors") @@ -43,8 +43,6 @@ set(CPACK_STRIP_FILES "bin/nedit-import") set(CPACK_STRIP_FILES "bin/nedit-ng") include(CPack) -find_package(Boost 1.35 REQUIRED) - set(NEDIT_PURIFY OFF CACHE BOOL "Fill Unused TextBuffer space") set(NEDIT_PER_TAB_CLOSE ON CACHE BOOL "Per Tab Close Buttons") set(NEDIT_VISUAL_CTRL_CHARS ON CACHE BOOL "Visualize ASCII Control Characters") diff --git a/Interpreter/CMakeLists.txt b/Interpreter/CMakeLists.txt index b4c41d60..4e73106c 100644 --- a/Interpreter/CMakeLists.txt +++ b/Interpreter/CMakeLists.txt @@ -34,11 +34,13 @@ PUBLIC Qt5::Core Util GSL -PRIVATE - Boost::boost ) target_add_warnings(Interpreter) -set_property(TARGET Interpreter PROPERTY CXX_STANDARD 17) -set_property(TARGET Interpreter PROPERTY CXX_EXTENSIONS OFF) +set_target_properties(Interpreter +PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF +) diff --git a/Interpreter/DataValue.h b/Interpreter/DataValue.h index a67615cf..31e20df3 100644 --- a/Interpreter/DataValue.h +++ b/Interpreter/DataValue.h @@ -6,12 +6,12 @@ #include +#include #include #include #include #include - -#include +#include #include @@ -33,8 +33,8 @@ struct ArrayIterator { Array::iterator it; }; -using Data = boost::variant< - boost::blank, +using Data = std::variant< + std::monostate, int32_t, std::string, ArrayPtr, @@ -124,55 +124,55 @@ inline DataValue make_value(LibraryRoutine routine) { } inline bool is_unset(const DataValue &dv) { - return dv.value.which() == 0; + return dv.value.index() == 0; } inline bool is_integer(const DataValue &dv) { - return dv.value.which() == 1; + return dv.value.index() == 1; } inline bool is_string(const DataValue &dv) { - return dv.value.which() == 2; + return dv.value.index() == 2; } inline bool is_array(const DataValue &dv) { - return dv.value.which() == 3; + return dv.value.index() == 3; } inline std::string to_string(const DataValue &dv) { - if (auto n = boost::get(&dv.value)) { - return std::to_string(*n); + if (auto n = std::get(dv.value)) { + return std::to_string(n); } - return boost::get(dv.value); + return std::get(dv.value); } inline int to_integer(const DataValue &dv) { - return boost::get(dv.value); + return std::get(dv.value); } inline Program *to_program(const DataValue &dv) { - return boost::get(dv.value); + return std::get(dv.value); } inline LibraryRoutine to_subroutine(const DataValue &dv) { - return boost::get(dv.value); + return std::get(dv.value); } inline DataValue *to_data_value(const DataValue &dv) { - return boost::get(dv.value); + return std::get(dv.value); } inline Inst *to_instruction(const DataValue &dv) { - return boost::get(dv.value); + return std::get(dv.value); } inline ArrayPtr to_array(const DataValue &dv) { - return boost::get(dv.value); + return std::get(dv.value); } inline ArrayIterator to_iterator(const DataValue &dv) { - return boost::get(dv.value); + return std::get(dv.value); } #endif diff --git a/README.md b/README.md index 7d270991..6c15536f 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,11 @@ [![License](https://img.shields.io/badge/license-GPL2-blue.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) nedit-ng is a Qt port of the [Nirvana Editor (NEdit)](https://sourceforge.net/projects/nedit/) version 5.6. It is intended -to be a **drop in replacement** for nedit in every practical way, just as on +to be a **drop in replacement** for nedit in every practical way, just as on many systems `/usr/bin/vi` is now a symlink to `/usr/bin/vim`. -Because it is a true port of the original code, it (at least for now) inherits -some (but not all) of the limitations of the original. On the other hand, some +Because it is a true port of the original code, it (at least for now) inherits +some (but not all) of the limitations of the original. On the other hand, some aspects have been improved simply by the fact that it is now a Qt application. ![Nedit-ng](https://eteran.github.io/nedit-ng/latest/img/nedit-ng-find.png) @@ -19,7 +19,6 @@ aspects have been improved simply by the fact that it is now a Qt application. Dependency | Version Required ------------------------------------------- | ---------------- [Qt](http://www.qt.io/) | >= 5.5 -[Boost](http://boost.org) (Headers Only) | >= 1.35 [Bison](https://www.gnu.org/software/bison/)| >= 3.0 [CMake](https://cmake.org) | >= 3.0 @@ -29,7 +28,7 @@ Dependency | Version Required $ cd build $ cmake .. $ make - + ### Help Documentation NEdit had extensive help texts, which have been carefully updated and made available online here: https://eteran.github.io/nedit-ng/ @@ -37,34 +36,34 @@ NEdit had extensive help texts, which have been carefully updated and made avail ### Inherited Limitations: * Text display is still ASCII only (for now). -* Regex engine is the original nedit proprietary implementation. This was kept +* Regex engine is the original nedit proprietary implementation. This was kept for a few reasons: - 1. NEdit's syntax is **slightly** non-standard, and I wanted to keep + 1. NEdit's syntax is **slightly** non-standard, and I wanted to keep things backwards compatible for now. - 2. NEdit's syntax highligher has very carefully created regex's which - result in things being highlighted in a way that I (and I assume other + 2. NEdit's syntax highligher has very carefully created regex's which + result in things being highlighted in a way that I (and I assume other nedit users) have grown to appreciate. A change in regex engine would likely require a rework on the syntax highlighting algorithm. 3. The original highligher has some insider information of the regex - implementation which it uses in order to be more efficient. I could + implementation which it uses in order to be more efficient. I could fake this information, but at the cost of efficiency. ### Improvements already available: -* Bug fixes! Yes, NEdit 5.6 unfortunately has some bugs, some of which can +* Bug fixes! Yes, NEdit 5.6 unfortunately has some bugs, some of which can result in a crash. Where possible, the new code has these fixed. * Anti-aliased font rendering. * Modern look and feel. * Internally, counted strings are used instead of NUL terminated strings. This - removes the need to have code that played games with substituting NUL + removes the need to have code that played games with substituting NUL characters mid-stream. * Use of some C++ containers means many internal size limits are no longer present. -* Code as been reworked using modern C++ techniques using a toolkit with an +* Code as been reworked using modern C++ techniques using a toolkit with an active developer community, making it significantly easier for contributions to be made by the open source community. -The goal of the initial release is to be a nearly 1:1 port of the original NEdit. +The goal of the initial release is to be a nearly 1:1 port of the original NEdit. Now that we have achieved that goal. looking towards the future, some additional goals are: @@ -73,5 +72,5 @@ goals are: - [ ] Python/LUA scripting support in addition to the built-in macro system - [ ] An improved preferences system - [ ] Extensibility though plugins -- [ ] Sessions, meaning that you can save and restore an edit session (such as +- [ ] Sessions, meaning that you can save and restore an edit session (such as several open tabs) diff --git a/Regex/CMakeLists.txt b/Regex/CMakeLists.txt index 4ccc5698..e491aaf9 100644 --- a/Regex/CMakeLists.txt +++ b/Regex/CMakeLists.txt @@ -41,8 +41,12 @@ target_link_libraries(Regex PUBLIC target_add_warnings(Regex) -set_property(TARGET Regex PROPERTY CXX_STANDARD 17) -set_property(TARGET Regex PROPERTY CXX_EXTENSIONS OFF) +set_target_properties(Regex +PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF +) if(NEDIT_BUILD_TESTS) if(NOT MSVC) diff --git a/Regex/Decompile.h b/Regex/Decompile.h index 74dcaa03..f9b1d6d4 100644 --- a/Regex/Decompile.h +++ b/Regex/Decompile.h @@ -3,7 +3,7 @@ #define DECOMPILE_H_ #include "Opcodes.h" -#include +#include #include #include class Regex; @@ -46,7 +46,7 @@ struct Instruction6 { uint16_t op2; }; -using Instruction = boost::variant; +using Instruction = std::variant; std::vector decompileRegex(const Regex &re); diff --git a/Regex/test/CMakeLists.txt b/Regex/test/CMakeLists.txt index be9916ca..2d0aa2da 100644 --- a/Regex/test/CMakeLists.txt +++ b/Regex/test/CMakeLists.txt @@ -13,8 +13,14 @@ if(NEDIT_INCLUDE_DECOMPILER) target_compile_definitions(nedit-regex-test PUBLIC -DNEDIT_INCLUDE_DECOMPILER) endif() -set_property(TARGET nedit-regex-test PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") -set_property(TARGET nedit-regex-test PROPERTY CXX_STANDARD 14) + +set_target_properties(nedit-regex-test +PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" +) add_test( NAME nedit-regex-test diff --git a/Settings/CMakeLists.txt b/Settings/CMakeLists.txt index fe393f78..e6f65576 100644 --- a/Settings/CMakeLists.txt +++ b/Settings/CMakeLists.txt @@ -25,7 +25,9 @@ PUBLIC target_add_warnings(Settings) -set_property(TARGET Settings PROPERTY CXX_STANDARD 17) -set_property(TARGET Settings PROPERTY CXX_EXTENSIONS OFF) - - +set_target_properties(Settings +PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF +) diff --git a/Util/CMakeLists.txt b/Util/CMakeLists.txt index 858b0d05..04c3eca7 100644 --- a/Util/CMakeLists.txt +++ b/Util/CMakeLists.txt @@ -111,12 +111,13 @@ PUBLIC GSL Qt5::Core Qt5::Network - Boost::boost ) target_add_warnings(Util) -set_property(TARGET Util PROPERTY CXX_STANDARD 17) -set_property(TARGET Util PROPERTY CXX_EXTENSIONS OFF) - - +set_target_properties(Util +PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF +) diff --git a/Util/include/Util/FileSystem.h b/Util/include/Util/FileSystem.h index 7f05db72..a77b1c97 100644 --- a/Util/include/Util/FileSystem.h +++ b/Util/include/Util/FileSystem.h @@ -5,7 +5,7 @@ #include "string_view.h" #include #include -#include +#include #include enum class FileFormats : int; diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 9e67c621..0bcc3d0b 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -16,14 +16,17 @@ target_link_libraries(nc-ng PUBLIC Qt5::Network Util Settings - Boost::boost ) target_add_warnings(nc-ng) -set_property(TARGET nc-ng PROPERTY CXX_STANDARD 17) -set_property(TARGET nc-ng PROPERTY CXX_EXTENSIONS OFF) -set_property(TARGET nc-ng PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") +set_target_properties(nc-ng +PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" +) if(TARGET_COMPILER_MSVC) set_property(TARGET nc-ng PROPERTY WIN32_EXECUTABLE ON) diff --git a/client/nc.cpp b/client/nc.cpp index 17d0e5c4..b0bed204 100644 --- a/client/nc.cpp +++ b/client/nc.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include #include @@ -153,7 +153,7 @@ void printNcVersion() { * Converts command line into a command string suitable for passing to the * server */ -boost::optional parseCommandLine(const QStringList &args) { +std::optional parseCommandLine(const QStringList &args) { CommandLine commandLine; QString toDoCommand; @@ -348,7 +348,7 @@ boost::optional parseCommandLine(const QStringList &args) { CommandLine processCommandLine(const QStringList &args) { // Convert command line arguments into a command string for the server - if (boost::optional commandLine = parseCommandLine(args)) { + if (std::optional commandLine = parseCommandLine(args)) { return *commandLine; } diff --git a/cmake/Modules/DetectCompiler.cmake b/cmake/Modules/DetectCompiler.cmake index ece0d0ef..68339069 100644 --- a/cmake/Modules/DetectCompiler.cmake +++ b/cmake/Modules/DetectCompiler.cmake @@ -9,21 +9,3 @@ else() message(FATAL_ERROR "Unsupported Compiler: ${CMAKE_CXX_COMPILER_ID}") endif() -list (FIND CMAKE_CXX_COMPILE_FEATURES "cxx_std_11" _index) -if (${_index} GREATER -1) - set(TARGET_COMPILER_SUPPORTS_CXX11 1) - set(TARGET_COMPILER_HIGHEST_STD_SUPPORTED 11) -endif() - -list (FIND CMAKE_CXX_COMPILE_FEATURES "cxx_std_14" _index) -if (${_index} GREATER -1) - set(TARGET_COMPILER_SUPPORTS_CXX14 1) - set(TARGET_COMPILER_HIGHEST_STD_SUPPORTED 14) -endif() - -list (FIND CMAKE_CXX_COMPILE_FEATURES "cxx_std_17" _index) -if (${_index} GREATER -1) - set(TARGET_COMPILER_SUPPORTS_CXX17 1) - set(TARGET_COMPILER_HIGHEST_STD_SUPPORTED 17) -endif() - diff --git a/import/CMakeLists.txt b/import/CMakeLists.txt index 4c115174..2491c062 100644 --- a/import/CMakeLists.txt +++ b/import/CMakeLists.txt @@ -29,10 +29,12 @@ target_include_directories(nedit-import PRIVATE ${X11_INCLUDE_DIR} ) -target_add_warnings(nedit-import) - -set_property(TARGET nedit-import PROPERTY CXX_STANDARD 17) -set_property(TARGET nedit-import PROPERTY CXX_EXTENSIONS OFF) -set_property(TARGET nedit-import PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") +set_target_properties(nedit-import +PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" +) install(TARGETS nedit-import DESTINATION bin) diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index e2ab7fef..c006f3dc 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.15) add_subdirectory(yaml-cpp-0.8.0) -set(GSL_CXX_STANDARD "${TARGET_COMPILER_HIGHEST_STD_SUPPORTED}" CACHE STRING "Use c++ standard") -set(GSL_CXX_STD "cxx_std_${GSL_CXX_STANDARD}") +set(GSL_CXX_STANDARD "17") +set(GSL_CXX_STD "cxx_std_17") add_subdirectory(GSL-3.1.0 EXCLUDE_FROM_ALL) diff --git a/libs/yaml-cpp-0.8.0/CMakeLists.txt b/libs/yaml-cpp-0.8.0/CMakeLists.txt index ce20de7e..07920f30 100644 --- a/libs/yaml-cpp-0.8.0/CMakeLists.txt +++ b/libs/yaml-cpp-0.8.0/CMakeLists.txt @@ -77,7 +77,9 @@ target_include_directories(yaml-cpp target_compile_definitions(yaml-cpp PUBLIC YAML_CPP_STATIC_DEFINE) -set_property(TARGET yaml-cpp PROPERTY CXX_STANDARD 14) -set_property(TARGET yaml-cpp PROPERTY CXX_EXTENSIONS OFF) - - +set_target_properties(yaml-cpp +PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dd5554e0..b37dfe5f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -268,12 +268,16 @@ PUBLIC Qt5::Xml Qt5::PrintSupport PRIVATE - Boost::boost yaml-cpp ) -set_property(TARGET nedit-ng PROPERTY CXX_EXTENSIONS OFF) -set_property(TARGET nedit-ng PROPERTY CXX_STANDARD 17) -set_property(TARGET nedit-ng PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") + +set_target_properties(nedit-ng +PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" +) if(TARGET_COMPILER_MSVC) set_property(TARGET nedit-ng PROPERTY WIN32_EXECUTABLE ON) diff --git a/src/CallTip.h b/src/CallTip.h index eba88cfd..12742c7c 100644 --- a/src/CallTip.h +++ b/src/CallTip.h @@ -3,7 +3,7 @@ #define CALL_TIP_H_ #include "TextCursor.h" -#include +#include enum class TipHAlignMode { Left, @@ -22,7 +22,7 @@ enum class TipAlignMode { }; // a cursor if it's anchored, otherwise it's a relative x position -using CallTipPosition = boost::variant; +using CallTipPosition = std::variant; struct CallTip { int ID = 0; // ID of displayed calltip. Equals zero if none is displayed. diff --git a/src/DialogDrawingStyles.cpp b/src/DialogDrawingStyles.cpp index 4c10d6a9..a7a6ae68 100644 --- a/src/DialogDrawingStyles.cpp +++ b/src/DialogDrawingStyles.cpp @@ -248,13 +248,13 @@ bool DialogDrawingStyles::validateFields(Verbosity verbosity) { * @param mode * @return */ -boost::optional DialogDrawingStyles::readFields(Verbosity verbosity) { +std::optional DialogDrawingStyles::readFields(Verbosity verbosity) { HighlightStyle hs; QString name = ui.editName->text().simplified(); if (name.isNull()) { - return boost::none; + return {}; } hs.name = name; @@ -265,13 +265,13 @@ boost::optional DialogDrawingStyles::readFields(Verbosity verbos tr("Please specify a name for the highlight style")); } - return boost::none; + return {}; } // read the color field QString color = ui.editColorFG->text().simplified(); if (color.isEmpty()) { - return boost::none; + return {}; } hs.color = color; @@ -279,7 +279,7 @@ boost::optional DialogDrawingStyles::readFields(Verbosity verbos if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Style Color"), tr("Please specify a color for the highlight style")); } - return boost::none; + return {}; } // Verify that the color is a valid X color spec @@ -288,7 +288,7 @@ boost::optional DialogDrawingStyles::readFields(Verbosity verbos if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Invalid Color"), tr("Invalid X color specification: %1").arg(hs.color)); } - return boost::none; + return {}; } // read the background color field - this may be empty @@ -309,7 +309,7 @@ boost::optional DialogDrawingStyles::readFields(Verbosity verbos tr("Invalid X background color specification: %1").arg(hs.bgColor)); } - return boost::none; + return {}; } } diff --git a/src/DialogDrawingStyles.h b/src/DialogDrawingStyles.h index ba8fbdf8..2c17e803 100644 --- a/src/DialogDrawingStyles.h +++ b/src/DialogDrawingStyles.h @@ -8,7 +8,7 @@ #include -#include +#include class DialogSyntaxPatterns; class HighlightStyleModel; @@ -43,7 +43,7 @@ class DialogDrawingStyles final : public Dialog { private: bool applyDialogChanges(); bool validateFields(Verbosity verbosity); - boost::optional readFields(Verbosity verbosity); + std::optional readFields(Verbosity verbosity); bool updateCurrentItem(); bool updateCurrentItem(const QModelIndex &index); int countPlainEntries() const; diff --git a/src/DialogFind.cpp b/src/DialogFind.cpp index e48f8ce1..91e21aff 100644 --- a/src/DialogFind.cpp +++ b/src/DialogFind.cpp @@ -220,7 +220,7 @@ void DialogFind::buttonFind_clicked() { } // fetch find string, direction and type from the dialog - boost::optional fields = readFields(); + std::optional fields = readFields(); if (!fields) { return; } @@ -246,7 +246,7 @@ void DialogFind::buttonFind_clicked() { ** strings and search type from the Find dialog. If the strings are ok, ** save a copy in the search history, and return the fields */ -boost::optional DialogFind::readFields() { +std::optional DialogFind::readFields() { Fields fields; @@ -271,7 +271,7 @@ boost::optional DialogFind::readFields() { this, tr("Regex Error"), tr("Please re-specify the search string:\n%1").arg(QString::fromLatin1(e.what()))); - return boost::none; + return {}; } } else { if (ui.checkCase->isChecked()) { diff --git a/src/DialogFind.h b/src/DialogFind.h index e4a3294c..4ee8ea1a 100644 --- a/src/DialogFind.h +++ b/src/DialogFind.h @@ -7,7 +7,7 @@ #include "SearchType.h" #include -#include +#include #include "ui_DialogFind.h" @@ -42,7 +42,7 @@ class DialogFind : public Dialog { void updateFindButton(); private: - boost::optional readFields(); + std::optional readFields(); private: void textFind_textChanged(const QString &text); diff --git a/src/DialogLanguageModes.cpp b/src/DialogLanguageModes.cpp index 42e3cd1b..8dc3096b 100644 --- a/src/DialogLanguageModes.cpp +++ b/src/DialogLanguageModes.cpp @@ -231,7 +231,7 @@ void DialogLanguageModes::buttonBox_clicked(QAbstractButton *button) { ** structure reflecting the current state of the selected language mode in the dialog. ** If any of the information is incorrect or missing, display a warning dialog. */ -boost::optional DialogLanguageModes::readFields(Verbosity verbosity) { +std::optional DialogLanguageModes::readFields(Verbosity verbosity) { LanguageMode lm; @@ -241,7 +241,7 @@ boost::optional DialogLanguageModes::readFields(Verbosity verbosit if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Language Mode Name"), tr("Please specify a name for the language mode")); } - return boost::none; + return {}; } lm.name = name; @@ -264,7 +264,7 @@ boost::optional DialogLanguageModes::readFields(Verbosity verbosit if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Regex"), tr("Recognition expression:\n%1").arg(QString::fromLatin1(e.what()))); } - return boost::none; + return {}; } } @@ -278,7 +278,7 @@ boost::optional DialogLanguageModes::readFields(Verbosity verbosit if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Error reading Calltips"), tr("Can't read default calltips file(s):\n \"%1\"\n").arg(tipsFile)); } - return boost::none; + return {}; } if (!Tags::deleteTagsFile(tipsFile, Tags::SearchMode::TIP, false)) { @@ -296,7 +296,7 @@ boost::optional DialogLanguageModes::readFields(Verbosity verbosit int tabsSpacingValue = tabsSpacing.toInt(&ok); if (!ok) { QMessageBox::warning(this, tr("Warning"), tr("Can't read integer value \"%1\" in tab spacing").arg(tabsSpacing)); - return boost::none; + return {}; } lm.tabDist = tabsSpacingValue; @@ -311,7 +311,7 @@ boost::optional DialogLanguageModes::readFields(Verbosity verbosit int emulatedTabSpacingValue = emulatedTabSpacing.toInt(&ok); if (!ok) { QMessageBox::warning(this, tr("Warning"), tr("Can't read integer value \"%1\" in emulated tab spacing").arg(tabsSpacing)); - return boost::none; + return {}; } lm.emTabDist = emulatedTabSpacingValue; diff --git a/src/DialogLanguageModes.h b/src/DialogLanguageModes.h index 0e447076..b90e4316 100644 --- a/src/DialogLanguageModes.h +++ b/src/DialogLanguageModes.h @@ -8,7 +8,7 @@ #include -#include +#include class DialogSyntaxPatterns; class LanguageMode; @@ -44,7 +44,7 @@ class DialogLanguageModes final : public Dialog { bool updateCurrentItem(const QModelIndex &index); bool updateLanguageList(Verbosity verbosity); bool updateLMList(Verbosity verbosity); - boost::optional readFields(Verbosity verbosity); + std::optional readFields(Verbosity verbosity); int countLanguageModes(const QString &name) const; bool LMHasHighlightPatterns(const QString &name) const; diff --git a/src/DialogMacros.cpp b/src/DialogMacros.cpp index f29ba42c..ff653f3d 100644 --- a/src/DialogMacros.cpp +++ b/src/DialogMacros.cpp @@ -260,7 +260,7 @@ bool DialogMacros::validateFields(Verbosity verbosity) { ** pointer to the new MenuItem structure as the function value, or nullptr on ** failure. */ -boost::optional DialogMacros::readFields(Verbosity verbosity) { +std::optional DialogMacros::readFields(Verbosity verbosity) { QString nameText = ui.editName->text(); @@ -268,14 +268,14 @@ boost::optional DialogMacros::readFields(Verbosity verbosity) { if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Menu Entry"), tr("Please specify a name for the menu item")); } - return boost::none; + return {}; } if (nameText.indexOf(QLatin1Char(':')) != -1) { if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Menu Entry"), tr("Menu item names may not contain colon (:) characters")); } - return boost::none; + return {}; } QString cmdText = ui.editMacro->toPlainText(); @@ -283,12 +283,12 @@ boost::optional DialogMacros::readFields(Verbosity verbosity) { if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Command to Execute"), tr("Please specify macro command(s) to execute")); } - return boost::none; + return {}; } cmdText = ensure_newline(cmdText); if (!checkMacroText(cmdText, verbosity)) { - return boost::none; + return {}; } MenuItem menuItem; diff --git a/src/DialogMacros.h b/src/DialogMacros.h index 652206d4..29fb2a49 100644 --- a/src/DialogMacros.h +++ b/src/DialogMacros.h @@ -6,7 +6,7 @@ #include "Verbosity.h" #include "ui_DialogMacros.h" -#include +#include struct MenuItem; class MenuItemModel; @@ -42,7 +42,7 @@ class DialogMacros final : public Dialog { bool checkMacroText(const QString ¯o, Verbosity verbosity); bool updateCurrentItem(); bool updateCurrentItem(const QModelIndex &index); - boost::optional readFields(Verbosity verbosity); + std::optional readFields(Verbosity verbosity); private: Ui::DialogMacros ui; diff --git a/src/DialogMultiReplace.cpp b/src/DialogMultiReplace.cpp index 3962ab25..3644f4ed 100644 --- a/src/DialogMultiReplace.cpp +++ b/src/DialogMultiReplace.cpp @@ -86,7 +86,7 @@ void DialogMultiReplace::buttonReplace_clicked() { /* Fetch the find and replace strings from the dialog; * they should have been validated already, but it is possible that the * user modified the strings again, so we should verify them again too. */ - boost::optional fields = replace_->readFields(); + std::optional fields = replace_->readFields(); if (!fields) { return; } diff --git a/src/DialogReplace.cpp b/src/DialogReplace.cpp index 103b6423..63a36c06 100644 --- a/src/DialogReplace.cpp +++ b/src/DialogReplace.cpp @@ -242,7 +242,7 @@ void DialogReplace::textFind_textChanged(const QString &text) { void DialogReplace::buttonFind_clicked() { // Validate and fetch the find and replace strings from the dialog - boost::optional fields = readFields(); + std::optional fields = readFields(); if (!fields) { return; } @@ -280,7 +280,7 @@ void DialogReplace::buttonFind_clicked() { void DialogReplace::buttonReplace_clicked() { // Validate and fetch the find and replace strings from the dialog - boost::optional fields = readFields(); + std::optional fields = readFields(); if (!fields) { return; } @@ -312,7 +312,7 @@ void DialogReplace::buttonReplace_clicked() { void DialogReplace::buttonReplaceFind_clicked() { // Validate and fetch the find and replace strings from the dialog - boost::optional fields = readFields(); + std::optional fields = readFields(); if (!fields) { return; } @@ -344,7 +344,7 @@ void DialogReplace::buttonReplaceFind_clicked() { void DialogReplace::buttonWindow_clicked() { // Validate and fetch the find and replace strings from the dialog - boost::optional fields = readFields(); + std::optional fields = readFields(); if (!fields) { return; } @@ -374,7 +374,7 @@ void DialogReplace::buttonWindow_clicked() { void DialogReplace::buttonSelection_clicked() { // Validate and fetch the find and replace strings from the dialog - boost::optional fields = readFields(); + std::optional fields = readFields(); if (!fields) { return; } @@ -404,7 +404,7 @@ void DialogReplace::buttonSelection_clicked() { void DialogReplace::buttonMulti_clicked() { // Validate and fetch the find and replace strings from the dialog - boost::optional fields = readFields(); + std::optional fields = readFields(); if (!fields) { return; } @@ -596,7 +596,7 @@ void DialogReplace::setActionButtons(bool replaceBtn, bool replaceFindBtn, bool ** strings and search type from the Replace dialog. If the strings are ok, ** save a copy in the search history, and return the fields */ -boost::optional DialogReplace::readFields() { +std::optional DialogReplace::readFields() { Fields fields; @@ -620,7 +620,7 @@ boost::optional DialogReplace::readFields() { auto compiledRE = make_regex(replaceText, regexDefault); } catch (const RegexError &e) { QMessageBox::warning(this, tr("Search String"), tr("Please re-specify the search string:\n%1").arg(QString::fromLatin1(e.what()))); - return boost::none; + return {}; } } else { if (ui.checkCase->isChecked()) { diff --git a/src/DialogReplace.h b/src/DialogReplace.h index cdc2d276..3da3c753 100644 --- a/src/DialogReplace.h +++ b/src/DialogReplace.h @@ -7,7 +7,7 @@ #include "SearchType.h" #include -#include +#include #include "ui_DialogReplace.h" @@ -48,7 +48,7 @@ class DialogReplace : public Dialog { void updateFindButton(); private: - boost::optional readFields(); + std::optional readFields(); private: void textFind_textChanged(const QString &text); diff --git a/src/DialogShellMenu.cpp b/src/DialogShellMenu.cpp index d538fdce..1e400349 100644 --- a/src/DialogShellMenu.cpp +++ b/src/DialogShellMenu.cpp @@ -242,21 +242,21 @@ void DialogShellMenu::buttonBox_accepted() { ** pointer to the new MenuItem structure as the function value, or nullptr on ** failure. */ -boost::optional DialogShellMenu::readFields(Verbosity verbosity) { +std::optional DialogShellMenu::readFields(Verbosity verbosity) { QString nameText = ui.editName->text(); if (nameText.isEmpty()) { if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Menu Entry"), tr("Please specify a name for the menu item")); } - return boost::none; + return {}; } if (nameText.indexOf(QLatin1Char(':')) != -1) { if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Menu Entry"), tr("Menu item names may not contain colon (:) characters")); } - return boost::none; + return {}; } QString cmdText = ui.editCommand->toPlainText(); @@ -264,7 +264,7 @@ boost::optional DialogShellMenu::readFields(Verbosity verbosity) { if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Command to Execute"), tr("Please specify macro command(s) to execute")); } - return boost::none; + return {}; } MenuItem menuItem; diff --git a/src/DialogShellMenu.h b/src/DialogShellMenu.h index 65ed9e1f..7a9e9e42 100644 --- a/src/DialogShellMenu.h +++ b/src/DialogShellMenu.h @@ -6,7 +6,7 @@ #include "Verbosity.h" #include "ui_DialogShellMenu.h" -#include +#include struct MenuItem; class MenuItemModel; @@ -40,7 +40,7 @@ class DialogShellMenu final : public Dialog { bool validateFields(Verbosity verbosity); bool updateCurrentItem(); bool updateCurrentItem(const QModelIndex &index); - boost::optional readFields(Verbosity verbosity); + std::optional readFields(Verbosity verbosity); private: Ui::DialogShellMenu ui; diff --git a/src/DialogSyntaxPatterns.cpp b/src/DialogSyntaxPatterns.cpp index 320ae442..8b0fec78 100644 --- a/src/DialogSyntaxPatterns.cpp +++ b/src/DialogSyntaxPatterns.cpp @@ -454,7 +454,7 @@ void DialogSyntaxPatterns::buttonRestore_clicked() { const QString languageMode = ui.comboLanguageMode->currentText(); - boost::optional patternSet = Highlight::readDefaultPatternSet(languageMode); + std::optional patternSet = Highlight::readDefaultPatternSet(languageMode); if (!patternSet) { QMessageBox::warning( this, @@ -792,7 +792,7 @@ std::unique_ptr DialogSyntaxPatterns::getDialogPatternSet() { ** telling the user what's wrong (Passing "silent" as true, suppresses these ** dialogs). Returns nullptr on error. */ -boost::optional DialogSyntaxPatterns::readFields(Verbosity verbosity) { +std::optional DialogSyntaxPatterns::readFields(Verbosity verbosity) { HighlightPattern pat; @@ -807,7 +807,7 @@ boost::optional DialogSyntaxPatterns::readFields(Verbosity ver // read the name field QString name = ui.editPatternName->text().simplified(); if (name.isNull()) { - return boost::none; + return {}; } pat.name = name; @@ -815,7 +815,7 @@ boost::optional DialogSyntaxPatterns::readFields(Verbosity ver if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Pattern Name"), tr("Please specify a name for the pattern")); } - return boost::none; + return {}; } // read the startRE field @@ -824,7 +824,7 @@ boost::optional DialogSyntaxPatterns::readFields(Verbosity ver if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Matching Regex"), tr("Please specify a regular expression to match")); } - return boost::none; + return {}; } /* Make sure coloring patterns contain only sub-expression references @@ -853,7 +853,7 @@ boost::optional DialogSyntaxPatterns::readFields(Verbosity ver tr("Pattern Error"), tr("The expression field in patterns which specify highlighting for a parent, must contain only sub-expression references in regular expression replacement form (&\\1\\2 etc.). See Help -> Regular Expressions and Help -> Syntax Highlighting for more information")); } - return boost::none; + return {}; } } @@ -864,7 +864,7 @@ boost::optional DialogSyntaxPatterns::readFields(Verbosity ver if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Specify Parent Pattern"), tr("Please specify a parent pattern")); } - return boost::none; + return {}; } if (!parent.isNull()) { @@ -882,7 +882,7 @@ boost::optional DialogSyntaxPatterns::readFields(Verbosity ver if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Specify Regex"), tr("Please specify an ending regular expression")); } - return boost::none; + return {}; } } diff --git a/src/DialogSyntaxPatterns.h b/src/DialogSyntaxPatterns.h index 726bd91c..d668b447 100644 --- a/src/DialogSyntaxPatterns.h +++ b/src/DialogSyntaxPatterns.h @@ -8,7 +8,7 @@ #include -#include +#include #include class HighlightPattern; @@ -64,7 +64,7 @@ private Q_SLOTS: bool updateCurrentItem(); bool updateCurrentItem(const QModelIndex &index); bool updatePatternSet(); - boost::optional readFields(Verbosity verbosity); + std::optional readFields(Verbosity verbosity); std::unique_ptr getDialogPatternSet(); void setStyleMenu(const QString &name); void updateLabels(); diff --git a/src/DialogWindowBackgroundMenu.cpp b/src/DialogWindowBackgroundMenu.cpp index 00435cf5..346faf7e 100644 --- a/src/DialogWindowBackgroundMenu.cpp +++ b/src/DialogWindowBackgroundMenu.cpp @@ -243,7 +243,7 @@ bool DialogWindowBackgroundMenu::validateFields(Verbosity verbosity) { /* ** Read the name, accelerator, mnemonic, and command fields. */ -boost::optional DialogWindowBackgroundMenu::readFields(Verbosity verbosity) { +std::optional DialogWindowBackgroundMenu::readFields(Verbosity verbosity) { QString nameText = ui.editName->text(); @@ -251,14 +251,14 @@ boost::optional DialogWindowBackgroundMenu::readFields(Verbosity verbo if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Menu Entry"), tr("Please specify a name for the menu item")); } - return boost::none; + return {}; } if (nameText.indexOf(QLatin1Char(':')) != -1) { if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Menu Entry"), tr("Menu item names may not contain colon (:) characters")); } - return boost::none; + return {}; } QString cmdText = ui.editMacro->toPlainText(); @@ -266,12 +266,12 @@ boost::optional DialogWindowBackgroundMenu::readFields(Verbosity verbo if (verbosity == Verbosity::Verbose) { QMessageBox::warning(this, tr("Command to Execute"), tr("Please specify macro command(s) to execute")); } - return boost::none; + return {}; } cmdText = ensure_newline(cmdText); if (!checkMacroText(cmdText, verbosity)) { - return boost::none; + return {}; } MenuItem menuItem; diff --git a/src/DialogWindowBackgroundMenu.h b/src/DialogWindowBackgroundMenu.h index 294d0ae8..6478182a 100644 --- a/src/DialogWindowBackgroundMenu.h +++ b/src/DialogWindowBackgroundMenu.h @@ -6,7 +6,7 @@ #include "Verbosity.h" #include "ui_DialogWindowBackgroundMenu.h" -#include +#include struct MenuItem; class MenuItemModel; @@ -45,7 +45,7 @@ class DialogWindowBackgroundMenu final : public Dialog { bool checkMacroText(const QString ¯o, Verbosity verbosity); bool updateCurrentItem(); bool updateCurrentItem(const QModelIndex &index); - boost::optional readFields(Verbosity verbosity); + std::optional readFields(Verbosity verbosity); private: Ui::DialogWindowBackgroundMenu ui; diff --git a/src/DocumentWidget.cpp b/src/DocumentWidget.cpp index cd4c11a0..6ccf6b82 100644 --- a/src/DocumentWidget.cpp +++ b/src/DocumentWidget.cpp @@ -886,7 +886,7 @@ size_t DocumentWidget::matchLanguageMode() const { for (size_t i = 0; i < Preferences::LanguageModes.size(); i++) { if (!Preferences::LanguageModes[i].recognitionExpr.isNull()) { - boost::optional searchResult = Search::SearchString( + std::optional searchResult = Search::SearchString( first200, Preferences::LanguageModes[i].recognitionExpr, Direction::Forward, @@ -3660,7 +3660,7 @@ void DocumentWidget::includeFile(const QString &name) { } } -boost::optional DocumentWidget::findMatchingChar(char toMatch, Style styleToMatch, TextCursor charPos, TextCursor startLimit, TextCursor endLimit) { +std::optional DocumentWidget::findMatchingChar(char toMatch, Style styleToMatch, TextCursor charPos, TextCursor startLimit, TextCursor endLimit) { Style style; bool matchSyntaxBased = info_->matchSyntaxBased; @@ -3676,7 +3676,7 @@ boost::optional DocumentWidget::findMatchingChar(char toMatch, Style }); if (matchIt == std::end(MatchingChars)) { - return boost::none; + return {}; } const char matchChar = matchIt->match; @@ -3746,7 +3746,7 @@ boost::optional DocumentWidget::findMatchingChar(char toMatch, Style break; } - return boost::none; + return {}; } void DocumentWidget::gotoMatchingCharacter(TextArea *area, bool select) { @@ -3776,7 +3776,7 @@ void DocumentWidget::gotoMatchingCharacter(TextArea *area, bool select) { } // Search for it in the buffer - boost::optional matchPos = findMatchingChar( + std::optional matchPos = findMatchingChar( info_->buffer->BufGetCharacter(range.start), getHighlightInfo(range.start), range.start, @@ -3952,7 +3952,7 @@ void DocumentWidget::executeShellCommand(TextArea *area, const QString &command, for # in the shell command */ QString fullName = fullPath(); - boost::optional loc = area->positionToLineAndCol(pos); + std::optional loc = area->positionToLineAndCol(pos); if (!loc) { loc = Location{-1, -1}; } @@ -4447,7 +4447,7 @@ void DocumentWidget::gotoAP(TextArea *area, int64_t line, int64_t column) { if (line == -1) { position = area->cursorPos(); - boost::optional loc = area->positionToLineAndCol(position); + std::optional loc = area->positionToLineAndCol(position); if (!loc) { return; } @@ -4905,7 +4905,7 @@ void DocumentWidget::execCursorLine(TextArea *area, CommandSource source) { /* Substitute the current file name for % and the current line number for # in the shell command */ - const boost::optional loc = area->positionToLineAndCol(pos); + const std::optional loc = area->positionToLineAndCol(pos); auto substitutedCommand = escapeCommand(QString::fromStdString(cmdText), fullPath(), loc->line); @@ -5006,7 +5006,7 @@ void DocumentWidget::doShellMenuCmd(MainWindow *inWindow, TextArea *area, const for # in the shell command */ TextCursor pos = area->cursorPos(); - const boost::optional loc = area->positionToLineAndCol(pos); + const std::optional loc = area->positionToLineAndCol(pos); QString substitutedCommand = escapeCommand(command, fullPath(), loc ? loc->line : 0); @@ -5501,7 +5501,7 @@ void DocumentWidget::flashMatchingChar(TextArea *area) { } // do the search - boost::optional matchPos = findMatchingChar(ch, style, searchPos, startPos, endPos); + std::optional matchPos = findMatchingChar(ch, style, searchPos, startPos, endPos); if (!matchPos) { return; } diff --git a/src/DocumentWidget.h b/src/DocumentWidget.h index ad8d7e5b..a12d1d2b 100644 --- a/src/DocumentWidget.h +++ b/src/DocumentWidget.h @@ -31,7 +31,7 @@ #include -#include +#include #include @@ -242,7 +242,7 @@ class DocumentWidget : public QWidget { bool saveDocumentAs(const QString &newName, bool addWrap); bool writeBackupFile(); bool writeBckVersion(); - boost::optional findMatchingChar(char toMatch, Style styleToMatch, TextCursor charPos, TextCursor startLimit, TextCursor endLimit); + std::optional findMatchingChar(char toMatch, Style styleToMatch, TextCursor charPos, TextCursor startLimit, TextCursor endLimit); int findAllMatches(TextArea *area, const QString &string); size_t matchLanguageMode() const; std::unique_ptr compilePatterns(const std::vector &patternSrc, Verbosity verbosity = Verbosity::Silent); diff --git a/src/Highlight.cpp b/src/Highlight.cpp index 12c18ab6..4fb712fc 100644 --- a/src/Highlight.cpp +++ b/src/Highlight.cpp @@ -102,7 +102,7 @@ TextCursor lastModified(const Ptr &buffer) { */ bool isDefaultPatternSet(const PatternSet &patternSet) { - boost::optional defaultPatSet = readDefaultPatternSet(patternSet.languageMode); + std::optional defaultPatSet = readDefaultPatternSet(patternSet.languageMode); if (!defaultPatSet) { return false; } @@ -791,14 +791,14 @@ bool readHighlightPattern(Input &in, QString *errMsg, HighlightPattern *pattern) ** structures, and a language mode name. If unsuccessful, returns an empty ** vector message in "errMsg". */ -boost::optional> readHighlightPatterns(Input &in, QString *errMsg) { +std::optional> readHighlightPatterns(Input &in, QString *errMsg) { // skip over blank space in.skipWhitespaceNL(); // look for initial brace if (*in != QLatin1Char('{')) { *errMsg = tr("pattern list must begin with \"{\""); - return boost::none; + return {}; } ++in; @@ -809,7 +809,7 @@ boost::optional> readHighlightPatterns(Input &in, in.skipWhitespaceNL(); if (in.atEnd()) { *errMsg = tr("end of pattern list not found"); - return boost::none; + return {}; } if (*in == QLatin1Char('}')) { @@ -819,7 +819,7 @@ boost::optional> readHighlightPatterns(Input &in, HighlightPattern pat; if (!readHighlightPattern(in, errMsg, &pat)) { - return boost::none; + return {}; } ret.push_back(pat); @@ -871,7 +871,7 @@ HighlightPattern readPatternYaml(const YAML::Node &patterns) { * @param it * @return */ -boost::optional readPatternSetYaml(YAML::const_iterator it) { +std::optional readPatternSetYaml(YAML::const_iterator it) { struct HighlightError { QString message; }; @@ -919,14 +919,14 @@ boost::optional readPatternSetYaml(YAML::const_iterator it) { qWarning("NEdit: %s", qPrintable(ex.message)); } - return boost::none; + return {}; } /* ** Read in a pattern set character string, and advance *inPtr beyond it. ** Returns nullptr and outputs an error to stderr on failure. */ -boost::optional readPatternSet(Input &in) { +std::optional readPatternSet(Input &in) { struct HighlightError { QString message; @@ -954,7 +954,7 @@ boost::optional readPatternSet(Input &in) { /* look for "Default" keyword, and if it's there, return the default pattern set */ if (in.match(QLatin1String("Default"))) { - boost::optional retPatSet = readDefaultPatternSet(patSet.languageMode); + std::optional retPatSet = readDefaultPatternSet(patSet.languageMode); if (!retPatSet) { Raise(tr("No default pattern set")); } @@ -976,7 +976,7 @@ boost::optional readPatternSet(Input &in) { } // read pattern list - boost::optional> patterns = readHighlightPatterns(in, &errMsg); + std::optional> patterns = readHighlightPatterns(in, &errMsg); if (!patterns) { Raise(errMsg); } @@ -993,7 +993,7 @@ boost::optional readPatternSet(Input &in) { tr("highlight pattern"), error.message); - return boost::none; + return {}; } } @@ -1031,7 +1031,7 @@ std::vector readDefaultPatternSets() { for (auto it = patternSets.begin(); it != patternSets.end(); ++it) { // Read each pattern set, abort on error - if (boost::optional patSet = readPatternSetYaml(it)) { + if (std::optional patSet = readPatternSetYaml(it)) { defaultPatterns.push_back(*patSet); } } @@ -1466,7 +1466,7 @@ void LoadHighlightString(const QString &string) { for (auto it = patternSets.begin(); it != patternSets.end(); ++it) { // Read each pattern set, abort on error - boost::optional patSet = readPatternSetYaml(it); + std::optional patSet = readPatternSetYaml(it); if (!patSet) { break; } @@ -1482,7 +1482,7 @@ void LoadHighlightString(const QString &string) { Q_FOREVER { // Read each pattern set, abort on error - boost::optional patSet = readPatternSet(in); + std::optional patSet = readPatternSet(in); if (!patSet) { break; } @@ -1653,7 +1653,7 @@ PatternSet *FindPatternSet(const QString &languageMode) { ** Given a language mode name, determine if there is a default (built-in) ** pattern set available for that language mode, and if so, return it */ -boost::optional readDefaultPatternSet(const QString &langModeName) { +std::optional readDefaultPatternSet(const QString &langModeName) { static const std::vector defaultPatternSets = readDefaultPatternSets(); @@ -1665,7 +1665,7 @@ boost::optional readDefaultPatternSet(const QString &langModeName) { return *it; } - return boost::none; + return {}; } /* diff --git a/src/Highlight.h b/src/Highlight.h index 4ea19e8e..f7558299 100644 --- a/src/Highlight.h +++ b/src/Highlight.h @@ -7,7 +7,7 @@ #include "Util/QtHelper.h" #include "Util/string_view.h" -#include +#include #include #include @@ -64,7 +64,7 @@ QString BgColorOfNamedStyle(const QString &styleName); QString FgColorOfNamedStyle(const QString &styleName); QString WriteHighlightString(); size_t IndexOfNamedStyle(const QString &styleName); -boost::optional readDefaultPatternSet(const QString &langModeName); +std::optional readDefaultPatternSet(const QString &langModeName); TextCursor backwardOneContext(TextBuffer *buf, const ReparseContext &context, TextCursor fromPos); TextCursor forwardOneContext(TextBuffer *buf, const ReparseContext &context, TextCursor fromPos); void RenameHighlightPattern(const QString &oldName, const QString &newName); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 5d4a9640..7b81a7e8 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -74,7 +74,7 @@ QVector PrevOpen; /* ** Extract the line and column number from the text string. */ -boost::optional StringToLineAndCol(const QString &text) { +std::optional StringToLineAndCol(const QString &text) { static const QRegularExpression re(QLatin1String( "^" @@ -109,13 +109,13 @@ boost::optional StringToLineAndCol(const QString &text) { } if (r == -1 && c == -1) { - return boost::none; + return {}; } return Location{r, c}; } - return boost::none; + return {}; } /** @@ -142,7 +142,7 @@ void changeCase(DocumentWidget *document, TextArea *area) { TextBuffer *buf = document->buffer(); // Get the selection. Use character before cursor if no selection - if (boost::optional pos = buf->BufGetSelectionPos()) { + if (std::optional pos = buf->BufGetSelectionPos()) { bool modified = false; std::string text = buf->BufGetSelectionText(); @@ -2602,7 +2602,7 @@ void MainWindow::action_Goto_Line_Number(DocumentWidget *document, const QString [line]:[column] (menu action) line (macro call) line, column (macro call) */ - boost::optional loc = StringToLineAndCol(s); + std::optional loc = StringToLineAndCol(s); if (!loc) { QApplication::beep(); return; @@ -6902,7 +6902,7 @@ void MainWindow::replaceInSelection(DocumentWidget *document, TextArea *area, co TextBuffer *buffer = document->buffer(); // find out where the selection is - boost::optional pos = buffer->BufGetSelectionPos(); + std::optional pos = buffer->BufGetSelectionPos(); if (!pos) { return; } @@ -6929,7 +6929,7 @@ void MainWindow::replaceInSelection(DocumentWidget *document, TextArea *area, co int64_t realOffset = 0; Q_FOREVER { - boost::optional searchResult = Search::SearchString( + std::optional searchResult = Search::SearchString( fileString, searchString, Direction::Forward, @@ -7142,7 +7142,7 @@ bool MainWindow::replaceAll(DocumentWidget *document, TextArea *area, const QStr QString delimiters = document->getWindowDelimiters(); - boost::optional newFileString = Search::ReplaceAllInString( + std::optional newFileString = Search::ReplaceAllInString( fileString, searchString, replaceString, @@ -7278,7 +7278,7 @@ bool MainWindow::searchMatchesSelection(DocumentWidget *document, const QString // search for the string in the selection (we are only interested // in an exact match, but the procedure SearchString does important // stuff like applying the correct matching algorithm) - boost::optional searchResult = Search::SearchString( + std::optional searchResult = Search::SearchString( string, searchString, Direction::Forward, @@ -7469,7 +7469,7 @@ void MainWindow::updateStatus(DocumentWidget *document, TextArea *area) { QString slinecol; const int64_t length = document->buffer()->length(); - if (boost::optional loc = area->positionToLineAndCol(pos)) { + if (std::optional loc = area->positionToLineAndCol(pos)) { slinecol = tr("L: %1 C: %2").arg(loc->line).arg(loc->column); if (showLineNumbers_) { string = tr("%1%2%3 byte %4 of %5").arg(document->path(), document->filename(), format).arg(to_integer(pos)).arg(length); diff --git a/src/Preferences.cpp b/src/Preferences.cpp index 59850048..6e2c5d99 100644 --- a/src/Preferences.cpp +++ b/src/Preferences.cpp @@ -79,7 +79,7 @@ QStringList readExtensionList(Input &in) { return extensionList; } -boost::optional readLanguageModeYaml(const YAML::Node &language) { +std::optional readLanguageModeYaml(const YAML::Node &language) { struct ModeError { QString message; @@ -143,10 +143,10 @@ boost::optional readLanguageModeYaml(const YAML::Node &language) { qWarning("NEdit: %s", qPrintable(ex.message)); } - return boost::none; + return {}; } -boost::optional readLanguageMode(Input &in) { +std::optional readLanguageMode(Input &in) { struct ModeError { QString message; @@ -283,7 +283,7 @@ boost::optional readLanguageMode(Input &in) { error.message); } - return boost::none; + return {}; } void loadLanguageModesString(const QString &string) { @@ -302,7 +302,7 @@ void loadLanguageModesString(const QString &string) { for (YAML::Node language : languages) { - boost::optional lm = readLanguageModeYaml(language); + std::optional lm = readLanguageModeYaml(language); if (!lm) { break; } @@ -315,7 +315,7 @@ void loadLanguageModesString(const QString &string) { Input in(&string); Q_FOREVER { - boost::optional lm = readLanguageMode(in); + std::optional lm = readLanguageMode(in); if (!lm) { break; } diff --git a/src/Rangeset.cpp b/src/Rangeset.cpp index 2d6090d9..15180a18 100644 --- a/src/Rangeset.cpp +++ b/src/Rangeset.cpp @@ -559,9 +559,9 @@ QString Rangeset::name() const { * @brief Rangeset::RangesetSpan * @return */ -boost::optional Rangeset::RangesetSpan() const { +std::optional Rangeset::RangesetSpan() const { if (ranges_.empty()) { - return boost::none; + return {}; } TextRange r; @@ -575,11 +575,11 @@ boost::optional Rangeset::RangesetSpan() const { * @param index * @return */ -boost::optional Rangeset::RangesetFindRangeNo(int index) const { +std::optional Rangeset::RangesetFindRangeNo(int index) const { const auto n = static_cast(index); if (index < 0 || ranges_.size() <= n) { - return boost::none; + return {}; } return ranges_[n]; diff --git a/src/Rangeset.h b/src/Rangeset.h index fb662a09..e3f8a72b 100644 --- a/src/Rangeset.h +++ b/src/Rangeset.h @@ -6,7 +6,7 @@ #include "TextCursor.h" #include "TextRange.h" #include -#include +#include #include // NOTE(eteran): a bit of an artificial limit, but we'll keep it for now @@ -44,8 +44,8 @@ class Rangeset { RangesetInfo RangesetGetInfo() const; public: - boost::optional RangesetFindRangeNo(int index) const; - boost::optional RangesetSpan() const; + std::optional RangesetFindRangeNo(int index) const; + std::optional RangesetSpan() const; public: int64_t RangesetCheckRangeOfPos(TextCursor pos); diff --git a/src/Search.cpp b/src/Search.cpp index 833dad01..e142e591 100644 --- a/src/Search.cpp +++ b/src/Search.cpp @@ -37,7 +37,7 @@ int HistStart = 0; * @param defaultFlags * @return */ -boost::optional forwardRegexSearch(view::string_view string, view::string_view searchString, WrapMode wrap, int64_t beginPos, const char *delimiters, int defaultFlags) { +std::optional forwardRegexSearch(view::string_view string, view::string_view searchString, WrapMode wrap, int64_t beginPos, const char *delimiters, int defaultFlags) { try { Regex compiledRE(searchString, defaultFlags); @@ -55,7 +55,7 @@ boost::optional forwardRegexSearch(view::string_view string, vie // if wrap turned off, we're done if (wrap == WrapMode::NoWrap) { - return boost::none; + return {}; } // search from the beginning of the string to beginPos @@ -69,13 +69,13 @@ boost::optional forwardRegexSearch(view::string_view string, vie return result; } - return boost::none; + return {}; } catch (const RegexError &e) { Q_UNUSED(e) /* Note that this does not process errors from compiling the expression. * It assumes that the expression was checked earlier. */ - return boost::none; + return {}; } } @@ -89,7 +89,7 @@ boost::optional forwardRegexSearch(view::string_view string, vie * @param defaultFlags * @return */ -boost::optional backwardRegexSearch(view::string_view string, view::string_view searchString, WrapMode wrap, int64_t beginPos, const char *delimiters, int defaultFlags) { +std::optional backwardRegexSearch(view::string_view string, view::string_view searchString, WrapMode wrap, int64_t beginPos, const char *delimiters, int defaultFlags) { try { Regex compiledRE(searchString, defaultFlags); @@ -110,7 +110,7 @@ boost::optional backwardRegexSearch(view::string_view string, vi // if wrap turned off, we're done if (wrap == WrapMode::NoWrap) { - return boost::none; + return {}; } // search from the end of the string to beginPos @@ -127,13 +127,13 @@ boost::optional backwardRegexSearch(view::string_view string, vi return result; } - return boost::none; + return {}; } catch (const RegexError &e) { Q_UNUSED(e) /* Note that this does not process errors from compiling the expression. * It assumes that the expression was checked earlier. */ - return boost::none; + return {}; } } @@ -148,7 +148,7 @@ boost::optional backwardRegexSearch(view::string_view string, vi * @param defaultFlags * @return */ -boost::optional searchRegex(view::string_view string, view::string_view searchString, Direction direction, WrapMode wrap, int64_t beginPos, const char *delimiters, int defaultFlags) { +std::optional searchRegex(view::string_view string, view::string_view searchString, Direction direction, WrapMode wrap, int64_t beginPos, const char *delimiters, int defaultFlags) { switch (direction) { case Direction::Forward: @@ -170,10 +170,10 @@ boost::optional searchRegex(view::string_view string, view::stri * @param beginPos * @return */ -boost::optional searchLiteral(view::string_view string, view::string_view searchString, Direction direction, WrapMode wrap, int64_t beginPos, Qt::CaseSensitivity caseSensitivity) { +std::optional searchLiteral(view::string_view string, view::string_view searchString, Direction direction, WrapMode wrap, int64_t beginPos, Qt::CaseSensitivity caseSensitivity) { if (searchString.empty()) { - return boost::none; + return {}; } std::string lcString; @@ -191,7 +191,7 @@ boost::optional searchLiteral(view::string_view string, view::st const auto mid = first + beginPos; const auto last = string.end(); - auto do_search = [&](view::string_view::iterator it) -> boost::optional { + auto do_search = [&](view::string_view::iterator it) -> std::optional { if (*it == ucString[0] || *it == lcString[0]) { // matched first character auto ucPtr = ucString.begin(); @@ -215,30 +215,30 @@ boost::optional searchLiteral(view::string_view string, view::st } } - return boost::none; + return {}; }; if (direction == Direction::Forward) { // search from beginPos to end of string for (auto it = mid; it != last; ++it) { - if (boost::optional result = do_search(it)) { + if (std::optional result = do_search(it)) { return result; } } if (wrap == WrapMode::NoWrap) { - return boost::none; + return {}; } // search from start of file to beginPos for (auto it = first; it != mid; ++it) { - if (boost::optional result = do_search(it)) { + if (std::optional result = do_search(it)) { return result; } } - return boost::none; + return {}; } // Direction::Backward @@ -247,24 +247,24 @@ boost::optional searchLiteral(view::string_view string, view::st if (beginPos >= 0) { for (auto it = mid; it >= first; --it) { - if (boost::optional result = do_search(it)) { + if (std::optional result = do_search(it)) { return result; } } } if (wrap == WrapMode::NoWrap) { - return boost::none; + return {}; } // search from end of file to beginPos for (auto it = last; it >= mid; --it) { - if (boost::optional result = do_search(it)) { + if (std::optional result = do_search(it)) { return result; } } - return boost::none; + return {}; } /* @@ -281,10 +281,10 @@ boost::optional searchLiteral(view::string_view string, view::st ** will suffice in that case. ** */ -boost::optional searchLiteralWord(view::string_view string, view::string_view searchString, Direction direction, WrapMode wrap, int64_t beginPos, const char *delimiters, Qt::CaseSensitivity caseSensitivity) { +std::optional searchLiteralWord(view::string_view string, view::string_view searchString, Direction direction, WrapMode wrap, int64_t beginPos, const char *delimiters, Qt::CaseSensitivity caseSensitivity) { if (searchString.empty()) { - return boost::none; + return {}; } std::string lcString; @@ -296,7 +296,7 @@ boost::optional searchLiteralWord(view::string_view string, view const auto mid = first + beginPos; const auto last = string.end(); - auto do_search_word = [&](const view::string_view::iterator it) -> boost::optional { + auto do_search_word = [&](const view::string_view::iterator it) -> std::optional { if (*it == ucString[0] || *it == lcString[0]) { // matched first character @@ -329,7 +329,7 @@ boost::optional searchLiteralWord(view::string_view string, view } } - return boost::none; + return {}; }; // If there is no language mode, we use the default list of delimiters @@ -358,22 +358,22 @@ boost::optional searchLiteralWord(view::string_view string, view // search from beginPos to end of string for (auto it = mid; it != last; ++it) { - if (boost::optional result = do_search_word(it)) { + if (std::optional result = do_search_word(it)) { return result; } } if (wrap == WrapMode::NoWrap) { - return boost::none; + return {}; } // search from start of file to beginPos for (auto it = first; it != mid; ++it) { - if (boost::optional result = do_search_word(it)) { + if (std::optional result = do_search_word(it)) { return result; } } - return boost::none; + return {}; } // Direction::Backward @@ -381,23 +381,23 @@ boost::optional searchLiteralWord(view::string_view string, view // says begin searching from the far end of the file if (beginPos >= 0) { for (auto it = mid; it >= first; --it) { - if (boost::optional result = do_search_word(it)) { + if (std::optional result = do_search_word(it)) { return result; } } } if (wrap == WrapMode::NoWrap) { - return boost::none; + return {}; } // search from end of file to beginPos for (auto it = last; it >= mid; --it) { - if (boost::optional result = do_search_word(it)) { + if (std::optional result = do_search_word(it)) { return result; } } - return boost::none; + return {}; } /* @@ -406,7 +406,7 @@ boost::optional searchLiteralWord(view::string_view string, view ** for regular expression "<" and ">" characters, or simply passed as nullptr ** for the default delimiter set. */ -boost::optional SearchStringEx(view::string_view string, view::string_view searchString, Direction direction, SearchType searchType, WrapMode wrap, int64_t beginPos, const char *delimiters) { +std::optional SearchStringEx(view::string_view string, view::string_view searchString, Direction direction, SearchType searchType, WrapMode wrap, int64_t beginPos, const char *delimiters) { switch (searchType) { case SearchType::CaseSenseWord: return searchLiteralWord(string, searchString, direction, wrap, beginPos, delimiters, Qt::CaseSensitive); @@ -453,14 +453,14 @@ bool replaceUsingRegex(view::string_view searchStr, view::string_view replaceStr ** first replacement (returned in "copyStart", and the end of the last ** replacement (returned in "copyEnd") */ -boost::optional Search::ReplaceAllInString(view::string_view inString, const QString &searchString, const QString &replaceString, SearchType searchType, int64_t *copyStart, int64_t *copyEnd, const QString &delimiters) { +std::optional Search::ReplaceAllInString(view::string_view inString, const QString &searchString, const QString &replaceString, SearchType searchType, int64_t *copyStart, int64_t *copyEnd, const QString &delimiters) { Result searchResult; int64_t lastEndPos; // reject empty string if (searchString.isNull()) { - return boost::none; + return {}; } /* rehearse the search first to determine the size of the buffer needed @@ -520,7 +520,7 @@ boost::optional Search::ReplaceAllInString(view::string_view inStri } if (nFound == 0) { - return boost::none; + return {}; } const int64_t copyLen = *copyEnd - *copyStart; @@ -594,7 +594,7 @@ boost::optional Search::ReplaceAllInString(view::string_view inStri * @param delimiters * @return */ -boost::optional Search::SearchString(view::string_view string, const QString &searchString, Direction direction, SearchType searchType, WrapMode wrap, int64_t beginPos, const QString &delimiters) { +std::optional Search::SearchString(view::string_view string, const QString &searchString, Direction direction, SearchType searchType, WrapMode wrap, int64_t beginPos, const QString &delimiters) { return SearchStringEx(string, searchString.toStdString(), direction, searchType, wrap, beginPos, delimiters.isNull() ? nullptr : delimiters.toLatin1().data()); } @@ -614,7 +614,7 @@ bool Search::SearchString(view::string_view string, const QString &searchString, assert(result); - if (boost::optional r = SearchString(string, searchString, direction, searchType, wrap, beginPos, delimiters)) { + if (std::optional r = SearchString(string, searchString, direction, searchType, wrap, beginPos, delimiters)) { *result = *r; return true; } diff --git a/src/Search.h b/src/Search.h index 6fbc9c84..e09c1d63 100644 --- a/src/Search.h +++ b/src/Search.h @@ -8,7 +8,7 @@ #include "WrapMode.h" #include -#include +#include class DocumentWidget; class MainWindow; @@ -33,10 +33,10 @@ struct Result { bool isRegexType(SearchType searchType); bool replaceUsingRE(const QString &searchStr, const QString &replaceStr, view::string_view sourceStr, int64_t beginPos, std::string &dest, int prevChar, const QString &delimiters, int defaultFlags); bool SearchString(view::string_view string, const QString &searchString, Direction direction, SearchType searchType, WrapMode wrap, int64_t beginPos, Result *result, const QString &delimiters); -boost::optional SearchString(view::string_view string, const QString &searchString, Direction direction, SearchType searchType, WrapMode wrap, int64_t beginPos, const QString &delimiters); +std::optional SearchString(view::string_view string, const QString &searchString, Direction direction, SearchType searchType, WrapMode wrap, int64_t beginPos, const QString &delimiters); int defaultRegexFlags(SearchType searchType); int historyIndex(int nCycles); -boost::optional ReplaceAllInString(view::string_view inString, const QString &searchString, const QString &replaceString, SearchType searchType, int64_t *copyStart, int64_t *copyEnd, const QString &delimiters); +std::optional ReplaceAllInString(view::string_view inString, const QString &searchString, const QString &replaceString, SearchType searchType, int64_t *copyStart, int64_t *copyEnd, const QString &delimiters); void saveSearchHistory(const QString &searchString, QString replaceString, SearchType searchType, bool isIncremental); HistoryEntry *HistoryByIndex(int index); diff --git a/src/TextArea.cpp b/src/TextArea.cpp index 745b812e..0da9b6d2 100644 --- a/src/TextArea.cpp +++ b/src/TextArea.cpp @@ -728,7 +728,7 @@ void TextArea::beginningOfLine(EventFlags flags) { if (smartHome_) { // if the user presses home, go to the first non-whitespace character // if they are already there, go to the actual beginning of the line - if (boost::optional p = spanForward(buffer_, lineStart, " \t", false)) { + if (std::optional p = spanForward(buffer_, lineStart, " \t", false)) { if (p != insertPos) { lineStart = *p; } @@ -2855,7 +2855,7 @@ void TextArea::redisplayLine(QPainter *painter, int visLineNum, int leftClip, in char *outPtr = buffer; int x = startX; size_t charIndex; - boost::optional cursorX; + std::optional cursorX; for (charIndex = startIndex;; ++charIndex) { @@ -3462,14 +3462,14 @@ void TextArea::updateCalltip(int calltipID) { if (calltip_.anchored) { // Put it at the anchor position - if (!positionToXY(boost::get(calltip_.pos), &rel_x, &rel_y)) { + if (!positionToXY(std::get(calltip_.pos), &rel_x, &rel_y)) { if (calltip_.alignMode == TipAlignMode::Strict) { TextDKillCalltip(calltip_.ID); } return; } } else { - if (boost::get(calltip_.pos) < 0) { + if (std::get(calltip_.pos) < 0) { // First display of tip with cursor offscreen (detected in ShowCalltip) calltip_.pos = viewRect.width() / 2; calltip_.hAlign = TipHAlignMode::Center; @@ -3481,7 +3481,7 @@ void TextArea::updateCalltip(int calltipID) { } return; } - rel_x = boost::get(calltip_.pos); + rel_x = std::get(calltip_.pos); } const int lineHeight = fixedFontHeight_; @@ -4730,7 +4730,7 @@ TextCursor TextArea::startOfWord(TextCursor pos) const { const char ch = buffer_->BufGetCharacter(pos); - boost::optional startPos; + std::optional startPos; if (ch == ' ' || ch == '\t') { startPos = spanBackward(buffer_, pos, view::string_view(" \t", 2), false); @@ -4755,7 +4755,7 @@ TextCursor TextArea::endOfWord(TextCursor pos) const { const char ch = buffer_->BufGetCharacter(pos); - boost::optional endPos; + std::optional endPos; if (ch == ' ' || ch == '\t') { endPos = spanForward(buffer_, pos, view::string_view(" \t", 2), false); @@ -4777,10 +4777,10 @@ TextCursor TextArea::endOfWord(TextCursor pos) const { ** "searchChars", starting with the character BEFORE "startPos". If ** ignoreSpace is set, then Space, Tab, and Newlines are ignored in searchChars. */ -boost::optional TextArea::spanBackward(TextBuffer *buf, TextCursor startPos, view::string_view searchChars, bool ignoreSpace) const { +std::optional TextArea::spanBackward(TextBuffer *buf, TextCursor startPos, view::string_view searchChars, bool ignoreSpace) const { if (startPos == 0) { - return boost::none; + return {}; } TextCursor pos = startPos - 1; @@ -4803,7 +4803,7 @@ boost::optional TextArea::spanBackward(TextBuffer *buf, TextCursor s --pos; } - return boost::none; + return {}; } /* @@ -4811,7 +4811,7 @@ boost::optional TextArea::spanBackward(TextBuffer *buf, TextCursor s ** "searchChars", starting with the character "startPos". If ignoreSpace ** is set, then Space, Tab, and Newlines are ignored in searchChars. */ -boost::optional TextArea::spanForward(TextBuffer *buf, TextCursor startPos, view::string_view searchChars, bool ignoreSpace) const { +std::optional TextArea::spanForward(TextBuffer *buf, TextCursor startPos, view::string_view searchChars, bool ignoreSpace) const { TextCursor pos = startPos; while (pos < buf->length()) { @@ -4831,7 +4831,7 @@ boost::optional TextArea::spanForward(TextBuffer *buf, TextCursor st ++pos; } - return boost::none; + return {}; } void TextArea::processShiftUpAP(EventFlags flags) { @@ -7191,13 +7191,13 @@ TextCursor TextArea::cursorPos() const { ** WORKS FOR DISPLAYED LINES AND, IN CONTINUOUS WRAP MODE, ONLY WHEN THE ** ABSOLUTE LINE NUMBER IS BEING MAINTAINED. Otherwise, it returns false. */ -boost::optional TextArea::positionToLineAndCol(TextCursor pos) const { +std::optional TextArea::positionToLineAndCol(TextCursor pos) const { /* In continuous wrap mode, the absolute (non-wrapped) line count is maintained separately, as needed. Only return it if we're actually keeping track of it and pos is in the displayed text */ if (continuousWrap_) { if (!maintainingAbsTopLineNum() || pos < firstChar_ || pos > lastChar_) { - return boost::none; + return {}; } Location loc; @@ -7209,7 +7209,7 @@ boost::optional TextArea::positionToLineAndCol(TextCursor pos) const { // Only return the data if pos is within the displayed text int visLineNum; if (!posToVisibleLineNum(pos, &visLineNum)) { - return boost::none; + return {}; } Location loc; @@ -7573,7 +7573,7 @@ int TextArea::TextDShowCalltip(const QString &text, bool anchored, CallTipPositi if (anchored) { // Put it at the specified position // If position is not displayed, return 0 - if (boost::get(pos) < firstChar_ || boost::get(pos) > lastChar_) { + if (std::get(pos) < firstChar_ || std::get(pos) > lastChar_) { QApplication::beep(); return 0; } @@ -7685,7 +7685,7 @@ void TextArea::beginningOfSelectionAP(EventFlags flags) { EMIT_EVENT_0("beginning_of_selection"); - const boost::optional pos = buffer_->BufGetSelectionPos(); + const std::optional pos = buffer_->BufGetSelectionPos(); if (!pos) { return; } @@ -7759,7 +7759,7 @@ void TextArea::endOfSelectionAP(EventFlags flags) { EMIT_EVENT_0("end_of_selection"); - const boost::optional pos = buffer_->BufGetSelectionPos(); + const std::optional pos = buffer_->BufGetSelectionPos(); if (!pos) { return; } diff --git a/src/TextArea.h b/src/TextArea.h index 99d64f39..33fb2cb0 100644 --- a/src/TextArea.h +++ b/src/TextArea.h @@ -24,7 +24,7 @@ #include #include -#include +#include class CallTipWidget; class TextArea; @@ -197,7 +197,7 @@ private Q_SLOTS: void secondaryStartAP(QMouseEvent *event, TextArea::EventFlags flags = NoneFlag); public: - boost::optional positionToLineAndCol(TextCursor pos) const; + std::optional positionToLineAndCol(TextCursor pos) const; DocumentWidget *document() const; int fixedFontHeight() const; int fixedFontWidth() const; @@ -287,8 +287,8 @@ private Q_SLOTS: bool visibleLineContainsCursor(int visLine, TextCursor cursor) const; bool wrapLine(TextBuffer *buf, int64_t bufOffset, TextCursor lineStartPos, TextCursor lineEndPos, TextCursor limitPos, TextCursor *breakAt, int64_t *charsAdded); bool wrapUsesCharacter(TextCursor lineEndPos) const; - boost::optional spanBackward(TextBuffer *buf, TextCursor startPos, view::string_view searchChars, bool ignoreSpace) const; - boost::optional spanForward(TextBuffer *buf, TextCursor startPos, view::string_view searchChars, bool ignoreSpace) const; + std::optional spanBackward(TextBuffer *buf, TextCursor startPos, view::string_view searchChars, bool ignoreSpace) const; + std::optional spanForward(TextBuffer *buf, TextCursor startPos, view::string_view searchChars, bool ignoreSpace) const; int offsetWrappedColumn(int row, int column) const; int offsetWrappedRow(int row) const; int64_t preferredColumn(int *visLineNum, TextCursor *lineStartPos); diff --git a/src/TextBuffer.h b/src/TextBuffer.h index 3e8a31a0..279213f8 100644 --- a/src/TextBuffer.h +++ b/src/TextBuffer.h @@ -15,7 +15,7 @@ #include #include -#include +#include struct SelectionPos { TextCursor start; @@ -60,7 +60,7 @@ class BasicTextBuffer : public BasicTextBufferBase, public std::enable_shared_fr friend class BasicTextBuffer; public: - boost::optional getSelectionPos() const; + std::optional getSelectionPos() const; bool getSelectionPos(TextCursor *start, TextCursor *end, bool *isRect, int64_t *rectStart, int64_t *rectEnd) const; bool inSelection(TextCursor pos, TextCursor lineStartPos, int64_t dispIndex) const; bool rangeTouchesRectSel(TextCursor rangeStart, TextCursor rangeEnd) const; @@ -108,13 +108,13 @@ class BasicTextBuffer : public BasicTextBufferBase, public std::enable_shared_fr void BufSetSelectionUpdate(selection_update_callback_type fn); bool BufGetEmptySelectionPos(TextCursor *start, TextCursor *end, bool *isRect, int64_t *rectStart, int64_t *rectEnd) const noexcept; bool BufGetSelectionPos(TextCursor *start, TextCursor *end, bool *isRect, int64_t *rectStart, int64_t *rectEnd) const noexcept; - boost::optional BufGetSelectionPos() const noexcept; + std::optional BufGetSelectionPos() const noexcept; bool BufGetSyncXSelection() const; bool BufGetUseTabs() const noexcept; bool BufIsEmpty() const noexcept; bool BufSetSyncXSelection(bool sync); - boost::optional searchBackward(TextCursor startPos, view_type searchChars) const noexcept; - boost::optional searchForward(TextCursor startPos, view_type searchChars) const noexcept; + std::optional searchBackward(TextCursor startPos, view_type searchChars) const noexcept; + std::optional searchForward(TextCursor startPos, view_type searchChars) const noexcept; Ch BufGetCharacter(TextCursor pos) const noexcept; int64_t BufCountDispChars(TextCursor lineStartPos, TextCursor targetPos) const noexcept; int64_t BufCountLines(TextCursor startPos, TextCursor endPos) const noexcept; @@ -183,8 +183,8 @@ class BasicTextBuffer : public BasicTextBufferBase, public std::enable_shared_fr bool GetSimpleSelection(TextRange *range) const noexcept; private: - boost::optional searchBackward(TextCursor startPos, Ch searchChar) const noexcept; - boost::optional searchForward(TextCursor startPos, Ch searchChar) const noexcept; + std::optional searchBackward(TextCursor startPos, Ch searchChar) const noexcept; + std::optional searchForward(TextCursor startPos, Ch searchChar) const noexcept; int64_t insert(TextCursor pos, view_type text) noexcept; int64_t insert(TextCursor pos, Ch ch) noexcept; string_type getSelectionText(const Selection *sel) const; diff --git a/src/TextBuffer.tcc b/src/TextBuffer.tcc index 330dcdde..7447e428 100644 --- a/src/TextBuffer.tcc +++ b/src/TextBuffer.tcc @@ -572,7 +572,7 @@ void BasicTextBuffer::BufRectSelect(TextCursor start, TextCursor end, in } template -boost::optional BasicTextBuffer::BufGetSelectionPos() const noexcept { +std::optional BasicTextBuffer::BufGetSelectionPos() const noexcept { return primary.getSelectionPos(); } @@ -738,7 +738,7 @@ TextCursor BasicTextBuffer::BufEndOfBuffer() const noexcept { template TextCursor BasicTextBuffer::BufStartOfLine(TextCursor pos) const noexcept { - boost::optional startPos = searchBackward(pos, Ch('\n')); + std::optional startPos = searchBackward(pos, Ch('\n')); if (!startPos) { return {}; } @@ -754,7 +754,7 @@ TextCursor BasicTextBuffer::BufStartOfLine(TextCursor pos) const noexcep template TextCursor BasicTextBuffer::BufEndOfLine(TextCursor pos) const noexcept { - boost::optional endPos = searchForward(pos, Ch('\n')); + std::optional endPos = searchForward(pos, Ch('\n')); if (!endPos) { return BufEndOfBuffer(); } @@ -994,7 +994,7 @@ TextCursor BasicTextBuffer::BufCountBackwardNLines(TextCursor startPos, ** with the character at "startPos", and returning the result */ template -boost::optional BasicTextBuffer::searchForward(TextCursor startPos, view_type searchChars) const noexcept { +std::optional BasicTextBuffer::searchForward(TextCursor startPos, view_type searchChars) const noexcept { TextCursor pos = startPos; TextCursor end = BufEndOfBuffer(); @@ -1012,7 +1012,7 @@ boost::optional BasicTextBuffer::searchForward(TextCursor st ++pos; } - return boost::none; + return {}; } /* @@ -1020,12 +1020,12 @@ boost::optional BasicTextBuffer::searchForward(TextCursor st ** with the character BEFORE at "startPos" */ template -boost::optional BasicTextBuffer::searchBackward(TextCursor startPos, view_type searchChars) const noexcept { +std::optional BasicTextBuffer::searchBackward(TextCursor startPos, view_type searchChars) const noexcept { const TextCursor start = BufStartOfBuffer(); if (startPos == start) { - return boost::none; + return {}; } TextCursor pos = startPos - 1; @@ -1047,7 +1047,7 @@ boost::optional BasicTextBuffer::searchBackward(TextCursor s --pos; } - return boost::none; + return {}; } /* @@ -1108,7 +1108,7 @@ int64_t BasicTextBuffer::insert(TextCursor pos, Ch ch) noexcept { ** count lines quickly, hence searching for a single character: newline) */ template -boost::optional BasicTextBuffer::searchForward(TextCursor startPos, Ch searchChar) const noexcept { +std::optional BasicTextBuffer::searchForward(TextCursor startPos, Ch searchChar) const noexcept { TextCursor pos = startPos; TextCursor end = BufEndOfBuffer(); @@ -1120,7 +1120,7 @@ boost::optional BasicTextBuffer::searchForward(TextCursor st ++pos; } - return boost::none; + return {}; } /* @@ -1131,12 +1131,12 @@ boost::optional BasicTextBuffer::searchForward(TextCursor st ** count lines quickly, hence searching for a single character: newline) */ template -boost::optional BasicTextBuffer::searchBackward(TextCursor startPos, Ch searchChar) const noexcept { +std::optional BasicTextBuffer::searchBackward(TextCursor startPos, Ch searchChar) const noexcept { TextCursor start = BufStartOfBuffer(); if (startPos == start) { - return boost::none; + return {}; } TextCursor pos = startPos - 1; @@ -1146,7 +1146,7 @@ boost::optional BasicTextBuffer::searchBackward(TextCursor s } if (pos == start) { - return boost::none; + return {}; } --pos; @@ -2159,9 +2159,9 @@ bool BasicTextBuffer::Selection::getSelectionPos(TextCursor *start, Text } template -boost::optional BasicTextBuffer::Selection::getSelectionPos() const { +std::optional BasicTextBuffer::Selection::getSelectionPos() const { if (!selected_) { - return boost::none; + return {}; } SelectionPos pos = {}; diff --git a/src/macro.cpp b/src/macro.cpp index ac210054..4814be88 100644 --- a/src/macro.cpp +++ b/src/macro.cpp @@ -24,7 +24,7 @@ #include "interpret.h" #include "parse.h" -#include +#include #include #include @@ -177,7 +177,7 @@ std::string MacroErrorCategory::message(int ev) const { * @param firstFlag * @return The flags if all arguments were valid, otherwise, nothing */ -boost::optional flagsFromArguments(Arguments arguments, size_t firstFlag) { +std::optional flagsFromArguments(Arguments arguments, size_t firstFlag) { TextArea::EventFlags f = TextArea::NoneFlag; for (size_t i = firstFlag; i < arguments.size(); ++i) { @@ -215,7 +215,7 @@ boost::optional flagsFromArguments(Arguments arguments, si } else if (s == "nobell") { f |= TextArea::NoBellFlag; } else { - return boost::none; + return {}; } } @@ -572,13 +572,13 @@ SearchType searchType(Arguments arguments, size_t index) { * @param error * @return */ -boost::optional toggle_or_bool(Arguments arguments, bool previous, std::error_code *error) { +std::optional toggle_or_bool(Arguments arguments, bool previous, std::error_code *error) { switch (arguments.size()) { case 1: { int next; if (std::error_code ec = readArguments(arguments, 0, &next)) { *error = ec; - return boost::none; + return {}; } return next; } @@ -586,7 +586,7 @@ boost::optional toggle_or_bool(Arguments arguments, bool previous, std::er return !previous; default: *error = MacroErrorCode::WrongNumberOfToggleArguments; - return boost::none; + return {}; } } @@ -595,7 +595,7 @@ std::error_code menuToggleEvent(DocumentWidget *document, Arguments arguments, D document = MacroFocusDocument(); std::error_code ec; - if (boost::optional next = toggle_or_bool(arguments, (document->*Get)(), &ec)) { + if (std::optional next = toggle_or_bool(arguments, (document->*Get)(), &ec)) { (document->*Set)(*next); *result = make_value(); return MacroErrorCode::Success; @@ -612,7 +612,7 @@ std::error_code menuToggleEvent(DocumentWidget *document, Arguments arguments, D Q_ASSERT(win); std::error_code ec; - if (boost::optional next = toggle_or_bool(arguments, (win->*Get)(), &ec)) { + if (std::optional next = toggle_or_bool(arguments, (win->*Get)(), &ec)) { (win->*Set)(*next); *result = make_value(); return MacroErrorCode::Success; @@ -624,7 +624,7 @@ std::error_code menuToggleEvent(DocumentWidget *document, Arguments arguments, D template std::error_code textEvent(DocumentWidget *document, Arguments arguments, DataValue *result) { - boost::optional flags = flagsFromArguments(arguments, 0); + std::optional flags = flagsFromArguments(arguments, 0); if (!flags) { return MacroErrorCode::InvalidArgument; } @@ -651,7 +651,7 @@ std::error_code textEventArg(DocumentWidget *document, Arguments arguments, Data return ec; } - boost::optional flags = flagsFromArguments(arguments, 1); + std::optional flags = flagsFromArguments(arguments, 1); if (!flags) { return MacroErrorCode::InvalidArgument; } @@ -2300,7 +2300,7 @@ std::error_code replaceInStringMS(DocumentWidget *document, Arguments arguments, } // Do the replace - boost::optional replacedStr = Search::ReplaceAllInString( + std::optional replacedStr = Search::ReplaceAllInString( string, searchStr, replaceStr, @@ -3270,7 +3270,7 @@ std::error_code lineMV(DocumentWidget *document, Arguments arguments, DataValue TextArea *area = MainWindow::fromDocument(document)->lastFocus(); TextCursor cursorPos = area->cursorPos(); - if (const boost::optional loc = area->positionToLineAndCol(cursorPos)) { + if (const std::optional loc = area->positionToLineAndCol(cursorPos)) { *result = make_value(loc->line); } else { *result = make_value(buf->BufCountLines(buf->BufStartOfBuffer(), cursorPos) + 1); @@ -4177,7 +4177,7 @@ std::error_code rangesetRangeMS(DocumentWidget *document, Arguments arguments, D QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") // NOTE(eteran): GCC 7+ false positive - boost::optional range; + std::optional range; if (Rangeset *rangeset = rangesetTable->RangesetFetch(label)) { if (arguments.size() == 1) { diff --git a/src/userCmds.cpp b/src/userCmds.cpp index 40922e7f..eba79e58 100644 --- a/src/userCmds.cpp +++ b/src/userCmds.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include @@ -269,7 +269,7 @@ QString writeContextMenuYaml(const std::vector &menuItems) { * @param in * @param listType */ -boost::optional readMenuItem(Input &in, CommandTypes listType) { +std::optional readMenuItem(Input &in, CommandTypes listType) { struct ParseError { std::string message; @@ -370,7 +370,7 @@ boost::optional readMenuItem(Input &in, CommandTypes listType) { QString p = copyMacroToEnd(in); if (p.isNull()) { - return boost::none; + return {}; } cmdStr = p; @@ -392,7 +392,7 @@ boost::optional readMenuItem(Input &in, CommandTypes listType) { return menuItem; } catch (const ParseError &error) { qWarning("NEdit: Parse error in user defined menu item, %s", error.message.c_str()); - return boost::none; + return {}; } } @@ -617,7 +617,7 @@ void loadMenuItemString(const QString &inString, std::vector &menuItem return; } - boost::optional f = readMenuItem(in, listType); + std::optional f = readMenuItem(in, listType); if (!f) { break; }