static void move_cursor(int target, int ignore_scrolloff);
static char *load_input(int fd, const char *path);
static int set_sort_flags(int r);
-static void (*printptr)(const struct entry *ent, uint_t namecols, bool sel);
-static void printent_long(const struct entry *ent, uint_t namecols, bool sel);
#ifndef NOFIFO
static void notify_fifo(bool force);
#endif
static void printent(const struct entry *ent, uint_t namecols, bool sel)
{
+ if (cfg.showdetail) {
+ int attrs = g_state.oldcolor ? (resetdircolor(ent->flags), A_DIM)
+ : (fcolors[C_MIS] ? COLOR_PAIR(C_MIS) : 0);
+ int entry_type = ent->mode & S_IFMT;
+ char perms[6] = {' ', ' ', (char)('0' + ((ent->mode >> 6) & 7)),
+ (char)('0' + ((ent->mode >> 3) & 7)), (char)('0' + (ent->mode & 7)), '\0'};
+ char ind[2] = {'\0'};
+
+ addch(sel ? ' ' | A_REVERSE : ' '); /* Reversed block for hovered entry */
+
+ if (attrs)
+ attron(attrs);
+
+ /* Print details */
+ print_time(&ent->sec);
+
+ printw("%s%9s ", perms, (entry_type == S_IFREG || entry_type == S_IFDIR)
+ ? coolsize(cfg.blkorder ? (blkcnt_t)ent->blocks << blk_shift : ent->size)
+ : (ind[0] = get_detail_ind(ent->mode), ind));
+
+ if (attrs)
+ attroff(attrs);
+ }
+
char ind = '\0';
int attrs = 0;
uchar_t color_pair = get_color_pair_name_ind(ent, &ind, &attrs);
addch(ind);
}
-/* For the usage of comma operator in C, visit https://en.wikipedia.org/wiki/Comma_operator */
-static void printent_long(const struct entry *ent, uint_t namecols, bool sel)
-{
- int attrs = g_state.oldcolor ? (resetdircolor(ent->flags), A_DIM)
- : (fcolors[C_MIS] ? COLOR_PAIR(C_MIS) : 0);
- int entry_type = ent->mode & S_IFMT;
- char perms[6] = {' ', ' ', (char)('0' + ((ent->mode >> 6) & 7)),
- (char)('0' + ((ent->mode >> 3) & 7)), (char)('0' + (ent->mode & 7)), '\0'};
- char ind[2] = {'\0'};
-
- addch(sel ? ' ' | A_REVERSE : ' '); /* Reversed block for hovered entry */
-
- if (attrs)
- attron(attrs);
-
- /* Print details */
- print_time(&ent->sec);
-
- printw("%s%9s ", perms, (entry_type == S_IFREG || entry_type == S_IFDIR)
- ? coolsize(cfg.blkorder ? (blkcnt_t)ent->blocks << blk_shift : ent->size)
- : (ind[0] = get_detail_ind(ent->mode), ind));
-
- if (attrs)
- attroff(attrs);
-
- printent(ent, namecols, sel);
-}
-
-static void (*printptr)(const struct entry *ent, uint_t namecols, bool sel) = &printent;
-
static void savecurctx(settings *curcfg, char *path, char *curname, int nextctx)
{
settings tmpcfg = *curcfg;
g_ctx[tmpcfg.curctx].c_cfg = tmpcfg;
- if (ctxr->c_cfg.ctxactive) { /* Switch to saved context */
- /* Switch light/detail mode */
- if (tmpcfg.showdetail != ctxr->c_cfg.showdetail)
- /* set the reverse */
- printptr = tmpcfg.showdetail ? &printent : &printent_long;
-
+ if (ctxr->c_cfg.ctxactive) /* Switch to saved context */
tmpcfg = ctxr->c_cfg;
- } else { /* Set up a new context from current context */
+ else { /* Set up a new context from current context */
ctxr->c_cfg.ctxactive = 1;
xstrsncpy(ctxr->c_path, path, PATH_MAX);
ctxr->c_last[0] = ctxr->c_name[0] = ctxr->c_fltr[0] = ctxr->c_fltr[1] = '\0';
*path = g_ctx[cfg.curctx].c_path;
*lastdir = g_ctx[cfg.curctx].c_last;
*lastname = g_ctx[cfg.curctx].c_name;
- printptr = cfg.showdetail ? &printent_long : &printent;
set_sort_flags('\0'); /* Set correct sort options */
status = TRUE;
blk_shift = ffs(S_BLKSIZE) - 1;
}
- if (cfg.blkorder) {
+ if (cfg.blkorder)
cfg.showdetail = 1;
- printptr = &printent_long;
- }
cfg.timeorder = 0;
cfg.sizeorder = 0;
cfg.extnorder = 0;
#endif
if (cfg.showdetail) {
/* Fallback to light mode if less than 35 columns */
- if (n < 36) {
+ if (n < 36)
cfg.showdetail ^= 1;
- printptr = &printent;
- } else {
+ else {
/* 3 more accounted for below */
n -= 32;
}
}
move(2 + last - curscroll, 0);
- printptr(&pdents[last], ncols, FALSE);
+ printent(&pdents[last], ncols, FALSE);
if (g_state.oldcolor && (pdents[cur].flags & DIR_OR_LINK_TO_DIR)) {
if (!dir) {/* First file is not a directory */
}
move(2 + cur - curscroll, 0);
- printptr(&pdents[cur], ncols, TRUE);
+ printent(&pdents[cur], ncols, TRUE);
/* Must reset e.g. no files in dir */
if (dir)
/* Print listing */
for (i = curscroll; i < ndents && i < curscroll + onscreen; ++i) {
move(++j, 0);
- printptr(&pdents[i], ncols, i == cur);
+ printent(&pdents[i], ncols, i == cur);
}
/* Must reset e.g. no files in dir */
goto begin;
case SEL_DETAIL:
cfg.showdetail ^= 1;
- cfg.showdetail ? (printptr = &printent_long) : (printptr = &printent);
cfg.blkorder = 0;
continue;
default: /* SEL_SORT */
lastdir = g_ctx[r].c_last;
lastname = g_ctx[r].c_name;
- /* Switch light/detail mode */
- if (cfg.showdetail != g_ctx[r].c_cfg.showdetail)
- /* Set the reverse */
- printptr = cfg.showdetail ?
- &printent : &printent_long;
-
cfg = g_ctx[r].c_cfg;
cfg.curctx = r;
break;
case 'd':
cfg.showdetail = 1;
- printptr = &printent_long;
break;
case 'D':
g_state.dirctx = 1;