diff --git a/.gitignore b/.gitignore index df60db3..66abf2f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ *~ build/ -test.* +test* diff --git a/Makefile b/Makefile index ce9affe..5e8a65d 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ SRC:=src/*.cpp INCLUDE:=include/ BUILD:=build -CFLAGS:=-Wall -pedantic -O3 -march=native --std=gnu++20 -LFLAGS:=-ltickit -lfmt +CFLAGS:=-Wall -pedantic -O3 -march=native --std=gnu++20 -fgraphite -flto +LFLAGS:=-O2 -flto -ltickit -lfmt hexview: g++ $(SRC) $(CFLAGS) -I$(INCLUDE) -o $(BUILD)/$@ $(LFLAGS) diff --git a/src/graphics.cpp b/src/graphics.cpp index 4b01cbc..74fd3e8 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -2,18 +2,28 @@ #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>()) { - //TODO: Graphics. - //TODO: Change hex.cpp print_screen to use these graphics instead of stdout with fmt + impl->context = tickit_new_stdtty(); + impl->root = tickit_get_rootwin(impl->context); + + if(!impl->root) throw "couldn't create window."; } Context::~Context() diff --git a/src/hex.cpp b/src/hex.cpp index 6ab8cce..8db205d 100644 --- a/src/hex.cpp +++ b/src/hex.cpp @@ -20,26 +20,28 @@ const static constexpr char ascii_map[255] = { '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', }; +const constexpr int ROW_SZ = 24; + namespace hv { void print_screen(const span memory, unsigned long offset) { fmt::print("0x{:016x} ", offset); - char ascii[17]; - ascii[16] = 0; + char ascii[1 + ROW_SZ]; + ascii[ROW_SZ] = 0; std::size_t i=0; for(;i\n", argv[0]); + return 1; + } + + auto map = map_file(argv[1]); auto memory = map.span(); hv::print_screen(memory, 0);