aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-06-29 21:13:51 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2017-06-29 21:13:51 +0200
commitc8498c9165f5bbbf0cc3e5bd941b2d2d1bb6c17d (patch)
tree972447b34dd9f623b0bdc8aa8a485c7ddadff636
parenta55fc17f31c19361c8cd014068c3753b0c28853f (diff)
downloadsdn-c8498c9165f5bbbf0cc3e5bd941b2d2d1bb6c17d.tar.gz
sdn-c8498c9165f5bbbf0cc3e5bd941b2d2d1bb6c17d.tar.xz
sdn-c8498c9165f5bbbf0cc3e5bd941b2d2d1bb6c17d.zip
Move contents to the bottom of the screen
Maybe this should have a switch.
-rw-r--r--sdn.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/sdn.cpp b/sdn.cpp
index 0a46a75..1afa865 100644
--- a/sdn.cpp
+++ b/sdn.cpp
@@ -135,27 +135,21 @@ static struct {
wstring editor_line;
} g;
-static inline int visible_lines () { return LINES - 2; }
+static inline int visible_lines () { return max (0, LINES - 2); }
static void
update () {
erase ();
- attrset (A_BOLD);
- mvprintw (0, 0, "%s", g.cwd.c_str ());
- if (g.out_of_date)
- addstr (" [+]");
-
- for (int i = 0; i < visible_lines (); i++) {
- int index = g.offset + i;
- if (index >= int (g.entries.size ()))
- break;
-
+ int available = visible_lines ();
+ int used = min (available, int (g.entries.size ()) - g.offset);
+ for (int i = 0; i < used; i++) {
attrset (0);
+ int index = g.offset + i;
if (index == g.cursor)
attron (A_REVERSE);
- move (2 + i, 0);
+ move (available - used + i, 0);
auto &entry = g.entries[index];
// TODO display more information from "info"
@@ -174,12 +168,17 @@ update () {
hline (' ', width - print (to_wide (entry.filename), width));
}
+ attrset (A_BOLD);
+ mvprintw (LINES - 2, 0, "%s", g.cwd.c_str ());
+ if (g.out_of_date)
+ addstr (" [+]");
+
attrset (0);
if (g.editor) {
- move (1, 0);
+ move (LINES - 1, 0);
wchar_t prefix[] = { g.editor, L' ', L'\0' };
addwstr (prefix);
- move (1, print (g.editor_line, COLS - 3) + 2);
+ move (LINES - 1, print (g.editor_line, COLS - 3) + 2);
curs_set (1);
} else
curs_set (0);