diff options
author | Sven Eden <sven.eden@gmx.de> | 2013-01-16 13:56:22 +0100 |
---|---|---|
committer | Sven Eden <sven.eden@gmx.de> | 2013-01-16 13:56:22 +0100 |
commit | 8db257e9c8e2c8fa2bacdf826fc24e00467c7f03 (patch) | |
tree | a28a6c8a925cab39fb1d07a9a11f3ba657214ca5 /ufed-curses.c | |
parent | Added checks to disallow breaking the masked/unmasked flag filtering (diff) | |
download | ufed-8db257e9c8e2c8fa2bacdf826fc24e00467c7f03.tar.gz ufed-8db257e9c8e2c8fa2bacdf826fc24e00467c7f03.tar.bz2 ufed-8db257e9c8e2c8fa2bacdf826fc24e00467c7f03.zip |
Added the functonality to toggle masked flag display by pressing the
tab key.
Further added the key description to the bottom display and the
current filterstate (normal, masked, all) to the bottom right.
Diffstat (limited to 'ufed-curses.c')
-rw-r--r-- | ufed-curses.c | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/ufed-curses.c b/ufed-curses.c index edaef38..d7ff8da 100644 --- a/ufed-curses.c +++ b/ufed-curses.c @@ -208,18 +208,30 @@ static void draw(void) { { char *p = buf; const struct key *key; + const size_t maxAdr = (const size_t)(buf+wWidth(Bottom)-3); *p++ = ' '; for(key=keys; key->key!='\0'; key++) { - int n = (buf+wWidth(Bottom)-3) - p; + size_t n = maxAdr - (size_t)p; if(n > key->length) n = key->length; memcpy(p, key->descr, n); p += n; - *p++ = ' '; - if(p == buf+wWidth(Bottom)-3) + if ((size_t)p == maxAdr) break; + *p++ = ' '; + } + /* If there is enough space, show which kind of flags + * are displayed: normal, masked or all + */ + if ((size_t)p < (maxAdr - 9)) { + memset(p, ' ', maxAdr - 9 - (size_t)p); + p += maxAdr - 9 - (size_t)p; + if (show_unmasked == showMasked) strcpy(p, "[normal]"); + if (show_masked == showMasked) strcpy(p, "[masked]"); + if (show_both == showMasked) strcpy(p, "[ all ]"); + p += 8; } - memset(p, ' ', buf+wWidth(Bottom)-2-p); + memset(p, ' ', maxAdr + 1 - (size_t)p); buf[wWidth(Bottom)-2] = '\0'; } waddstr(w, buf); @@ -434,7 +446,7 @@ int maineventloop( continue; x -= 2; for(key = keys; key->key!='\0'; key++) { - if(x < key->length) { + if((size_t)x < key->length) { event.x -= x; wattrset(win(Bottom), COLOR_PAIR(3) | A_BOLD | A_REVERSE); mvwaddstr(win(Bottom), event.y, event.x, key->descr); @@ -549,7 +561,25 @@ int maineventloop( (*drawitem)(currentitem, TRUE); } break; - + + case '\t': + if (show_masked == showMasked) showMasked = show_unmasked; + else if (show_both == showMasked) showMasked = show_masked; + else if (show_unmasked == showMasked) showMasked = show_both; + currentitem = items; + topy = 0; + draw(); + break; + + case KEY_BTAB: + if (show_masked == showMasked) showMasked = show_both; + else if (show_both == showMasked) showMasked = show_unmasked; + else if (show_unmasked == showMasked) showMasked = show_masked; + currentitem = items; + topy = 0; + draw(); + break; + #ifdef KEY_RESIZE case KEY_RESIZE: resizeterm(LINES, COLS); |