aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2019-12-05 19:26:09 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2019-12-05 19:26:09 +0100
commit66d82ed8acfd374fdaf95a6ee521a5a6ad920891 (patch)
tree9cb081a7c78ddb4b3d7e6ed92b00ba782aadb9e8
parenta7bb3846d2a4b6bd60fa476129de642518a9ed09 (diff)
downloadd2tk-66d82ed8acfd374fdaf95a6ee521a5a6ad920891.tar.xz
base: use config.h to store D2TK_PTY macro.
-rw-r--r--VERSION2
-rw-r--r--d2tk/base.h9
-rw-r--r--d2tk/config.h.in1
-rw-r--r--example/example.c4
-rw-r--r--meson.build10
-rw-r--r--src/base.c2
-rw-r--r--src/base_internal.h4
-rw-r--r--src/base_pty.c11
8 files changed, 29 insertions, 14 deletions
diff --git a/VERSION b/VERSION
index cc0f03e..66a939f 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.899
+0.1.901
diff --git a/d2tk/base.h b/d2tk/base.h
index 2a10f39..f36e90f 100644
--- a/d2tk/base.h
+++ b/d2tk/base.h
@@ -25,6 +25,8 @@
#include <utf8.h/utf8.h>
+#include "config.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -128,7 +130,8 @@ typedef enum _d2tk_state_t {
D2TK_STATE_MOTION = (1 << 11),
D2TK_STATE_CHANGED = (1 << 12),
D2TK_STATE_ENTER = (1 << 13),
- D2TK_STATE_OVER = (1 << 14)
+ D2TK_STATE_OVER = (1 << 14),
+ D2TK_STATE_CLOSE = (1 << 15)
} d2tk_state_t;
typedef enum _d2tk_flag_t {
@@ -463,10 +466,10 @@ d2tk_base_link(d2tk_base_t *base, d2tk_id_t id, ssize_t lbl_len, const char *lbl
#define d2tk_base_link_is_changed(...) \
d2tk_state_is_changed(d2tk_base_link(__VA_ARGS__))
-#if defined(D2TK_PTY)
+#if D2TK_PTY
D2TK_API d2tk_state_t
d2tk_base_pty(d2tk_base_t *base, d2tk_id_t id, char **args, d2tk_coord_t ncols,
- d2tk_coord_t nrows, const d2tk_rect_t *rect);
+ const d2tk_rect_t *rect);
#define d2tk_base_pty_is_changed(...) \
d2tk_state_is_changed(d2tk_base_pty(__VA_ARGS__))
diff --git a/d2tk/config.h.in b/d2tk/config.h.in
new file mode 100644
index 0000000..b6d1f63
--- /dev/null
+++ b/d2tk/config.h.in
@@ -0,0 +1 @@
+#define D2TK_PTY @D2TK_PTY@
diff --git a/example/example.c b/example/example.c
index a6cec03..7316c28 100644
--- a/example/example.c
+++ b/example/example.c
@@ -804,15 +804,13 @@ static inline void
_render_c_pty(d2tk_base_t *base, const d2tk_rect_t *rect)
{
#define NCOLS 84
-#define NROWS 40
static char *argv [] = {
"bash",
NULL
};
- d2tk_base_pty(base, D2TK_ID, argv, NCOLS, NROWS, rect);
+ d2tk_base_pty(base, D2TK_ID, argv, NCOLS, rect);
-#undef NROWS
#undef NCOLS
}
#endif
diff --git a/meson.build b/meson.build
index b66ba29..1821271 100644
--- a/meson.build
+++ b/meson.build
@@ -92,9 +92,11 @@ lib_srcs = [
]
if vterm_dep.found()
- add_project_arguments('-DD2TK_PTY', language : 'c')
+ conf_data.set('D2TK_PTY', 1)
lib_srcs += join_paths('src', 'base_pty.c')
deps += util_dep
+else
+ conf_data.set('D2TK_PTY', 0)
endif
bin_srcs = [
@@ -210,6 +212,12 @@ executable('d2tk.nanovg', [bin_srcs, pugl_bin_srcs],
install : false)
configure_file(
+ input : join_paths('d2tk', 'config.h.in'),
+ output : 'config.h',
+ configuration : conf_data,
+ install : false)
+
+configure_file(
input : join_paths('ttf', 'FiraSans-Bold.ttf'),
output : 'FiraSans-Bold.ttf',
copy : true,
diff --git a/src/base.c b/src/base.c
index 9a7dd25..1cffff6 100644
--- a/src/base.c
+++ b/src/base.c
@@ -121,7 +121,7 @@ _d2tk_base_get_atom(d2tk_base_t *base, d2tk_id_t id, d2tk_atom_type_t type)
{
len = d2tk_atom_body_flow_sz;
} break;
-#if defined(D2TK_PTY)
+#if D2TK_PTY
case D2TK_ATOM_PTY:
{
len = d2tk_atom_body_pty_sz;
diff --git a/src/base_internal.h b/src/base_internal.h
index dd1fb34..f9f471f 100644
--- a/src/base_internal.h
+++ b/src/base_internal.h
@@ -32,7 +32,7 @@ typedef enum _d2tk_atom_type_t {
D2TK_ATOM_FLOW,
D2TK_ATOM_FLOW_NODE,
D2TK_ATOM_FLOW_ARC,
-#if defined(D2TK_PTY)
+#if D2TK_PTY
D2TK_ATOM_PTY,
#endif
} d2tk_atom_type_t;
@@ -100,7 +100,7 @@ struct _d2tk_base_t {
extern const size_t d2tk_atom_body_flow_sz;
extern const size_t d2tk_atom_body_pane_sz;
extern const size_t d2tk_atom_body_scroll_sz;
-#if defined(D2TK_PTY)
+#if D2TK_PTY
extern const size_t d2tk_atom_body_pty_sz;
#endif
diff --git a/src/base_pty.c b/src/base_pty.c
index 2242f92..6dcd259 100644
--- a/src/base_pty.c
+++ b/src/base_pty.c
@@ -693,11 +693,14 @@ _term_draw(d2tk_base_t *base, d2tk_atom_body_pty_t *vpty,
D2TK_API d2tk_state_t
d2tk_base_pty(d2tk_base_t *base, d2tk_id_t id, char **argv, d2tk_coord_t ncols,
- d2tk_coord_t nrows, const d2tk_rect_t *rect)
+ const d2tk_rect_t *rect)
{
d2tk_atom_body_pty_t *vpty = _d2tk_base_get_atom(base, id, D2TK_ATOM_PTY);
+ const d2tk_coord_t sz = rect->w / ncols;
+ const d2tk_coord_t nrows = rect->h / sz / 2;
+ d2tk_state_t state = D2TK_STATE_NONE;
- if( (vpty->ncols == 0) && (vpty->nrows == 0) )
+ if(vpty->ncols == 0)
{
if(_term_init(vpty, argv, ncols, nrows) != 0)
{
@@ -732,9 +735,11 @@ d2tk_base_pty(d2tk_base_t *base, d2tk_id_t id, char **argv, d2tk_coord_t ncols,
if(_term_done(vpty))
{
_term_deinit(vpty);
+
+ state |= D2TK_STATE_CLOSE;
}
d2tk_base_set_style(base, old_style);
- return D2TK_STATE_NONE;
+ return state;
}