Introduction
Introduction Statistics Contact Development Disclaimer Help
tvi: center the current line for long jumps - neatvi - [fork] simple vi-type ed…
git clone git://src.adamsgaard.dk/neatvi
Log
Files
Refs
README
---
commit 69f88a475e1d3633b0f944a1917ba7cc74da823a
parent 9724b248644e35bd73ecf9fa0a2adae08f372f14
Author: Ali Gholami Rudi <[email protected]>
Date: Mon, 18 May 2015 17:09:46 +0430
vi: center the current line for long jumps
Diffstat:
M vi.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/vi.c b/vi.c
t@@ -1025,6 +1025,7 @@ static void vi(void)
int redraw = 0;
int nrow = xrow;
int ncol = ren_noeol(lbuf_get(xb, xrow), xcol);
+ int otop = xtop;
int mv, n;
vi_arg2 = 0;
vi_ybuf = vi_yankbuf();
t@@ -1197,11 +1198,13 @@ static void vi(void)
}
if (xrow < 0 || xrow >= lbuf_len(xb))
xrow = lbuf_len(xb) ? lbuf_len(xb) - 1 : 0;
- if (xrow < xtop || xrow >= xtop + xrows) {
- xtop = xrow < xtop ? xrow : MAX(0, xrow - xrows + 1);
- redraw = 1;
- }
- if (redraw)
+ if (xtop > xrow)
+ xtop = xtop - xrows / 2 > xrow ?
+ MAX(0, xrow - xrows / 2) : xrow;
+ if (xtop + xrows <= xrow)
+ xtop = xtop + xrows + xrows / 2 <= xrow ?
+ xrow - xrows / 2 : xrow - xrows + 1;
+ if (redraw || xtop != otop)
vi_draw();
if (xmsg[0])
vi_drawmsg();
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.