zsh-workers
 help / color / mirror / code / Atom feed
From: Felix Rosencrantz <f.rosencrantz@gmail.com>
To: zsh-workers@zsh.org
Subject: Adding tests for zle? The missing X series tests
Date: Tue, 20 Dec 2011 08:20:07 -0800	[thread overview]
Message-ID: <CANGpWcegC1R2ayUs34PKK3o3PFFPEKh5wsTVh8mEX5ERi-Sz0Q@mail.gmail.com> (raw)

I was thinking about refactoring doisearch(), so it is easier to
read/understand/change, so the base function might look like below.
Though before attempting this I would like to have the safety net of
tests, to assure the changes don't break the incremental search
widgets. There are no zle tests, though the letter X was reserved for
zle tests.  I was wondering if anyone had thought about how this might
be done.  I looked at the tests for the completion, and tried to copy
that, though got mired down a little, since I'm not  familiar with the
terminal codes.  The completion code added xml like tags with zstyle
formatting controls (list-colors, message format, etc) and then parses
that output, though the incremental search widgets don't have that
kind of control.

-FR

How the base function might be refactored:

/*
 * doisearch:
 *   args: (char**) args to search widget
 *      Currently only first arg is used, given as input to ungetbytes, for
 *      initial search string.
 *   dir: (int) direction (-1=reverse, 1= forward)
 *   is_regex: (int) is search string a regex? (0= No, 1=Yes)
 */
static int
doisearch(char **args, int dir, int is_regex)
{
    int action, ret;
    struct isearch_globals *isg;
    isg = doisearch_init(args, dir);
    if (isg == NULL) return 1;
    for(;;) {
      doisearch_search(isg, is_regex);
      doisearch_highlighting(isg);
      action = doisearch_handleinput(isg);
      if (act == SEARCH_DONE) break;
    }
    ret = doisearch_cleanup(isg);
    return ret;
}


             reply	other threads:[~2011-12-20 16:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-20 16:20 Felix Rosencrantz [this message]
2011-12-21 11:39 ` Peter Stephenson
2012-01-04 17:38   ` Peter Stephenson
2012-01-09  0:20     ` Felix Rosencrantz
2012-01-09 10:02       ` Peter Stephenson
2012-01-11 16:45         ` Felix Rosencrantz
2012-01-29 18:49       ` Peter Stephenson
2011-12-21 16:48 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANGpWcegC1R2ayUs34PKK3o3PFFPEKh5wsTVh8mEX5ERi-Sz0Q@mail.gmail.com \
    --to=f.rosencrantz@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).