Skip to content

Commit

Permalink
add tb_version
Browse files Browse the repository at this point in the history
  • Loading branch information
adsr committed Sep 18, 2022
1 parent 145c76e commit 3e4c167
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion termbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MIT License
Copyright (c) 2010-2020 nsf <[email protected]>
2015-2021 Adam Saponara <[email protected]>
2015-2022 Adam Saponara <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -58,6 +58,8 @@ extern "C" {

// __ffi_start

#define TB_VERSION_STR "2.0.0"

#if defined(TB_LIB_OPTS) || 0 // __tb_lib_opts
// Ensure consistent compile-time options when using as a library
#undef TB_OPT_TRUECOLOR
Expand Down Expand Up @@ -541,6 +543,7 @@ const char *tb_strerror(int err);
struct tb_cell *tb_cell_buffer();
int tb_has_truecolor();
int tb_has_egc();
const char *tb_version();

#ifdef __cplusplus
}
Expand Down Expand Up @@ -1860,6 +1863,10 @@ int tb_has_egc() {
#endif
}

const char *tb_version() {
return TB_VERSION_STR;
}

static int tb_reset() {
int ttyfd_open = global.ttyfd_open;
memset(&global, 0, sizeof(global));
Expand Down
2 changes: 1 addition & 1 deletion tests/test_basic/expected.ansi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#5version=2.0.0
#5width=80
#5height=24
#5attr=TB_BOLD
Expand All @@ -21,4 +22,3 @@




1 change: 1 addition & 0 deletions tests/test_basic/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
$blue = $test->defines['TB_BLUE'];

$y = 0;
$test->ffi->tb_printf(0, $y++, 0, 0, "version=%s", $test->ffi->tb_version());
$test->ffi->tb_printf(0, $y++, $red, $bg, "width=%d", $w);
$test->ffi->tb_printf(0, $y++, $green, $bg, "height=%d", $h);
foreach (['TB_BOLD', 'TB_UNDERLINE', 'TB_ITALIC', 'TB_REVERSE'] as $attr) {
Expand Down

0 comments on commit 3e4c167

Please sign in to comment.