Hi

Sorry for delay.

Do you need this for something else, not sure it saves enough code to be
worth it?


On Sun, Jul 15, 2012 at 12:31:10PM +0100, Thomas Adam wrote:
> Create a function for setting a given grid_cell to the mode-* values, and
> use it.
> ---
>  trunk/tmux.h        |    1 +
>  trunk/window-copy.c |   10 ++--------
>  trunk/window.c      |   10 ++++++++++
>  3 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/trunk/tmux.h b/trunk/tmux.h
> index 3fbec0c..c6a7e96 100644
> --- a/trunk/tmux.h
> +++ b/trunk/tmux.h
> @@ -2087,6 +2087,7 @@ void             window_set_name(struct window *, const 
> char *);
>  void          winlink_clear_flags(struct winlink *);
>  void          winlink_set_alert_colours(
>                   struct winlink *, struct grid_cell *);
> +void          window_mode_attrs(struct grid_cell *, struct options *);
>  
>  /* layout.c */
>  u_int                 layout_count_cells(struct layout_cell *);
> diff --git a/trunk/window-copy.c b/trunk/window-copy.c
> index 35742a6..6d18dd4 100644
> --- a/trunk/window-copy.c
> +++ b/trunk/window-copy.c
> @@ -1115,10 +1115,7 @@ window_copy_write_line(
>       char                             hdr[32];
>       size_t                           last, xoff = 0, size = 0;
>  
> -     memcpy(&gc, &grid_default_cell, sizeof gc);
> -     colour_set_fg(&gc, options_get_number(oo, "mode-fg"));
> -     colour_set_bg(&gc, options_get_number(oo, "mode-bg"));
> -     gc.attr |= options_get_number(oo, "mode-attr");
> +     window_mode_attrs(&gc, oo);
>  
>       last = screen_size_y(s) - 1;
>       if (py == 0) {
> @@ -1232,10 +1229,7 @@ window_copy_update_selection(struct window_pane *wp)
>               return (0);
>  
>       /* Set colours. */
> -     memcpy(&gc, &grid_default_cell, sizeof gc);
> -     colour_set_fg(&gc, options_get_number(oo, "mode-fg"));
> -     colour_set_bg(&gc, options_get_number(oo, "mode-bg"));
> -     gc.attr |= options_get_number(oo, "mode-attr");
> +     window_mode_attrs(&gc, oo);
>  
>       /* Find top of screen. */
>       ty = screen_hsize(data->backing) - data->oy;
> diff --git a/trunk/window.c b/trunk/window.c
> index 5e2d65c..8b66c52 100644
> --- a/trunk/window.c
> +++ b/trunk/window.c
> @@ -1238,3 +1238,13 @@ winlink_set_alert_colours(struct winlink *wl, struct 
> grid_cell *gc)
>                       gc->attr = attr;
>       }
>  }
> +
> +/* Set the grid_cell with fg/bg/attr information when window is in a mode. */
> +void
> +window_mode_attrs(struct grid_cell *gc, struct options *oo)
> +{
> +     memcpy(gc, &grid_default_cell, sizeof gc);
> +     colour_set_fg(gc, options_get_number(oo, "mode-fg"));
> +     colour_set_bg(gc, options_get_number(oo, "mode-bg"));
> +     gc->attr |= options_get_number(oo, "mode-attr");
> +}
> -- 
> 1.7.10
> 
> 
> ------------------------------------------------------------------------------
> 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

------------------------------------------------------------------------------
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

Reply via email to