From 6ccd89df272a5cb5f5970bbe91096d516b83b44e Mon Sep 17 00:00:00 2001 From: ttibsi Date: Wed, 19 Feb 2025 17:13:53 +0000 Subject: [PATCH 1/5] Update git tag in readme! --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b9856c7..0d7b33d 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ include(FetchContent) fetchcontent_declare( rawterm GIT_REPOSITORY https://github.com/ttibsi/rawterm - GIT_TAG 25989a41742bd4105a796c9607bb88260cd682fb + GIT_TAG v4.0.7 ) fetchcontent_makeavailable(rawterm) ``` From 6a0f426bc8ec7646c328c940217b478d9205687b Mon Sep 17 00:00:00 2001 From: ttibsi Date: Wed, 19 Feb 2025 17:18:06 +0000 Subject: [PATCH 2/5] tweak hello world! --- examples/hello_world.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/hello_world.cpp b/examples/hello_world.cpp index 09c1a32..654abeb 100644 --- a/examples/hello_world.cpp +++ b/examples/hello_world.cpp @@ -1,10 +1,10 @@ +#include #include #include #include #include -#include "rawterm/color.h" int main() { // Raw mode automatically gets disabled at the end of the program @@ -27,6 +27,5 @@ int main() { // Wait for user input auto k = rawterm::wait_for_input(); - rawterm::exit_alt_screen(); return 0; } From 87891cce778d5a41ba2067ccb94aa307344b1f80 Mon Sep 17 00:00:00 2001 From: ttibsi Date: Wed, 19 Feb 2025 17:18:52 +0000 Subject: [PATCH 3/5] add example to readme --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0d7b33d..6573c8c 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # rawterm -A c++20 library for working with raw mode in a terminal. See the -`examples/` directory for examples on how to use this library, and each -header file in `rawterm/` has a relevant markdown file in `docs/` when -relevant - -See `examples/hello_world.cpp` for a simple place to start. +A c++20 library for working with raw mode in a terminal, used for building +custom TUI applications without the old-school overhead of ncurses. +Documentation is mostly provided in the `docs/` directory, where every header +file has a partner mardown file to describe it's methods usecases. ### How to use As of `v4.0.0`, rawterm can be imported with cmake fetchcontent. Add the @@ -29,6 +27,44 @@ zig fetch --save=rawterm git+https://github.com/ttibsi/rawterm This has only been tested with zig 0.13.0 +### Example +A minimal hello world example looks like this: + +```cpp +#include +#include +#include +#include + +#include + +int main() { + // Raw mode automatically gets disabled at the end of the program + rawterm::enable_raw_mode(); + + rawterm::enter_alt_screen(); + + // Create a cursor object to control the cursor, and reset it's position + rawterm::Cursor c = rawterm::Cursor(); + c.reset(); + + // Set the background colour to grey + rawterm::set_terminal_background(rawterm::Colors::gray); + + // Display text to the screen. This can be done the same as any other + // c++ text output. Rawterm provides a series of functions for customising + // text appearance + std::cout << rawterm::inverse("Hello world!\r\n"); + + // Wait for user input + auto k = rawterm::wait_for_input(); + + return 0; +``` + +Please see the (examples)[https://github.com/Ttibsi/rawterm/tree/main/examples] +directory for more! + ### New in version: 4.0.7 * Added unit testing in `tests/` directory * Added zig build option From 0105e7c92046c4563648e7184e49bdf24c4b8ad3 Mon Sep 17 00:00:00 2001 From: ttibsi Date: Thu, 20 Feb 2025 08:48:34 +0000 Subject: [PATCH 4/5] cleanup example in readmeW --- README.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6573c8c..328221a 100644 --- a/README.md +++ b/README.md @@ -27,21 +27,20 @@ zig fetch --save=rawterm git+https://github.com/ttibsi/rawterm This has only been tested with zig 0.13.0 -### Example +#### Example A minimal hello world example looks like this: ```cpp -#include -#include -#include -#include +#include // set_terminal_background +#include // enable_raw_mode, enter_alt_screen, wait_for_input +#include // Cursor +#include // inverse #include int main() { - // Raw mode automatically gets disabled at the end of the program + // Raw mode and alt_screen automatically gets disabled at the end of the program rawterm::enable_raw_mode(); - rawterm::enter_alt_screen(); // Create a cursor object to control the cursor, and reset it's position From 44d85f4aa34f563947a0aa4e4b86304c94fd55d7 Mon Sep 17 00:00:00 2001 From: ttibsi Date: Thu, 20 Feb 2025 08:56:21 +0000 Subject: [PATCH 5/5] format and tidy --- README.md | 2 +- examples/hello_world.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 328221a..e4cc975 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # rawterm A c++20 library for working with raw mode in a terminal, used for building -custom TUI applications without the old-school overhead of ncurses. +custom TUI applications without the old-school overhead of ncurses. Documentation is mostly provided in the `docs/` directory, where every header file has a partner mardown file to describe it's methods usecases. diff --git a/examples/hello_world.cpp b/examples/hello_world.cpp index 654abeb..f94750d 100644 --- a/examples/hello_world.cpp +++ b/examples/hello_world.cpp @@ -5,7 +5,6 @@ #include - int main() { // Raw mode automatically gets disabled at the end of the program rawterm::enable_raw_mode();