aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2021-08-06 12:01:24 +0100
committerThomas Adam <thomas@xteddy.org>2021-08-06 12:01:24 +0100
commit33e332428c41408cc51ade69c9cbf1994dbab431 (patch)
treea771e45f1b6b582ebcab089cf2226e60446a58bd
parent4bccff95566c64ae99935b74a603203a1530a360 (diff)
parent24cd6851f6a4e0152f59d22bf446e553cd7f23f9 (diff)
downloadrtmux-33e332428c41408cc51ade69c9cbf1994dbab431.tar.gz
rtmux-33e332428c41408cc51ade69c9cbf1994dbab431.tar.bz2
rtmux-33e332428c41408cc51ade69c9cbf1994dbab431.zip
Merge branch 'obsd-master' into master
-rw-r--r--options-table.c2
-rw-r--r--screen-write.c32
-rw-r--r--tmux.14
-rw-r--r--tmux.h1
-rw-r--r--tty-keys.c7
5 files changed, 40 insertions, 6 deletions
diff --git a/options-table.c b/options-table.c
index 674c96f1..4460c951 100644
--- a/options-table.c
+++ b/options-table.c
@@ -1147,6 +1147,8 @@ const struct options_table_entry options_table[] = {
OPTIONS_TABLE_HOOK("client-active", ""),
OPTIONS_TABLE_HOOK("client-attached", ""),
OPTIONS_TABLE_HOOK("client-detached", ""),
+ OPTIONS_TABLE_HOOK("client-focus-in", ""),
+ OPTIONS_TABLE_HOOK("client-focus-out", ""),
OPTIONS_TABLE_HOOK("client-resized", ""),
OPTIONS_TABLE_HOOK("client-session-changed", ""),
OPTIONS_TABLE_PANE_HOOK("pane-died", ""),
diff --git a/screen-write.c b/screen-write.c
index 8cc81f92..b04155c3 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -1726,6 +1726,8 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
{
struct screen *s = ctx->s;
struct grid *gd = s->grid;
+ const struct utf8_data *ud = &gc->data;
+ const struct utf8_data zwj = { "\342\200\215", 0, 3, 0 };
struct grid_line *gl;
struct grid_cell_entry *gce;
struct grid_cell tmp_gc, now_gc;
@@ -1738,16 +1740,38 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
if (gc->flags & GRID_FLAG_PADDING)
return;
- /* If the width is zero, combine onto the previous character. */
- if (width == 0) {
+ /*
+ * If this is a zero width joiner, set the flag so the next character
+ * will be treated as zero width and appended. Note that we assume a
+ * ZWJ will not change the width - the width of the first character is
+ * used.
+ */
+ if (ud->size == 3 && memcmp(ud->data, "\342\200\215", 3) == 0) {
+ log_debug("zero width joiner at %u,%u", s->cx, s->cy);
+ ctx->flags |= SCREEN_WRITE_ZWJ;
+ return;
+ }
+
+ /*
+ * If the width is zero, combine onto the previous character. We always
+ * combine with the cell to the left of the cursor position. In theory,
+ * the application could have moved the cursor somewhere else, but if
+ * they are silly enough to do that, who cares?
+ */
+ if (ctx->flags & SCREEN_WRITE_ZWJ) {
+ screen_write_collect_flush(ctx, 0, __func__);
+ screen_write_combine(ctx, &zwj, &xx);
+ }
+ if (width == 0 || (ctx->flags & SCREEN_WRITE_ZWJ)) {
+ ctx->flags &= ~SCREEN_WRITE_ZWJ;
screen_write_collect_flush(ctx, 0, __func__);
- if ((gc = screen_write_combine(ctx, &gc->data, &xx)) != 0) {
+ if ((gc = screen_write_combine(ctx, ud, &xx)) != 0) {
cx = s->cx; cy = s->cy;
screen_write_set_cursor(ctx, xx, s->cy);
screen_write_initctx(ctx, &ttyctx, 0);
ttyctx.cell = gc;
tty_write(tty_cmd_cell, &ttyctx);
- s->cx = cx; s->cy = cy;
+ s->cx = xx + gc->data.width; s->cy = cy;
}
return;
}
diff --git a/tmux.1 b/tmux.1
index 3f9589ae..de9d023b 100644
--- a/tmux.1
+++ b/tmux.1
@@ -4402,6 +4402,10 @@ Run when a client becomes the latest active client of its session.
Run when a client is attached.
.It client-detached
Run when a client is detached
+.It client-focus-in
+Run when focus enters a client
+.It client-focus-out
+Run when focus exits a client
.It client-resized
Run when a client is resized.
.It client-session-changed
diff --git a/tmux.h b/tmux.h
index e23044ba..c65651b8 100644
--- a/tmux.h
+++ b/tmux.h
@@ -867,6 +867,7 @@ struct screen_write_ctx {
int flags;
#define SCREEN_WRITE_SYNC 0x1
+#define SCREEN_WRITE_ZWJ 0x2
screen_write_init_ctx_cb init_ctx_cb;
void *arg;
diff --git a/tty-keys.c b/tty-keys.c
index 3012be3d..02fba0e5 100644
--- a/tty-keys.c
+++ b/tty-keys.c
@@ -820,10 +820,13 @@ complete_key:
tty->flags &= ~TTY_TIMER;
/* Check for focus events. */
- if (key == KEYC_FOCUS_OUT)
+ if (key == KEYC_FOCUS_OUT) {
tty->client->flags &= ~CLIENT_FOCUSED;
- else if (key == KEYC_FOCUS_IN)
+ notify_client("client-focus-out", c);
+ } else if (key == KEYC_FOCUS_IN) {
tty->client->flags |= CLIENT_FOCUSED;
+ notify_client("client-focus-in", c);
+ }
/* Fire the key. */
if (key != KEYC_UNKNOWN) {