Discussion:
[tmux:tickets] #133 Line drawing characters become ascii letters on mouse highlight
Egmont Koblinger
2014-06-17 21:00:47 UTC
Permalink
---

** [tickets:#133] Line drawing characters become ascii letters on mouse highlight**

**Status:** open
**Created:** Tue Jun 17, 2014 09:00 PM UTC by Egmont Koblinger
**Last Updated:** Tue Jun 17, 2014 09:00 PM UTC
**Owner:** nobody

Inside tmux (current git) execute
echo -e '\e(0lqqqk'

Line drawing characters appear on the screen:
┌───┐

Now highlight with the mouse (tmux's builtin mouse handling).

Expected behavior: they stay line drawing characters.

Actual behavior: they become lqqqk instead.


---

Sent from sourceforge.net because tmux-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/tmux/tickets/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/tmux/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Balazs Kezes
2014-06-21 11:25:51 UTC
Permalink
Post by Egmont Koblinger
Inside tmux (current git) execute
echo -e '\e(0lqqqk'
┌───┐
Now highlight with the mouse (tmux's builtin mouse handling).
Expected behavior: they stay line drawing characters.
Actual behavior: they become lqqqk instead.
Nick: Is there any reason why in the code ACS is a cell attribute rather
than just directly writing the translated characters into the cell data?
I think the latter would simplify the code a bit also fixing this
particular bug.
--
Balazs
Nicholas Marriott
2014-06-21 23:58:36 UTC
Permalink
That would work for UTF-8 but unfortunately for ACS we need to use
smacs/rmacs so it has to be an attribute - unless you are suggesting
sending them for every ACS cell which would be inefficient.

This is probably the fix, but not tested.


Index: screen-write.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/screen-write.c,v
retrieving revision 1.69
diff -u -p -r1.69 screen-write.c
--- screen-write.c 17 Apr 2014 14:45:49 -0000 1.69
+++ screen-write.c 21 Jun 2014 23:55:59 -0000
@@ -990,6 +990,8 @@ screen_write_cell(struct screen_write_ct
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);
Post by Balazs Kezes
Post by Egmont Koblinger
Inside tmux (current git) execute
echo -e '\e(0lqqqk'
???????????????
Now highlight with the mouse (tmux's builtin mouse handling).
Expected behavior: they stay line drawing characters.
Actual behavior: they become lqqqk instead.
Nick: Is there any reason why in the code ACS is a cell attribute rather
than just directly writing the translated characters into the cell data?
I think the latter would simplify the code a bit also fixing this
particular bug.
--
Balazs
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Balazs Kezes
2014-06-22 10:03:27 UTC
Permalink
Post by Nicholas Marriott
That would work for UTF-8 but unfortunately for ACS we need to use
smacs/rmacs so it has to be an attribute - unless you are suggesting
sending them for every ACS cell which would be inefficient.
Ah, makes sense, thanks.
Post by Nicholas Marriott
This is probably the fix, but not tested.
I've tested it and it shows the characters correctly. But when I copy I
still get "lqqqk" in the clipboard.
--
Balazs
Nicholas Marriott
2014-06-23 07:04:47 UTC
Permalink
Well, I'm not sure what we can or should do about that. And in fact if
we're going to copy without ACS maybe we should continue to display the
characters without ACS.
Post by Balazs Kezes
Post by Nicholas Marriott
That would work for UTF-8 but unfortunately for ACS we need to use
smacs/rmacs so it has to be an attribute - unless you are suggesting
sending them for every ACS cell which would be inefficient.
Ah, makes sense, thanks.
Post by Nicholas Marriott
This is probably the fix, but not tested.
I've tested it and it shows the characters correctly. But when I copy I
still get "lqqqk" in the clipboard.
--
Balazs
Balazs Kezes
2014-06-23 18:32:28 UTC
Permalink
Post by Nicholas Marriott
Well, I'm not sure what we can or should do about that. And in fact if
we're going to copy without ACS maybe we should continue to display
the characters without ACS.
Not sure about the "should" part but would something along these lines
work?


diff --git a/screen-write.c b/screen-write.c
index 325fb9a..8c059d1 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -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/tty-acs.c b/tty-acs.c
index ae84f0d..140ad4d 100644
--- a/tty-acs.c
+++ b/tty-acs.c
@@ -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/window-copy.c b/window-copy.c
index 0775bcb..d1eb7d0 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -1579,6 +1579,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)) {
+ const char *acs = tty_acs_get(NULL, ud.data[0]);
+ if (acs != NULL) {
+ strcpy(ud.data, acs);
+ ud.size = strlen(acs);
+ }
+ }

*buf = xrealloc(*buf, 1, (*off) + ud.size);
memcpy(*buf + *off, ud.data, ud.size);
--
Balazs
Nicholas Marriott
2014-10-02 08:36:48 UTC
Permalink
Seems more useful than what we have, applied thanks.
Post by Balazs Kezes
Post by Nicholas Marriott
Well, I'm not sure what we can or should do about that. And in fact if
we're going to copy without ACS maybe we should continue to display
the characters without ACS.
Not sure about the "should" part but would something along these lines
work?
diff --git a/screen-write.c b/screen-write.c
index 325fb9a..8c059d1 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -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/tty-acs.c b/tty-acs.c
index ae84f0d..140ad4d 100644
--- a/tty-acs.c
+++ b/tty-acs.c
@@ -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/window-copy.c b/window-copy.c
index 0775bcb..d1eb7d0 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -1579,6 +1579,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)) {
+ const char *acs = tty_acs_get(NULL, ud.data[0]);
+ if (acs != NULL) {
+ strcpy(ud.data, acs);
+ ud.size = strlen(acs);
+ }
+ }
*buf = xrealloc(*buf, 1, (*off) + ud.size);
memcpy(*buf + *off, ud.data, ud.size);
--
Balazs
Loading...