diff --git a/man/vi.1 b/man/vi.1 index 7226cac..5966573 100644 --- a/man/vi.1 +++ b/man/vi.1 @@ -2482,7 +2482,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 "window size / 2" Set the number of lines scrolled. .It Cm searchincr Bq off diff --git a/vi/vs_refresh.c b/vi/vs_refresh.c index d02fe96..406a89a 100644 --- a/vi/vs_refresh.c +++ b/vi/vs_refresh.c @@ -774,7 +774,8 @@ vs_modeline(SCR *sp) size_t cols, curcol, curlen, endpoint, len, midpoint; const char *t = NULL; int ellipsis; - char buf[20]; + char buf[30]; + recno_t last; gp = sp->gp; @@ -846,8 +847,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,%lu", - (u_long)sp->lno, (u_long)(curcol + 1)); + + if (db_last(sp, &last) || last == 0) + len = snprintf(buf, sizeof(buf), "%lu,%zu", + (u_long)sp->lno, curcol + 1); + else + len = snprintf(buf, sizeof(buf), "%lu,%zu %lu%%", + (u_long)sp->lno, curcol + 1, + (u_long)(sp->lno * 100) / last); midpoint = (cols - ((len + 1) / 2)) / 2; if (curlen < midpoint) {