TUI Library
CPPurses is a Terminal User Interface(TUI) Library built on top of ncurses. It defines a framework of Widgets, Layouts, and Events that let you focus on user interface design, while boilerplate common to ncurses applications is handled behind the scenes.
CPPurses contains a collection of common Widgets that can be pieced together to create a composite application. It is also possible to expand and build on top of existing Widgets, or to create completely new Widget types, by overriding a few virtual functions.
This is a work in progress. The API is not stable.
Usage
See the wiki for examples.
Reference documentation can be found here.
Features
- Simple event system interface for handling mouse, keyboard and animation events, among others.
- Library of commonly used Widget types.
- Widget reuse and expansion through inheritance.
- Layout Widgets which automatically resize and move their children.
- Signals and Slots for communication between Widgets.
- Extensible color palettes.
- Border drawing and customization.
Build Instructions
CPPurses depends on two header only libraries, this repo includes them as git submodules. You'll need NCurses installed on your system.
git clone https://github.com/a-n-t-h-o-n-y/CPPurses.git
mkdir CPPurses/build && cd CPPurses/build
git submodule update --init --recursive # Pull in dependencies
cmake -DCMAKE_BUILD_TYPE=Release .. # Generate Makefiles
make # Build library
make demos # Build demos(optional)
sudo make install # Install header and library archive to system defaults
Installing the library with CMake will place the headers and the library archive in the standard GNU install directories.
Using the Library
As a submodule:
# CMakeLists.txt
cmake_minimum_required(VERSION 3.2)
add_executable(foo foo.cpp ...)
# CPPurses is cloned into a directory named external/
add_subdirectory(external/CPPurses)
target_link_libraries(foo cppurses)
As an installed library:
# CMakeLists.txt
cmake_minimum_required(VERSION 3.2)
add_executable(foo foo.cpp ...)
# CPPurses is installed on your system and linker can find cppurses:
target_compile_features(foo PRIVATE cxx_std_14)
target_link_libraries(foo cppurses ncursesw pthread)
Without CMake, link with cppurses, ncursesw(or ncurses if ncursesw is not available) and your system's thread library. If the library is installed your linker flags will be something like:
-lcppurses -lncursesw -pthread
C++14 or above will need to be used.
License
This software is distributed under the MIT License.
Gallery
Game of Life
Chess