Applied with some fairly unimportant style changes, thanks.
On Tue, Mar 20, 2012 at 09:15:18AM -0700, Jonathan Daugherty wrote:
> > But that's four diffs... just -T -N -C would be ok but if you do one
> > -T flag I think we should have all three.
>
> Please see the attached patch, which adds -T, -C, and -N options for
> find-window and defaults to -TCN as discussed. I've also updated
> tmux.1.
>
> --
> Jonathan Daugherty
> Software Engineer
> Galois, Inc.
> Index: tmux.1
> ===================================================================
> --- tmux.1 (revision 2749)
> +++ tmux.1 (working copy)
> @@ -1103,6 +1103,7 @@
> .Ql 9
> keys.
> .It Xo Ic find-window
> +.Op Fl TCN
> .Op Fl t Ar target-window
> .Ar match-string
> .Xc
> @@ -1112,9 +1113,18 @@
> pattern
> .Ar match-string
> in window names, titles, and visible content (but not history).
> -If only one window is matched, it'll be automatically selected, otherwise a
> -choice list is shown.
> -This command only works from inside
> +Specify one or more of
> +.Fl TCN
> +to control matching behavior:
> +.Fl T
> +matches only the window title,
> +.Fl C
> +matches only visible window contents, and
> +.Fl N
> +matches only the window name. The default is
> +.Fl TCN .
> +If only one window is matched, it'll be automatically selected,
> +otherwise a choice list is shown. This command only works from inside
> .Nm .
> .It Xo Ic join-pane
> .Op Fl bdhv
> Index: cmd-find-window.c
> ===================================================================
> --- cmd-find-window.c (revision 2749)
> +++ cmd-find-window.c (working copy)
> @@ -32,10 +32,21 @@
> void cmd_find_window_callback(void *, int);
> void cmd_find_window_free(void *);
>
> +/*
> + * Flags for determining matching behavior.
> + */
> +#define FIND_BY_TITLE 0x1
> +#define FIND_BY_CONTENT 0x2
> +#define FIND_BY_NAME 0x4
> +
> +#define MATCH_NAME(flags) flags & FIND_BY_NAME
> +#define MATCH_TITLE(flags) flags & FIND_BY_TITLE
> +#define MATCH_CONTENT(flags) flags & FIND_BY_CONTENT
> +
> const struct cmd_entry cmd_find_window_entry = {
> "find-window", "findw",
> - "t:", 1, 1,
> - CMD_TARGET_WINDOW_USAGE " match-string",
> + "TCNt:", 1, 4,
> + "[-TCN] " CMD_TARGET_WINDOW_USAGE " match-string",
> 0,
> NULL,
> NULL,
> @@ -46,6 +57,31 @@
> struct session *session;
> };
>
> +u_int
> +match_flags_from_args(struct args *args)
> +{
> + u_int match_flags = 0;
> +
> + // Turn on flags based on the options.
> + if (args_has(args, 'T'))
> + match_flags |= FIND_BY_TITLE;
> +
> + if (args_has(args, 'C'))
> + match_flags |= FIND_BY_CONTENT;
> +
> + if (args_has(args, 'N'))
> + match_flags |= FIND_BY_NAME;
> +
> + // If none of the flags were set, default to matching
> + // anything.
> + if (!match_flags)
> + match_flags = FIND_BY_TITLE |
> + FIND_BY_CONTENT |
> + FIND_BY_NAME;
> +
> + return match_flags;
> +}
> +
> int
> cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
> {
> @@ -59,6 +95,7 @@
> ARRAY_DECL(, char *) list_ctx;
> char *str, *sres, *sctx, *searchstr;
> u_int i, line;
> + u_int match_flags;
>
> if (ctx->curclient == NULL) {
> ctx->error(ctx, "must be run interactively");
> @@ -69,6 +106,7 @@
> if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
> return (-1);
>
> + match_flags = match_flags_from_args(args);
> str = args->argv[0];
>
> ARRAY_INIT(&list_idx);
> @@ -80,12 +118,21 @@
> TAILQ_FOREACH(wp, &wm->window->panes, entry) {
> i++;
>
> - if (fnmatch(searchstr, wm->window->name, 0) == 0)
> + if (MATCH_NAME(match_flags) &&
> + fnmatch(searchstr, wm->window->name, 0) == 0)
> sctx = xstrdup("");
> else {
> - sres = window_pane_search(wp, str, &line);
> + sres = NULL;
> + if (MATCH_CONTENT(match_flags))
> + sres = window_pane_search(wp, str,
> &line);
> +
> + // If match_title isn't set we don't
> + // want to bother checking the title,
> + // but that also constitutes a failure
> + // to match so we still want to abort.
> if (sres == NULL &&
> - fnmatch(searchstr, wp->base.title, 0) != 0)
> + (!MATCH_TITLE(match_flags) ||
> + fnmatch(searchstr, wp->base.title, 0) !=
> 0))
> continue;
>
> if (sres == NULL) {
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
tmux-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-users