Hi
Looks like the right idea - please break the BCE stuff out into a
separate diff and we can check it separately. I suggest adding a flag
TTY_NOBCE rather than looking up TTYC_BCE every time.
Also I don't want a new command, so this will need to be a flag (or two:
one for fg, one for for bg) on another command. Perhaps select-pane or
resize-pane? Or just display-panes?
I think you should do the default colour changes in tty_reset or perhaps
tty_colours rather than everywhere it gets passed in.
Thanks
On Wed, Feb 11, 2015 at 10:03:21PM -0600, J Raynor wrote:
> > This will not work as it is on terminals which do not support BCE. To
> > make it do so you will pretty much have to make tmux support BCE :-).
>
> Ok, it now works on systems that don't support BCE. I've attached a new
> patch.
> diff --git a/cmd-display-panes.c b/cmd-display-panes.c
> index 9ce8971..150b6f4 100644
> --- a/cmd-display-panes.c
> +++ b/cmd-display-panes.c
> @@ -18,14 +18,28 @@
>
> #include
>
> +#include
> +#include
> +
> #include "tmux.h"
>
> /*
> * Display panes on a client.
> + *
> + * Set or get pane default fg/bg colours.
> */
>
> +enum cmd_retval cmd_colour_pane_exec(struct cmd *, struct cmd_q *);
> enum cmd_retval cmd_display_panes_exec(struct cmd *, struct cmd_q *);
>
> +const struct cmd_entry cmd_colour_pane_entry = {
> + "colour-pane", "colourp",
> + "gt:APW", 0, 1,
> + CMD_TARGET_PANE_USAGE " [-A|P|W] colour-style",
> + 0,
> + cmd_colour_pane_exec
> +};
> +
> const struct cmd_entry cmd_display_panes_entry = {
> "display-panes", "displayp",
> "t:", 0, 0,
> @@ -47,3 +61,107 @@ cmd_display_panes_exec(struct cmd *self, struct cmd_q
> *cmdq)
>
> return (CMD_RETURN_NORMAL);
> }
> +
> +enum cmd_retval
> +cmd_colour_pane_exec(struct cmd *self, struct cmd_q *cmdq)
> +{
> + struct args *args = self->args;
> + struct session *s;
> + struct winlink *wl;
> + struct window_pane *wp;
> + int ret, nflags = 0;
> + struct grid_cell *gc;
> + const char *str;
> +
> +
> +
> + if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
> + return (CMD_RETURN_ERROR);
> +
> + if (args_has(args, 'g')) nflags++;
> + if (args_has(args, 'A')) nflags++;
> + if (args_has(args, 'P')) nflags++;
> + if (args_has(args, 'W')) nflags++;
> +
> + if (nflags == 0 || nflags > 1) {
> + cmdq_error(cmdq, "need exactly 1 of -g, -A, -P, or -W");
> + return (CMD_RETURN_ERROR);
> + }
> +
> + if (args_has(args, 'g')) {
> + if (args->argc > 0) {
> + cmdq_error(cmdq, "don't specify style with -g");
> + return (CMD_RETURN_ERROR);
> + }
> +
> + gc = wp->window->apcolgc;
> + if (gc == NULL)
> + str = "\"\"";
> + else
> + str = style_tostring(gc);
> + cmdq_print(cmdq, "active-pane %s", str);
> +
> +
> + gc = wp->colgc;
> + if (gc == NULL)
> + str = "\"\"";
> + else
> + str = style_tostring(gc);
> + cmdq_print(cmdq, "pane %s", str);
> +
> +
> + gc = wp->window->colgc;
> + if (gc == NULL)
> + str = "\"\"";
> + else
> + str = style_tostring(gc);
> + cmdq_print(cmdq, "window %s", str);
> +
> + return (CMD_RETURN_NORMAL);
> + }
> +
> + if (args->argc == 0) {
> + cmdq_error(cmdq, "need a style argument");
> + return (CMD_RETURN_ERROR);
> + }
> +
> + str = args->argv[0];
> + if (*str == '\0')
> + gc = NULL;
> + else {
> + gc = xmalloc(sizeof *gc);
> + memcpy(gc, &grid_default_cell, sizeof *gc);
> + ret = style_parse(&grid_default_cell, gc, str);
> +
> + if (ret == -1) {
> + free(gc);
> + cmdq_error(cmdq, "bad colour style");
> + return (CMD_RETURN_ERROR);
> + }
> +
> + gc->attr = grid_default_cell.attr;
> + }
> +
> + if (args_has(args, 'A')) {
> + free(wp->window->apcolgc);
> + wp->window->apcolgc = gc;
> + server_redraw_window(wp->window);
> + return (CMD_RETURN_NORMAL);
> + }
> +
> + if (args_has(args, 'P')) {
> + free(wp->colgc);
> + wp->colgc = gc;
> + wp->flags |= PANE_REDRAW;
> + return (CMD_RETURN_NORMAL);
> + }
> +
> + if (args_has(args, 'W')) {
> + free(wp->window->colgc);
> + wp->window->colgc = gc;
> + server_redraw_window(wp->window);
> + return (CMD_RETURN_NORMAL);
> + }
> +
> + return (CMD_RETURN_NORMAL);
> +}