Here's what I'd do for just the window id bits. I'm not quite sure about
how to do the list-windows target yet, I need to fiddle with it more.

Adding pane id to layout can be separate too.

I'm not sure if you told me, but what are you using the session id for?
Session names are unique, so why is another id desirable?


Index: cmd-list-windows.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/cmd-list-windows.c,v
retrieving revision 1.16
diff -u -p -r1.16 cmd-list-windows.c
--- cmd-list-windows.c  23 Sep 2011 12:23:24 -0000      1.16
+++ cmd-list-windows.c  29 Jan 2012 22:32:25 -0000
@@ -87,14 +87,14 @@ cmd_list_windows_session(
                        template = "#{window_index}: "
                            "#{window_name} "
                            "[#{window_width}x#{window_height}] "
-                           "[layout #{window_layout}]"
+                           "[layout #{window_layout}] #{window_id}"
                            "#{?window_active, (active),}";
                        break;
                case 1:
                        template = "#{session_name}:#{window_index}: "
                            "#{window_name} "
                            "[#{window_width}x#{window_height}] "
-                           "[layout #{window_layout}]"
+                           "[layout #{window_layout}] #{window_id} "
                            "#{?window_active, (active),}";
                        break;
                }
Index: cmd.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/cmd.c,v
retrieving revision 1.59
diff -u -p -r1.59 cmd.c
--- cmd.c       20 Jan 2012 19:54:07 -0000      1.59
+++ cmd.c       29 Jan 2012 22:32:26 -0000
@@ -120,8 +120,10 @@ struct session     *cmd_lookup_session(const
 struct winlink *cmd_lookup_window(struct session *, const char *, int *);
 int             cmd_lookup_index(struct session *, const char *, int *);
 struct window_pane *cmd_lookup_paneid(const char *);
-struct session *cmd_pane_session(struct cmd_ctx *,
-                   struct window_pane *, struct winlink **);
+struct winlink *cmd_lookup_winlink_windowid(struct session *, const char *);
+struct window  *cmd_lookup_windowid(const char *);
+struct session *cmd_window_session(struct cmd_ctx *,
+                   struct window *, struct winlink **);
 struct winlink *cmd_find_window_offset(const char *, struct session *, int *);
 int             cmd_find_index_offset(const char *, struct session *, int *);
 struct window_pane *cmd_find_pane_offset(const char *, struct winlink *);
@@ -587,6 +589,10 @@ cmd_lookup_window(struct session *s, con
 
        *ambiguous = 0;
 
+       /* Try as a window id. */
+       if ((wl = cmd_lookup_winlink_windowid(s, name)) != NULL)
+           return (wl);
+
        /* First see if this is a valid window index in this session. */
        idx = strtonum(name, 0, INT_MAX, &errstr);
        if (errstr == NULL) {
@@ -649,10 +655,7 @@ cmd_lookup_index(struct session *s, cons
        return (-1);
 }
 
-/*
- * Lookup pane id. An initial % means a pane id. sp must already point to the
- * current session.
- */
+/* Lookup pane id. An initial % means a pane id. */
 struct window_pane *
 cmd_lookup_paneid(const char *arg)
 {
@@ -668,19 +671,50 @@ cmd_lookup_paneid(const char *arg)
        return (window_pane_find_by_id(paneid));
 }
 
-/* Find session and winlink for pane. */
+/* Lookup window id in a session. An initial @ means a window id. */
+struct winlink *
+cmd_lookup_winlink_windowid(struct session *s, const char *arg)
+{
+       const char      *errstr;
+       u_int            windowid;
+
+       if (*arg != '@')
+               return (NULL);
+
+       windowid = strtonum(arg + 1, 0, UINT_MAX, &errstr);
+       if (errstr != NULL)
+               return (NULL);
+       return (winlink_find_by_window_id(&s->windows, windowid));
+}
+
+/* Lookup window id. An initial @ means a window id. */
+struct window *
+cmd_lookup_windowid(const char *arg)
+{
+       const char      *errstr;
+       u_int            windowid;
+
+       if (*arg != '@')
+               return (NULL);
+
+       windowid = strtonum(arg + 1, 0, UINT_MAX, &errstr);
+       if (errstr != NULL)
+               return (NULL);
+       return (window_find_by_id(windowid));
+}
+
+/* Find session and winlink for window. */
 struct session *
-cmd_pane_session(struct cmd_ctx *ctx, struct window_pane *wp,
-    struct winlink **wlp)
+cmd_window_session(struct cmd_ctx *ctx, struct window *w, struct winlink **wlp)
 {
        struct session          *s;
        struct sessionslist      ss;
        struct winlink          *wl;
 
-       /* If this pane is in the current session, return that winlink. */
+       /* If this window is in the current session, return that winlink. */
        s = cmd_current_session(ctx, 0);
        if (s != NULL) {
-               wl = winlink_find_by_window(&s->windows, wp->window);
+               wl = winlink_find_by_window(&s->windows, w);
                if (wl != NULL) {
                        if (wlp != NULL)
                                *wlp = wl;
@@ -688,16 +722,16 @@ cmd_pane_session(struct cmd_ctx *ctx, st
                }
        }
 
-       /* Otherwise choose from all sessions with this pane. */
+       /* Otherwise choose from all sessions with this window. */
        ARRAY_INIT(&ss);
        RB_FOREACH(s, sessions, &sessions) {
-               if (winlink_find_by_window(&s->windows, wp->window) != NULL)
+               if (winlink_find_by_window(&s->windows, w) != NULL)
                        ARRAY_ADD(&ss, s);
        }
        s = cmd_choose_session_list(&ss);
        ARRAY_FREE(&ss);
        if (wlp != NULL)
-               *wlp = winlink_find_by_window(&s->windows, wp->window);
+               *wlp = winlink_find_by_window(&s->windows, w);
        return (s);
 }
 
@@ -707,6 +741,7 @@ cmd_find_session(struct cmd_ctx *ctx, co
 {
        struct session          *s;
        struct window_pane      *wp;
+       struct window           *w;
        struct client           *c;
        char                    *tmparg;
        size_t                   arglen;
@@ -716,9 +751,11 @@ cmd_find_session(struct cmd_ctx *ctx, co
        if (arg == NULL)
                return (cmd_current_session(ctx, prefer_unattached));
 
-       /* Lookup as pane id. */
+       /* Lookup as pane id or window id. */
        if ((wp = cmd_lookup_paneid(arg)) != NULL)
-               return (cmd_pane_session(ctx, wp, NULL));
+               return (cmd_window_session(ctx, wp->window, NULL));
+       if ((w = cmd_lookup_windowid(arg)) != NULL)
+               return (cmd_window_session(ctx, w, NULL));
 
        /* Trim a single trailing colon if any. */
        tmparg = xstrdup(arg);
@@ -780,7 +817,7 @@ cmd_find_window(struct cmd_ctx *ctx, con
 
        /* Lookup as pane id. */
        if ((wp = cmd_lookup_paneid(arg)) != NULL) {
-               s = cmd_pane_session(ctx, wp, &wl);
+               s = cmd_window_session(ctx, wp->window, &wl);
                if (sp != NULL)
                        *sp = s;
                return (wl);
@@ -1081,7 +1118,7 @@ cmd_find_pane(struct cmd_ctx *ctx,
 
        /* Lookup as pane id. */
        if ((*wpp = cmd_lookup_paneid(arg)) != NULL) {
-               s = cmd_pane_session(ctx, *wpp, &wl);
+               s = cmd_window_session(ctx, (*wpp)->window, &wl);
                if (sp != NULL)
                        *sp = s;
                return (wl);
Index: format.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/format.c,v
retrieving revision 1.4
diff -u -p -r1.4 format.c
--- format.c    15 Nov 2011 23:21:52 -0000      1.4
+++ format.c    29 Jan 2012 22:32:26 -0000
@@ -341,6 +341,7 @@ format_winlink(struct format_tree *ft, s
        layout = layout_dump(w);
        flags = window_printable_flags(s, wl);
 
+       format_add(ft, "window_id", "@%u", w->id);
        format_add(ft, "window_index", "%d", wl->idx);
        format_add(ft, "window_name", "%s", w->name);
        format_add(ft, "window_width", "%u", w->sx);
Index: tmux.1
===================================================================
RCS file: /cvs/src/usr.bin/tmux/tmux.1,v
retrieving revision 1.269
diff -u -p -r1.269 tmux.1
--- tmux.1      29 Jan 2012 09:37:02 -0000      1.269
+++ tmux.1      29 Jan 2012 22:32:27 -0000
@@ -385,8 +385,9 @@ follows the same rules as for
 .Ar target-session ,
 and
 .Em window
-is looked for in order: as a window index, for example mysession:1; as an exact
-window name, such as mysession:mywindow; then as an
+is looked for in order: as a window index, for example mysession:1;
+as a window id, such as @1;
+as an exact window name, such as mysession:mywindow; then as an
 .Xr fnmatch 3
 pattern or the start of a window name, such as mysession:mywin* or
 mysession:mywin.
Index: tmux.h
===================================================================
RCS file: /cvs/src/usr.bin/tmux/tmux.h,v
retrieving revision 1.308
diff -u -p -r1.308 tmux.h
--- tmux.h      29 Jan 2012 09:37:02 -0000      1.308
+++ tmux.h      29 Jan 2012 22:32:29 -0000
@@ -848,6 +848,7 @@ RB_HEAD(window_pane_tree, window_pane);
 
 /* Window structure. */
 struct window {
+       u_int            id;
        char            *name;
        struct event     name_timer;
        struct timeval   silence_timer;
@@ -1905,6 +1906,7 @@ int                window_pane_cmp(struct window_pane
 RB_PROTOTYPE(window_pane_tree, window_pane, tree_entry, window_pane_cmp);
 struct winlink *winlink_find_by_index(struct winlinks *, int);
 struct winlink *winlink_find_by_window(struct winlinks *, struct window *);
+struct winlink *winlink_find_by_window_id(struct winlinks *, u_int);
 int             winlink_next_index(struct winlinks *, int);
 u_int           winlink_count(struct winlinks *);
 struct winlink *winlink_add(struct winlinks *, int);
@@ -1919,6 +1921,7 @@ struct winlink    *winlink_previous_by_numb
 void            winlink_stack_push(struct winlink_stack *, struct winlink *);
 void            winlink_stack_remove(struct winlink_stack *, struct winlink *);
 int             window_index(struct window *, u_int *);
+struct window  *window_find_by_id(u_int);
 struct window  *window_create1(u_int, u_int);
 struct window  *window_create(const char *, const char *, const char *,
                     const char *, struct environ *, struct termios *,
Index: window.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/window.c,v
retrieving revision 1.70
diff -u -p -r1.70 window.c
--- window.c    29 Jan 2012 02:22:11 -0000      1.70
+++ window.c    29 Jan 2012 22:32:29 -0000
@@ -58,7 +58,8 @@ struct windows windows;
 
 /* Global panes tree. */
 struct window_pane_tree all_window_panes;
-u_int  next_window_pane;
+u_int  next_window_pane_id;
+u_int  next_window_id;
 
 void   window_pane_read_callback(struct bufferevent *, void *);
 void   window_pane_error_callback(struct bufferevent *, short, void *);
@@ -104,6 +105,18 @@ winlink_find_by_index(struct winlinks *w
        return (RB_FIND(winlinks, wwl, &wl));
 }
 
+struct winlink *
+winlink_find_by_window_id(struct winlinks *wwl, u_int id)
+{
+       struct winlink *wl;
+
+       RB_FOREACH(wl, winlinks, wwl) {
+               if (wl->window->id == id)
+                       return (wl);
+       }
+       return NULL;
+}
+
 int
 winlink_next_index(struct winlinks *wwl, int idx)
 {
@@ -249,12 +262,27 @@ window_index(struct window *s, u_int *i)
 }
 
 struct window *
+window_find_by_id(u_int id)
+{
+       struct window   *w;
+       u_int            i;
+
+       for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
+               w = ARRAY_ITEM(&windows, i);
+               if (w->id == id)
+                       return (w);
+       }
+       return NULL;
+}
+
+struct window *
 window_create1(u_int sx, u_int sy)
 {
        struct window   *w;
        u_int            i;
 
        w = xcalloc(1, sizeof *w);
+       w->id = next_window_id++;
        w->name = NULL;
        w->flags = 0;
 
@@ -571,7 +599,7 @@ window_pane_create(struct window *w, u_i
        wp = xcalloc(1, sizeof *wp);
        wp->window = w;
 
-       wp->id = next_window_pane++;
+       wp->id = next_window_pane_id++;
        RB_INSERT(window_pane_tree, &all_window_panes, wp);
 
        wp->cmd = NULL;




On Sun, Jan 29, 2012 at 09:29:23PM +0000, Nicholas Marriott wrote:
> Have you started changing this yet? I can pick it up and make the
> changes if you want to get the next bit ready.
> 
> I'd like to get as much of the low impact bits in as possible in before
> the OpenBSD tree locks for 5.1, so I don't have to merge too much back
> from SF after it unlocks.
> 
> 
> On Sun, Jan 29, 2012 at 01:28:55AM +0000, Nicholas Marriott wrote:
> > Hi
> > 
> > So the comment in my last mail applies, I think probably we should just
> > change cmd_find_session to return a struct window ** and if the arg
> > matches a windowid it returns that window as well as doing a choose as
> > normal on the sessions it is a member of. So it does something like:
> > 
> >         /* Lookup as window id. */
> >         if ((w = cmd_lookup_windowid(arg)) != NULL) {
> >                 *wwp = w;
> >                 return (cmd_window_session(ctx, w, NULL));
> >         }
> > 
> > Similar to how it does with paneid, but returning the result.
> > 
> > I think all of cmd_find_session, cmd_find_window and cmd_find_pane need
> > to accept session and window ids as well as pane ids.
> > 
> > One other comment inline below.
> > 
> > Thanks
> > 
> > On Sat, Jan 28, 2012 at 03:32:41PM -0800, George Nachman wrote:
> > > The following patch includes these changes:
> > > - Define a window ID and a session ID that is unique for the lifetime
> > > of a tmux server. (session ID isn't yet exposed, but will be visible
> > > to control clients in a future patch)
> > > - Change layout_dump to include window pane IDs in its output
> > > - Define a window_id format
> > > - Change list-windows to accept either a window or session as its target
> > > - Change cmd_lookup_window to accept @number as a window ID.
> > > - Updates the man page to describe these changes.
> > > 
> > > Index: tmux.h
> > > ===================================================================
> > > --- tmux.h        (revision 2682)
> > > +++ tmux.h        (working copy)
> > > @@ -844,6 +844,7 @@
> > > 
> > >  /* Window structure. */
> > >  struct window {
> > > + u_int            id;
> > >   char            *name;
> > >   struct event     name_timer;
> > >   struct timeval   silence_timer;
> > > @@ -947,6 +948,7 @@
> > > 
> > >  struct session {
> > >   u_int            idx;
> > > + u_int            id;
> > > 
> > >   char            *name;
> > >   char            *cwd;
> > > @@ -1318,6 +1320,7 @@
> > >  #define CMD_TARGET_PANE_USAGE "[-t target-pane]"
> > >  #define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
> > >  #define CMD_TARGET_SESSION_USAGE "[-t target-session]"
> > > +#define CMD_TARGET_SESSION_OR_WINDOW_USAGE "[-t target]"
> > >  #define CMD_TARGET_CLIENT_USAGE "[-t target-client]"
> > >  #define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]"
> > >  #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]"
> > > @@ -1544,6 +1547,9 @@
> > >  struct client    *cmd_current_client(struct cmd_ctx *);
> > >  struct client    *cmd_find_client(struct cmd_ctx *, const char *);
> > >  struct session   *cmd_find_session(struct cmd_ctx *, const char *, int);
> > > +struct winlink   *cmd_find_session_or_window(
> > > +             struct cmd_ctx *ctx, const char *arg, struct session **sp,
> > > +             int prefer_unattached);
> > >  struct winlink   *cmd_find_window(
> > >                struct cmd_ctx *, const char *, struct session **);
> > >  int               cmd_find_index(
> > > @@ -1897,6 +1903,7 @@
> > >  RB_PROTOTYPE(window_pane_tree, window_pane, tree_entry, window_pane_cmp);
> > >  struct winlink   *winlink_find_by_index(struct winlinks *, int);
> > >  struct winlink   *winlink_find_by_window(struct winlinks *, struct 
> > > window *);
> > > +struct winlink   *winlink_find_by_window_id(struct winlinks *, u_int);
> > >  int               winlink_next_index(struct winlinks *, int);
> > >  u_int             winlink_count(struct winlinks *);
> > >  struct winlink   *winlink_add(struct winlinks *, int);
> > > Index: layout-custom.c
> > > ===================================================================
> > > --- layout-custom.c       (revision 2682)
> > > +++ layout-custom.c       (working copy)
> > > @@ -78,9 +78,15 @@
> > > 
> > >   if (len == 0)
> > >           return (-1);
> > > -
> > > - tmplen = xsnprintf(tmp, sizeof tmp,
> > > -     "%ux%u,%u,%u", lc->sx, lc->sy, lc->xoff, lc->yoff);
> > > + if (lc->wp) {
> > > +         tmplen = xsnprintf(tmp, sizeof tmp,
> > > +             "%ux%u,%u,%u,%u", lc->sx, lc->sy, lc->xoff,
> > > +             lc->yoff, lc->wp->id);
> > > + } else {
> > > +         tmplen = xsnprintf(tmp, sizeof tmp,
> > > +             "%ux%u,%u,%u,na", lc->sx, lc->sy, lc->xoff,
> > > +             lc->yoff);
> > 
> > Does this actually happen where lc->wp is ever NULL? IIRC you can have
> > panes w/o cells but not vice versa?
> > 
> > Also you will need to change an sscanf somewhere for this to work I
> > guess, probably the one in layout_construct.
> > 
> > > + }
> > >   if (tmplen > (sizeof tmp) - 1)
> > >           return (-1);
> > >   if (strlcat(buf, tmp, len) >= len)
> > > Index: session.c
> > > ===================================================================
> > > --- session.c     (revision 2682)
> > > +++ session.c     (working copy)
> > > @@ -34,6 +34,7 @@
> > > 
> > >  struct winlink *session_next_alert(struct winlink *);
> > >  struct winlink *session_previous_alert(struct winlink *);
> > > +u_int            next_session_id = 0;
> > > 
> > >  RB_GENERATE(sessions, session, entry, session_cmp);
> > > 
> > > @@ -91,6 +92,7 @@
> > >   struct session  *s;
> > > 
> > >   s = xmalloc(sizeof *s);
> > > + s->id = next_session_id++;
> > >   s->references = 0;
> > >   s->flags = 0;
> > > 
> > > Index: format.c
> > > ===================================================================
> > > --- format.c      (revision 2682)
> > > +++ format.c      (working copy)
> > > @@ -71,7 +71,7 @@
> > >   "window_name",  /* W */
> > >   NULL,           /* X */
> > >   NULL,           /* Y */
> > > - NULL            /* Z */
> > > + NULL            /* Z */
> > >  };
> > > 
> > >  /* Create a new tree. */
> > > @@ -210,7 +210,7 @@
> > >   char            *buf, *ptr;
> > >   const char      *s;
> > >   size_t           off, len, n;
> > > - int              ch;
> > > + int              ch;
> > > 
> > >   len = 64;
> > >   buf = xmalloc(len);
> > > @@ -341,6 +341,7 @@
> > >   layout = layout_dump(w);
> > >   flags = window_printable_flags(s, wl);
> > > 
> > > + format_add(ft, "window_id", "%u", w->id);
> > >   format_add(ft, "window_index", "%d", wl->idx);
> > >   format_add(ft, "window_name", "%s", w->name);
> > >   format_add(ft, "window_width", "%u", w->sx);
> > > Index: cmd-list-windows.c
> > > ===================================================================
> > > --- cmd-list-windows.c    (revision 2682)
> > > +++ cmd-list-windows.c    (working copy)
> > > @@ -30,12 +30,13 @@
> > > 
> > >  void     cmd_list_windows_server(struct cmd *, struct cmd_ctx *);
> > >  void     cmd_list_windows_session(
> > > -     struct cmd *, struct session *, struct cmd_ctx *, int);
> > > +     struct cmd *, struct session *,struct winlink *,
> > > +     struct cmd_ctx *, int);
> > > 
> > >  const struct cmd_entry cmd_list_windows_entry = {
> > >   "list-windows", "lsw",
> > >   "aF:t:", 0, 0,
> > > - "[-a] [-F format] " CMD_TARGET_SESSION_USAGE,
> > > + "[-a] [-F format] " CMD_TARGET_SESSION_OR_WINDOW_USAGE,
> > >   0,
> > >   NULL,
> > >   NULL,
> > > @@ -47,14 +48,16 @@
> > >  {
> > >   struct args     *args = self->args;
> > >   struct session  *s;
> > > + struct winlink  *wl;
> > > 
> > >   if (args_has(args, 'a'))
> > >           cmd_list_windows_server(self, ctx);
> > >   else {
> > > -         s = cmd_find_session(ctx, args_get(args, 't'), 0);
> > > +         s = NULL;
> > > +         wl = cmd_find_session_or_window(ctx, args_get(args, 't'), &s, 
> > > 0);
> > >           if (s == NULL)
> > >                   return (-1);
> > > -         cmd_list_windows_session(self, s, ctx, 0);
> > > +         cmd_list_windows_session(self, s, wl, ctx, 0);
> > >   }
> > > 
> > >   return (0);
> > > @@ -66,12 +69,13 @@
> > >   struct session  *s;
> > > 
> > >   RB_FOREACH(s, sessions, &sessions)
> > > -         cmd_list_windows_session(self, s, ctx, 1);
> > > +         cmd_list_windows_session(self, s, NULL, ctx, 1);
> > >  }
> > > 
> > >  void
> > >  cmd_list_windows_session(
> > > -    struct cmd *self, struct session *s, struct cmd_ctx *ctx, int type)
> > > +    struct cmd *self, struct session *s, struct winlink *target_wl,
> > > +    struct cmd_ctx *ctx, int type)
> > >  {
> > >   struct args             *args = self->args;
> > >   struct winlink          *wl;
> > > @@ -102,6 +106,9 @@
> > > 
> > >   n = 0;
> > >   RB_FOREACH(wl, winlinks, &s->windows) {
> > > +         if (target_wl && target_wl->window->id != wl->window->id)
> > > +                 continue;
> > > +
> > >           ft = format_create();
> > >           format_add(ft, "line", "%u", n);
> > >           format_session(ft, s);
> > > Index: tmux.1
> > > ===================================================================
> > > --- tmux.1        (revision 2682)
> > > +++ tmux.1        (working copy)
> > > @@ -389,8 +389,9 @@
> > >  .Ar target-session ,
> > >  and
> > >  .Em window
> > > -is looked for in order: as a window index, for example mysession:1; as 
> > > an exact
> > > -window name, such as mysession:mywindow; then as an
> > > +is looked for in order: as a window index, for example mysession:1;
> > > +as a window id, such as @1;
> > > +as an exact window name, such as mysession:mywindow; then as an
> > >  .Xr fnmatch 3
> > >  pattern or the start of a window name, such as mysession:mywin* or
> > >  mysession:mywin.
> > > @@ -1200,14 +1201,18 @@
> > >  .It Xo Ic list-windows
> > >  .Op Fl a
> > >  .Op Fl F Ar format
> > > -.Op Fl t Ar target-session
> > > +.Op Fl t Ar target
> > >  .Xc
> > >  .D1 (alias: Ic lsw )
> > >  If
> > >  .Fl a
> > >  is given, list all windows on the server.
> > > -Otherwise, list windows in the current session or in
> > > -.Ar target-session .
> > > +Otherwise, list windows in the current session or, if
> > > +.Ar target
> > > +names a session, list all the windows in that session.
> > > +If
> > > +.Ar target
> > > +names a session and window, list only that window.
> > >  For the meaning of the
> > >  .Fl F
> > >  flag, see the
> > > Index: cmd.c
> > > ===================================================================
> > > --- cmd.c (revision 2682)
> > > +++ cmd.c (working copy)
> > > @@ -593,6 +593,20 @@
> > >                   return (wl);
> > >   }
> > > 
> > > + /* Look up by window ID. @n gives an id. */
> > > + if (name[0] == '@') {
> > > +         struct winlink *c_wl;
> > > +         errstr = NULL;
> > > +         u_int id = strtonum(name + 1, 0, INT_MAX, &errstr);
> > > +         if (errstr == NULL) {
> > > +                 RB_FOREACH(c_wl, winlinks, &s->windows) {
> > > +                         if (c_wl->window->id == id) {
> > > +                                 return (c_wl);
> > > +                         }
> > > +                 }
> > > +         }
> > > + }
> > > +
> > >   /* Look for exact matches, error if more than one. */
> > >   wlfound = NULL;
> > >   RB_FOREACH(wl, winlinks, &s->windows) {
> > > @@ -750,6 +764,22 @@
> > >   return (s);
> > >  }
> > > 
> > > +/* The target may specify a session to find or "session:window". */
> > > +struct winlink *
> > > +cmd_find_session_or_window(struct cmd_ctx *ctx, const char *arg,
> > > +                    struct session **sp, int prefer_unattached)
> > > +{
> > > +    const char   *colon;
> > > +    if (arg)
> > > + colon = strchr(arg, ':');
> > > +    if (arg && colon && colon[1])
> > > + return cmd_find_window(ctx, arg, sp);
> > > +    else {
> > > + *sp = cmd_find_session(ctx, arg, prefer_unattached);
> > > + return NULL;
> > > +    }
> > > +}
> > > +
> > >  /* Find the target session and window or report an error and return 
> > > NULL. */
> > >  struct winlink *
> > >  cmd_find_window(struct cmd_ctx *ctx, const char *arg, struct session 
> > > **sp)
> > > Index: window.c
> > > ===================================================================
> > > --- window.c      (revision 2682)
> > > +++ window.c      (working copy)
> > > @@ -56,6 +56,7 @@
> > >  /* Global panes tree. */
> > >  struct window_pane_tree all_window_panes;
> > >  u_int    next_window_pane;
> > > +u_int    next_window;
> > > 
> > >  void     window_pane_read_callback(struct bufferevent *, void *);
> > >  void     window_pane_error_callback(struct bufferevent *, short, void *);
> > > @@ -101,6 +102,18 @@
> > >   return (RB_FIND(winlinks, wwl, &wl));
> > >  }
> > > 
> > > +struct winlink *
> > > +winlink_find_by_window_id(struct winlinks *wwl, u_int id)
> > > +{
> > > + struct winlink *c_wl;
> > > + RB_FOREACH(c_wl, winlinks, wwl) {
> > > +         if (c_wl->window->id == id) {
> > > +                 return (c_wl);
> > > +         }
> > > + }
> > > + return NULL;
> > > +}
> > > +
> > >  int
> > >  winlink_next_index(struct winlinks *wwl, int idx)
> > >  {
> > > @@ -252,6 +265,7 @@
> > >   u_int            i;
> > > 
> > >   w = xcalloc(1, sizeof *w);
> > > + w->id = next_window++;
> > >   w->name = NULL;
> > >   w->flags = 0;
> > > 
> > > @@ -732,7 +746,7 @@
> > >  window_pane_read_callback(unused struct bufferevent *bufev, void *data)
> > >  {
> > >   struct window_pane     *wp = data;
> > > - char                   *new_data;
> > > + char                   *new_data;
> > >   size_t                  new_size;
> > > 
> > >   new_size = EVBUFFER_LENGTH(wp->event->input) - wp->pipe_off;
> > > @@ -964,7 +978,7 @@
> > >  {
> > >   struct screen   *s = &wp->base;
> > >   char            *newsearchstr, *line, *msg;
> > > - u_int            i;
> > > + u_int            i;
> > > 
> > >   msg = NULL;
> > >   xasprintf(&newsearchstr, "*%s*", searchstr);
> > > 
> > > ------------------------------------------------------------------------------
> > > Try before you buy = See our experts in action!
> > > The most comprehensive online learning library for Microsoft developers
> > > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> > > Metro Style Apps, more. Free future releases when you subscribe now!
> > > http://p.sf.net/sfu/learndevnow-dev2
> > > _______________________________________________
> > > tmux-users mailing list
> > > tmux-users@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/tmux-users

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to