]> _ Git - termbox2.git/log
termbox2.git
18 months agobump version
Adam Saponara [Fri, 9 Feb 2024 01:54:38 +0000 (20:54 -0500)]
bump version

18 months agoupdate docs
Adam Saponara [Fri, 9 Feb 2024 01:52:17 +0000 (20:52 -0500)]
update docs

18 months agonull-terminate output of `tb_utf8_unicode_to_char`
Adam Saponara [Fri, 9 Feb 2024 01:50:22 +0000 (20:50 -0500)]
null-terminate output of `tb_utf8_unicode_to_char`

18 months agoupdate copyright year
Adam Saponara [Fri, 9 Feb 2024 01:46:37 +0000 (20:46 -0500)]
update copyright year

18 months agopermit overriding docker in makefile (like with podman)
Adam Saponara [Fri, 9 Feb 2024 01:45:07 +0000 (20:45 -0500)]
permit overriding docker in makefile (like with podman)

18 months agostop reading at null-terminator in `tb_utf8_char_to_unicode` (#63)
Adam Saponara [Fri, 9 Feb 2024 01:40:24 +0000 (20:40 -0500)]
stop reading at null-terminator in `tb_utf8_char_to_unicode` (#63)

if this occurs in `tb_print_ex`, replace the invalid character with a U+FFFD.

18 months agofix compile warning in demo
Adam Saponara [Fri, 17 Nov 2023 01:03:06 +0000 (20:03 -0500)]
fix compile warning in demo

```
In file included from demo/keyboard.c:5:
demo/keyboard.c: In function ‘draw_keyboard’:
demo/../termbox2.h:252:33: warning: unsigned conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} changes value from ‘16777222’ to ‘6’ [-Woverflow]
  252 | #define TB_MAGENTA              0x0006
      |                                 ^
demo/keyboard.c:512:22: note: in expansion of macro ‘TB_MAGENTA’
  512 |     printf_tb(33, 1, TB_MAGENTA | TB_BOLD, TB_DEFAULT, "Keyboard demo!");
```

21 months agoREADME: add Chez Scheme's letloop to bindings list.
ⵄⵎⵉⵔⵓⵛ [Sat, 18 Nov 2023 18:36:45 +0000 (19:36 +0100)]
README: add Chez Scheme's letloop to bindings list.

21 months agodelete unnecessary if_not_init_return() check in tb_set_cell()
Mitchell Rosen [Tue, 14 Nov 2023 20:01:00 +0000 (15:01 -0500)]
delete unnecessary if_not_init_return() check in tb_set_cell()

21 months agoupdate readme
Adam Saponara [Fri, 17 Nov 2023 00:43:39 +0000 (19:43 -0500)]
update readme

21 months agofix egc bug, clarify docs, add test
Adam Saponara [Tue, 7 Nov 2023 03:21:02 +0000 (22:21 -0500)]
fix egc bug, clarify docs, add test

23 months agoadd nim example
Adam Saponara [Fri, 22 Sep 2023 04:46:25 +0000 (00:46 -0400)]
add nim example

2 years agoupdate readme
Adam Saponara [Tue, 22 Aug 2023 03:24:38 +0000 (23:24 -0400)]
update readme

2 years agoupdate readme
Adam Saponara [Sat, 19 Aug 2023 23:17:22 +0000 (19:17 -0400)]
update readme

2 years agoparse test macros from `gcc -E -dM` output instead of the raw header
Adam Saponara [Thu, 13 Jul 2023 08:23:41 +0000 (04:23 -0400)]
parse test macros from `gcc -E -dM` output instead of the raw header

previously we had no way intelligently parsing out conditional
defines such as:

```c
```

we would parse out TB_XYZ twice and overwrite the first value. this
was breaking tests as we now, for example, have TB_BOLD defined
conditionally.

we are now parsing the output of `gcc -E -dM` instead which give us a
simple list of macro key-vals after the preprocessor has executed.

2 years agoadd support for more style attrs and 64-bit attrs (#56)
Adam Saponara [Thu, 13 Jul 2023 06:57:59 +0000 (02:57 -0400)]
add support for more style attrs and 64-bit attrs (#56)

probably should have broken this into multiple commits but it was all
inter-related:

* deprecate TB_OPT_TRUECOLOR in favor of TB_OPT_ATTR_W which defaults
  to 16, but can be 32 (truecolor) or 64 (truecolor + additional
  styles). for back compat, TB_OPT_TRUECOLOR sets TB_OPT_ATTR_W to 32
  if not already set.

* add TB_BRIGHT, available in TB_OUTPUT_NORMAL only.

* add TB_DIM and TB_INVISIBLE. TB_INVISIBLE is available only when
  TB_OPT_ATTR_W=64.

* add TB_STRIKEOUT, TB_UNDERLINE_2, TB_OVERLINE, available only when
  TB_OPT_ATTR_W=64. these are hard-coded caps because they don't
  appear to be in terminfo.

* deprecate TB_256_BLACK and TB_TRUECOLOR_BLACK in favor of
  TB_HI_BLACK which can be used in any of the hi-color modes.

* deprecate all TB_TRUECOLOR_* style attributes. users can use
  TB_BOLD, TB_UNDERLINE, etc in truecolor mode now.

* add tests for new features.

* document compile-time options.

2 years agoignore cap collisions
Adam Saponara [Fri, 7 Jul 2023 03:04:48 +0000 (23:04 -0400)]
ignore cap collisions

many terms have duplicate escape codes even for our modest subset of
caps. see inline comment for an example as well as a todo.

2 years agointerpret oob terminfo strings as absent caps
Adam Saponara [Fri, 7 Jul 2023 02:58:04 +0000 (22:58 -0400)]
interpret oob terminfo strings as absent caps

if either the string offset or string value is beyond the entry
bounds, interpret this as an absent cap. several terms seem to do
this.

this behavior is still slightly stricter than ncurses which ignores
corrupt or truncated terminfo entries. we still error in that case.

2 years agoskip empty caps (#57)
Adam Saponara [Fri, 7 Jul 2023 00:30:14 +0000 (20:30 -0400)]
skip empty caps (#57)

this slipped under the radar because none of the built-in terms have
more than one empty key cap, or an empty string for one of the caps
we use in init/shutdown.

some terms do of course have multiple empty caps. for example,
`xterm-color` is missing `khome`, `kend`, and `kcbt` (back-tab),
which leads to adding `""` more than once, which leads to a
`TB_ERR_CAP_COLLISION` error on init. other terms don't have caps for
hiding and showing the cursor, for example.

to avoid these errors, we avoid adding empty caps to the trie, and
similarly avoid emitting empty caps.

it's kind of hard to add a functional test for this as it gets into
testing multiple term envs and terminal emulators which is a bit of a
pandora's box. as an alternative, i'm going to do some more manual
testing on various terms on my system.

2 years agoupdate readme
Adam Saponara [Fri, 9 Jun 2023 03:43:40 +0000 (23:43 -0400)]
update readme

2 years agoupdate readme
Adam Saponara [Mon, 5 Jun 2023 05:32:41 +0000 (01:32 -0400)]
update readme

2 years agopermit single-line-if in clang-format
Adam Saponara [Sun, 4 Jun 2023 17:08:44 +0000 (13:08 -0400)]
permit single-line-if in clang-format

2 years agoavoid setting `PATH_MAX` (use `TB_PATH_MAX`) h/t @rofl0r
Adam Saponara [Sun, 4 Jun 2023 17:06:16 +0000 (13:06 -0400)]
avoid setting `PATH_MAX` (use `TB_PATH_MAX`) h/t @rofl0r

2 years agodefine `PATH_MAX` if undefined
Adam Saponara [Fri, 2 Jun 2023 23:16:04 +0000 (19:16 -0400)]
define `PATH_MAX` if undefined

some architectures apparently don't define it. e.g.:

https://buildd.debian.org/status/fetch.php?pkg=mle&arch=hurd-i386&ver=1.5.0-1&stamp=1654066958&raw=0

2 years agoadd: a demo in rust
rilysh [Wed, 17 May 2023 01:58:35 +0000 (21:58 -0400)]
add: a demo in rust

2 years agoadd clang-format makefile rule
Adam Saponara [Sat, 6 May 2023 01:02:31 +0000 (21:02 -0400)]
add clang-format makefile rule

2 years agoadd example in dlang
Adam Saponara [Sat, 29 Apr 2023 17:45:52 +0000 (13:45 -0400)]
add example in dlang

2 years agoinvalidate last_(fg|bg) after mode switch
Adam Saponara [Mon, 3 Apr 2023 00:06:56 +0000 (20:06 -0400)]
invalidate last_(fg|bg) after mode switch

last_(fg|bg) are no longer valid after a mode switch. see the test
for an example of the bug in action.

2 years agomake test_basic version agnostic
Adam Saponara [Mon, 3 Apr 2023 00:06:14 +0000 (20:06 -0400)]
make test_basic version agnostic

2 years agoadd `tb_invalidate`
Adam Saponara [Mon, 3 Apr 2023 00:05:35 +0000 (20:05 -0400)]
add `tb_invalidate`

2 years agorestore `TB_DEFAULT==0` in all modes (#51)
Adam Saponara [Sun, 2 Apr 2023 22:10:10 +0000 (18:10 -0400)]
restore `TB_DEFAULT==0` in all modes (#51)

this removes `TB_TRUECOLOR_DEFAULT` added in 846bba4b and goes back to
`TB_DEFAULT==0` in all modes. instead, hi-bit macros `TB_256_BLACK`
and `TB_TRUECOLOR_BLACK` are added which provide a way to emit black
in those modes.

turns out there were some subtle bugs associated with `TB_DEFAULT!=0`
(in addition to the bug identified in #51). the bugs were fixable but
required uglying up some code. zero as default in all modes is more
intuitive and easier to reason about (e.g., `memset(..., 0, ...)`).

2 years agoupdate copyright date
Adam Saponara [Sun, 2 Apr 2023 19:07:43 +0000 (15:07 -0400)]
update copyright date

2 years agotermbox -> termbox2 (#53)
Adam Saponara [Sun, 2 Apr 2023 19:05:55 +0000 (15:05 -0400)]
termbox -> termbox2 (#53)

2 years agoadd example `lavat` (#47)
Adam Saponara [Mon, 17 Oct 2022 22:59:04 +0000 (18:59 -0400)]
add example `lavat` (#47)

2 years agofix the no-cap case of `get_terminfo_string`
Adam Saponara [Thu, 6 Oct 2022 06:03:04 +0000 (02:03 -0400)]
fix the no-cap case of `get_terminfo_string`

a negative string offset indicates the corresponding cap is
not supported on that terminal. return an empty string in
this case. previously we'd return garbage.

for a test case, observe what happens when fetching `smcup`
on `TERM=linux`.

2 years agoFixed narrowing conversions, cast some values where deemed safe
Daniel [Mon, 19 Sep 2022 09:18:45 +0000 (11:18 +0200)]
Fixed narrowing conversions, cast some values where deemed safe

2 years agoAdded (void) to functions taking no args
Daniel [Mon, 19 Sep 2022 05:42:38 +0000 (07:42 +0200)]
Added (void) to functions taking no args

2 years agostrerror -> strerror_r (#43)
Adam Saponara [Sun, 18 Sep 2022 22:59:47 +0000 (18:59 -0400)]
strerror -> strerror_r (#43)

2 years agocomments
Adam Saponara [Sun, 18 Sep 2022 22:59:33 +0000 (18:59 -0400)]
comments

2 years agosupport default colors in non-`TB_OUTPUT_NORMAL` modes (#41)
Adam Saponara [Sun, 18 Sep 2022 22:05:50 +0000 (18:05 -0400)]
support default colors in non-`TB_OUTPUT_NORMAL` modes (#41)

`TB_DEFAULT` is now defined as a bitwise attribute similar to
`TB_BOLD`. previously it was defined as 0 which made it impossible to
use default colors in non-`TB_OUTPUT_NORMAL` modes.

for convenience and limited back-compat, 0 is still interpreted as
`TB_DEFAULT` in `TB_OUTPUT_NORMAL`, `TB_OUTPUT_216`, and
`TB_OUTPUT_GRAYSCALE`, though `TB_DEFAULT` may be used as well.

in `TB_OUTPUT_256` and `TB_OUTPUT_TRUECOLOR`, 0 is black, so
`TB_DEFAULT` and `TB_TRUECOLOR_DEFAULT` respectively must be used if
a default color is desired.

2 years agoadd tb_version
Adam Saponara [Sun, 18 Sep 2022 19:19:34 +0000 (15:19 -0400)]
add tb_version

2 years agoprevent compile-time option mismatch when used as library
Adam Saponara [Thu, 4 Aug 2022 05:37:58 +0000 (01:37 -0400)]
prevent compile-time option mismatch when used as library

2 years agoadd soname and install rules
Adam Saponara [Tue, 2 Aug 2022 02:43:37 +0000 (22:43 -0400)]
add soname and install rules

3 years agoadd examples in other languages
Adam Saponara [Tue, 5 Jul 2022 04:42:16 +0000 (00:42 -0400)]
add examples in other languages

3 years agoadd .gitignore
Adam Saponara [Mon, 27 Jun 2022 01:01:22 +0000 (21:01 -0400)]
add .gitignore

3 years agofactor out ffi creation
Adam Saponara [Sun, 26 Jun 2022 20:06:30 +0000 (16:06 -0400)]
factor out ffi creation

3 years agoadd TODO about resize errors
Adam Saponara [Sat, 25 Jun 2022 03:37:05 +0000 (23:37 -0400)]
add TODO about resize errors

3 years agodocument optimistic nature of tb_set_output_mode (#37)
Adam Saponara [Sat, 25 Jun 2022 03:27:44 +0000 (23:27 -0400)]
document optimistic nature of tb_set_output_mode (#37)

3 years agomake resize immediate
Adam Saponara [Tue, 21 Jun 2022 23:39:56 +0000 (19:39 -0400)]
make resize immediate

3 years agoadd demo image
Adam Saponara [Sat, 18 Jun 2022 04:39:58 +0000 (00:39 -0400)]
add demo image

3 years agoswitch back to select() as poll() is broken on implementations like mac OS
git-bruh [Wed, 15 Jun 2022 11:12:23 +0000 (16:42 +0530)]
switch back to select() as poll() is broken on implementations like mac OS

3 years agoconvert test_mod from xvkdb- to memfd-based test (was flaky)
Adam Saponara [Sat, 4 Jun 2022 22:43:54 +0000 (18:43 -0400)]
convert test_mod from xvkdb- to memfd-based test (was flaky)

3 years agoRun tests for non-truecolor and non-egc builds.
Adam Saponara [Sat, 4 Jun 2022 21:27:20 +0000 (17:27 -0400)]
Run tests for non-truecolor and non-egc builds.

This patch introduces a few new things:

* Build artifact termbox.ffi.h for easier FFI header file parsing. As a result, no more `__ffi_strip` bs, but probably more complex overall. The other idea I had would have been uglier. I think the test coverage is worth it.

* Functions `tb_has_truecolor` and `tb_has_egc` for determining support for those features at runtime.

* Test container uses `debian:11-slim` image instead of `debian:10-slim`.

* Test container uses PHP 8 instead of PHP 7.

* Test container now accepts `cflags` build argument.

* Tests can now be skipped via `$test->skip()`.

* Test suite covers 3 different builds: normal, non-truecolor, non-egc.

3 years agoadd a few missing if_err_return and fmt
Adam Saponara [Fri, 3 Jun 2022 23:51:52 +0000 (19:51 -0400)]
add a few missing if_err_return and fmt

3 years agofix non-truecolor (#26)
Adam Saponara [Fri, 3 Jun 2022 23:50:48 +0000 (19:50 -0400)]
fix non-truecolor (#26)

3 years agoadd `TB_BLINK` and `TB_TRUECOLOR_*` attributes (#16)
Adam Saponara [Wed, 1 Jun 2022 02:05:14 +0000 (22:05 -0400)]
add `TB_BLINK` and `TB_TRUECOLOR_*` attributes (#16)

3 years agoupdate docs concerning style attributes (#24)
Adam Saponara [Tue, 31 May 2022 01:35:18 +0000 (21:35 -0400)]
update docs concerning style attributes (#24)

in particular, document the hidden feature of applying `TB_BOLD` as a
background attribute, which emits `TB_CAP_BLINK`.

3 years agoClarify what 0x08-0x0f in TB_OUTPUT_256 means, a bit
Mitchell Rosen [Mon, 2 May 2022 19:58:29 +0000 (15:58 -0400)]
Clarify what 0x08-0x0f in TB_OUTPUT_256 means, a bit

3 years agoupdate docs for TB_INPUT_MOUSE (#20)
Adam Saponara [Mon, 2 May 2022 17:04:57 +0000 (13:04 -0400)]
update docs for TB_INPUT_MOUSE (#20)

3 years ago[0..216] -> [0..215]
Mitchell Rosen [Mon, 2 May 2022 02:35:25 +0000 (22:35 -0400)]
[0..216] -> [0..215]

3 years agoupdate readme with examples (#19)
Adam Saponara [Sun, 27 Feb 2022 22:41:37 +0000 (17:41 -0500)]
update readme with examples (#19)

3 years agoadd build rule for static lib
Adam Saponara [Sun, 27 Feb 2022 22:41:06 +0000 (17:41 -0500)]
add build rule for static lib

3 years agodefine required feature test macros
Adam Saponara [Sun, 27 Feb 2022 22:40:31 +0000 (17:40 -0500)]
define required feature test macros

3 years agoActually fix non-truecolor build
git-bruh [Wed, 26 Jan 2022 07:23:57 +0000 (12:53 +0530)]
Actually fix non-truecolor build

3 years agofix build without truecolor
git-bruh [Tue, 25 Jan 2022 08:56:15 +0000 (14:26 +0530)]
fix build without truecolor

3 years agosave errno in resize handler, deinit signal handler in tb_shutdown()
git-bruh [Mon, 10 Jan 2022 11:32:26 +0000 (17:02 +0530)]
save errno in resize handler, deinit signal handler in tb_shutdown()

3 years agoprevent emitting attrs in true-color mode
Adam Saponara [Tue, 25 Jan 2022 03:59:07 +0000 (22:59 -0500)]
prevent emitting attrs in true-color mode

3 years agofix some warnings
Adam Saponara [Mon, 10 Jan 2022 02:56:59 +0000 (21:56 -0500)]
fix some warnings

3 years agofmt termbox.h
Adam Saponara [Mon, 10 Jan 2022 02:56:39 +0000 (21:56 -0500)]
fmt termbox.h

3 years agoadd mouse support
Wolf Gupta [Mon, 10 Jan 2022 02:43:35 +0000 (08:13 +0530)]
add mouse support

3 years agoadd test for f715214
Adam Saponara [Fri, 7 Jan 2022 00:31:58 +0000 (19:31 -0500)]
add test for f715214

3 years agofix `#define` regex in tests
Adam Saponara [Fri, 7 Jan 2022 00:10:36 +0000 (19:10 -0500)]
fix `#define` regex in tests

3 years agoinclude tb_init_rwfd in api
Adam Saponara [Thu, 6 Jan 2022 06:36:10 +0000 (01:36 -0500)]
include tb_init_rwfd in api

3 years agofix bug in `extract_esc_cap`.
Adam Saponara [Thu, 6 Jan 2022 06:06:30 +0000 (01:06 -0500)]
fix bug in `extract_esc_cap`.

previously we were able to read past the actual end of the
input buffer (`global.in.buf`). we would not segfault due
to how bytebufs are implemented, but we could erroneously
re-process segments of input. in practice i think this
could only occur with an instantaneous burst of tty input
greater than the read buffer in `wait_event` (64 bytes). i
noticed this by accidentally mouse-wheeling very fast in
xfce4-terminal which, in my setup, sends a bunch of
up-arrow events (`\x1bOA`) all at once, in which case
termbox was pseduo-randomly emitting "O" and "A" events.

3 years agoadd test for tb_strerror
Adam Saponara [Thu, 6 Jan 2022 05:15:14 +0000 (00:15 -0500)]
add test for tb_strerror

3 years agorecompile in container before running tests
Adam Saponara [Thu, 6 Jan 2022 03:30:37 +0000 (22:30 -0500)]
recompile in container before running tests

3 years agoadd tb_strerror (#11)
Wolf Gupta [Thu, 6 Jan 2022 03:28:45 +0000 (08:58 +0530)]
add tb_strerror (#11)

3 years agouse github actions for ci
Adam Saponara [Fri, 31 Dec 2021 06:43:30 +0000 (01:43 -0500)]
use github actions for ci

3 years agoadd and apply `.clang-format`
git-bruh [Mon, 27 Dec 2021 02:04:27 +0000 (21:04 -0500)]
add and apply `.clang-format`

3 years agoexpose internal fds for external polling
git-bruh [Wed, 15 Dec 2021 11:12:01 +0000 (16:42 +0530)]
expose internal fds for external polling

3 years agoupdate inline docs (#4).
Adam Saponara [Fri, 10 Dec 2021 02:07:38 +0000 (21:07 -0500)]
update inline docs (#4).

specifically document return code TB_ERR_SELECT on
tb_peek/poll_event.

3 years agoadd regression test for #3
Adam Saponara [Sun, 28 Nov 2021 18:55:10 +0000 (13:55 -0500)]
add regression test for #3

3 years agoprevent segfault in `tb_deinit` when TERM is invalid
git-bruh [Sun, 28 Nov 2021 18:54:02 +0000 (13:54 -0500)]
prevent segfault in `tb_deinit` when TERM is invalid

3 years agoadd test case for `tb_printf_ex`
Adam Saponara [Sun, 28 Nov 2021 18:24:07 +0000 (13:24 -0500)]
add test case for `tb_printf_ex`

3 years agoadd `tb_print_ex` and `tb_printf_ex`.
git-bruh [Sun, 28 Nov 2021 18:21:04 +0000 (13:21 -0500)]
add `tb_print_ex` and `tb_printf_ex`.

these functions have an optional `out_w` param that
receives the printed width of the string if specified.

3 years agoadd readme
Adam Saponara [Sun, 24 Oct 2021 00:48:05 +0000 (20:48 -0400)]
add readme

3 years agoreplace linear cap search with trie.
Adam Saponara [Sun, 19 Sep 2021 01:07:56 +0000 (21:07 -0400)]
replace linear cap search with trie.

for every input, termbox used to iterate over termcaps one
at a time, `strncmp`ing it to the input buffer. the benefit
of this approach was that it had a very simple
implementation. the downside was that it was inefficient,
increasingly so as we added more caps such as modified
arrow keys.

the trie makes it easy to detect when there are overlaps in
termcaps. the obvious one is `TB_KEY_ESC` versus all other
escape codes. in the future we can modify function
`extract_esc_cap` to, e.g., potentially return `TB_KEY_ESC`
in `TB_INPUT_ALT` mode if no further input is available
after a certain amount of time.

3 years agoadd license header
Adam Saponara [Sun, 19 Sep 2021 01:05:52 +0000 (21:05 -0400)]
add license header

3 years agoadd cap kcbt (TB_KEY_BACK_TAB)
Adam Saponara [Sun, 19 Sep 2021 01:05:17 +0000 (21:05 -0400)]
add cap kcbt (TB_KEY_BACK_TAB)

3 years agotermbox rewrite (wip)
Adam Saponara [Tue, 7 Sep 2021 01:53:45 +0000 (21:53 -0400)]
termbox rewrite (wip)