# TermOx
**Repository Path**: shangu1976/TermOx
## Basic Information
- **Project Name**: TermOx
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: develop
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2023-12-26
- **Last Updated**: 2023-12-26
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
[](https://github.com/a-n-t-h-o-n-y/TermOx/actions?query=workflow%3Abuild)
[](docs/manual/index.md)
[](https://a-n-t-h-o-n-y.github.io/TermOx/hierarchy.html)
# TermOx 🐂
**TermOx** is a Terminal User Interface(TUI) Framework written in C++17. Built
on top of [Escape](https://github.com/a-n-t-h-o-n-y/Escape), it defines a set of
Widgets, Layouts, and Events that make it quick to craft unique user interfaces
in the terminal.
## Widget Library
The TermOx [Widget Library](docs/manual/widget.md#widget-library) contains a
handful of common Widget and Layout types. These are often the building blocks
for significant portions of an application's TUI.
The library Widgets attempt to be generic enough for most use cases. Template
parameters allow for slight variantions of the same Widget, many of the
most common variations are provided as named type aliases.
## Layouts
Widgets are glued together via Layouts, the three Layout types provided by
TermOx are `Vertical`, `Horizontal`, and `Stack`. Layouts are themselves Widgets
that are able to hold other Widgets, they provide the logic for enabling,
resizing, and placement of each of their child Widgets.
Common Layout patterns are encapsulated in the generic `Pair`, `Tuple`, and
`Array` class templates; organizing Widgets is as simple as listing Widget types
in order, or the number of Widgets of a specific type, as in the case of
`Array`.
## Colors
TermOx Color Palettes support full true color with RGB and HSL values, [XTerm
256 color indices](https://jonasjacek.github.io/colors/), and Dynamic Colors.
Color Palettes define a set of names and color values. Palettes can be set at
runtime, giving applications a simple way to implement color schemes.
Dynamic Colors are animated colors. Their definition changes over time, and they
can be assigned to a any color name in a Palette.
Not all terminals support true color or the complete 256 colors defined by
XTerm.
## Interactivity
Mouse and Keyboard input is fully supported. Widgets are able to handle Events,
update their state and re-paint themselves.
Mouse input supports up to 11 mouse buttons(including scrolling), modifier
keys(`shift`, `ctrl`, `alt`), mouse click and drag, and always-on mouse
movement.
Keyboard input supports all printable and non-printable keyboard/keypad presses
and modifier keys(`shift`, `ctrl`, `alt`, `meta`). Signals generated by special
key presses(`Ctrl+c`, `Ctrl+z`, etc...) can be supressed by TermOx and sent to
Widgets as key combinations.
Most(but not all) terminals support mouse movement. Some terminals intercept
modifier keys for their own purposes.
## Animation
Each Widget is capable of Animation via Timer Events. Overriding the
`timer_event` handler lets the Widget update its state and repaint itself.
Color definitions can be animated with Dynamic Colors.
## Custom Widgets
Beyond the Widget Library, anyone can create new Widgets from scratch. By
inheriting from the `Widget` class, you are provided with virtual function event
handlers. These allow handling of everything from user input, animation,
painting the screen, focus in/out, etc... Inheriting from an existing Widget
type lets you build on top of existing behavior.
## Signals
TermOx uses the [Signals Light](https://github.com/a-n-t-h-o-n-y/signals-light)
library to facilitate communication between Widgets. Signals are added to
Widgets as members and emitted at anytime to notify registered observers, along
with any data sent when emitted.
All event handlers(mouse, keyboard, etc...) have a cooresponding Signal emitted
on the event, these can be connected to for a more reactive style of
programming.
## Build Instructions
TermOx depends on the [Signals
Light](https://github.com/a-n-t-h-o-n-y/signals-light) and
[Escape](https://github.com/a-n-t-h-o-n-y/Escape) libraries, these are both
included as git submodules.
git clone https://github.com/a-n-t-h-o-n-y/TermOx.git
mkdir TermOx/build && cd TermOx/build
git submodule update --init --recursive # Pull in dependencies
cmake .. -DCMAKE_BUILD_TYPE=Release # Generate Makefiles
make # Build library
make demos # Build demos(optional)
make termox.unit.tests # Build Unit Tests(optional)
make termox.ui.tests # Build UI Tests(optional)
make install # Install to system directories(optional)
Try out the `./demos/demos` app to get a feel for what TermOx is capable of.
## Using the Library
It is recommended to clone this library into your project and use it as a
submodule rather than installing it to your system. This way you can lock your
application to a specific version of TermOx.
CMake will add the library target `TermOx` if you add the TermOx directory
with `add_subdirectory(...)`.
```cmake
# CMakeLists.txt
cmake_minimum_required(VERSION 3.2)
add_executable(my_app
...
my_app.main.cpp
)
# If TermOx is cloned into a directory named external/
add_subdirectory(external/TermOx)
target_link_libraries(my_app TermOx)
```
## Projects using TermOx
- [CrabWise](https://github.com/a-n-t-h-o-n-y/CrabWise)
- [NES-Term](https://github.com/a-n-t-h-o-n-y/NES-Term)
- [GB-Term](https://github.com/a-n-t-h-o-n-y/GB-Term)
- [RegExplore](https://github.com/a-n-t-h-o-n-y/RegExplore)
- [Typer](https://github.com/a-n-t-h-o-n-y/Typer)
## Code Example
### Custom Widget
This code creates a new Widget type from scratch. It is a simple `Pinbox` Widget
that lets a user place pins of various colors on a dark background, much like a
Lite-Brite toy.
```cpp
#include