replaced confusing u64 joinded colors with struct TimStyle
This commit is contained in:
55
readme.md
55
readme.md
@@ -5,6 +5,26 @@ Fork of https://codeberg.org/chuvok/tim.h
|
||||
tim is a portable library to create simple terminal applications
|
||||
Demo video: https://asciinema.org/a/zn3p0dsVCOQOzwY1S9gDfyaxQ
|
||||
|
||||
## build
|
||||
1. Clone this repository.
|
||||
```
|
||||
git clone https://timerix.ddns.net/git/Timerix/tim.git
|
||||
```
|
||||
|
||||
2. Install [cbuild](https://timerix.ddns.net/git/Timerix/cbuild/releases).
|
||||
Select latest version compatible with the one in `project.config`.
|
||||
Example: For `2.3.2` download latest `2.3.x`.
|
||||
|
||||
3. Build static library
|
||||
```
|
||||
cd tim
|
||||
cbuild build_static_lib
|
||||
```
|
||||
4. Build tests and examples
|
||||
```
|
||||
cbuild ask hello snek test color string
|
||||
```
|
||||
|
||||
## quick start
|
||||
See [example/hello.c](./example/hello.c)
|
||||
|
||||
@@ -44,18 +64,10 @@ take the full available space from parent.
|
||||
The layout automatically adopts to terminal window resize events.
|
||||
|
||||
## colors
|
||||
Most elements have a uint64 color argument which holds up to eight colors.
|
||||
Typically byte 0 is the text color and byte 1 is the background color.
|
||||
|
||||
For example 0x08040f encodes three colors. When used with a button the text
|
||||
is white (0f), the background is blue (04), and the frame is gray (08).
|
||||
|
||||
The terminal should support xterm-256 colors. The TERM variable is ignored.
|
||||
The lower 16 colors vary across different terminals, so the upper 240 colors
|
||||
should be used if consistency is important.
|
||||
|
||||
xterm-256 color chart
|
||||
https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg
|
||||
Colors are stored as 8-bit values.
|
||||
Most terminals support 16 basic colors. You can see them in TimColor16 enum.
|
||||
There is also support for xterm-256 colors.
|
||||

|
||||
|
||||
## events
|
||||
tim_run blocks until it observes an event. Mouse and key events are always
|
||||
@@ -66,20 +78,13 @@ event when focused in order to prevent other key handlers on acting on them.
|
||||
|
||||
The current event is stored in tim->event.
|
||||
|
||||
event | cause
|
||||
-------------|-----------------------
|
||||
DRAW_EVENT | input, timeout, resize
|
||||
KEY_EVENT | key press
|
||||
MOUSE_EVENT | mouse click
|
||||
VOID_EVENT | consumed event
|
||||
|
||||
## elements
|
||||
frame (x, y, w, h, color)
|
||||
|
||||
Draw an empty frame and fill area.
|
||||
|
||||
x/y/w/h see layout documentation
|
||||
color background, frame
|
||||
style background, frame
|
||||
|
||||
label (str, x, y, w, h, color)
|
||||
|
||||
@@ -88,7 +93,7 @@ label (str, x, y, w, h, color)
|
||||
|
||||
str zero terminated string
|
||||
x/y/w/h see layout documentation
|
||||
color background, text
|
||||
style background, text
|
||||
|
||||
button (str, x, y, w, h, color) -> bool
|
||||
|
||||
@@ -97,7 +102,7 @@ button (str, x, y, w, h, color) -> bool
|
||||
|
||||
str zero terminated string
|
||||
x/y/w/h see layout documentation
|
||||
color frame, background, text
|
||||
style frame, background, text
|
||||
|
||||
edit (state, x, y, w, color) -> int
|
||||
|
||||
@@ -108,7 +113,7 @@ edit (state, x, y, w, color) -> int
|
||||
|
||||
state pointer to persistent edit state struct
|
||||
x/y/w see layout documentation
|
||||
color f rame, background, text
|
||||
style f rame, background, text
|
||||
|
||||
check (str, state, x, y, w, color) -> bool
|
||||
|
||||
@@ -119,7 +124,7 @@ check (str, state, x, y, w, color) -> bool
|
||||
str zero terminated string
|
||||
state pointer to persistent state variable
|
||||
x/y/w see layout documentation
|
||||
color check, background, text
|
||||
style check, background, text
|
||||
|
||||
radio (str, state, v, x, y, w, color) -> bool
|
||||
|
||||
@@ -131,7 +136,7 @@ radio (str, state, v, x, y, w, color) -> bool
|
||||
state pointer to persistent state variable
|
||||
v unique state value
|
||||
x/y/w see layout documentation
|
||||
color radio, background, text
|
||||
style radio, background, text
|
||||
|
||||
## functions
|
||||
tim_run (fps) -> bool
|
||||
|
||||
Reference in New Issue
Block a user