summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Carbonneaux2014-10-21 19:32:14 -0400
committerQuentin Carbonneaux2014-10-21 19:32:14 -0400
commit8264d498d4629a511180210e5ea04ed42023062a (patch)
tree1e2857cb2ed1f7918b124b4a5420118761df93fb
parenta2514692d72915d55a54b6870bc43ae765487597 (diff)
add minimal location indicator
-rw-r--r--gui.h2
-rw-r--r--win.c6
-rw-r--r--x11.c10
3 files changed, 14 insertions, 4 deletions
diff --git a/gui.h b/gui.h
index ae8564c..8d69b67 100644
--- a/gui.h
+++ b/gui.h
@@ -96,7 +96,7 @@ struct gui {
void (*fini)(void);
void (*sync)(void);
void (*getfont)(GFont *fret);
- void (*decorate)(GRect *clip, int dirty, GColor color);
+ void (*decorate)(GRect *clip, int dirty, float pos, GColor color);
void (*drawtext)(GRect *clip, Rune *str, int len,
int x, int y, GColor color);
void (*drawrect)(GRect *clip, int x, int y, int w, int h, GColor c);
diff --git a/win.c b/win.c
index fc196e9..1da13ee 100644
--- a/win.c
+++ b/win.c
@@ -448,6 +448,8 @@ draw(W *w, GColor bg)
int x, y, cx, cy, cw, rw, sel;
unsigned *next, c, s0, s1;
Rune r;
+ float pos;
+ int dirty;
s0 = eb_getmark(w->eb, SelBeg);
s1 = eb_getmark(w->eb, SelEnd);
@@ -498,7 +500,9 @@ draw(W *w, GColor bg)
if (cw != 0)
g->drawrect(&w->rect, cx, cy, cw, font.height, GXBlack);
- g->decorate(&w->rect, w->eb->path && w->eb->frev != eb_revision(w->eb), GGray);
+ dirty = w->eb->path && w->eb->frev != eb_revision(w->eb);
+ pos = w->eb->b.limbo ? (float)w->l[0] / w->eb->b.limbo : 0;
+ g->decorate(&w->rect, dirty, pos, GGray);
w->dirty = 0;
}
diff --git a/x11.c b/x11.c
index 14e8afb..be43d43 100644
--- a/x11.c
+++ b/x11.c
@@ -160,15 +160,21 @@ drawrect(GRect *clip, int x, int y, int w, int h, GColor c)
}
static void
-decorate(GRect *clip, int dirty, GColor c)
+decorate(GRect *clip, int dirty, float pos, GColor c)
{
- int boxh;
+ int boxh, scrlh, scrly;
boxh = VMargin + font->height;
drawrect(clip, HMargin-3, 0, 1, clip->h, c);
drawrect(clip, 0, boxh, HMargin-3, 1, c);
if (dirty)
drawrect(clip, 2, 2, HMargin-7, boxh-4, c);
+ scrlh = clip->h - boxh - 5;
+ scrly = pos * (scrlh - font->height);
+ if (scrly > scrlh - font->height)
+ scrly = scrlh - font->height;
+ scrly += boxh + 3;
+ drawrect(clip, 2, scrly, HMargin-7, font->height, c);
}
static void