Start Frame class.

This commit is contained in:
Kyle Isom 2023-10-14 23:28:43 -07:00
parent 8edcba0f88
commit a00d358b15
8 changed files with 233 additions and 30 deletions

View File

@ -66,11 +66,14 @@ Buffer::Buffer(std::filesystem::path fPath)
this->name = fPath.filename().string(); this->name = fPath.filename().string();
this->cursor = Cursor(); this->cursor = Cursor();
this->file = OptFile(fPath.string()); this->file = OptFile(fPath.string());
if (this->Exists()) { // N.B. I am leaving this in to show that I thought about it, but
/// \todo Should I signal an error here, or is it // it's the wrong choice. A Frame should call Refresh on a buffer
/// okay for this to be a best-effort thing? // when it's ready to load it.
this->status = this->Refresh(); // if (this->Exists()) {
} // /// \todo Should I signal an error here, or is it
// /// okay for this to be a best-effort thing?
// this->status = this->Refresh();
// }
} }

View File

@ -59,12 +59,14 @@ set(HEADER_FILES
Buffer.h Buffer.h
File.h File.h
Cursor.h Cursor.h
Frame.h
) )
set(SOURCE_FILES set(SOURCE_FILES
Defs.cc Defs.cc
Buffer.cc Buffer.cc
File.cc File.cc
Cursor.cc Cursor.cc
Frame.cc
) )
add_executable(ke main.cc ${SOURCE_FILES} ${HEADER_FILES}) add_executable(ke main.cc ${SOURCE_FILES} ${HEADER_FILES})

64
Frame.cc Normal file
View File

@ -0,0 +1,64 @@
//
// Created by kyle on 10/14/23.
//
#include "Frame.h"
void
Frame::Add()
{
auto buffer = new Buffer;
this->bmap[buffer->Name()] = buffer;
if (this->bmap.size() == 1) {
this->activeBuffer = buffer->Name();
}
}
void
Frame::Add(std::string name)
{
auto buffer = new Buffer(name);
// TODO: find the small buffer name that doesn't conflict with
// any other buffers. Idea: deconflict private method?
this->bmap[buffer->Name()] = buffer;
if (this->bmap.size() == 1) {
this->activeBuffer = buffer->Name();
}
}
void
Frame::Add(std::filesystem::path path)
{
auto buffer = new Buffer(path);
// TODO: find the small buffer name that doesn't conflict with
// any other buffers. Idea: deconflict private method?
this->bmap[buffer->Name()] = buffer;
if (this->bmap.size() == 1) {
this->activeBuffer = buffer->Name();
}
}
Buffer::FileStatus
Frame::Refresh()
{
return this->bmap[this->activeBuffer]->Refresh();
}
Buffer::FileStatus
Frame::Flush()
{
return this->bmap[this->activeBuffer]->Flush();
}

37
Frame.h Normal file
View File

@ -0,0 +1,37 @@
//
// Created by kyle on 10/14/23.
//
#ifndef KGE_FRAME_H
#define KGE_FRAME_H
#include <filesystem>
#include <string>
#include <vector>
#include <map>
#include "Buffer.h"
class Frame {
public:
Frame();
void Add();
void Add(std::string name);
void Add(std::filesystem::path path);
/// Refresh will attempt to load the active buffer.
Buffer::FileStatus Refresh();
/// Flush will attempt to write the active buffer.
bool Flush();
private:
std::map<std::string, Buffer *> bmap;
std::string activeBuffer;
};
#endif //KGE_FRAME_H

0
ext/imgui/backends/vulkan/generate_spv.sh Executable file → Normal file
View File

0
fonts/gen_font_includes.py Executable file → Normal file
View File

50
scripts/install-cmake-debian.sh Normal file → Executable file
View File

