Status bar in context color

This commit is contained in:
Arun Prakash Jana 2020-04-04 23:39:21 +05:30
parent 5bd4a65b91
commit 0e3146ebd2
No known key found for this signature in database
GPG Key ID: A75979F35C080412
1 changed files with 27 additions and 23 deletions

View File

@ -668,7 +668,6 @@ static haiku_nm_h haiku_hnd;
/* Function macros */ /* Function macros */
#define tolastln() move(xlines - 1, 0) #define tolastln() move(xlines - 1, 0)
#define exitcurses() endwin() #define exitcurses() endwin()
#define clearprompt() printmsg("")
#define printwarn(presel) printwait(strerror(errno), presel) #define printwarn(presel) printwait(strerror(errno), presel)
#define istopdir(path) ((path)[1] == '\0' && (path)[0] == '/') #define istopdir(path) ((path)[1] == '\0' && (path)[0] == '/')
#define copycurname() xstrlcpy(lastname, dents[cur].name, NAME_MAX + 1) #define copycurname() xstrlcpy(lastname, dents[cur].name, NAME_MAX + 1)
@ -789,8 +788,10 @@ static void clearoldprompt(void)
static void printmsg(const char *msg) static void printmsg(const char *msg)
{ {
tolastln(); tolastln();
attron(COLOR_PAIR(cfg.curctx + 1) | A_REVERSE);
addstr(msg); addstr(msg);
addch('\n'); hline(' ', xcols);
attroff(COLOR_PAIR(cfg.curctx + 1) | A_REVERSE);
} }
static void printwait(const char *msg, int *presel) static void printwait(const char *msg, int *presel)
@ -814,13 +815,6 @@ static void printerr(int linenum)
exit(1); exit(1);
} }
/* Print prompt on the last line */
static void printprompt(const char *str)
{
clearprompt();
addstr(str);
}
static void printinfoln(const char *str) static void printinfoln(const char *str)
{ {
clearinfoln(); clearinfoln();
@ -837,7 +831,7 @@ static int get_input(const char *prompt)
int r; int r;
if (prompt) if (prompt)
printprompt(prompt); printmsg(prompt);
cleartimeout(); cleartimeout();
#ifdef KEY_RESIZE #ifdef KEY_RESIZE
do { do {
@ -845,7 +839,7 @@ static int get_input(const char *prompt)
if (r == KEY_RESIZE && prompt) { if (r == KEY_RESIZE && prompt) {
clearoldprompt(); clearoldprompt();
xlines = LINES; xlines = LINES;
printprompt(prompt); printmsg(prompt);
} }
} while (r == KEY_RESIZE); } while (r == KEY_RESIZE);
#else #else
@ -2415,7 +2409,7 @@ static void showfilterinfo(void)
static void showfilter(char *str) static void showfilter(char *str)
{ {
showfilterinfo(); showfilterinfo();
printprompt(str); printmsg(str);
} }
static inline void swap_ent(int id1, int id2) static inline void swap_ent(int id1, int id2)
@ -2689,7 +2683,7 @@ static char *xreadline(const char *prefill, const char *prompt)
errexit(); errexit();
cleartimeout(); cleartimeout();
printprompt(prompt); printmsg(prompt);
if (prefill) { if (prefill) {
DPRINTF_S(prefill); DPRINTF_S(prefill);
@ -2707,8 +2701,10 @@ static char *xreadline(const char *prefill, const char *prompt)
while (1) { while (1) {
buf[len] = ' '; buf[len] = ' ';
attron(COLOR_PAIR(cfg.curctx + 1) | A_REVERSE);
mvaddnwstr(xlines - 1, x, buf, len + 1); mvaddnwstr(xlines - 1, x, buf, len + 1);
move(xlines - 1, x + wcswidth(buf, pos)); move(xlines - 1, x + wcswidth(buf, pos));
attroff(COLOR_PAIR(cfg.curctx + 1) | A_REVERSE);
r = get_wch(ch); r = get_wch(ch);
if (r == ERR) if (r == ERR)
@ -2747,7 +2743,7 @@ static char *xreadline(const char *prefill, const char *prompt)
--pos; --pos;
continue; continue;
case CONTROL('W'): case CONTROL('W'):
printprompt(prompt); printmsg(prompt);
do { do {
if (pos == 0) if (pos == 0)
break; break;
@ -2757,11 +2753,11 @@ static char *xreadline(const char *prefill, const char *prompt)
} while (buf[pos - 1] != ' ' && buf[pos - 1] != '/'); // NOLINT } while (buf[pos - 1] != ' ' && buf[pos - 1] != '/'); // NOLINT
continue; continue;
case CONTROL('K'): case CONTROL('K'):
printprompt(prompt); printmsg(prompt);
len = pos; len = pos;
continue; continue;
case CONTROL('L'): case CONTROL('L'):
printprompt(prompt); printmsg(prompt);
len = pos = 0; len = pos = 0;
continue; continue;
case CONTROL('A'): case CONTROL('A'):
@ -2771,7 +2767,7 @@ static char *xreadline(const char *prefill, const char *prompt)
pos = len; pos = len;
continue; continue;
case CONTROL('U'): case CONTROL('U'):
printprompt(prompt); printmsg(prompt);
memmove(buf, buf + pos, (len - pos) * WCHAR_T_WIDTH); memmove(buf, buf + pos, (len - pos) * WCHAR_T_WIDTH);
len -= pos; len -= pos;
pos = 0; pos = 0;
@ -2798,7 +2794,7 @@ static char *xreadline(const char *prefill, const char *prompt)
case KEY_RESIZE: case KEY_RESIZE:
clearoldprompt(); clearoldprompt();
xlines = LINES; xlines = LINES;
printprompt(prompt); printmsg(prompt);
break; break;
#endif #endif
case KEY_LEFT: case KEY_LEFT:
@ -2838,7 +2834,7 @@ static char *xreadline(const char *prefill, const char *prompt)
END: END:
curs_set(FALSE); curs_set(FALSE);
settimeout(); settimeout();
clearprompt(); printmsg("");
buf[len] = '\0'; buf[len] = '\0';
@ -4066,7 +4062,7 @@ static size_t handle_bookmark(const char *mark, char *newpath)
++r; ++r;
} }
printkeys(bookmark, g_buf + r - 1, maxbm); printkeys(bookmark, g_buf + r - 1, maxbm);
printprompt(g_buf); printmsg(g_buf);
r = FALSE; r = FALSE;
fd = get_input(NULL); fd = get_input(NULL);
@ -4353,7 +4349,8 @@ static blkcnt_t dirwalk(char *path, struct stat *psb)
ent_blocks = 0; ent_blocks = 0;
tolastln(); tolastln();
addstr(xbasename(path)); addstr(xbasename(path));
addstr(" [^C aborts]\n"); addstr(" [^C aborts]");
hline(' ', xcols);
refresh(); refresh();
if (nftw(path, nftw_fn, open_max, FTW_MOUNT | FTW_PHYS) < 0) { if (nftw(path, nftw_fn, open_max, FTW_MOUNT | FTW_PHYS) < 0) {
@ -4402,6 +4399,8 @@ static int dentfill(char *path, struct entry **dents)
goto exit; goto exit;
} else } else
clear_hash(); clear_hash();
attron(COLOR_PAIR(cfg.curctx + 1) | A_REVERSE);
} }
#if _POSIX_C_SOURCE >= 200112L #if _POSIX_C_SOURCE >= 200112L
@ -4575,6 +4574,9 @@ static int dentfill(char *path, struct entry **dents)
} while ((dp = readdir(dirp))); } while ((dp = readdir(dirp)));
exit: exit:
if (cfg.blkorder)
attroff(COLOR_PAIR(cfg.curctx + 1) | A_REVERSE);
/* Should never be null */ /* Should never be null */
if (closedir(dirp) == -1) if (closedir(dirp) == -1)
errexit(); errexit();
@ -4890,6 +4892,7 @@ static void statusbar(char *path)
ptr = "\b"; ptr = "\b";
tolastln(); tolastln();
attron(COLOR_PAIR(cfg.curctx + 1) | A_REVERSE);
if (cfg.blkorder) { /* du mode */ if (cfg.blkorder) { /* du mode */
char buf[24]; char buf[24];
@ -4921,7 +4924,8 @@ static void statusbar(char *path)
addstr(ptr); addstr(ptr);
} }
addch('\n'); hline(' ', xcols);
attroff(COLOR_PAIR(cfg.curctx + 1) | A_REVERSE);
} }
static int adjust_cols(int ncols) static int adjust_cols(int ncols)
@ -6121,7 +6125,7 @@ nochange:
r = xstrlcpy(g_buf, messages[MSG_PLUGIN_KEYS], CMD_LEN_MAX); r = xstrlcpy(g_buf, messages[MSG_PLUGIN_KEYS], CMD_LEN_MAX);
printkeys(plug, g_buf + r - 1, maxplug); printkeys(plug, g_buf + r - 1, maxplug);
printprompt(g_buf); printmsg(g_buf);
r = get_input(NULL); r = get_input(NULL);
if (r != '\r') { if (r != '\r') {
endselection(); endselection();