diff --git a/README.md b/README.md index b9856c7..e4cc975 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 @@ -16,7 +14,7 @@ include(FetchContent) fetchcontent_declare( rawterm GIT_REPOSITORY https://github.com/ttibsi/rawterm - GIT_TAG 25989a41742bd4105a796c9607bb88260cd682fb + GIT_TAG v4.0.7 ) fetchcontent_makeavailable(rawterm) ``` @@ -29,6 +27,43 @@ 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 // set_terminal_background +#include // enable_raw_mode, enter_alt_screen, wait_for_input +#include // Cursor +#include // inverse + +#include + +int main() { + // 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 + 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 diff --git a/examples/hello_world.cpp b/examples/hello_world.cpp index 09c1a32..f94750d 100644 --- a/examples/hello_world.cpp +++ b/examples/hello_world.cpp @@ -1,11 +1,10 @@ +#include #include #include #include #include -#include "rawterm/color.h" - int main() { // Raw mode automatically gets disabled at the end of the program rawterm::enable_raw_mode(); @@ -27,6 +26,5 @@ int main() { // Wait for user input auto k = rawterm::wait_for_input(); - rawterm::exit_alt_screen(); return 0; }