diff options
| author | Quentin Carbonneaux | 2014-10-21 19:32:14 -0400 |
|---|---|---|
| committer | Quentin Carbonneaux | 2014-10-21 19:32:14 -0400 |
| commit | 8264d498d4629a511180210e5ea04ed42023062a (patch) | |
| tree | 1e2857cb2ed1f7918b124b4a5420118761df93fb | |
| parent | a2514692d72915d55a54b6870bc43ae765487597 (diff) | |
add minimal location indicator
| -rw-r--r-- | gui.h | 2 | ||||
| -rw-r--r-- | win.c | 6 | ||||
| -rw-r--r-- | x11.c | 10 |
3 files changed, 14 insertions, 4 deletions
@@ -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); @@ -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; } @@ -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 |
