summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2014-10-02 08:36:27 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2014-10-02 08:36:27 +0000
commit8c0aeacb54f02f1a0636067147ddc62e033e1465 (patch)
tree6b259248f045f2fb60d6ff92351f00a0fe02a864
parent7bf169ff2d1a22fa719ed88ff56346d8e4e24a95 (diff)
Copy ACS characters as UTF-8, from Balazs Kezes.
-rw-r--r--usr.bin/tmux/screen-write.c4
-rw-r--r--usr.bin/tmux/tty-acs.c4
-rw-r--r--usr.bin/tmux/window-copy.c10
3 files changed, 14 insertions, 4 deletions
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c
index 3d3220a162d..e9d52c3f88b 100644
--- a/usr.bin/tmux/screen-write.c
+++ b/usr.bin/tmux/screen-write.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen-write.c,v 1.69 2014/04/17 14:45:49 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.70 2014/10/02 08:36:26 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -990,6 +990,8 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
memcpy(&tmp_gc, &s->sel.cell, sizeof tmp_gc);
grid_cell_get(gc, &ud);
grid_cell_set(&tmp_gc, &ud);
+ tmp_gc.attr = tmp_gc.attr & ~GRID_ATTR_CHARSET;
+ tmp_gc.attr |= gc->attr & GRID_ATTR_CHARSET;
tmp_gc.flags = gc->flags & ~(GRID_FLAG_FG256|GRID_FLAG_BG256);
tmp_gc.flags |= s->sel.cell.flags &
(GRID_FLAG_FG256|GRID_FLAG_BG256);
diff --git a/usr.bin/tmux/tty-acs.c b/usr.bin/tmux/tty-acs.c
index 45a73782c63..83703e95661 100644
--- a/usr.bin/tmux/tty-acs.c
+++ b/usr.bin/tmux/tty-acs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty-acs.c,v 1.2 2013/11/24 19:38:32 nicm Exp $ */
+/* $OpenBSD: tty-acs.c,v 1.3 2014/10/02 08:36:26 nicm Exp $ */
/*
* Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -81,7 +81,7 @@ tty_acs_get(struct tty *tty, u_char ch)
struct tty_acs_entry *entry;
/* If not a UTF-8 terminal, use the ACS set. */
- if (!(tty->flags & TTY_UTF8)) {
+ if (tty != NULL && !(tty->flags & TTY_UTF8)) {
if (tty->term->acs[ch][0] == '\0')
return (NULL);
return (&tty->term->acs[ch][0]);
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index 6cefc9e8af4..bc650e9a399 100644
--- a/usr.bin/tmux/window-copy.c
+++ b/usr.bin/tmux/window-copy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-copy.c,v 1.114 2014/09/01 21:50:18 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.115 2014/10/02 08:36:26 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1552,6 +1552,7 @@ window_copy_copy_line(struct window_pane *wp,
struct grid_line *gl;
struct utf8_data ud;
u_int i, xx, wrapped = 0;
+ const char *s;
if (sx > ex)
return;
@@ -1580,6 +1581,13 @@ window_copy_copy_line(struct window_pane *wp,
if (gc->flags & GRID_FLAG_PADDING)
continue;
grid_cell_get(gc, &ud);
+ if (ud.size == 1 && (gc->attr & GRID_ATTR_CHARSET)) {
+ s = tty_acs_get(NULL, ud.data[0]);
+ if (s != NULL && strlen(s) <= sizeof ud.data) {
+ ud.size = strlen(s);
+ memcpy (ud.data, s, ud.size);
+ }
+ }
*buf = xrealloc(*buf, 1, (*off) + ud.size);
memcpy(*buf + *off, ud.data, ud.size);