aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2019-12-30 21:46:16 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2019-12-30 21:46:16 +0100
commitbe052e7b1f04afdaf6cea1bae595d1872c87d69e (patch)
tree423aad79b7f770964bb8f1009f79dc2abfa7a588
parent4d4595b988ea488e9b55251822f7415b6c8da9bd (diff)
downloadd2tk-be052e7b1f04afdaf6cea1bae595d1872c87d69e.tar.xz
base: capture terminal bell.
-rw-r--r--VERSION2
-rw-r--r--d2tk/base.h6
-rw-r--r--src/base.c6
-rw-r--r--src/base_pty.c19
-rw-r--r--test/base.c3
5 files changed, 34 insertions, 2 deletions
diff --git a/VERSION b/VERSION
index b8f9776..8f1a1d5 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.939
+0.1.941
diff --git a/d2tk/base.h b/d2tk/base.h
index 07b95ca..38108e7 100644
--- a/d2tk/base.h
+++ b/d2tk/base.h
@@ -132,7 +132,8 @@ typedef enum _d2tk_state_t {
D2TK_STATE_CHANGED = (1 << 12),
D2TK_STATE_ENTER = (1 << 13),
D2TK_STATE_OVER = (1 << 14),
- D2TK_STATE_CLOSE = (1 << 15)
+ D2TK_STATE_CLOSE = (1 << 15),
+ D2TK_STATE_BELL = (1 << 16)
} d2tk_state_t;
typedef enum _d2tk_flag_t {
@@ -356,6 +357,9 @@ D2TK_API bool
d2tk_state_is_close(d2tk_state_t state);
D2TK_API bool
+d2tk_state_is_bell(d2tk_state_t state);
+
+D2TK_API bool
d2tk_base_is_hit(d2tk_base_t *base, const d2tk_rect_t *rect);
D2TK_API void
diff --git a/src/base.c b/src/base.c
index 81f546e..63c11f7 100644
--- a/src/base.c
+++ b/src/base.c
@@ -342,6 +342,12 @@ d2tk_state_is_close(d2tk_state_t state)
}
D2TK_API bool
+d2tk_state_is_bell(d2tk_state_t state)
+{
+ return (state & D2TK_STATE_BELL);
+}
+
+D2TK_API bool
d2tk_base_is_hit(d2tk_base_t *base, const d2tk_rect_t *rect)
{
if( (base->mouse.x < rect->x)
diff --git a/src/base_pty.c b/src/base_pty.c
index 4d25007..2255fb3 100644
--- a/src/base_pty.c
+++ b/src/base_pty.c
@@ -57,6 +57,7 @@ struct _d2tk_atom_body_pty_t {
d2tk_coord_t ncols;
d2tk_coord_t nrows;
+ unsigned bell;
int fd;
pid_t kid;
@@ -205,8 +206,19 @@ _screen_resize(int nrows, int ncols, void *data)
return 0;
}
+static int
+_screen_bell(void *data)
+{
+ d2tk_atom_body_pty_t *vpty = data;
+
+ vpty->bell += 1;
+
+ return 0;
+}
+
static const VTermScreenCallbacks screen_callbacks = {
.settermprop = _screen_settermprop,
+ .bell = _screen_bell,
.resize = _screen_resize
};
@@ -885,6 +897,13 @@ d2tk_base_pty(d2tk_base_t *base, d2tk_id_t id, d2tk_clone_t clone, void *data,
state |= D2TK_STATE_CLOSE;
}
+ if(vpty->bell)
+ {
+ state |= D2TK_STATE_BELL;
+
+ vpty->bell = 0;
+ }
+
d2tk_base_set_style(base, old_style);
return state;
diff --git a/test/base.c b/test/base.c
index 0a50c7f..7405a31 100644
--- a/test/base.c
+++ b/test/base.c
@@ -1437,6 +1437,9 @@ _test_state()
assert(d2tk_state_is_close(D2TK_STATE_CLOSE));
assert(!d2tk_state_is_close(D2TK_STATE_NONE));
+
+ assert(d2tk_state_is_bell(D2TK_STATE_BELL));
+ assert(!d2tk_state_is_bell(D2TK_STATE_NONE));
}
static void