Re: [PATCH] Window reference printable flag/format option

2015-05-04 Thread Thomas Adam
On Sun, May 03, 2015 at 09:08:51AM +0100, Nicholas Marriott wrote:
> 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 +.

Here's an updated version:

* Now just uses #{?window_flags,#{window_flags},} to check if there are
  any flags; removing the previous #{has_window_flags} format.

* The hard-coded space in window_printable_flags() has been removed,
  allowing expansion of that through formats instead.

-- Thomas Adam

-- 
"Deep in my heart I wish I was wrong.  But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)
>From 6fd7702571fcc64b26d184a9b790e4f3fafdf952 Mon Sep 17 00:00:00 2001
From: Thomas Adam 
Date: Sat, 2 May 2015 22:51:36 +0100
Subject: [PATCH] Window flags: window_linked

This primarily adds support for a new flag, 'window_linked' to indicate
whether the given window is linked across multiple sessions.  In the case of
grouped sessions, only those windows explicitly linked via lastw are
counted.  This is so that the flag doesn't always return 1 for windows in
grouped sessions.

To make this flag printable as part of the window_flags without hardcoding
it, and to not leave an extra space present (because no window flags means a
single space is printed), this extra space has been removed, and the default
options changed to add the space back in, so there's no regressions.

This means it's now entirely possible to override the window printable flags
through formats alone, albeit long-winded.
---
 format.c|  3 +++
 options-table.c |  4 ++--
 session.c   | 19 +++
 tmux.1  |  2 ++
 tmux.h  |  1 +
 window.c|  4 +---
 6 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/format.c b/format.c
index 9e9b6c8..871 100644
--- a/format.c
+++ b/format.c
@@ -602,6 +602,7 @@ format_defaults_winlink(struct format_tree *ft, struct session *s,
 {
 	struct window	*w = wl->window;
 	char		*flags;
+	int		 window_has_flags;
 
 	if (ft->w == NULL)
 		ft->w = wl->window;
@@ -622,6 +623,8 @@ format_defaults_winlink(struct format_tree *ft, struct session *s,
 	!!(wl->flags & WINLINK_SILENCE));
 	format_add(ft, "window_last_flag", "%d",
 	!!(wl == TAILQ_FIRST(&s->lastw)));
+	format_add(ft, "window_linked", "%d",
+	session_count_window_refs(s, wl) > 1);
 
 	free(flags);
 }
diff --git a/options-table.c b/options-table.c
index a4f3ac4..0bf6558 100644
--- a/options-table.c
+++ b/options-table.c
@@ -736,7 +736,7 @@ const struct options_table_entry window_options_table[] = {
 
 	{ .name = "window-status-current-format",
 	  .type = OPTIONS_TABLE_STRING,
-	  .default_str = "#I:#W#F"
+	  .default_str = "#I:#W#{?window_flags,#{window_flags},}"
 	},
 
 	{ .name = "window-status-current-style",
@@ -752,7 +752,7 @@ const struct options_table_entry window_options_table[] = {
 
 	{ .name = "window-status-format",
 	  .type = OPTIONS_TABLE_STRING,
-	  .default_str = "#I:#W#F"
+	  .default_str = "#I:#W#{?window_flags,#{window_flags}, }"
 	},
 
 	{ .name = "window-status-last-attr",
diff --git a/session.c b/session.c
index 7d86f68..072c84b 100644
--- a/session.c
+++ b/session.c
@@ -659,3 +659,22 @@ 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) {
+		/*
+		 * We only want to consider unique links for each session in a
+		 * group, and not all of them.
+		 */
+		return (session_group_count(sg) - wl->window->references);
+	} else
+		return (wl->window->references);
+}
diff --git a/tmux.1 b/tmux.1
index b97fd8a..f2861b9 100644
--- a/tmux.1
+++ b/tmux.1
@@ -3345,11 +3345,13 @@ The following variables are available, where appropriate:
 .It Li "window_bell_flag" Ta "" Ta "1 if window has bell"
 .It Li "window_find_matches" Ta "" Ta "Matched data from the find-window"
 .It Li "window_flags" Ta "#F" Ta "Window flags"
+.It Li "window_has_flags" Ta "1 if the window has flags"
 .It Li "window_height" Ta "" Ta "Height of window"
 .It Li "window_id" Ta "" Ta "Unique window ID"
 .It Li "window_index" Ta "#I" Ta "Index of window"
 .It Li "window_last_flag" Ta "" Ta "1 if window is the last used"
 .It Li "window_layout" Ta "" Ta "Window layout description"
+.It Li "window_linked" Ta "" Ta "1 if window is linked across sessions"
 .It Li "window_name" Ta "#W" Ta "Name of window"
 .It Li "window_panes" Ta "" Ta "Number of panes in window"
 .It Li "window_silence_flag" Ta "" Ta "1 if window has silence alert"
diff --git a/tmux.h b/tmux.h
index 4f8..012f7f8 100644
--- a/tmux.h
+++ b/tmux.h
@@ -2340,6 +

Re: tmux complete documentation.

2015-05-04 Thread Chas. Owens
On the command line: man tmux

On the Internet:
http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man1/tmux.1?query=tmux&sec=1

The specific section you are looking for:

split-window [-bdhvP] [-c start-directory] [-l size | -p percentage]
[-ttarget-pane] [shell-command] [-F format]

(alias: splitw)

Create a new pane by splitting target-pane: -h does a horizontal split
and -v a vertical split; if neither is specified, -v is assumed.
The -l and -p options specify the size of the new pane in lines (for
vertical split) or in cells (for horizontal split), or as a percentage,
respectively. The -b option causes the new pane to be created to the left
of or above target-pane. All other options have the same meaning as for
the new-window command.

On Mon, May 4, 2015, 04:46 Sinbad  wrote:

> hi,
> i'm unable to find the complete documentation of tmux, detailing the
> syntax of each and every
> aspect of tmux. for instance i'm trying to look for complete command
> syntax of 'split-window'
> command i'm unable to find it anywhere. when i type the command under tmux
> the syntax
> briefly appears and goes away. any pointers to complete documentation will
> be helpful.
>
> thanks
>
>
> --
> 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


tmux complete documentation.

2015-05-04 Thread Sinbad
hi,
i'm unable to find the complete documentation of tmux, detailing the syntax
of each and every
aspect of tmux. for instance i'm trying to look for complete command syntax
of 'split-window'
command i'm unable to find it anywhere. when i type the command under tmux
the syntax
briefly appears and goes away. any pointers to complete documentation will
be helpful.

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