@ -6,36 +6,36 @@ set -eu
source /etc/lsb-release source /etc/lsb-release
preinstall () { preinstall () {
echo "[+] preparing to install" echo "[+] preparing to install"
sudo apt-get update sudo apt-get update
sudo apt-get install ca-certificates gpg wget sudo apt-get install ca-certificates gpg wget
} }
do_install () { do_install () {
if [ ! -f /etc/apt/sources.list.d/kitware.list ] if [ ! -f /etc/apt/sources.list.d/kitware.list ]
then then
echo "[+] fetching initial keyring" 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 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 "[+] 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" | \ 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 tee /etc/apt/sources.list.d/kitware.list >/dev/null
sudo apt-get update sudo apt-get update
echo "[+] installing kitware keyring" echo "[+] installing kitware keyring"
if [ -f "/usr/share/keyrings/kitware-archive-keyring.gpg" ] if [ -f "/usr/share/keyrings/kitware-archive-keyring.gpg" ]
then then
sudo rm /usr/share/keyrings/kitware-archive-keyring.gpg sudo rm /usr/share/keyrings/kitware-archive-keyring.gpg
fi fi
sudo apt-get install kitware-archive-keyring sudo apt-get install kitware-archive-keyring
fi fi
if [ "${USE_CMAKE_RC}" = "YES" ] if [ "${USE_CMAKE_RC}" = "YES" ]
then then
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ ${DISTRIB_RELEASE}-rc main' | \ 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 tee -a /etc/apt/sources.list.d/kitware.list >/dev/null
sudo apt-get update sudo apt-get update
fi fi
} }
sudo apt-get install cmake cmake-curses-gui cmake-extras do_install

97
scripts/install-depdendencies.sh Normal file → Executable file
View File

@ -1,4 +1,101 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#####################################################################
# This script attempts to install the appopriate build dependencies #
# for the host system. #
# #
# For platforms marked as unverified, it means that I was able to #
# start a Docker container for that platform and could look up the #
# right package names. I haven't actually tried building on these #
# platforms. #
# #
# This is primarily developed on the latest Ubuntu LTS release and #
# MacOS; other platforms are best-effort. #
#####################################################################
set -eu set -eu
install_debianesque () {
echo "[+] distribution is ${DISTRIB_ID}, choosing Debianesque install."
echo "[+] installing tools"
sudo apt-get install git cmake clang scdoc
echo "[+] installing libraries and development headers"
sudo apt-get install libsdl2-dev libfreetype-dev
}
install_redhat () {
echo "[+] distribution is ${DISTRIB_ID}, choosing Redhat install."
echo "[!] WARNING: installation for Redhat systems is unverified."
echo "[+] installing tools"
sudo dnf install git cmake clang scdoc
echo "[+] installing libraries and development headers"
sudo dnf install SDL2-devel freetype-devel
}
install_alpine () {
echo "[+] distribution is ${DISTRIB_ID}, choosing Alpine install."
echo "[!] WARNING: installation for Alpine systems is unverified."
echo "[+] installing tools"
sudo dnf install git cmake clang scdoc
echo "[+] installing libraries and development headers"
sudo dnf install sdl2-dev freetype-dev
}
install_macos () {
# TODO: consider supporting macports?
echo "[+] host system is MacOS"
echo "[+] installing tools"
brew install git cmake scdoc
echo "[+] installing libraries and development headers"
# TODO: look up proper package names in homebrew
}
install_linux () {
echo "[+] host system is Linux"
[[ -f "/etc/lsb-release" ]] && source /etc/lsb-release
if [ -z "${DISTRIB_ID}" ]
then
if [ -d /etc/apt ]
then
DISTRIB_ID="apt-based"
elif [ -f /etc/alpine-release ]
DISTRIB_ID=Alpine
elif [ -d /etc/dnf -o /etc/yum.repos.d ]
# I don't use Fedora, this is based on a cursory
# glance at the filesystem on a Docker image.
DISTRIB_ID="Fedora"
fi
fi
case ${DISTRIB_ID} in
Ubuntu) install_debianesque ;;
Debian) install_debianesque ;;
apt-based) install_debianesque ;;
Fedora) install_redhat ;;
Alpine) install_alpine ;;
*)
echo "[!] distribution ${DISTRIB_ID} isn't supported in this script." > /dev/null
;;
esac
}
case "$(uname -s)" in
Linux) install_linux ;;
Darwin) install_macos ;;
*)
echo "[!] platform $(uname -s) isn't supported in this script." > /dev/null
;;
esac