From fd6e0c6899635e8cfbb1c4f859ba4edc29cd3bde Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Wed, 11 Oct 2023 19:25:24 -0700 Subject: [PATCH] Store project style settings in VCS. I'm sick of getting my settings stomped on every god damn time I open CLion. --- .gitignore | 2 +- .idea/.gitignore | 8 ++ .idea/codeStyles/Project.xml | 29 ++++++ .idea/codeStyles/codeStyleConfig.xml | 5 + .idea/kge.iml | 2 + .idea/misc.xml | 9 ++ .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ Buffer.cc | 6 +- Buffer.h | 3 + CMakeLists.txt | 138 ++++++++++++++------------- Cursor.h | 3 +- 12 files changed, 148 insertions(+), 71 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/kge.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 04fa645..d785d51 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ .cmake -.idea .trunk .vc +.vs .vscode *.a diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..5ff5750 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/kge.iml b/.idea/kge.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/.idea/kge.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..595bbce --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..1934a74 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Buffer.cc b/Buffer.cc index 8c0e03a..a9a97b0 100644 --- a/Buffer.cc +++ b/Buffer.cc @@ -44,20 +44,20 @@ anonymousName() Buffer::Buffer() - : name(anonymousName()), path(std::nullopt), file(std::nullopt) + : name(anonymousName()) { } Buffer::Buffer(std::string fName) - : name(std::move(fName)), path(std::nullopt), file(std::nullopt) + : name(std::move(fName)) { } Buffer::Buffer(std::string fName, std::string fPath) -: name(std::move(fName)), path(std::move(fPath)), file(std::nullopt) +: name(std::move(fName)), path(std::move(fPath)) { if (this->path) { this->file = OptFile(File(this->path.value())); diff --git a/Buffer.h b/Buffer.h index 94b5838..4f5f02b 100644 --- a/Buffer.h +++ b/Buffer.h @@ -9,10 +9,12 @@ #define KEPP_FRAME_H +#include #include #include "Defs.h" #include "File.h" +#include "Cursor.h" typedef std::vector> BufferContents; @@ -50,6 +52,7 @@ private: std::string name; OptString path; OptFile file; + Cursor cursor; BufferContents contents; }; diff --git a/CMakeLists.txt b/CMakeLists.txt index 186d839..beffa40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required(VERSION 3.22) project(kge - DESCRIPTION "kyle's editor" - LANGUAGES CXX - VERSION 0.0.1) + DESCRIPTION "kyle's editor" + LANGUAGES CXX + VERSION 0.0.1) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_VERBOSE_MAKEFILES TRUE) @@ -20,98 +20,104 @@ string(TIMESTAMP TODAY "%Y%m%d") set(BUILD_GUI OFF CACHE BOOL "Disable building the graphical version.") if (CMAKE_HOST_UNIX) - message(STATUS "Build system is POSIX.") -endif() + message(STATUS "Build system is POSIX.") +else () + message(STATUS "Build system is NOT POSIX.") +endif () -if(MSVC) - add_compile_options("/W4" "$<$:/O2>") -else() - add_compile_options( - "-Wall" - "-Wextra" - "-Werror" - "-static" - "$<$:-g>" - "$<$:-O2>") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - add_compile_options("-stdlib=libc++") - else() - # nothing special for gcc at the moment - endif() -endif() +if (MSVC) + add_compile_options("/W4" "$<$:/O2>") +else () + add_compile_options( + "-Wall" + "-Wextra" + "-Werror" + "-static" + "$<$:-g>" + "$<$:-O2>") + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_compile_options("-stdlib=libc++") + else () + # nothing special for gcc at the moment + endif () +endif () add_compile_definitions(KGE_PLATFORM=${CMAKE_HOST_SYSTEM_NAME}) add_compile_definitions(KGE_VERSION=${PROJECT_VERSION}) message(STATUS "Build system: ${CMAKE_HOST_SYSTEM_NAME}") -if(${BUILD_GUI}) -include(cmake/imgui.cmake) -endif() +if (${BUILD_GUI}) + include(cmake/imgui.cmake) +endif () ##################### ### BUILD TARGETS ### ##################### set(HEADER_FILES - Defs.h - Buffer.h - File.h - Cursor.h + Defs.h + Buffer.h + File.h + Cursor.h ) set(SOURCE_FILES - Defs.cc - Buffer.cc - File.cc - Cursor.cc + Defs.cc + Buffer.cc + File.cc + Cursor.cc ) add_executable(ke main.cc ${SOURCE_FILES} ${HEADER_FILES}) -add_custom_target(manpages) -configure_file(docs/ke.md ke.1.scdoc @ONLY) -add_custom_command(TARGET manpages COMMAND scdoc < ke.1.scdoc > ke.1 - OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/ke.1) -add_dependencies(ke manpages) +if (CMAKE_HOST_UNIX) + add_custom_target(manpages) + configure_file(docs/ke.md ke.1.scdoc @ONLY) + add_custom_command(TARGET manpages COMMAND scdoc < ke.1.scdoc > ke.1 + OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/ke.1) + add_dependencies(ke manpages) +endif () -if(${BUILD_GUI}) - configure_file(resources/kge.desktop.in kge.desktop @ONLY) - add_executable(kge gmain.cc ${SOURCE_FILES} ${HEADER_FILES}) - target_link_libraries(kge imgui) - add_dependencies(kge ke) +if (${BUILD_GUI}) + configure_file(resources/kge.desktop.in kge.desktop @ONLY) + add_executable(kge gmain.cc ${SOURCE_FILES} ${HEADER_FILES}) + target_link_libraries(kge imgui) + add_dependencies(kge ke) - configure_file(docs/kge.md kge.1.scdoc @ONLY) - add_custom_command(TARGET manpages COMMAND scdoc < kge.1.scdoc > kge.1 - OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/kge.1) + if (CMAKE_HOST_UNIX) + configure_file(docs/kge.md kge.1.scdoc @ONLY) + add_custom_command(TARGET manpages COMMAND scdoc < kge.1.scdoc > kge.1 + OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/kge.1) - add_dependencies(kge manpages) -endif() + add_dependencies(kge manpages) + endif () +endif () ####################### ### INSTALL TARGETS ### ####################### install(TARGETS ke - DESTINATION bin - COMPONENT nox) + DESTINATION bin + COMPONENT nox) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ke.1 - DESTINATION share/man/man1 - COMPONENT nox) + DESTINATION share/man/man1 + COMPONENT nox) -if(${BUILD_GUI}) - install(TARGETS kge - DESTINATION bin - COMPONENT nox - COMPONENT gui) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kge.desktop - DESTINATION share/applications - COMPONENT gui) - install(FILES resources/kge.png - DESTINATION share/${PROJECT_NAME} - COMPONENT gui) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kge.1 - DESTINATION share/man/man1 - COMPONENT gui) -endif() +if (${BUILD_GUI}) + install(TARGETS kge + DESTINATION bin + COMPONENT nox + COMPONENT gui) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kge.desktop + DESTINATION share/applications + COMPONENT gui) + install(FILES resources/kge.png + DESTINATION share/${PROJECT_NAME} + COMPONENT gui) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kge.1 + DESTINATION share/man/man1 + COMPONENT gui) +endif () include(cmake/packaging.cmake) diff --git a/Cursor.h b/Cursor.h index ba6ba25..cb9e00f 100644 --- a/Cursor.h +++ b/Cursor.h @@ -32,7 +32,8 @@ /// Cursors represent a position in a Buffer. class Cursor { public: - Cursor(size_t _x, size_t _y) : x(_x), y(_y) {}; + Cursor() : x(0), y(0) {} + Cursor(size_t _x, size_t _y) : x(_x), y(_y) {} size_t X() const { return this->x; } size_t Y() const { return this->y; }