Hi

format_defaults_window can't rely on ft->s being set. Perhaps you want
to put it in format_defaults_winlink, although check if that always has
the session.

I don't think it's good that every window in a grouped session should
suddenly grow a +.

Possibly you should just add the format and then add
#{?window_references,+,,} to window-status-format yourself rather than
making it a new fixed flag.

Also I think the count will be incorrect if the window is linked into
multiple non-grouped sessions and also in grouped sessions, if you don't
want to make it exact a 0 or 1 would be better.

I think I'd call it window_sessions if it's an exact count, or
window_linked if it is a flag.


On Sat, May 02, 2015 at 10:57:20PM +0100, Thomas Adam wrote:
> This adds support for indicating in the status line whether a given window
> has been referenced more than once.  In the case of grouped sessions this is
> likely always going to be the case, but this also helps in showing which
> windows in a session have been included via linkw, for example.  Currently,
> the window printable flag for this is '+'.
> 
> Also, add the corresponding #{window_references} flag for returning the
> number of references on the window.
> ---
>  format.c  |  2 ++
>  session.c | 15 +++++++++++++++
>  tmux.1    |  2 ++
>  tmux.h    |  1 +
>  window.c  |  2 ++
>  5 files changed, 22 insertions(+)
> 
> diff --git a/format.c b/format.c
> index 9e9b6c8..a388a9a 100644
> --- a/format.c
> +++ b/format.c
> @@ -589,6 +589,8 @@ format_defaults_window(struct format_tree *ft, struct 
> window *w)
>       format_add(ft, "window_height", "%u", w->sy);
>       format_add(ft, "window_layout", "%s", layout);
>       format_add(ft, "window_panes", "%u", window_count_panes(w));
> +     format_add(ft, "window_references", "%u",
> +         session_count_window_refs(ft->s, ft->s->curw));
>       format_add(ft, "window_zoomed_flag", "%d",
>           !!(w->flags & WINDOW_ZOOMED));
>  
> diff --git a/session.c b/session.c
> index 7d86f68..4076053 100644
> --- a/session.c
> +++ b/session.c
> @@ -659,3 +659,18 @@ session_renumber_windows(struct session *s)
>       RB_FOREACH_SAFE(wl, winlinks, &old_wins, wl1)
>               winlink_remove(&old_wins, wl);
>  }
> +
> +/*
> + * Returns the number of refences on a window, which may be across a session
> + * group.
> + */
> +u_int
> +session_count_window_refs(struct session *s, struct winlink *wl)
> +{
> +     struct session_group    *sg;
> +
> +     if ((sg = session_group_find(s)) != NULL)
> +             return (session_group_count(sg));
> +     else
> +             return (wl->window->references);
> +}
> diff --git a/tmux.1 b/tmux.1
> index b97fd8a..3e186d2 100644
> --- a/tmux.1
> +++ b/tmux.1
> @@ -3352,6 +3352,7 @@ The following variables are available, where 
> appropriate:
>  .It Li "window_layout" Ta "" Ta "Window layout description"
>  .It Li "window_name" Ta "#W" Ta "Name of window"
>  .It Li "window_panes" Ta "" Ta "Number of panes in window"
> +.It Li "window_references" Ta "" Ta "Number of references a window has"
>  .It Li "window_silence_flag" Ta "" Ta "1 if window has silence alert"
>  .It Li "window_width" Ta "" Ta "Width of window"
>  .It Li "window_zoomed_flag" Ta "" Ta "1 if window is zoomed"
> @@ -3508,6 +3509,7 @@ The flag is one of the following symbols appended to 
> the window name:
>  .It Li "!" Ta "A bell has occurred in the window."
>  .It Li "~" Ta "The window has been silent for the monitor-silence interval."
>  .It Li "Z" Ta "The window's active pane is zoomed."
> +.It Li "+" Ta "The window has been linked from another session."
>  .El
>  .Pp
>  The # symbol relates to the
> diff --git a/tmux.h b/tmux.h
> index dddd4f8..012f7f8 100644
> --- a/tmux.h
> +++ b/tmux.h
> @@ -2340,6 +2340,7 @@ void             session_group_synchronize_to(struct 
> session *);
>  void          session_group_synchronize_from(struct session *);
>  void          session_group_synchronize1(struct session *, struct session *);
>  void          session_renumber_windows(struct session *);
> +u_int                 session_count_window_refs(struct session *, struct 
> winlink *);
>  
>  /* utf8.c */
>  void          utf8_build(void);
> diff --git a/window.c b/window.c
> index 57e8ae4..57db62a 100644
> --- a/window.c
> +++ b/window.c
> @@ -662,6 +662,8 @@ window_printable_flags(struct session *s, struct winlink 
> *wl)
>               flags[pos++] = '-';
>       if (wl->window->flags & WINDOW_ZOOMED)
>               flags[pos++] = 'Z';
> +     if (session_count_window_refs(s, wl) > 1)
> +             flags[pos++] = '+';
>       if (pos == 0)
>               flags[pos++] = ' ';
>       flags[pos] = '\0';
> -- 
> 2.1.4
> 
> 
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud 
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to