From b3dd6c608b7303acbf612838b46a525ba9f6b7a1 Mon Sep 17 00:00:00 2001 From: Avril Date: Mon, 7 Sep 2020 20:24:14 +0100 Subject: [PATCH] start varaible size row length --- Makefile | 5 +++-- include/graphics.hpp | 15 --------------- src/graphics.cpp | 33 --------------------------------- src/hex.cpp | 18 +++++++++++++++--- src/main.cpp | 1 - 5 files changed, 18 insertions(+), 54 deletions(-) delete mode 100644 include/graphics.hpp delete mode 100644 src/graphics.cpp diff --git a/Makefile b/Makefile index 5e8a65d..454f174 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,9 @@ SRC:=src/*.cpp INCLUDE:=include/ BUILD:=build -CFLAGS:=-Wall -pedantic -O3 -march=native --std=gnu++20 -fgraphite -flto -LFLAGS:=-O2 -flto -ltickit -lfmt +FEATURES?=-DFIXED_ROW_SIZE=24 +CFLAGS:= $(FEATURES) -Wall -pedantic -O3 -march=native --std=gnu++20 -fgraphite -flto +LFLAGS:=-O3 -flto -lfmt hexview: g++ $(SRC) $(CFLAGS) -I$(INCLUDE) -o $(BUILD)/$@ $(LFLAGS) diff --git a/include/graphics.hpp b/include/graphics.hpp deleted file mode 100644 index 75a0aac..0000000 --- a/include/graphics.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include - -namespace gr -{ - struct Context - { - Context(); - ~Context(); - private: - struct _impl; - std::unique_ptr<_impl> impl; - }; -} diff --git a/src/graphics.cpp b/src/graphics.cpp deleted file mode 100644 index 74fd3e8..0000000 --- a/src/graphics.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include - -#include - -static int on_geomchange(TickitWindow* win, TickitEventFlags flags, void* info, void* data) -{ - tickit_window_expose(win, NULL); - gr::Context* ctx = (gr::Context*)data; - -} - -namespace gr -{ - struct Context::_impl - { - Tickit* context; - TickitWindow* root; - }; - - Context::Context() - : impl(std::make_unique<_impl>()) - { - impl->context = tickit_new_stdtty(); - impl->root = tickit_get_rootwin(impl->context); - - if(!impl->root) throw "couldn't create window."; - } - - Context::~Context() - { - tickit_unref(impl->context); - } -} diff --git a/src/hex.cpp b/src/hex.cpp index 8db205d..a17e84f 100644 --- a/src/hex.cpp +++ b/src/hex.cpp @@ -20,18 +20,30 @@ const static constexpr char ascii_map[255] = { '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', }; -const constexpr int ROW_SZ = 24; +#ifndef FIXED_ROW_SIZE +#include +#endif + +#ifdef FIXED_ROW_SIZE +constexpr int ROW_SZ = FIXED_ROW_SIZE; +#endif namespace hv { void print_screen(const span memory, unsigned long offset) { +#ifndef FIXED_ROW_SIZE +#define S (const char*) + int ROW_SZ = 24; +#else +#define S +#endif fmt::print("0x{:016x} ", offset); char ascii[1 + ROW_SZ]; ascii[ROW_SZ] = 0; std::size_t i=0; for(;i #include #include -#include std::ifstream::pos_type filesize(const char* filename) {