import kepp, clean up build dependencies
This commit is contained in:
parent
0d0d63ede4
commit
a61916206c
|
@ -1,3 +1,4 @@
|
|||
.cmake
|
||||
.idea
|
||||
.trunk
|
||||
.vc
|
||||
|
@ -12,6 +13,5 @@ core
|
|||
core.*
|
||||
cmake-build-*
|
||||
|
||||
bufferTest
|
||||
dictionaryTest
|
||||
tlvTest
|
||||
ke
|
||||
kge
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
///
|
||||
/// \file Buffer.cc
|
||||
/// \author kyle
|
||||
/// \created 10/10/23
|
||||
/// \brief Buffer implementation.
|
||||
///
|
||||
/// \section COPYRIGHT
|
||||
/// Copyright 2023 K. Isom <kyle@imap.cc>
|
||||
///
|
||||
/// Permission to use, copy, modify, and/or distribute this software for
|
||||
/// any purpose with or without fee is hereby granted, provided that the
|
||||
/// above copyright notice and this permission notice appear in all copies.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
/// WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
/// WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
||||
/// BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
/// OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
/// WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
/// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
/// SOFTWARE.
|
||||
///
|
||||
/// @\section DESCRIPTION
|
||||
|
||||
|
||||
#include <optional>
|
||||
#include <random>
|
||||
#include <sstream>
|
||||
|
||||
#include "Buffer.h"
|
||||
|
||||
|
||||
static std::string
|
||||
anonymousName()
|
||||
{
|
||||
std::uniform_int_distribution<> dist(1000, 9999);
|
||||
std::random_device randomDevice;
|
||||
std::mt19937 rng(randomDevice());
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "Buffer<" << dist(rng) << ">";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
||||
Buffer::Buffer()
|
||||
: name(anonymousName()), path(std::nullopt), file(std::nullopt)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Buffer::Buffer(std::string fName)
|
||||
: name(std::move(fName)), path(std::nullopt), file(std::nullopt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
Buffer::Buffer(std::string fName, std::string fPath)
|
||||
: name(std::move(fName)), path(std::move(fPath)), file(std::nullopt)
|
||||
{
|
||||
if (this->path) {
|
||||
this->file = OptFile(File(this->path.value()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int Buffer::Flush(OptString altPath)
|
||||
{
|
||||
return altPath ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
void Buffer::ChangePath(std::string newPath)
|
||||
{
|
||||
this->path = OptString(std::move(newPath));
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
///
|
||||
/// \file Buffer.h
|
||||
/// \author kyle
|
||||
/// \date 2023-10-10
|
||||
/// \brief A buffer is the basic document type.
|
||||
///
|
||||
|
||||
#ifndef KEPP_FRAME_H
|
||||
#define KEPP_FRAME_H
|
||||
|
||||
|
||||
#include "Defs.h"
|
||||
#include "File.h"
|
||||
|
||||
|
||||
typedef std::vector<std::vector<uint8_t>> BufferContents;
|
||||
|
||||
|
||||
/// A Buffer is the atom of text editing. It represents a single document,
|
||||
/// whether a memory-only buffer or a file-backed buffer.
|
||||
///
|
||||
/// \details
|
||||
///
|
||||
/// There are currently two main types of Buffers: file-backed and virtual.
|
||||
/// A virtual buffer describes any buffer that isn't backed by a file.
|
||||
///
|
||||
/// A virtual buffer can be promoted to a file frame, but a file buffer
|
||||
/// cannot be demoted to a virtual buffer.
|
||||
class Buffer {
|
||||
public:
|
||||
/// The constructor with no arguments generates a new anonymous
|
||||
/// buffer.
|
||||
Buffer();
|
||||
|
||||
/// A single constructor generates a virtual buffer.
|
||||
Buffer(std::string fName);
|
||||
|
||||
/// Instantiate a Buffer pointing to fPath.
|
||||
Buffer(std::string fName, std::string fPath);
|
||||
|
||||
std::string Name() const { return this->name; }
|
||||
|
||||
int Flush(OptString altPath);
|
||||
void ChangePath(std::string newPath);
|
||||
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
OptString path;
|
||||
OptFile file;
|
||||
BufferContents contents;
|
||||
};
|
||||
|
||||
|
||||
#endif // KEPP_FRAME_H
|
||||
|
148
CMakeLists.txt
148
CMakeLists.txt
|
@ -1,34 +1,32 @@
|
|||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(kge LANGUAGES CXX VERSION 0.0.1)
|
||||
project(kge
|
||||
DESCRIPTION "kyle's editor"
|
||||
LANGUAGES CXX
|
||||
VERSION 0.0.1)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
string(TIMESTAMP TODAY "%Y%m%d")
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
klib
|
||||
GIT_REPOSITORY https://git.wntrmute.dev/kyle/klib
|
||||
GIT_TAG master
|
||||
FIND_PACKAGE_ARGS NAMES klib
|
||||
)
|
||||
FetchContent_MakeAvailable(klib)
|
||||
####################
|
||||
### BUILD CONFIG ###
|
||||
####################
|
||||
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(klib REQUIRED)
|
||||
find_package(Freetype)
|
||||
if (DEFINED FREETYPE_INCLUDE_DIRS)
|
||||
add_definitions(-DIMGUI_ENABLE_FREETYPE)
|
||||
set(FREETYPE_SOURCES
|
||||
ext/imgui/misc/freetype/imgui_freetype.cpp
|
||||
ext/imgui/misc/freetype/imgui_freetype.h)
|
||||
endif()
|
||||
# in "prod", this will be ON by default; the docstring is written this
|
||||
# way as I am likely to forget to change it later.
|
||||
set(BUILD_GUI OFF CACHE BOOL "Disable building the graphical version.")
|
||||
|
||||
if(MSVC)
|
||||
add_compile_options("/W4" "$<$<CONFIG:RELEASE>:/O2>")
|
||||
else()
|
||||
add_compile_options("-Wall" "-Wextra" "-Werror" "$<$<CONFIG:RELEASE>:-O3>")
|
||||
add_compile_options(
|
||||
"-Wall"
|
||||
"-Wextra"
|
||||
"-Werror"
|
||||
"-static"
|
||||
"$<$<CONFIG:DEBUG>:-g>"
|
||||
"$<$<CONFIG:RELEASE>:-O2>")
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
add_compile_options("-stdlib=libc++")
|
||||
else()
|
||||
|
@ -36,65 +34,71 @@ else()
|
|||
endif()
|
||||
endif()
|
||||
|
||||
add_library(imgui STATIC
|
||||
# Main Imgui files
|
||||
ext/imgui/imgui.cpp
|
||||
ext/imgui/imgui.h
|
||||
ext/imgui/imgui_draw.cpp
|
||||
ext/imgui/imgui_tables.cpp
|
||||
ext/imgui/imgui_widgets.cpp
|
||||
ext/imgui/imgui_demo.cpp
|
||||
if(${BUILD_GUI})
|
||||
include(imgui.cmake)
|
||||
endif()
|
||||
|
||||
ext/imgui/backends/imgui_impl_sdl2.cpp
|
||||
ext/imgui/backends/imgui_impl_sdl2.h
|
||||
ext/imgui/backends/imgui_impl_opengl3.cpp
|
||||
ext/imgui/backends/imgui_impl_opengl3.h
|
||||
#####################
|
||||
### BUILD TARGETS ###
|
||||
#####################
|
||||
|
||||
$<IF:$<TARGET_EXISTS:Freetype::Freetype>,${FREETYPE_SOURCES},>)
|
||||
add_library(imgui::imgui ALIAS imgui)
|
||||
target_link_libraries(imgui
|
||||
PUBLIC
|
||||
OpenGL::GL
|
||||
$<IF:$<TARGET_EXISTS:Freetype::Freetype>,Freetype::Freetype,>
|
||||
$<TARGET_NAME_IF_EXISTS:SDL2::SDL2main>
|
||||
$<IF:$<TARGET_EXISTS:SDL2::SDL2>,SDL2::SDL2,SDL2::SDL2-static>)
|
||||
target_include_directories(imgui PUBLIC
|
||||
ext/imgui/
|
||||
ext/imgui/backends/
|
||||
ext/imgui/misc/freetype
|
||||
$<IF:$<TARGET_EXISTS:Freetype::Freetype>,${FREETYPE_INCLUDE_DIRS},>)
|
||||
|
||||
include_directories(ext/ ${SDL2_INCLUDE_DIRS} ${KLIB_INCLUDE_DIRS})
|
||||
|
||||
configure_file(kge.desktop.in kge.desktop @ONLY)
|
||||
add_executable(kge
|
||||
kge.cc
|
||||
set(HEADER_FILES
|
||||
Defs.h
|
||||
Buffer.h
|
||||
File.h
|
||||
Cursor.h
|
||||
)
|
||||
target_link_libraries(kge imgui ${KLIB_LIBRARIES})
|
||||
set(SOURCE_FILES
|
||||
Defs.cc
|
||||
Buffer.cc
|
||||
File.cc
|
||||
Cursor.cc
|
||||
)
|
||||
|
||||
add_executable(ke main.cc ${SOURCE_FILES} ${HEADER_FILES})
|
||||
|
||||
add_custom_target(manpages)
|
||||
configure_file(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)
|
||||
configure_file(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)
|
||||
|
||||
install(TARGETS kge
|
||||
if(${BUILD_GUI})
|
||||
configure_file(kge.desktop.in kge.desktop @ONLY)
|
||||
add_executable(kge gmain.cc ${SOURCE_FILES} ${HEADER_FILES})
|
||||
target_link_libraries(kge imgui)
|
||||
|
||||
configure_file(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()
|
||||
|
||||
#######################
|
||||
### INSTALL TARGETS ###
|
||||
#######################
|
||||
|
||||
install(TARGETS ke
|
||||
DESTINATION bin
|
||||
COMPONENT dist)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kge.desktop
|
||||
DESTINATION share/applications
|
||||
COMPONENT dist)
|
||||
install(FILES kge.png
|
||||
DESTINATION share/${PROJECT_NAME}
|
||||
COMPONENT dist)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kge.1
|
||||
COMPONENT dist COMPONENT nox)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ke.1
|
||||
DESTINATION share/man/man1
|
||||
COMPONENT dist)
|
||||
COMPONENT dist COMPONENT nox)
|
||||
|
||||
include(CMakePack.txt)
|
||||
if(${BUILD_GUI})
|
||||
install(TARGETS kge
|
||||
DESTINATION bin
|
||||
COMPONENT dist nox)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kge.desktop
|
||||
DESTINATION share/applications
|
||||
COMPONENT dist)
|
||||
install(FILES kge.png
|
||||
DESTINATION share/${PROJECT_NAME}
|
||||
COMPONENT dist)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kge.1
|
||||
DESTINATION share/man/man1
|
||||
COMPONENT dist)
|
||||
endif()
|
||||
|
||||
get_cmake_property(_variableNames VARIABLES)
|
||||
list (SORT _variableNames)
|
||||
foreach (_variableName ${_variableNames})
|
||||
message(STATUS "${_variableName}=${${_variableName}}")
|
||||
endforeach()
|
||||
include(packaging.cmake)
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
///
|
||||
/// \file Cursor.cc
|
||||
/// \author kyle
|
||||
/// \created 10/11/23
|
||||
/// \brief
|
||||
///
|
||||
/// \section COPYRIGHT
|
||||
/// Copyright 2023 K. Isom <kyle@imap.cc>
|
||||
///
|
||||
/// Permission to use, copy, modify, and/or distribute this software for
|
||||
/// any purpose with or without fee is hereby granted, provided that the
|
||||
/// above copyright notice and this permission notice appear in all copies.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
/// WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
/// WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
||||
/// BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
/// OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
/// WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
/// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
/// SOFTWARE.
|
||||
///
|
||||
|
||||
#include "Cursor.h"
|
||||
#include "Defs.h"
|
||||
|
||||
|
||||
/// \todo kyle Can cursors be replaced with std::pair?
|
||||
|
||||
|
||||
static std::pair<size_t, size_t>
|
||||
orderedPair(size_t a, size_t b)
|
||||
{
|
||||
if (a > b) {
|
||||
return {b, a};
|
||||
}
|
||||
|
||||
return {a, b};
|
||||
}
|
||||
|
||||
|
||||
static size_t
|
||||
isqrt(size_t n)
|
||||
{
|
||||
if (n < 2) {
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t start = 0;
|
||||
size_t end = n / 2;
|
||||
size_t result = 0;
|
||||
|
||||
while (start <= end) {
|
||||
auto middle = (start + end) >> 1;
|
||||
result = middle * middle;
|
||||
if (result == n) {
|
||||
return middle;
|
||||
}
|
||||
|
||||
if (result < n) {
|
||||
start = middle + 1;
|
||||
result = middle;
|
||||
} else {
|
||||
end = middle - 1;
|
||||
result = middle;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Cursor Cursor::Update(const Cursor &c)
|
||||
{
|
||||
Cursor prev(this->x, this->y);
|
||||
this->X(c.X());
|
||||
this->Y(c.Y());
|
||||
return prev;
|
||||
}
|
||||
|
||||
|
||||
size_t Cursor::Distance(const Cursor &c) const
|
||||
{
|
||||
auto xPair = orderedPair(this->x, c.X());
|
||||
auto yPair = orderedPair(this->y, c.Y());
|
||||
|
||||
auto x0 = xPair.second - xPair.first;
|
||||
x0 *= x0;
|
||||
|
||||
auto y0 = yPair.second - xPair.first;
|
||||
y0 *= y0;
|
||||
|
||||
auto dist = x0 + y0;
|
||||
return isqrt(dist);
|
||||
}
|
||||
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const Cursor &cursor)
|
||||
{
|
||||
os << cursor.X() << "," << cursor.Y();
|
||||
return os;
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
///
|
||||
/// \file Cursor.h
|
||||
/// \author kyle
|
||||
/// \created 10/11/23
|
||||
/// \brief Cursor describes a position in a Buffer.
|
||||
///
|
||||
/// \section COPYRIGHT
|
||||
/// Copyright 2023 K. Isom <kyle@imap.cc>
|
||||
///
|
||||
/// Permission to use, copy, modify, and/or distribute this software for
|
||||
/// any purpose with or without fee is hereby granted, provided that the
|
||||
/// above copyright notice and this permission notice appear in all copies.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
/// WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
/// WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
||||
/// BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
/// OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
/// WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
/// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
/// SOFTWARE.
|
||||
///
|
||||
|
||||
#ifndef KEPP__CURSOR_H_
|
||||
#define KEPP__CURSOR_H_
|
||||
|
||||
|
||||
#include <cstddef>
|
||||
#include <ostream>
|
||||
|
||||
|
||||
/// Cursors represent a position in a Buffer.
|
||||
class Cursor {
|
||||
public:
|
||||
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; }
|
||||
void X(size_t nx) { this->x = nx; }
|
||||
void Y(size_t ny) { this->y = ny; }
|
||||
|
||||
void Update(size_t nx, size_t ny) { this->X(nx); this->Y(ny); }
|
||||
Cursor Update(const Cursor &c);
|
||||
|
||||
size_t Distance(const Cursor &c) const;
|
||||
|
||||
private:
|
||||
size_t x;
|
||||
size_t y;
|
||||
};
|
||||
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const Cursor &cursor);
|
||||
|
||||
|
||||
#endif // KEPP__CURSOR_H_
|
|
@ -0,0 +1,24 @@
|
|||
///
|
||||
/// \file Defs.cc
|
||||
/// \author kyle
|
||||
/// \created 10/11/23
|
||||
/// \brief
|
||||
///
|
||||
/// \section COPYRIGHT
|
||||
/// Copyright 2023 K. Isom <kyle@imap.cc>
|
||||
///
|
||||
/// Permission to use, copy, modify, and/or distribute this software for
|
||||
/// any purpose with or without fee is hereby granted, provided that the
|
||||
/// above copyright notice and this permission notice appear in all copies.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
/// WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
/// WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
||||
/// BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
/// OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
/// WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
/// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
/// SOFTWARE.
|
||||
///
|
||||
|
||||
#include "Defs.h"
|
|
@ -0,0 +1,42 @@
|
|||
///
|
||||
/// \file Defs.h
|
||||
/// \author kyle
|
||||
/// \created 10/11/23
|
||||
/// \brief
|
||||
///
|
||||
/// \section COPYRIGHT
|
||||
/// Copyright 2023 K. Isom <kyle@imap.cc>
|
||||
///
|
||||
/// Permission to use, copy, modify, and/or distribute this software for
|
||||
/// any purpose with or without fee is hereby granted, provided that the
|
||||
/// above copyright notice and this permission notice appear in all copies.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
/// WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
/// WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
||||
/// BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
/// OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
/// WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
/// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
/// SOFTWARE.
|
||||
///
|
||||
|
||||
#ifndef KEPP__DEFS_H_
|
||||
#define KEPP__DEFS_H_
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
|
||||
typedef std::optional<std::string> OptString;
|
||||
|
||||
template<typename T>
|
||||
T Min(T a, T b) { return a > b ? b : a; }
|
||||
template size_t Min<size_t>(size_t a, size_t b);
|
||||
|
||||
template<typename T>
|
||||
T Max(T a, T b) { return a > b ? a : b; }
|
||||
template size_t Max(size_t a, size_t b);
|
||||
|
||||
|
||||
#endif // KEPP__DEFS_H_
|
|
@ -0,0 +1,43 @@
|
|||
///
|
||||
/// \file File.cc
|
||||
/// \author kyle
|
||||
/// \created 10/11/23
|
||||
/// \brief
|
||||
///
|
||||
/// \section COPYRIGHT
|
||||
/// Copyright 2023 K. Isom <kyle@imap.cc>
|
||||
///
|
||||
/// Permission to use, copy, modify, and/or distribute this software for
|
||||
/// any purpose with or without fee is hereby granted, provided that the
|
||||
/// above copyright notice and this permission notice appear in all copies.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
/// WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
/// WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
||||
/// BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
/// OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
/// WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
/// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
/// SOFTWARE.
|
||||
///
|
||||
|
||||
#include "File.h"
|
||||
|
||||
|
||||
const std::string &File::Path() const
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
void File::SetPath(const std::string &fPath)
|
||||
{
|
||||
File::path = fPath;
|
||||
}
|
||||
|
||||
|
||||
File::File(std::string fPath)
|
||||
: path(fPath), readOnly(false)
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
///
|
||||
/// \file File.h
|
||||
/// \author kyle
|
||||
/// \created 10/11/23
|
||||
/// \brief File contains configuration information for a file.
|
||||
///
|
||||
/// \section COPYRIGHT
|
||||
/// Copyright 2023 K. Isom <kyle@imap.cc>
|
||||
///
|
||||
/// Permission to use, copy, modify, and/or distribute this software for
|
||||
/// any purpose with or without fee is hereby granted, provided that the
|
||||
/// above copyright notice and this permission notice appear in all copies.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
/// WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
/// WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
||||
/// BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
/// OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
/// WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
/// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
/// SOFTWARE.
|
||||
///
|
||||
|
||||
#ifndef KEPP__FILE_H_
|
||||
#define KEPP__FILE_H_
|
||||
|
||||
|
||||
#include <fstream>
|
||||
#include <ios>
|
||||
#include <string>
|
||||
|
||||
#include "Defs.h"
|
||||
|
||||
|
||||
static constexpr std::ios::openmode DefaultMode =
|
||||
std::ios::in|std::ios::out;
|
||||
|
||||
|
||||
/// A File abstracts a concrete file on disk.
|
||||
class File {
|
||||
public:
|
||||
File(std::string fPath);
|
||||
|
||||
const std::string &Path() const;
|
||||
void SetPath(const std::string &fPath);
|
||||
|
||||
// int Refresh(std::);
|
||||
|
||||
|
||||
[[nodiscard]] bool IsReadOnly() const { return this->readOnly; };
|
||||
void MarkReadOnly() { this->readOnly = true; }
|
||||
void ClearReadOnly() { this->readOnly = false; }
|
||||
|
||||
private:
|
||||
std::string path;
|
||||
bool readOnly;
|
||||
std::ios::openmode mode;
|
||||
};
|
||||
|
||||
|
||||
typedef std::optional<File> OptFile;
|
||||
|
||||
#endif // KEPP__FILE_H_
|
11
Makefile
11
Makefile
|
@ -2,7 +2,14 @@
|
|||
all:
|
||||
mkdir -p build && cd build && cmake .. && make
|
||||
|
||||
.PHONY: deps
|
||||
PHONY: deps
|
||||
deps:
|
||||
sudo apt-get install libfreetype-dev libsdl2-dev libopengl-dev
|
||||
sudo apt-get install doxygen scdoc
|
||||
|
||||
.PHONY: gui-deps
|
||||
gui-deps:
|
||||
sudo apt-get install libfreetype-dev libsdl2-dev libopengl-dev libglfw3-dev
|
||||
|
||||
.PHONY:
|
||||
clean:
|
||||
rm -r build cmake-build-*
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
find_package(SDL2 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(Freetype)
|
||||
if (DEFINED FREETYPE_INCLUDE_DIRS)
|
||||
add_definitions(-DIMGUI_ENABLE_FREETYPE)
|
||||
set(FREETYPE_SOURCES
|
||||
ext/imgui/misc/freetype/imgui_freetype.cpp
|
||||
ext/imgui/misc/freetype/imgui_freetype.h)
|
||||
endif()
|
||||
|
||||
add_library(imgui STATIC
|
||||
# Main Imgui files
|
||||
ext/imgui/imgui.cpp
|
||||
ext/imgui/imgui.h
|
||||
ext/imgui/imgui_draw.cpp
|
||||
ext/imgui/imgui_tables.cpp
|
||||
ext/imgui/imgui_widgets.cpp
|
||||
ext/imgui/imgui_demo.cpp
|
||||
|
||||
ext/imgui/backends/imgui_impl_sdl2.cpp
|
||||
ext/imgui/backends/imgui_impl_sdl2.h
|
||||
ext/imgui/backends/imgui_impl_opengl3.cpp
|
||||
ext/imgui/backends/imgui_impl_opengl3.h
|
||||
|
||||
$<IF:$<TARGET_EXISTS:Freetype::Freetype>,${FREETYPE_SOURCES},>)
|
||||
add_library(imgui::imgui ALIAS imgui)
|
||||
target_link_libraries(imgui
|
||||
PUBLIC
|
||||
OpenGL::GL
|
||||
$<IF:$<TARGET_EXISTS:Freetype::Freetype>,Freetype::Freetype,>
|
||||
$<TARGET_NAME_IF_EXISTS:SDL2::SDL2main>
|
||||
$<IF:$<TARGET_EXISTS:SDL2::SDL2>,SDL2::SDL2,SDL2::SDL2-static>)
|
||||
target_include_directories(imgui PUBLIC
|
||||
ext/imgui/
|
||||
ext/imgui/backends/
|
||||
ext/imgui/misc/freetype
|
||||
$<IF:$<TARGET_EXISTS:Freetype::Freetype>,${FREETYPE_INCLUDE_DIRS},>)
|
||||
|
||||
include_directories(ext/ ${SDL2_INCLUDE_DIRS})
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eu
|
||||
|
||||
|
||||
source /etc/lsb-release
|
||||
|
||||
preinstall () {
|
||||
echo "[+] preparing to install"
|
||||
sudo apt-get update
|
||||
sudo apt-get install ca-certificates gpg wget
|
||||
}
|
||||
|
||||
do_install () {
|
||||
if [ ! -f /etc/apt/sources.list.d/kitware.list ]
|
||||
then
|
||||
echo "[+] fetching initial keyring"
|
||||
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
|
||||
|
||||
echo "[+] adding repo to sources.list.d"
|
||||
echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ ${DISTRIB_RELEASE} main" | \
|
||||
sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null
|
||||
sudo apt-get update
|
||||
|
||||
echo "[+] installing kitware keyring"
|
||||
if [ -f "/usr/share/keyrings/kitware-archive-keyring.gpg" ]
|
||||
then
|
||||
sudo rm /usr/share/keyrings/kitware-archive-keyring.gpg
|
||||
fi
|
||||
sudo apt-get install kitware-archive-keyring
|
||||
fi
|
||||
|
||||
if [ "${USE_CMAKE_RC}" = "YES" ]
|
||||
then
|
||||
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ ${DISTRIB_RELEASE}-rc main' | \
|
||||
sudo tee -a /etc/apt/sources.list.d/kitware.list >/dev/null
|
||||
sudo apt-get update
|
||||
fi
|
||||
}
|
||||
|
||||
sudo apt-get install cmake cmake-curses-gui cmake-extras
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eu
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
ke(1) ["@TODAY@" ["Shimmering Clarity Industries"]]
|
||||
|
||||
# NAME
|
||||
|
||||
ke - kyle's editor
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
ke files...
|
||||
|
||||
# AUTHORS
|
||||
|
||||
Written by Kyle Isom <kyle@imap.cc>. Up-to-date sources can be found
|
||||
at https://git.wntrmute.dev/kyle/kge.
|
|
@ -0,0 +1,63 @@
|
|||
///
|
||||
/// \file main.cc
|
||||
/// \author kyle
|
||||
/// \date 2023-10-10
|
||||
/// \brief kyle's editor
|
||||
///
|
||||
/// \section COPYRIGHT
|
||||
/// Copyright 2023 K. Isom <kyle@imap.cc>
|
||||
///
|
||||
/// Permission to use, copy, modify, and/or distribute this software for
|
||||
/// any purpose with or without fee is hereby granted, provided that the
|
||||
/// above copyright notice and this permission notice appear in all copies.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
/// WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
/// WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
||||
/// BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
/// OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
/// WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
/// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
/// SOFTWARE.
|
||||
///
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "Cursor.h"
|
||||
|
||||
|
||||
static void
|
||||
usage(std::ostream &os, int exitCode)
|
||||
{
|
||||
os << "ke - kyle's editor ++\n";
|
||||
os << "\nUsage:\n";
|
||||
os << "\tke [files]\n";
|
||||
exit(exitCode);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowDist(Cursor a, Cursor b)
|
||||
{
|
||||
std::cout << a << " -> " << b << ": " << a.Distance(b) << "\n";
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
if ((argc == 2) && (std::string(argv[1]) == "-h")) {
|
||||
usage(std::cout, 0);
|
||||
}
|
||||
|
||||
Buffer frame;
|
||||
std::cout << frame.Name() << "\n";
|
||||
|
||||
ShowDist(Cursor(0, 0), Cursor(5, 5));
|
||||
ShowDist(Cursor(2, 2), Cursor(4, 4));
|
||||
ShowDist(Cursor(32, 12), Cursor(14, 71));
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -2,22 +2,23 @@
|
|||
include(InstallRequiredSystemLibraries)
|
||||
|
||||
set(CPACK_PACKAGE_VENDOR "Shimmering Clarity")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Kyle's Graphical Editor")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "kyle's editor")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
||||
|
||||
# Debian settings
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "K. Isom")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Kyle's Graphical Editor")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "kyle's editor")
|
||||
set(CPACK_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
|
||||
if(${BUILD_GUI})
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS
|
||||
# "libc++12 (>= 3.7.0-1)"
|
||||
"libsdl2-2.0-0, libfreetype6 (>= 2.11.1)"
|
||||
)
|
||||
endif()
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION universe/editors)
|
||||
set(CPACK_DEB_COMPONENT_INSTALL ON)
|
||||
set(CPACK_COMPONENTS_ALL dist)
|
||||
set(CPACK_COMPONENTS_ALL dist nox)
|
||||
set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP)
|
||||
|
||||
if(LINUX)
|
Loading…
Reference in New Issue