diff --git a/fuzzing/fuzztest.cpp b/fuzzing/fuzztest.cpp index 70ca41e..4b79467 100644 --- a/fuzzing/fuzztest.cpp +++ b/fuzzing/fuzztest.cpp @@ -6,9 +6,9 @@ extern "C" int LLVMFuzzerTestOneInput( std::uint8_t const* const bytes, std::size_t const size) { - gd100::decoder decoder; - gd100::terminal term{{132, 80}}; - gd100::terminal_instructee instructee{&term}; + katerm::decoder decoder; + katerm::terminal term{{132, 80}}; + katerm::terminal_instructee instructee{&term}; decoder.decode( reinterpret_cast(bytes), size, diff --git a/include/katerm/bit_container.hpp b/include/katerm/bit_container.hpp index 081d5ed..948b19c 100644 --- a/include/katerm/bit_container.hpp +++ b/include/katerm/bit_container.hpp @@ -3,7 +3,7 @@ #include -namespace gd100 { +namespace katerm { template class bit_container @@ -44,6 +44,6 @@ class bit_container } }; -} // gd100:: +} // katerm:: #endif // header guard diff --git a/include/katerm/colours.hpp b/include/katerm/colours.hpp index 0d1fcaf..77777e8 100644 --- a/include/katerm/colours.hpp +++ b/include/katerm/colours.hpp @@ -3,7 +3,7 @@ #include "glyph.hpp" -namespace gd100 { +namespace katerm { constexpr colour sgr_colours[16]{ {30, 30, 30}, // black @@ -53,6 +53,6 @@ constexpr colour eight_bit_lookup(int index) return {0, 0, 0}; } -} // gd100:: +} // katerm:: #endif // header guard diff --git a/include/katerm/glyph.hpp b/include/katerm/glyph.hpp index d0590b5..2cbbff7 100644 --- a/include/katerm/glyph.hpp +++ b/include/katerm/glyph.hpp @@ -6,7 +6,7 @@ #include "bit_container.hpp" #include "position.hpp" -namespace gd100 { +namespace katerm { enum class glyph_attr_bit { text_wraps = 1 << 0, @@ -55,6 +55,6 @@ struct glyph { code_point code; }; -} // gd100:: +} // katerm:: #endif // header guard diff --git a/include/katerm/position.hpp b/include/katerm/position.hpp index 485565b..abf58bf 100644 --- a/include/katerm/position.hpp +++ b/include/katerm/position.hpp @@ -3,7 +3,7 @@ #include -namespace gd100 { +namespace katerm { struct position { int x; @@ -22,6 +22,6 @@ struct position { std::ostream& operator<<(std::ostream&, position); -} // gd100:: +} // katerm:: #endif // header guard diff --git a/include/katerm/program.hpp b/include/katerm/program.hpp index 61faa02..79c23eb 100644 --- a/include/katerm/program.hpp +++ b/include/katerm/program.hpp @@ -3,7 +3,7 @@ #include -namespace gd100 { +namespace katerm { class program { public: @@ -11,6 +11,6 @@ class program { virtual ~program() = default; }; -} // gd100:: +} // katerm:: #endif // header guard diff --git a/include/katerm/program_terminal_manager.hpp b/include/katerm/program_terminal_manager.hpp index c843305..a8a3c93 100644 --- a/include/katerm/program_terminal_manager.hpp +++ b/include/katerm/program_terminal_manager.hpp @@ -9,7 +9,7 @@ #include "program.hpp" -namespace gd100 { +namespace katerm { class program_terminal_manager { public: @@ -39,6 +39,6 @@ class program_terminal_manager { std::unique_ptr read_buffer; }; -} // gd100:: +} // katerm:: #endif // header guard diff --git a/include/katerm/terminal.hpp b/include/katerm/terminal.hpp index d752366..5391d63 100644 --- a/include/katerm/terminal.hpp +++ b/include/katerm/terminal.hpp @@ -8,7 +8,7 @@ #include "terminal_data.hpp" #include "terminal_decoder.hpp" -namespace gd100 { +namespace katerm { class terminal { friend struct terminal_instructee; @@ -102,6 +102,6 @@ struct terminal_instructee : decoder_instructee { }; -} // gd100:: +} // katerm:: #endif // header guard diff --git a/include/katerm/terminal_data.hpp b/include/katerm/terminal_data.hpp index 6d363ca..0748ebb 100644 --- a/include/katerm/terminal_data.hpp +++ b/include/katerm/terminal_data.hpp @@ -1,7 +1,7 @@ #ifndef GDTERM_TERMINAL_DATA_HPP #define GDTERM_TERMINAL_DATA_HPP -namespace gd100 { +namespace katerm { enum cursor_state_bit { wrap_next = 1 << 0, @@ -42,6 +42,6 @@ enum class charset { graphic0, }; -} // gd100:: +} // katerm:: #endif // header guard diff --git a/include/katerm/terminal_decoder.hpp b/include/katerm/terminal_decoder.hpp index b1be22a..4207d30 100644 --- a/include/katerm/terminal_decoder.hpp +++ b/include/katerm/terminal_decoder.hpp @@ -7,7 +7,7 @@ #include "position.hpp" #include "terminal_data.hpp" -namespace gd100 { +namespace katerm { enum class direction { up, down, forward, back @@ -59,6 +59,6 @@ class decoder { void decode(char const* bytes, int count, decoder_instructee& t); }; -} // gd100:: +} // katerm:: #endif // header guard diff --git a/include/katerm/terminal_screen.hpp b/include/katerm/terminal_screen.hpp index 1d4fc0f..f3bbd10 100644 --- a/include/katerm/terminal_screen.hpp +++ b/include/katerm/terminal_screen.hpp @@ -6,7 +6,7 @@ #include "glyph.hpp" -namespace gd100 { +namespace katerm { struct line { glyph* glyphs; @@ -48,6 +48,6 @@ class terminal_screen { void set_scroll(int scroll); }; -} // gd100:: +} // katerm:: #endif // header guard diff --git a/src/position.cpp b/src/position.cpp index b36a664..a615e33 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -2,11 +2,11 @@ #include -namespace gd100 { +namespace katerm { std::ostream& operator<<(std::ostream& os, position const p) { return os << '(' << p.x << "; " << p.y << ')'; } -} // gd100:: +} // katerm:: diff --git a/src/terminal.cpp b/src/terminal.cpp index 66eec4b..1c71b76 100644 --- a/src/terminal.cpp +++ b/src/terminal.cpp @@ -5,7 +5,7 @@ #include #include -namespace gd100 { +namespace katerm { static_assert(std::is_copy_assignable_v); @@ -306,4 +306,4 @@ void terminal::reset_style() cursor.style = default_style; } -} // gd100:: +} // katerm:: diff --git a/src/terminal_decoder.cpp b/src/terminal_decoder.cpp index 018e84d..8e07725 100644 --- a/src/terminal_decoder.cpp +++ b/src/terminal_decoder.cpp @@ -5,7 +5,7 @@ #include #include -namespace gd100 { +namespace katerm { namespace { @@ -675,4 +675,4 @@ void decoder::decode( }; -} // gd100:: +} // katerm:: diff --git a/src/terminal_instructee.cpp b/src/terminal_instructee.cpp index beafcaf..41859a7 100644 --- a/src/terminal_instructee.cpp +++ b/src/terminal_instructee.cpp @@ -1,7 +1,7 @@ #include #include -namespace gd100 { +namespace katerm { void terminal_instructee::tab() { @@ -239,4 +239,4 @@ void terminal_instructee::set_bracketed_paste(bool set) term->mode.unset(terminal_mode_bit::bracketed_paste); } -} // gd100:: +} // katerm:: diff --git a/src/terminal_screen.cpp b/src/terminal_screen.cpp index 3130bf9..4b3447c 100644 --- a/src/terminal_screen.cpp +++ b/src/terminal_screen.cpp @@ -3,7 +3,7 @@ #include -namespace gd100 { +namespace katerm { static_assert(std::is_copy_assignable_v); @@ -82,4 +82,4 @@ void terminal_screen::set_scroll(int const scroll) m_scroll = height + bounded; } -} // gd100:: +} // katerm:: diff --git a/tests/decoding.cpp b/tests/decoding.cpp index d1917e8..34782c1 100644 --- a/tests/decoding.cpp +++ b/tests/decoding.cpp @@ -5,9 +5,9 @@ TEST_CASE("utf-8", "[utf-8]") { auto decode_utf8 = [](auto const& utf8) { - auto t = gd100::terminal{{10, 10}}; - auto d = gd100::decoder{}; - auto instructee = gd100::terminal_instructee{&t}; + auto t = katerm::terminal{{10, 10}}; + auto d = katerm::decoder{}; + auto instructee = katerm::terminal_instructee{&t}; d.decode(utf8, sizeof(utf8) - 1, instructee); diff --git a/tests/regressions.cpp b/tests/regressions.cpp index 3ac401d..3573de0 100644 --- a/tests/regressions.cpp +++ b/tests/regressions.cpp @@ -8,9 +8,9 @@ template void run(unsigned char (&crash_case)[N]) { - gd100::decoder decoder; - gd100::terminal term{{132, 80}}; - gd100::terminal_instructee instructee{&term}; + katerm::decoder decoder; + katerm::terminal term{{132, 80}}; + katerm::terminal_instructee instructee{&term}; decoder.decode( reinterpret_cast(crash_case), N, instructee); diff --git a/tests/terminal.cpp b/tests/terminal.cpp index 228fbcd..6257998 100644 --- a/tests/terminal.cpp +++ b/tests/terminal.cpp @@ -7,29 +7,29 @@ #include struct test_data { - gd100::terminal t; - gd100::decoder d; + katerm::terminal t; + katerm::decoder d; void process_bytes(char const* const ptr, std::size_t const count) { - auto instructee = gd100::terminal_instructee{&t}; + auto instructee = katerm::terminal_instructee{&t}; d.decode(ptr, count, instructee); } }; // non square terminal by default so that mixups with width/height will be caught. -auto test_term(gd100::extend size={5,4}) +auto test_term(katerm::extend size={5,4}) { return test_data{ - gd100::terminal{size}, - gd100::decoder{}}; + katerm::terminal{size}, + katerm::decoder{}}; } TEST_CASE("Terminal writing", "[write]") { auto tst = test_term(); SECTION("After initialisation") { - REQUIRE(tst.t.cursor.pos == gd100::position{0, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{0, 0}); REQUIRE(tst.t.screen.get_line(3)[4].code == 0); } @@ -37,7 +37,7 @@ TEST_CASE("Terminal writing", "[write]") { tst.t.write_char('A'); REQUIRE(tst.t.screen.get_glyph({0, 0}).code == 'A'); - REQUIRE(tst.t.cursor.pos == gd100::position{1, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{1, 0}); } SECTION("Cursor only goes to the next line when placing character there") { @@ -46,12 +46,12 @@ TEST_CASE("Terminal writing", "[write]") { tst.t.write_char('D'); tst.t.write_char('E'); REQUIRE(tst.t.screen.get_glyph({4, 0}).code == 'E'); - REQUIRE(tst.t.cursor.pos == gd100::position{4, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{4, 0}); tst.t.write_char('F'); REQUIRE(tst.t.screen.get_glyph({0, 1}).code == 'F'); - REQUIRE(tst.t.cursor.pos == gd100::position{1, 1}); + REQUIRE(tst.t.cursor.pos == katerm::position{1, 1}); } } @@ -69,11 +69,11 @@ TEST_CASE("Terminal scrolling", "[scroll]") { write_full_line(); write_full_line(); - REQUIRE(tst.t.cursor.pos == gd100::position{4, 3}); + REQUIRE(tst.t.cursor.pos == katerm::position{4, 3}); tst.t.write_char('a'); - REQUIRE(tst.t.cursor.pos == gd100::position{1, 3}); + REQUIRE(tst.t.cursor.pos == katerm::position{1, 3}); } } @@ -90,7 +90,7 @@ TEST_CASE("Terminal driven via decode", "[terminal-decode]") { REQUIRE(tst.t.screen.get_glyph({0, 2}).code == 'd'); REQUIRE(tst.t.screen.get_glyph({1, 2}).code == '!'); - REQUIRE(tst.t.cursor.pos == gd100::position{2, 2}); + REQUIRE(tst.t.cursor.pos == katerm::position{2, 2}); } } @@ -98,32 +98,32 @@ TEST_CASE("Backspace", "[backspace]") { auto tst = test_term(); SECTION("Backspace at the start of a line") { - REQUIRE(tst.t.cursor.pos == gd100::position{0, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{0, 0}); tst.process_bytes("\b", 1); - REQUIRE(tst.t.cursor.pos == gd100::position{0, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{0, 0}); tst.process_bytes("\n\b", 2); - REQUIRE(tst.t.cursor.pos == gd100::position{0, 1}); + REQUIRE(tst.t.cursor.pos == katerm::position{0, 1}); } SECTION("Backspacing over a character") { tst.process_bytes("Hey", 3); - REQUIRE(tst.t.cursor.pos == gd100::position{3, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{3, 0}); tst.process_bytes("\b", 1); - REQUIRE(tst.t.cursor.pos == gd100::position{2, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{2, 0}); tst.process_bytes("\b\b\b\b\b", 5); - REQUIRE(tst.t.cursor.pos == gd100::position{0, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{0, 0}); REQUIRE(tst.t.screen.get_glyph({1, 0}).code == 'e'); } SECTION("Backspace onto new line") { tst.process_bytes("12345", 5); // no space left in the first line - REQUIRE(tst.t.cursor.pos == gd100::position{4, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{4, 0}); // some shells use this trick to move the cursor to the next line tst.process_bytes(" \b", 2); - REQUIRE(tst.t.cursor.pos == gd100::position{0, 1}); + REQUIRE(tst.t.cursor.pos == katerm::position{0, 1}); } } @@ -132,36 +132,36 @@ TEST_CASE("Newline handling", "[newline]") { SECTION("Newline basics") { tst.process_bytes("\n", 1); - REQUIRE(tst.t.cursor.pos == gd100::position{0, 1}); + REQUIRE(tst.t.cursor.pos == katerm::position{0, 1}); tst.process_bytes("\n", 1); - REQUIRE(tst.t.cursor.pos == gd100::position{0, 2}); + REQUIRE(tst.t.cursor.pos == katerm::position{0, 2}); tst.process_bytes("\n", 1); - REQUIRE(tst.t.cursor.pos == gd100::position{0, 3}); + REQUIRE(tst.t.cursor.pos == katerm::position{0, 3}); tst.process_bytes("\n\n\n", 3); // Should start scrolling and leaving cursor alone - REQUIRE(tst.t.cursor.pos == gd100::position{0, 3}); + REQUIRE(tst.t.cursor.pos == katerm::position{0, 3}); } SECTION("Newline in middle") { tst.process_bytes("123", 3); tst.process_bytes("\n", 1); - REQUIRE(tst.t.cursor.pos == gd100::position{3, 1}); + REQUIRE(tst.t.cursor.pos == katerm::position{3, 1}); } SECTION("Newline at eol") { tst.process_bytes("12345", 5); tst.process_bytes("\n", 1); - REQUIRE(tst.t.cursor.pos == gd100::position{4, 1}); + REQUIRE(tst.t.cursor.pos == katerm::position{4, 1}); } SECTION("Newline and carriage return") { tst.process_bytes("123", 3); SECTION("CRLF") { tst.process_bytes("\r\n", 2); - REQUIRE(tst.t.cursor.pos == gd100::position{0, 1}); + REQUIRE(tst.t.cursor.pos == katerm::position{0, 1}); } SECTION("LFCR") { tst.process_bytes("\n\r", 2); - REQUIRE(tst.t.cursor.pos == gd100::position{0, 1}); + REQUIRE(tst.t.cursor.pos == katerm::position{0, 1}); } } } @@ -170,38 +170,38 @@ TEST_CASE("Carriage return handling", "[carriage-return]") { auto tst = test_term(); tst.process_bytes("abc\r", 4); - REQUIRE(tst.t.cursor.pos == gd100::position{0, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{0, 0}); REQUIRE(tst.t.screen.get_glyph({0, 0}).code == 'a'); REQUIRE(tst.t.screen.get_glyph({1, 0}).code == 'b'); tst.process_bytes("1", 1); - REQUIRE(tst.t.cursor.pos == gd100::position{1, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{1, 0}); REQUIRE(tst.t.screen.get_glyph({0, 0}).code == '1'); REQUIRE(tst.t.screen.get_glyph({1, 0}).code == 'b'); tst.process_bytes("\r", 1); - REQUIRE(tst.t.cursor.pos == gd100::position{0, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{0, 0}); } TEST_CASE("Tabs", "[tabs]") { auto tst = test_term({20, 4}); SECTION("Cursor positioning") { - REQUIRE(tst.t.cursor.pos == gd100::position{0, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{0, 0}); tst.process_bytes("\t", 1); - REQUIRE(tst.t.cursor.pos == gd100::position{8, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{8, 0}); tst.process_bytes("\t", 1); - REQUIRE(tst.t.cursor.pos == gd100::position{16, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{16, 0}); tst.process_bytes("Hi", 2); - REQUIRE(tst.t.cursor.pos == gd100::position{18, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{18, 0}); tst.process_bytes("\t", 1); - REQUIRE(tst.t.cursor.pos == gd100::position{19, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{19, 0}); } SECTION("Tab at end of line") { tst.process_bytes("\t\t\t\t", 4); - REQUIRE(tst.t.cursor.pos == gd100::position{19, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{19, 0}); tst.process_bytes("\tX", 2); REQUIRE(tst.t.screen.get_glyph({19, 0}).code == U'X'); @@ -210,7 +210,7 @@ TEST_CASE("Tabs", "[tabs]") { tst.process_bytes("\t$", 2); REQUIRE(tst.t.screen.get_glyph({19, 0}).code == U'$'); - REQUIRE(tst.t.cursor.pos == gd100::position{19, 0}); + REQUIRE(tst.t.cursor.pos == katerm::position{19, 0}); } SECTION("Tab results") { @@ -241,9 +241,9 @@ TEST_CASE("Double wide", "[double-wide]") { char const data1[] = "\nšŸ†\nXY"; tst.process_bytes(data1, sizeof(data1) - 1); REQUIRE(tst.t.screen.get_glyph({0, 1}).code == U'šŸ†'); - REQUIRE(tst.t.screen.get_glyph({0, 1}).style.mode.is_set(gd100::glyph_attr_bit::wide)); + REQUIRE(tst.t.screen.get_glyph({0, 1}).style.mode.is_set(katerm::glyph_attr_bit::wide)); REQUIRE(tst.t.screen.get_glyph({1, 1}).code == 0); - REQUIRE(tst.t.screen.get_glyph({1, 1}).style.mode == gd100::glyph_attr_bit::wdummy); + REQUIRE(tst.t.screen.get_glyph({1, 1}).style.mode == katerm::glyph_attr_bit::wdummy); char const data2[] = "\n"; tst.process_bytes(data2, sizeof(data2) - 1);