summaryrefslogtreecommitdiff
path: root/usr.bin/vi
diff options
context:
space:
mode:
authorJob Snijders <job@cvs.openbsd.org>2024-04-24 15:15:41 +0000
committerJob Snijders <job@cvs.openbsd.org>2024-04-24 15:15:41 +0000
commit0a102b31488ca4d6886d80936af54d53b48ac0c3 (patch)
tree2ef456968e93c4a5a6df7561a865a90d1af43326 /usr.bin/vi
parentbb1719229ba429903108c1ca51d69225e7516b4f (diff)
In ruler show the current line number as a percentage of the total lines
OK claudio@
Diffstat (limited to 'usr.bin/vi')
-rw-r--r--usr.bin/vi/docs/USD.doc/vi.man/vi.16
-rw-r--r--usr.bin/vi/vi/vs_refresh.c13
2 files changed, 13 insertions, 6 deletions
diff --git a/usr.bin/vi/docs/USD.doc/vi.man/vi.1 b/usr.bin/vi/docs/USD.doc/vi.man/vi.1
index 20abba2e8c1..585e033bce6 100644
--- a/usr.bin/vi/docs/USD.doc/vi.man/vi.1
+++ b/usr.bin/vi/docs/USD.doc/vi.man/vi.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: vi.1,v 1.84 2024/02/12 16:42:42 job Exp $
+.\" $OpenBSD: vi.1,v 1.85 2024/04/24 15:15:40 job Exp $
.\"
.\" Copyright (c) 1994
.\" The Regents of the University of California. All rights reserved.
@@ -14,7 +14,7 @@
.\"
.\" @(#)vi.1 8.51 (Berkeley) 10/10/96
.\"
-.Dd $Mdocdate: February 12 2024 $
+.Dd $Mdocdate: April 24 2024 $
.Dt VI 1
.Os
.Sh NAME
@@ -2461,7 +2461,7 @@ Set the number of lines about which the editor reports changes or yanks.
.It Cm ruler Bq off
.Nm vi
only.
-Display a row/column ruler on the colon command line.
+Display a row/column/percentage ruler on the colon command line.
.It Cm scroll , scr Bq "($LINES \- 1) / 2"
Set the number of lines scrolled.
.It Cm searchincr Bq off
diff --git a/usr.bin/vi/vi/vs_refresh.c b/usr.bin/vi/vi/vs_refresh.c
index 38b01ddee31..91769cfb3e6 100644
--- a/usr.bin/vi/vi/vs_refresh.c
+++ b/usr.bin/vi/vi/vs_refresh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vs_refresh.c,v 1.23 2024/02/12 16:42:43 job Exp $ */
+/* $OpenBSD: vs_refresh.c,v 1.24 2024/04/24 15:15:40 job Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -782,6 +782,7 @@ vs_modeline(SCR *sp)
const char *t = NULL;
int ellipsis;
char *p, buf[20];
+ recno_t last;
/*
* It's possible that this routine will be called after sp->frp
@@ -857,8 +858,14 @@ vs_modeline(SCR *sp)
cols = sp->cols - 1;
if (O_ISSET(sp, O_RULER)) {
vs_column(sp, &curcol);
- len = snprintf(buf, sizeof(buf), "%lu,%zu",
- (ulong)sp->lno, curcol + 1);
+
+ if (db_last(sp, &last))
+ len = snprintf(buf, sizeof(buf), "%lu,%zu",
+ (ulong)sp->lno, curcol + 1);
+ else
+ len = snprintf(buf, sizeof(buf), "%lu,%zu %lu%%",
+ (ulong)sp->lno, curcol + 1,
+ (unsigned long)(sp->lno * 100) / last);
midpoint = (cols - ((len + 1) / 2)) / 2;
if (curlen < midpoint) {