diff options
author | Přemysl Janouch <p@janouch.name> | 2018-11-02 18:14:53 +0100 |
---|---|---|
committer | Přemysl Janouch <p@janouch.name> | 2018-11-02 18:30:35 +0100 |
commit | 6b1ff048b84dda376c785b599fdd31f018cc902a (patch) | |
tree | dce524e8dfedf1bc0de87e2b94a75e9a6db8fabb | |
parent | 3790f8dfa0abb83ddede5a80cd42ffb1e75f163d (diff) | |
download | sdn-6b1ff048b84dda376c785b599fdd31f018cc902a.tar.gz sdn-6b1ff048b84dda376c785b599fdd31f018cc902a.tar.xz sdn-6b1ff048b84dda376c785b599fdd31f018cc902a.zip |
Flash column when sorting is changed
-rw-r--r-- | sdn.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -280,6 +280,12 @@ fun decolor (cchar_t &ch) { setcchar (&ch, c, attrs &~ A_REVERSE, 0, nullptr); } +fun invert (cchar_t &ch) { + wchar_t c[CCHARW_MAX]; attr_t attrs; short pair; + getcchar (&ch, c, &attrs, &pair, nullptr); + setcchar (&ch, c, attrs ^ A_REVERSE, 0, nullptr); +} + fun apply_attrs (const wstring &w, attr_t attrs) -> ncstring { ncstring res; for (auto c : w) @@ -465,6 +471,7 @@ static struct { bool show_hidden; ///< Show hidden files int max_widths[entry::COLUMNS]; ///< Column widths int sort_column = entry::FILENAME; ///< Sorting column + int sort_flash_ttl; ///< Sorting column flash TTL wstring message; ///< Message for the user int message_ttl; ///< Time to live for the message @@ -659,6 +666,8 @@ fun update () { for (int col = start_column; col < entry::COLUMNS; col++) { const auto &field = g.entries[index].cols[col]; auto aligned = align (field, alignment[col] * g.max_widths[col]); + if (g.sort_flash_ttl && col == g.sort_column) + for_each (begin (aligned), end (aligned), invert); if (selected) for_each (begin (aligned), end (aligned), decolor); used += print (aligned + apply_attrs (L" ", 0), COLS - used); @@ -965,10 +974,12 @@ fun handle (wint_t c) -> bool { case ACTION_SORT_LEFT: g.sort_column = (g.sort_column + entry::COLUMNS - 1) % entry::COLUMNS; + g.sort_flash_ttl = 2; reload (); break; case ACTION_SORT_RIGHT: g.sort_column = (g.sort_column + entry::COLUMNS + 1) % entry::COLUMNS; + g.sort_flash_ttl = 2; reload (); break; @@ -1392,6 +1403,8 @@ int main (int argc, char *argv[]) { wint_t c; while (!read_key (c) || handle (c)) { inotify_check (); + if (g.sort_flash_ttl && !--g.sort_flash_ttl) + update (); if (g.message_ttl && !--g.message_ttl) { g.message.clear (); update (); |