Start Frame class.
This commit is contained in:
parent
8edcba0f88
commit
a00d358b15
13
Buffer.cc
13
Buffer.cc
|
@ -66,11 +66,14 @@ Buffer::Buffer(std::filesystem::path fPath)
|
|||
this->name = fPath.filename().string();
|
||||
this->cursor = Cursor();
|
||||
this->file = OptFile(fPath.string());
|
||||
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();
|
||||
}
|
||||
// N.B. I am leaving this in to show that I thought about it, but
|
||||
// it's the wrong choice. A Frame should call Refresh on a buffer
|
||||
// when it's ready to load it.
|
||||
// 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();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -59,12 +59,14 @@ set(HEADER_FILES
|
|||
Buffer.h
|
||||
File.h
|
||||
Cursor.h
|
||||
Frame.h
|
||||
)
|
||||
set(SOURCE_FILES
|
||||
Defs.cc
|
||||
Buffer.cc
|
||||
File.cc
|
||||
Cursor.cc
|
||||
Frame.cc
|
||||
)
|
||||
|
||||
add_executable(ke main.cc ${SOURCE_FILES} ${HEADER_FILES})
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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
|
|
@ -38,4 +38,4 @@ then
|
|||
fi
|
||||
}
|
||||
|
||||
sudo apt-get install cmake cmake-curses-gui cmake-extras
|
||||
do_install
|
||||
|
|
|
@ -1,4 +1,101 @@
|
|||
#!/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
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue