Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Adding tests for zle? The missing X series tests



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;
}



Messages sorted by: Reverse Date, Date, Thread, Author