summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkjell <kjell@openbsd.org>2006-06-01 09:00:50 +0000
committerkjell <kjell@openbsd.org>2006-06-01 09:00:50 +0000
commitb2f80e6e2a1b516f4597c54c3341e397c4e64b9f (patch)
treef0e5037bcac0844d7156fb0d9080846690849b72
parentCorrect IRQ mappings for thecus devices. (diff)
downloadwireguard-openbsd-b2f80e6e2a1b516f4597c54c3341e397c4e64b9f.tar.xz
wireguard-openbsd-b2f80e6e2a1b516f4597c54c3341e397c4e64b9f.zip
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
-rw-r--r--usr.bin/mg/basic.c84
-rw-r--r--usr.bin/mg/buffer.c13
-rw-r--r--usr.bin/mg/def.h8
-rw-r--r--usr.bin/mg/dired.c3
-rw-r--r--usr.bin/mg/display.c43
-rw-r--r--usr.bin/mg/file.c17
-rw-r--r--usr.bin/mg/funmap.c3
-rw-r--r--usr.bin/mg/line.c8
-rw-r--r--usr.bin/mg/search.c26
-rw-r--r--usr.bin/mg/window.c5
10 files changed, 154 insertions, 56 deletions
diff --git a/usr.bin/mg/basic.c b/usr.bin/mg/basic.c
index b31c6f946df..6093376eee6 100644
--- a/usr.bin/mg/basic.c
+++ b/usr.bin/mg/basic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: basic.c,v 1.22 2006/05/28 23:30:16 kjell Exp $ */
+/* $OpenBSD: basic.c,v 1.23 2006/06/01 09:00:50 kjell Exp $ */
/* This file is in the public domain */
@@ -50,6 +50,7 @@ backchar(int f, int n)
curwp->w_dotp = lp;
curwp->w_doto = llength(lp);
curwp->w_flag |= WFMOVE;
+ curwp->w_dotline--;
} else
curwp->w_doto--;
}
@@ -89,6 +90,7 @@ forwchar(int f, int n)
return (FALSE);
}
curwp->w_doto = 0;
+ curwp->w_dotline++;
curwp->w_flag |= WFMOVE;
} else
curwp->w_doto++;
@@ -108,6 +110,7 @@ gotobob(int f, int n)
curwp->w_dotp = lforw(curbp->b_linep);
curwp->w_doto = 0;
curwp->w_flag |= WFFULL;
+ curwp->w_dotline = 1;
return (TRUE);
}
@@ -122,6 +125,7 @@ gotoeob(int f, int n)
(void) setmark(f, n);
curwp->w_dotp = lback(curbp->b_linep);
curwp->w_doto = llength(curwp->w_dotp);
+ curwp->w_dotline = curwp->w_bufp->b_lines;
curwp->w_flag |= WFFULL;
return (TRUE);
}
@@ -141,34 +145,27 @@ forwline(int f, int n)
if (n < 0)
return (backline(f | FFRAND, -n));
+ if ((dlp = curwp->w_dotp) == curbp->b_linep)
+ return(TRUE);
if ((lastflag & CFCPCN) == 0) /* Fix goal. */
setgoal();
thisflag |= CFCPCN;
if (n == 0)
return (TRUE);
- dlp = curwp->w_dotp;
- while (dlp != curbp->b_linep && n--)
+ while (n--) {
dlp = lforw(dlp);
- curwp->w_flag |= WFMOVE;
- if (dlp == curbp->b_linep) { /* ^N at end of buffer creates lines
- * (like gnu) */
- if (!(curbp->b_flag & BFCHG)) { /* first change */
- curbp->b_flag |= BFCHG;
- curwp->w_flag |= WFMODE;
- }
- curwp->w_doto = 0;
- while (n-- >= 0) {
- if ((dlp = lalloc(0)) == NULL)
- return (FALSE);
- dlp->l_fp = curbp->b_linep;
- dlp->l_bp = lback(dlp->l_fp);
- dlp->l_bp->l_fp = dlp->l_fp->l_bp = dlp;
+ if (dlp == curbp->b_linep) {
+ curwp->w_dotp = lback(dlp);
+ curwp->w_doto = llength(curwp->w_dotp);
+ curwp->w_flag |= WFMOVE;
+ return (TRUE);
}
- curwp->w_dotp = lback(curbp->b_linep);
- } else {
- curwp->w_dotp = dlp;
- curwp->w_doto = getgoal(dlp);
+ curwp->w_dotline++;
}
+ curwp->w_flag |= WFMOVE;
+ curwp->w_dotp = dlp;
+ curwp->w_doto = getgoal(dlp);
+
return (TRUE);
}
@@ -191,8 +188,10 @@ backline(int f, int n)
setgoal();
thisflag |= CFCPCN;
dlp = curwp->w_dotp;
- while (n-- && lback(dlp) != curbp->b_linep)
+ while (n-- && lback(dlp) != curbp->b_linep) {
dlp = lback(dlp);
+ curwp->w_dotline--;
+ }
curwp->w_dotp = dlp;
curwp->w_doto = getgoal(dlp);
curwp->w_flag |= WFMOVE;
@@ -273,8 +272,10 @@ forwpage(int f, int n)
n *= curwp->w_ntrows; /* to lines. */
#endif
lp = curwp->w_linep;
- while (n-- && lforw(lp) != curbp->b_linep)
+ while (n-- && lforw(lp) != curbp->b_linep) {
lp = lforw(lp);
+ curwp->w_dotline++;
+ }
curwp->w_linep = lp;
curwp->w_flag |= WFFULL;
/* if in current window, don't move dot */
@@ -311,8 +312,10 @@ backpage(int f, int n)
n *= curwp->w_ntrows; /* to lines. */
#endif
lp = curwp->w_linep;
- while (n-- && lback(lp) != curbp->b_linep)
+ while (n-- && lback(lp) != curbp->b_linep) {
lp = lback(lp);
+ curwp->w_dotline--;
+ }
curwp->w_linep = lp;
curwp->w_flag |= WFFULL;
/* if in current window, don't move dot */
@@ -379,6 +382,7 @@ isetmark(void)
{
curwp->w_markp = curwp->w_dotp;
curwp->w_marko = curwp->w_doto;
+ curwp->w_markline = curwp->w_dotline;
}
/*
@@ -407,7 +411,7 @@ int
swapmark(int f, int n)
{
struct line *odotp;
- int odoto;
+ int odoto, odotline;
if (curwp->w_markp == NULL) {
ewprintf("No mark in this window");
@@ -415,10 +419,13 @@ swapmark(int f, int n)
}
odotp = curwp->w_dotp;
odoto = curwp->w_doto;
+ odotline = curwp->w_dotline;
curwp->w_dotp = curwp->w_markp;
curwp->w_doto = curwp->w_marko;
+ curwp->w_dotline = curwp->w_markline;
curwp->w_markp = odotp;
curwp->w_marko = odoto;
+ curwp->w_markline = odotline;
curwp->w_flag |= WFMOVE;
return (TRUE);
}
@@ -435,36 +442,39 @@ int
gotoline(int f, int n)
{
struct line *clp;
- char buf[32], *bufp, *tmp;
- long nl;
+ char buf[32], *bufp;
+ const char *err;
if (!(f & FFARG)) {
if ((bufp = eread("Goto line: ", buf, sizeof(buf),
EFNUL | EFNEW | EFCR)) == NULL)
return (ABORT);
- nl = strtol(bufp, &tmp, 10);
- if (bufp[0] == '\0' || *tmp != '\0') {
- ewprintf("Invalid number");
+ n = (int)strtonum(buf, INT_MIN, INT_MAX, &err);
+ if (err) {
+ ewprintf("Line number %s", err);
return (FALSE);
}
- if (nl >= INT_MAX || nl <= INT_MIN) {
- ewprintf("Out of range");
- return (FALSE);
- }
- n = (int)nl;
}
if (n >= 0) {
+ if (n == 0)
+ n++;
+ curwp->w_dotline = n;
clp = lforw(curbp->b_linep); /* "clp" is first line */
while (--n > 0) {
- if (lforw(clp) == curbp->b_linep)
+ if (lforw(clp) == curbp->b_linep) {
+ curwp->w_dotline = curwp->w_bufp->b_lines;
break;
+ }
clp = lforw(clp);
}
} else {
+ curwp->w_dotline = curwp->w_bufp->b_lines + n;
clp = lback(curbp->b_linep); /* "clp" is last line */
while (n < 0) {
- if (lback(clp) == curbp->b_linep)
+ if (lback(clp) == curbp->b_linep) {
+ curwp->w_dotline = 1;
break;
+ }
clp = lback(clp);
n++;
}
diff --git a/usr.bin/mg/buffer.c b/usr.bin/mg/buffer.c
index 4dcb2122152..e8e9417723a 100644
--- a/usr.bin/mg/buffer.c
+++ b/usr.bin/mg/buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buffer.c,v 1.59 2006/06/01 01:41:49 kjell Exp $ */
+/* $OpenBSD: buffer.c,v 1.60 2006/06/01 09:00:50 kjell Exp $ */
/* This file is in the public domain. */
@@ -414,6 +414,7 @@ addlinef(struct buffer *bp, char *fmt, ...)
lp->l_bp = bp->b_linep->l_bp;
bp->b_linep->l_bp = lp;
lp->l_fp = bp->b_linep;
+ bp->b_lines++;
return (TRUE);
}
@@ -530,6 +531,8 @@ bnew()
lp->l_bp = lp;
bp->b_bufp = bheadp;
bheadp = bp;
+ bp->b_dotline = bp->b_markline = 1;
+ bp->b_lines = 0;
return (bp);
}
@@ -560,6 +563,9 @@ bclear(struct buffer *bp)
bp->b_doto = 0;
bp->b_markp = NULL; /* Invalidate "mark" */
bp->b_marko = 0;
+ bp->b_dotline = bp->b_markline = 1;
+ bp->b_lines = 0;
+
return (TRUE);
}
@@ -586,6 +592,8 @@ showbuffer(struct buffer *bp, struct mgwin *wp, int flags)
obp->b_doto = wp->w_doto;
obp->b_markp = wp->w_markp;
obp->b_marko = wp->w_marko;
+ obp->b_dotline = wp->w_dotline;
+ obp->b_markline = wp->w_markline;
}
}
/* Now, attach the new buffer to the window */
@@ -596,6 +604,8 @@ showbuffer(struct buffer *bp, struct mgwin *wp, int flags)
wp->w_doto = bp->b_doto;
wp->w_markp = bp->b_markp;
wp->w_marko = bp->b_marko;
+ wp->w_dotline = bp->b_dotline;
+ wp->w_markline = bp->b_markline;
} else
/* already on screen, steal values from other window */
for (owp = wheadp; owp != NULL; owp = wp->w_wndp)
@@ -604,6 +614,7 @@ showbuffer(struct buffer *bp, struct mgwin *wp, int flags)
wp->w_doto = owp->w_doto;
wp->w_markp = owp->w_markp;
wp->w_marko = owp->w_marko;
+ wp->w_dotline = owp->w_dotline;
break;
}
wp->w_flag |= WFMODE | flags;
diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h
index 20fe10a947c..f0834e65d75 100644
--- a/usr.bin/mg/def.h
+++ b/usr.bin/mg/def.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: def.h,v 1.91 2006/06/01 05:34:52 jason Exp $ */
+/* $OpenBSD: def.h,v 1.92 2006/06/01 09:00:50 kjell Exp $ */
/* This file is in the public domain. */
@@ -205,6 +205,8 @@ struct mgwin {
char w_frame; /* #lines to reframe by. */
char w_flag; /* Flags. */
struct line *w_wrapline;
+ int w_dotline; /* current line number of dot */
+ int w_markline; /* current line number of mark */
};
#define w_wndp w_list.l_p.l_wp
#define w_name w_list.l_name
@@ -254,6 +256,9 @@ struct buffer {
LIST_HEAD(, undo_rec) b_undo; /* Undo actions list */
int b_undopos; /* Where we were during last undo */
struct undo_rec *b_undoptr;
+ int b_dotline; /* Line number of dot */
+ int b_markline; /* Line number of mark */
+ int b_lines; /* Number of lines in file */
};
#define b_bufp b_list.l_p.x_bp
#define b_bname b_list.l_name
@@ -402,6 +407,7 @@ int vtresize(int, int, int);
void vtinit(void);
void vttidy(void);
void update(void);
+int linenotoggle(int, int);
/* echo.c X */
void eerase(void);
diff --git a/usr.bin/mg/dired.c b/usr.bin/mg/dired.c
index 8fcf444d080..396a992c421 100644
--- a/usr.bin/mg/dired.c
+++ b/usr.bin/mg/dired.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dired.c,v 1.38 2006/06/01 05:34:52 jason Exp $ */
+/* $OpenBSD: dired.c,v 1.39 2006/06/01 09:00:50 kjell Exp $ */
/* This file is in the public domain. */
@@ -359,6 +359,7 @@ d_expunge(int f, int n)
break;
}
lfree(lp);
+ curwp->w_bufp->b_lines--;
curwp->w_flag |= WFFULL;
}
}
diff --git a/usr.bin/mg/display.c b/usr.bin/mg/display.c
index c2a64dcddb3..cf9f947f6f1 100644
--- a/usr.bin/mg/display.c
+++ b/usr.bin/mg/display.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: display.c,v 1.28 2006/05/29 00:02:23 kjell Exp $ */
+/* $OpenBSD: display.c,v 1.29 2006/06/01 09:00:50 kjell Exp $ */
/* This file is in the public domain. */
@@ -101,6 +101,31 @@ struct video blanks; /* Blank line image. */
*/
struct score *score; /* [NROW * NROW] */
+#ifndef LINENOMODE
+#define LINENOMODE TRUE
+#endif /* !LINENOMODE */
+static int linenos = LINENOMODE;
+
+/*
+ * Since we don't have variables (we probably should) this is a command
+ * processor for changing the value of the line number mode flag.
+ */
+/* ARGSUSED */
+int
+linenotoggle(int f, int n)
+{
+ if (f & FFARG)
+ linenos = n > 0;
+ else
+ linenos = !linenos;
+
+ sgarbf = TRUE;
+
+ return (TRUE);
+}
+
+
+
/*
* Reinit the display data structures, this is called when the terminal
* size changes.
@@ -380,6 +405,13 @@ update(void)
wp = wp->w_wndp;
}
}
+ if (linenos) {
+ wp = wheadp;
+ while (wp != NULL) {
+ wp->w_flag |= WFMODE;
+ wp = wp->w_wndp;
+ }
+ }
hflag = FALSE; /* Not hard. */
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) {
/*
@@ -750,6 +782,8 @@ modeline(struct mgwin *wp)
{
int n, md;
struct buffer *bp;
+ char sl[21]; /* Overkill. Space for 2^64 in base 10. */
+ int len;
n = wp->w_toprow + wp->w_ntrows; /* Location. */
vscreen[n]->v_color = CMODE; /* Mode line color. */
@@ -791,6 +825,13 @@ modeline(struct mgwin *wp)
}
vtputc(')');
++n;
+
+ if (linenos) {
+ len = snprintf(sl, sizeof(sl), "--L%d", wp->w_dotline);
+ if (len < sizeof(sl) && len != -1)
+ n += vtputs(sl);
+ }
+
while (n < ncol) { /* Pad out. */
vtputc('-');
++n;
diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c
index fa2c79b04dc..0713208576c 100644
--- a/usr.bin/mg/file.c
+++ b/usr.bin/mg/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.58 2006/06/01 05:34:52 jason Exp $ */
+/* $OpenBSD: file.c,v 1.59 2006/06/01 09:00:50 kjell Exp $ */
/* This file is in the public domain. */
@@ -282,8 +282,9 @@ insertfile(char *fname, char *newname, int replacebuf)
struct line *lp1, *lp2;
struct line *olp; /* line we started at */
struct mgwin *wp;
- int nbytes, s, nline, siz, x = -1, x2;
+ int nbytes, s, nline = 0, siz, x = -1, x2;
int opos; /* offset we started at */
+ int oline; /* original line number */
if (replacebuf == TRUE)
x = undo_enable(FALSE);
@@ -334,8 +335,9 @@ insertfile(char *fname, char *newname, int replacebuf)
}
opos = curwp->w_doto;
- /* open a new line, at point, and start inserting after it */
+ /* Open a new line, at point, and start inserting after it. */
x2 = undo_enable(FALSE);
+ oline = curwp->w_dotline;
(void)lnewline();
olp = lback(curwp->w_dotp);
if (olp == curbp->b_linep) {
@@ -353,10 +355,10 @@ doneread:
siz += nbytes + 1;
switch (s) {
case FIOSUC:
- ++nline;
/* FALLTHRU */
case FIOEOF:
/* the last line of the file */
+ ++nline;
if ((lp1 = lalloc(nbytes)) == NULL) {
/* keep message on the display */
s = FIOERR;
@@ -402,7 +404,7 @@ doneread:
}
}
endoffile:
- undo_add_insert(olp, opos, siz-1);
+ undo_add_insert(olp, opos, siz - 1);
/* ignore errors */
ffclose(NULL);
@@ -419,6 +421,7 @@ endoffile:
(void)ldelnewline();
curwp->w_dotp = olp;
curwp->w_doto = opos;
+ curwp->w_dotline = oline;
if (olp == curbp->b_linep)
curwp->w_dotp = lforw(olp);
if (newname != NULL)
@@ -453,6 +456,7 @@ out: lp2 = NULL;
}
}
}
+ bp->b_lines += nline;
cleanup:
undo_enable(x);
@@ -564,8 +568,7 @@ buffsave(struct buffer *bp)
* Since we don't have variables (we probably should) this is a command
* processor for changing the value of the make backup flag. If no argument
* is given, sets makebackup to true, so backups are made. If an argument is
- * given, no backup files are made when saving a new version of a file. Only
- * used when BACKUP is #defined.
+ * given, no backup files are made when saving a new version of a file.
*/
/* ARGSUSED */
int
diff --git a/usr.bin/mg/funmap.c b/usr.bin/mg/funmap.c
index 9b541b61bd5..95ee3b271a9 100644
--- a/usr.bin/mg/funmap.c
+++ b/usr.bin/mg/funmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: funmap.c,v 1.23 2005/12/20 06:17:36 kjell Exp $ */
+/* $OpenBSD: funmap.c,v 1.24 2006/06/01 09:00:50 kjell Exp $ */
/*
* Copyright (c) 2001 Artur Grabowski <art@openbsd.org>. All rights reserved.
*
@@ -128,6 +128,7 @@ static struct funmap functnames[] = {
{killpara, "kill-paragraph",},
{killregion, "kill-region",},
{delfword, "kill-word",},
+ {linenotoggle, "line-number-mode",},
{listbuffers, "list-buffers",},
#ifndef NO_STARTUP
{evalfile, "load",},
diff --git a/usr.bin/mg/line.c b/usr.bin/mg/line.c
index df648807e11..20d90ccb303 100644
--- a/usr.bin/mg/line.c
+++ b/usr.bin/mg/line.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: line.c,v 1.39 2006/05/28 23:30:16 kjell Exp $ */
+/* $OpenBSD: line.c,v 1.40 2006/06/01 09:00:50 kjell Exp $ */
/* This file is in the public domain. */
@@ -377,6 +377,8 @@ lnewline(void)
ewprintf("Buffer is read only");
return (FALSE);
}
+ curwp->w_bufp->b_lines++;
+ curwp->w_dotline++;
return (lnewline_at(curwp->w_dotp, curwp->w_doto));
}
@@ -473,7 +475,8 @@ ldelete(RSIZE n, int kflag)
* operation. Even if nothing is done, this makes the kill buffer work
* "right". Easy cases can be done by shuffling data around. Hard cases
* require that lines be moved about in memory. Return FALSE on error and
- * TRUE if all looks ok.
+ * TRUE if all looks ok. We do not update w_dotline here, as deletes are done
+ * after moves.
*/
int
ldelnewline(void)
@@ -491,6 +494,7 @@ ldelnewline(void)
/* at the end of the buffer */
if (lp2 == curbp->b_linep)
return (TRUE);
+ curwp->w_bufp->b_lines--;
if (lp2->l_used <= lp1->l_size - lp1->l_used) {
bcopy(&lp2->l_text[0], &lp1->l_text[lp1->l_used], lp2->l_used);
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) {
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);
}
diff --git a/usr.bin/mg/window.c b/usr.bin/mg/window.c
index e446068c4a2..6e3a8744b08 100644
--- a/usr.bin/mg/window.c
+++ b/usr.bin/mg/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.23 2006/05/29 00:02:23 kjell Exp $ */
+/* $OpenBSD: window.c,v 1.24 2006/06/01 09:00:50 kjell Exp $ */
/* This file is in the public domain. */
@@ -25,6 +25,7 @@ new_window(struct buffer *bp)
wp->w_flag = 0;
wp->w_frame = 0;
wp->w_wrapline = NULL;
+ wp->w_dotline = wp->w_markline = 1;
if (bp)
bp->b_nwnd++;
return (wp);
@@ -223,6 +224,8 @@ splitwind(int f, int n)
wp->w_doto = curwp->w_doto;
wp->w_markp = curwp->w_markp;
wp->w_marko = curwp->w_marko;
+ wp->w_dotline = curwp->w_dotline;
+ wp->w_markline = curwp->w_markline;
/* figure out which half of the screen we're in */
ntru = (curwp->w_ntrows - 1) / 2; /* Upper size */