diff options
author | Kjell Wooding <kjell@cvs.openbsd.org> | 2005-10-11 01:00:42 +0000 |
---|---|---|
committer | Kjell Wooding <kjell@cvs.openbsd.org> | 2005-10-11 01:00:42 +0000 |
commit | 0ecee07d8fe56b1a0133782d5bd5870088af493a (patch) | |
tree | ee4cbbed3c751d8b23e29ee9c1f3ac7e2a57f8f8 | |
parent | a07578ea6c80ff63501ab46cade436e23c546f9a (diff) |
Allow the more traditional emacs keybindings during search/replace, too
(i.e. 'y' to accept, 'n' to skip, and <CR> to end)
ok deraadt@, cloder@
-rw-r--r-- | usr.bin/mg/search.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/usr.bin/mg/search.c b/usr.bin/mg/search.c index 437874a78da..3f71f25c086 100644 --- a/usr.bin/mg/search.c +++ b/usr.bin/mg/search.c @@ -1,4 +1,4 @@ -/* $OpenBSD: search.c,v 1.22 2005/08/09 00:53:48 kjell Exp $ */ +/* $OpenBSD: search.c,v 1.23 2005/10/11 01:00:41 kjell Exp $ */ /* This file is in the public domain. */ @@ -551,6 +551,7 @@ queryrepl(int f, int n) retry: update(); switch (getkey(FALSE)) { + case 'y': case ' ': if (lreplace((RSIZE)plen, news, f) == FALSE) return (FALSE); @@ -561,10 +562,11 @@ retry: return (FALSE); rcnt++; goto stopsearch; - /* ^G or ESC */ + /* ^G, CR or ESC */ case CCHR('G'): (void)ctrlg(FFRAND, 0); case CCHR('['): + case CCHR('M'): goto stopsearch; case '!': do { @@ -573,24 +575,23 @@ retry: rcnt++; } while (forwsrch() == TRUE); goto stopsearch; + case 'n': case CCHR('H'): /* To not replace */ case CCHR('?'): break; default: - ewprintf("<SP> replace, [.] rep-end, <DEL> don't, [!] repl rest <ESC> quit"); + ewprintf("y/n or <SP>/<DEL>: replace/don't, [.] repl-end, [!] repl-rest, <CR>/<ESC> quit"); goto retry; } } stopsearch: curwp->w_flag |= WFHARD; update(); - if (rcnt == 0) - ewprintf("(No replacements done)"); - else if (rcnt == 1) - ewprintf("(1 replacement done)"); + if (rcnt == 1) + ewprintf("Replaced 1 occurrence"); else - ewprintf("(%d replacements done)", rcnt); + ewprintf("Replaced %d occurrences", rcnt); return (TRUE); } @@ -626,9 +627,9 @@ replstr(int f, int n) update(); if (rcnt == 1) - ewprintf("(1 replacement done)"); + ewprintf("Replaced 1 occurrence"); else - ewprintf("(%d replacements done)", rcnt); + ewprintf("Replaced %d occurrences", rcnt); return (TRUE); } |