diff options
-rw-r--r-- | usr.bin/mg/def.h | 3 | ||||
-rw-r--r-- | usr.bin/mg/file.c | 5 | ||||
-rw-r--r-- | usr.bin/mg/main.c | 24 | ||||
-rw-r--r-- | usr.bin/mg/mg.1 | 13 |
4 files changed, 39 insertions, 6 deletions
diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h index 6473577fd5f..d4728ce7ece 100644 --- a/usr.bin/mg/def.h +++ b/usr.bin/mg/def.h @@ -1,4 +1,4 @@ -/* $OpenBSD: def.h,v 1.44 2002/07/24 14:08:33 vincent Exp $ */ +/* $OpenBSD: def.h,v 1.45 2003/01/06 17:04:09 deraadt Exp $ */ #include <sys/queue.h> @@ -603,6 +603,7 @@ extern MGWIN *wheadp; extern int thisflag; extern int lastflag; extern int curgoal; +extern int startrow; extern int epresf; extern int sgarbf; extern int mode; diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c index 7310c71e6ca..f8fd6e7605e 100644 --- a/usr.bin/mg/file.c +++ b/usr.bin/mg/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.23 2002/09/15 22:18:40 vincent Exp $ */ +/* $OpenBSD: file.c,v 1.24 2003/01/06 17:04:09 deraadt Exp $ */ /* * File commands. @@ -166,6 +166,9 @@ readin(char *fname) curbp->b_flag |= BFREADONLY; else curbp->b_flag &=~ BFREADONLY; + + if (startrow) + gotoline(FFARG, startrow); return status; } diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c index 4aa35a298fa..15785a5a0d0 100644 --- a/usr.bin/mg/main.c +++ b/usr.bin/mg/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.22 2002/07/25 16:37:54 vincent Exp $ */ +/* $OpenBSD: main.c,v 1.23 2003/01/06 17:04:09 deraadt Exp $ */ /* * Mainline. @@ -15,6 +15,7 @@ int thisflag; /* flags, this command */ int lastflag; /* flags, last command */ int curgoal; /* goal column */ +int startrow; /* row to start */ BUFFER *curbp; /* current buffer */ BUFFER *bheadp; /* BUFFER listhead */ MGWIN *curwp; /* current window */ @@ -62,7 +63,26 @@ main(int argc, char **argv) (void)load(cp); #endif /* !NO_STARTUP */ while (--argc > 0) { - cp = adjustname(*++argv); + argv++; + + if (argv[0][0] == '+' && strlen(argv[0]) >= 2) { + long lval; + char *ep; + + errno = 0; + lval = strtoul(&argv[0][1], &ep, 10); + if (argv[0][1] == '\0' || *ep != '\0') + goto notnum; + if ((errno == ERANGE && + (lval == LONG_MAX || lval == LONG_MIN)) || + (lval > INT_MAX || lval < INT_MIN)) + goto notnum; + startrow = (int)lval; + continue; + } +notnum: + + cp = adjustname(*argv); if (cp != NULL) { curbp = findbuffer(cp); (void)showbuffer(curbp, curwp, 0); diff --git a/usr.bin/mg/mg.1 b/usr.bin/mg/mg.1 index e7378224234..149dcda7362 100644 --- a/usr.bin/mg/mg.1 +++ b/usr.bin/mg/mg.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mg.1,v 1.15 2003/01/05 09:50:40 pvalchev Exp $ +.\" $OpenBSD: mg.1,v 1.16 2003/01/06 17:04:09 deraadt Exp $ .\" .Dd February 25, 2000 .Dt MG 1 @@ -8,7 +8,8 @@ .Nd emacs-like text editor .Sh SYNOPSIS .Nm mg -.Op Ar +.Op Ar options files +.Op Ar ... .Sh DESCRIPTION .Nm is intended to be a small, fast, and portable editor for @@ -20,6 +21,14 @@ It is compatible with emacs because there shouldn't be any reason to learn more editor types than emacs or .Xr vi 1 . .Pp +At present time only one option is supported: +.Pp +.Bl -tag -width xxxxx -compact +.It Ar +number +Go to the line specified by number (do not insert +a space between the "+" sign and the number). +.El +.Pp Normal editing commands are very similar to Gnu Emacs. In the following examples, ^X means control-X, and M-X means Meta-X, where the Meta key may be either a special key on your keyboard |