1[![Build Status](https://travis-ci.org/a-n-t-h-o-n-y/CPPurses.svg?branch=master)](https://travis-ci.org/a-n-t-h-o-n-y/CPPurses) [![Join the chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/CPPurses/Lobby) [![Read the Wiki](https://img.shields.io/badge/-Wiki-yellow.svg)](https://github.com/a-n-t-h-o-n-y/CPPurses/wiki) [![Read the Reference](https://img.shields.io/badge/-API%20Reference-blue.svg)](https://a-n-t-h-o-n-y.github.io/CPPurses/hierarchy.html)
2
3
4# TUI Library
5__CPPurses__ is a Terminal User Interface(TUI) Library built on top of
6[ncurses](https://www.gnu.org/software/ncurses/). It defines a framework of
7[Widgets](https://github.com/a-n-t-h-o-n-y/CPPurses/wiki/Widgets),
8[Layouts](https://github.com/a-n-t-h-o-n-y/CPPurses/wiki/Layouts), and
9[Events](https://github.com/a-n-t-h-o-n-y/CPPurses/wiki/Events) that let you focus on
10user interface design, while boilerplate common to ncurses applications is
11handled behind the scenes.
12
13CPPurses contains a collection of common Widgets that can be pieced together to
14create a composite application. It is also possible to expand and build on top
15of existing Widgets, or to create completely new Widget types, by overriding a
16few virtual functions.
17
18This is a __work in progress__. The API is not stable.
19
20<p align="center">
21  <img src="docs/images/regexplore.gif">
22</p>
23
24
25## Usage
26See the [wiki](https://github.com/a-n-t-h-o-n-y/CPPurses/wiki) for examples.
27
28Reference documentation can be found [here](
29https://a-n-t-h-o-n-y.github.io/CPPurses/annotated.html).
30
31## Features
32- Simple event system interface for handling mouse, keyboard
33and animation events, among others.
34- Library of commonly used Widget types.
35- Widget reuse and expansion through inheritance.
36- Layout Widgets which automatically resize and move their children.
37- Signals and Slots for communication between Widgets.
38- Extensible color palettes.
39- Border drawing and customization.
40
41## Build Instructions
42CPPurses depends on two header only libraries, this repo
43includes them as git submodules. You'll need NCurses installed on your system.
44```
45git clone https://github.com/a-n-t-h-o-n-y/CPPurses.git
46mkdir CPPurses/build && cd CPPurses/build
47git submodule update --init --recursive   # Pull in dependencies
48cmake -DCMAKE_BUILD_TYPE=Release ..       # Generate Makefiles
49make                                      # Build library
50make demos                                # Build demos(optional)
51sudo make install    # Install header and library archive to system defaults
52```
53Installing the library with CMake will place the headers and the library
54archive in the standard GNU install directories.
55
56## Using the Library
57As a submodule:
58```cmake
59# CMakeLists.txt
60cmake_minimum_required(VERSION 3.2)
61add_executable(foo foo.cpp ...)
62
63# CPPurses is cloned into a directory named external/
64add_subdirectory(external/CPPurses)
65target_link_libraries(foo cppurses)
66```
67
68As an installed library:
69```cmake
70# CMakeLists.txt
71cmake_minimum_required(VERSION 3.2)
72add_executable(foo foo.cpp ...)
73
74# CPPurses is installed on your system and linker can find cppurses:
75target_compile_features(foo PRIVATE cxx_std_14)
76target_link_libraries(foo cppurses ncursesw pthread)
77```
78
79Without CMake, link with cppurses, ncursesw(or ncurses if ncursesw
80is not available) and your system's thread library. If the library
81is installed your linker flags will be something like:
82```
83-lcppurses -lncursesw -pthread
84```
85C++14 or above will need to be used.
86
87## License
88This software is distributed under the [MIT License](LICENSE.txt).
89
90## Gallery
91Game of Life
92<p align="center">
93  <img src="docs/images/gol_demo.gif">
94</p>
95
96Chess
97<p align="center">
98  <img src="docs/images/chess_demo_1.png">
99</p>
100<p align="center">
101  <img src="docs/images/chess_demo_2.png">
102</p>
103