diff options
author | Kjell Wooding <kjell@cvs.openbsd.org> | 2006-06-01 09:00:51 +0000 |
---|---|---|
committer | Kjell Wooding <kjell@cvs.openbsd.org> | 2006-06-01 09:00:51 +0000 |
commit | 4956d7758a28db64bbbcfe10a31373dcebe45a9c (patch) | |
tree | 640f4b239a80c8112acb759569557e573cc6a240 /usr.bin/mg/search.c | |
parent | d06ef4eb5d7260b4ff329ed028f576e54b298fa6 (diff) |
Display line number in the mg statusbar. Yes, it seems like a fugly
way to do it, but all the clever and pretty ways utterly failed.
Basic use seems fine. We'll turdshine the special cases later.
If it bothers you, use M-x line-number-mode, or put same in your ~/.mg
file to disable.
ok cloder, jason
Diffstat (limited to 'usr.bin/mg/search.c')
-rw-r--r-- | usr.bin/mg/search.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/usr.bin/mg/search.c b/usr.bin/mg/search.c index cb259031925..4a298f948a7 100644 --- a/usr.bin/mg/search.c +++ b/usr.bin/mg/search.c @@ -1,4 +1,4 @@ -/* $OpenBSD: search.c,v 1.29 2006/05/28 23:30:16 kjell Exp $ */ +/* $OpenBSD: search.c,v 1.30 2006/06/01 09:00:50 kjell Exp $ */ /* This file is in the public domain. */ @@ -164,6 +164,7 @@ isearch(int dir) int xcase; int i; char opat[NPAT]; + int cdotline; #ifndef NO_MACRO if (macrodef) { @@ -179,6 +180,7 @@ isearch(int dir) pptr = -1; clp = curwp->w_dotp; cbo = curwp->w_doto; + cdotline = curwp->w_dotline; is_lpush(); is_cpush(SRCH_BEGIN); success = TRUE; @@ -212,6 +214,7 @@ isearch(int dir) } curwp->w_dotp = clp; curwp->w_doto = cbo; + curwp->w_dotline = cdotline; curwp->w_flag |= WFMOVE; srch_lastdir = dir; (void)ctrlg(FFRAND, 0); @@ -230,6 +233,7 @@ isearch(int dir) clp = lforw(curbp->b_linep); curwp->w_dotp = clp; curwp->w_doto = 0; + curwp->w_dotline = 1; if (is_find(dir) != FALSE) { is_cpush(SRCH_MARK); success = TRUE; @@ -262,6 +266,7 @@ isearch(int dir) curwp->w_dotp = clp; curwp->w_doto = llength(curwp->w_dotp); + curwp->w_dotline = curwp->w_bufp->b_lines; if (is_find(dir) != FALSE) { is_cpush(SRCH_MARK); success = TRUE; @@ -651,9 +656,11 @@ forwsrch(void) struct line *clp, *tlp; int cbo, tbo, c, i, xcase = 0; char *pp; + int nline; clp = curwp->w_dotp; cbo = curwp->w_doto; + nline = curwp->w_dotline; for (i = 0; pat[i]; i++) if (ISUPPER(CHARMASK(pat[i]))) xcase = 1; @@ -661,6 +668,7 @@ forwsrch(void) if (cbo == llength(clp)) { if ((clp = lforw(clp)) == curbp->b_linep) break; + nline++; cbo = 0; c = CCHR('J'); } else @@ -676,13 +684,18 @@ forwsrch(void) goto fail; tbo = 0; c = CCHR('J'); - } else + if (eq(c, *pp++, xcase) == FALSE) + goto fail; + nline++; + } else { c = lgetc(tlp, tbo++); - if (eq(c, *pp++, xcase) == FALSE) - goto fail; + if (eq(c, *pp++, xcase) == FALSE) + goto fail; + } } curwp->w_dotp = tlp; curwp->w_doto = tbo; + curwp->w_dotline = nline; curwp->w_flag |= WFMOVE; return (TRUE); } @@ -703,10 +716,12 @@ backsrch(void) struct line *clp, *tlp; int cbo, tbo, c, i, xcase = 0; char *epp, *pp; + int nline; for (epp = &pat[0]; epp[1] != 0; ++epp); clp = curwp->w_dotp; cbo = curwp->w_doto; + nline = curwp->w_dotline; for (i = 0; pat[i]; i++) if (ISUPPER(CHARMASK(pat[i]))) xcase = 1; @@ -715,6 +730,7 @@ backsrch(void) clp = lback(clp); if (clp == curbp->b_linep) return (FALSE); + nline--; cbo = llength(clp) + 1; } if (--cbo == llength(clp)) @@ -730,6 +746,7 @@ backsrch(void) tlp = lback(tlp); if (tlp == curbp->b_linep) goto fail; + nline--; tbo = llength(tlp) + 1; } if (--tbo == llength(tlp)) @@ -741,6 +758,7 @@ backsrch(void) } curwp->w_dotp = tlp; curwp->w_doto = tbo; + curwp->w_dotline = nline; curwp->w_flag |= WFMOVE; return (TRUE); } |