aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2019-12-10 09:55:42 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2019-12-10 09:55:42 +0100
commit6837027fd885a3617fcebeae2cd74788d48ae8df (patch)
tree1c5a3300e755da51cbcdfb423e1e52945788fbe6
parent05bc0c9376be0f4d495fad7664c5478a915a04f0 (diff)
downloadd2tk-6837027fd885a3617fcebeae2cd74788d48ae8df.tar.xz
base: split pty into behave an draw functions.
-rw-r--r--VERSION2
-rw-r--r--src/base.c2
-rw-r--r--src/base_pty.c76
3 files changed, 41 insertions, 39 deletions
diff --git a/VERSION b/VERSION
index c43ab73..af4df06 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.907
+0.1.909
diff --git a/src/base.c b/src/base.c
index 1cffff6..deb8900 100644
--- a/src/base.c
+++ b/src/base.c
@@ -774,6 +774,8 @@ d2tk_base_post(d2tk_base_t *base)
base->focused = false;
}
+ _d2tk_base_clear_chars(base);
+
d2tk_core_post(base->core);
}
diff --git a/src/base_pty.c b/src/base_pty.c
index eec2279..a106f5b 100644
--- a/src/base_pty.c
+++ b/src/base_pty.c
@@ -497,8 +497,8 @@ _term_input(d2tk_atom_body_pty_t *vpty)
return 0;
}
-static inline void
-_term_draw(d2tk_base_t *base, d2tk_atom_body_pty_t *vpty,
+static inline void
+_term_behave(d2tk_base_t *base, d2tk_atom_body_pty_t *vpty,
const d2tk_rect_t *rect)
{
const d2tk_state_t state = d2tk_base_is_active_hot(base, D2TK_ID, rect,
@@ -564,37 +564,6 @@ _term_draw(d2tk_base_t *base, d2tk_atom_body_pty_t *vpty,
{
vterm_keyboard_key(vpty->vterm, VTERM_KEY_PAGEDOWN, VTERM_MOD_NONE);
}
- }
-
- if(d2tk_state_is_hot(state))
- {
- {
- d2tk_coord_t mx, my;
- int dx, dy;
- d2tk_base_get_mouse_pos(base, &mx, &my);
- d2tk_base_get_mouse_scroll(base, &dx, &dy, false);
-
- const int row = (my - rect->y) * vpty->nrows / rect->h;
- const int col = (mx - rect->x) * vpty->ncols / rect->w;
-
- vterm_mouse_move(vpty->vterm, row, col, VTERM_MOD_NONE);
-
- vterm_mouse_button(vpty->vterm, 1,
- d2tk_base_get_butmask(base, D2TK_BUTMASK_LEFT, false), VTERM_MOD_NONE);
- vterm_mouse_button(vpty->vterm, 2,
- d2tk_base_get_butmask(base, D2TK_BUTMASK_MIDDLE, false), VTERM_MOD_NONE);
- vterm_mouse_button(vpty->vterm, 3,
- d2tk_base_get_butmask(base, D2TK_BUTMASK_RIGHT, false), VTERM_MOD_NONE);
-
- if(dy > 0)
- {
- vterm_mouse_button(vpty->vterm, 4, true, VTERM_MOD_NONE);
- }
- else if(dy < 0)
- {
- vterm_mouse_button(vpty->vterm, 5, true, VTERM_MOD_NONE);
- }
- }
{
ssize_t len = 0;
@@ -609,6 +578,40 @@ _term_draw(d2tk_base_t *base, d2tk_atom_body_pty_t *vpty,
}
}
+ if(d2tk_state_is_hot(state))
+ {
+ d2tk_coord_t mx, my;
+ int dx, dy;
+ d2tk_base_get_mouse_pos(base, &mx, &my);
+ d2tk_base_get_mouse_scroll(base, &dx, &dy, false);
+
+ const int row = (my - rect->y) * vpty->nrows / rect->h;
+ const int col = (mx - rect->x) * vpty->ncols / rect->w;
+
+ vterm_mouse_move(vpty->vterm, row, col, VTERM_MOD_NONE);
+
+ vterm_mouse_button(vpty->vterm, 1,
+ d2tk_base_get_butmask(base, D2TK_BUTMASK_LEFT, false), VTERM_MOD_NONE);
+ vterm_mouse_button(vpty->vterm, 2,
+ d2tk_base_get_butmask(base, D2TK_BUTMASK_MIDDLE, false), VTERM_MOD_NONE);
+ vterm_mouse_button(vpty->vterm, 3,
+ d2tk_base_get_butmask(base, D2TK_BUTMASK_RIGHT, false), VTERM_MOD_NONE);
+
+ if(dy > 0)
+ {
+ vterm_mouse_button(vpty->vterm, 4, true, VTERM_MOD_NONE);
+ }
+ else if(dy < 0)
+ {
+ vterm_mouse_button(vpty->vterm, 5, true, VTERM_MOD_NONE);
+ }
+ }
+}
+
+static inline void
+_term_draw(d2tk_base_t *base, d2tk_atom_body_pty_t *vpty,
+ const d2tk_rect_t *rect)
+{
D2TK_BASE_TABLE(rect, vpty->ncols, vpty->nrows, D2TK_FLAG_TABLE_REL, tab)
{
const int x = d2tk_table_get_index_x(tab);
@@ -729,6 +732,8 @@ d2tk_base_pty(d2tk_base_t *base, d2tk_id_t id, char **argv, d2tk_coord_t height,
_term_resize(vpty, ncols, nrows);
+ _term_behave(base, vpty, rect);
+
if(_term_input(vpty))
{
vpty->again = true;
@@ -736,11 +741,6 @@ d2tk_base_pty(d2tk_base_t *base, d2tk_id_t id, char **argv, d2tk_coord_t height,
_term_draw(base, vpty, rect);
- if(_term_input(vpty))
- {
- vpty->again = true;
- }
-
if(vpty->again)
{
d2tk_base_set_again(base);