Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 42 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
```
Expand All @@ -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 <rawterm/color.h> // set_terminal_background
#include <rawterm/core.h> // enable_raw_mode, enter_alt_screen, wait_for_input
#include <rawterm/cursor.h> // Cursor
#include <rawterm/text.h> // inverse

#include <iostream>

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
Expand Down
4 changes: 1 addition & 3 deletions examples/hello_world.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include <rawterm/color.h>
#include <rawterm/core.h>
#include <rawterm/cursor.h>
#include <rawterm/text.h>

#include <iostream>

#include "rawterm/color.h"

int main() {
// Raw mode automatically gets disabled at the end of the program
rawterm::enable_raw_mode();
Expand All @@ -27,6 +26,5 @@ int main() {
// Wait for user input
auto k = rawterm::wait_for_input();

rawterm::exit_alt_screen();
return 0;
}
Loading