Nicholas Marriott <nicholas.marri...@gmail.com> writes: > Don't think I want to use UTF-8 arrows unless the ACS arrows will work > too.
Ok. Conceptually we just have to use smacs/rmacs around the codes when writing to the terminal and it should work, right? I tried the naive approach below and the escape sequences are not interpreted, just output in the string. I guess the screen layer prevents writing directly to the terminal from the window-choose code? Or is the terminal in the wrong mode to do that? Do you see any way to make this work at all? Thanks. diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c index dd6dd3b..2b5fe06 100644 --- a/cmd-choose-tree.c +++ b/cmd-choose-tree.c @@ -74,6 +74,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx) struct args *args = self->args; struct winlink *wl, *wm; struct session *s, *s2; + struct tty *tty; struct window_choose_data *wcd = NULL; const char *ses_template, *win_template; char *final_win_action, *cur_win_template; @@ -92,6 +93,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx) } s = ctx->curclient->session; + tty = &ctx->curclient->tty; if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) return (CMD_RETURN_ERROR); @@ -149,8 +151,30 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx) * without any padding. */ if (wflag && sflag) { - xasprintf(&final_win_template_middle, " |-> %s", win_template); - xasprintf(&final_win_template_last, " \\-> %s", win_template); + if (tty_use_acs(tty)) { + xasprintf(&final_win_template_middle, " %s%s%s%s> %s", + tty_term_string(tty->term, TTYC_SMACS), + tty_acs_get(tty, 't'), tty_acs_get(tty, 'q'), + tty_term_string(tty->term, TTYC_RMACS), + win_template); + xasprintf(&final_win_template_last, " %s%s%s%s> %s", + tty_term_string(tty->term, TTYC_SMACS), + tty_acs_get(tty, 'm'), tty_acs_get(tty, 'q'), + tty_term_string(tty->term, TTYC_RMACS), + win_template); + } else if (tty->flags & TTY_UTF8) { + xasprintf(&final_win_template_middle, " %s%s> %s", + tty_acs_get(tty, 't'), tty_acs_get(tty, 'q'), + win_template); + xasprintf(&final_win_template_last, " %s%s> %s", + tty_acs_get(tty, 'm'), tty_acs_get(tty, 'q'), + win_template); + } else { + xasprintf(&final_win_template_middle, " |-> %s", + win_template); + xasprintf(&final_win_template_last, " \\-> %s", + win_template); + } } else if (wflag) { final_win_template_middle = xstrdup(win_template); final_win_template_last = xstrdup(win_template); diff --git a/tmux.h b/tmux.h index 9374012..dae2a83 100644 --- a/tmux.h +++ b/tmux.h @@ -423,6 +423,9 @@ struct tty_term_code_entry { const char *name; }; +#define tty_use_acs(tty) \ + (tty_term_has((tty)->term, TTYC_ACSC) && !((tty)->flags & TTY_UTF8)) + /* Message codes. */ enum msgtype { MSG_COMMAND, diff --git a/tty.c b/tty.c index fdc0551..6582da1 100644 --- a/tty.c +++ b/tty.c @@ -51,9 +51,6 @@ void tty_repeat_space(struct tty *, u_int); void tty_cell(struct tty *, const struct grid_cell *, const struct grid_utf8 *); -#define tty_use_acs(tty) \ - (tty_term_has((tty)->term, TTYC_ACSC) && !((tty)->flags & TTY_UTF8)) - #define tty_pane_full_width(tty, ctx) \ ((ctx)->xoff == 0 && screen_size_x((ctx)->wp->screen) >= (tty)->sx) ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users