aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2019-09-27 22:38:48 +0200
committerPřemysl Janouch <p@janouch.name>2019-09-27 22:38:48 +0200
commitbf38e4e9eaa08fbfeee69e3340594819942abf13 (patch)
tree832be88b16c331cc77e8f505038d1d071f04e9a4
parent2c847fb4a3af99379f283f85dff7983494ca34bc (diff)
downloadsdn-bf38e4e9eaa08fbfeee69e3340594819942abf13.tar.gz
sdn-bf38e4e9eaa08fbfeee69e3340594819942abf13.tar.xz
sdn-bf38e4e9eaa08fbfeee69e3340594819942abf13.zip
Position indicator like in vi
-rw-r--r--sdn.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/sdn.cpp b/sdn.cpp
index 913c705..428031b 100644
--- a/sdn.cpp
+++ b/sdn.cpp
@@ -665,7 +665,8 @@ fun update () {
erase ();
int available = visible_lines ();
- int used = min (available, int (g.entries.size ()) - g.offset);
+ int all = g.entries.size ();
+ int used = min (available, all - g.offset);
for (int i = 0; i < used; i++) {
auto index = g.offset + i;
bool selected = index == g.cursor;
@@ -693,7 +694,19 @@ fun update () {
move (LINES - 2, 0);
attrset (g.attrs[g.AT_BAR]);
- hline (' ', COLS - print (bar, COLS));
+ int unused = COLS - print (bar, COLS);
+ hline (' ', unused);
+
+ auto pos = to_wstring (int (double (g.offset) / all * 100)) + L"%";
+ if (used == all)
+ pos = L"All";
+ else if (g.offset == 0)
+ pos = L"Top";
+ else if (g.offset + used == all)
+ pos = L"Bot";
+
+ if (int (pos.size ()) < unused)
+ mvaddwstr (LINES - 2, COLS - pos.size (), pos.c_str ());
attrset (g.attrs[g.AT_INPUT]);
curs_set (0);