Changeset b6cf72f


Ignore:
Timestamp:
Sep 18, 2010, 5:07:40 PM (14 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.7, release-1.8, release-1.9
Children:
d2fd2f7
Parents:
9c1e61d4
git-author:
David Benjamin <davidben@mit.edu> (08/15/10 19:42:43)
git-committer:
David Benjamin <davidben@mit.edu> (09/18/10 17:07:40)
Message:
FINALLY! Add a popless:search command

That took a while.
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r9c1e61d4 rb6cf72f  
    10041004                  "popless:start-command [initial-value]",
    10051005                  "Initializes the command field to initial-value"),
     1006
     1007  OWLCMD_ARGS_CTX("popless:search", owl_viewwin_command_search, OWL_CTX_POPLESS,
     1008                  "search lines for a particular string",
     1009                  "popless:search [-r] [<string>]",
     1010                  "The popless:search command will find lines that contain the\n"
     1011                  "specified string and scroll the popwin there.  If no string\n"
     1012                  "argument is supplied then the previous one is used.  By\n"
     1013                  "default searches are done forwards; if -r is used the search\n"
     1014                  "is performed backwards"),
    10061015
    10071016  OWLCMD_ALIAS("webzephyr", "zwrite daemon.webzephyr -c webzephyr -i"),
  • keys.c

    r09ceee3 rb6cf72f  
    214214  BIND_CMD(":",           "popless:start-command",  "start a new command");
    215215  BIND_CMD("M-x",         "popless:start-command",  "start a new command");
     216
     217  BIND_CMD("/",   "popless:start-command popless:search ", "start a search command");
     218  BIND_CMD("?",   "popless:start-command popless:search -r ", "start a reverse search command");
     219  BIND_CMD("n",   "popless:search", "find next occurrence of search");
     220  BIND_CMD("N",   "popless:search -r", "find previous occurrence of search");
    216221
    217222  BIND_CMD("C-l",         "redisplay", "");
  • viewwin.c

    r9c1e61d4 rb6cf72f  
    140140  }
    141141  wattroff(curswin, A_REVERSE);
     142}
     143
     144char *owl_viewwin_command_search(owl_viewwin *v, int argc, const char *const *argv, const char *buff)
     145{
     146  int direction, mode;
     147  const char *buffstart;
     148
     149  direction=OWL_DIRECTION_DOWNWARDS;
     150  buffstart=skiptokens(buff, 1);
     151  if (argc>1 && !strcmp(argv[1], "-r")) {
     152    direction=OWL_DIRECTION_UPWARDS;
     153    buffstart=skiptokens(buff, 2);
     154  }
     155
     156  if (argc==1 || (argc==2 && !strcmp(argv[1], "-r"))) {
     157    mode = OWL_SEARCH_CONTINUE;
     158  } else {
     159    owl_function_set_search(buffstart);
     160    mode = OWL_SEARCH_MATCH_CURRENT;
     161  }
     162
     163  if (!owl_viewwin_search(v, owl_global_get_search_re(&g), mode, direction))
     164    owl_function_error("No more matches");
     165  return NULL;
    142166}
    143167
Note: See TracChangeset for help on using the changeset viewer.