summaryrefslogtreecommitdiffstats
path: root/commands.c
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2015-01-04 15:38:49 +0100
committerBert Münnich <ber.t@posteo.de>2015-01-04 21:24:43 +0100
commit9b9294bae67da4e0388e7c31d0063f4e114aa1f8 (patch)
tree8a9a6ece7fb48b548a75cae28dfe4b4acb99d3c3 /commands.c
parent0cb1d1130568d61c06a2cdd22ab050973e302fc8 (diff)
downloadnsxiv-9b9294bae67da4e0388e7c31d0063f4e114aa1f8.tar.zst
Use bit-field for boolean flags in fileinfo struct
Diffstat (limited to 'commands.c')
-rw-r--r--commands.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/commands.c b/commands.c
index 770f780..f77add3 100644
--- a/commands.c
+++ b/commands.c
@@ -61,7 +61,7 @@ bool cg_quit(arg_t a)
if (options->to_stdout && markcnt > 0) {
for (i = 0; i < filecnt; i++) {
- if (files[i].marked)
+ if (files[i].flags & FF_MARK)
printf("%s\n", files[i].name);
}
}
@@ -200,10 +200,10 @@ bool cg_zoom(arg_t a)
bool cg_toggle_image_mark(arg_t a)
{
- files[fileidx].marked = !files[fileidx].marked;
- markcnt += files[fileidx].marked ? 1 : -1;
+ files[fileidx].flags ^= FF_MARK;
+ markcnt += files[fileidx].flags & FF_MARK ? 1 : -1;
if (mode == MODE_THUMB)
- tns_mark(&tns, fileidx, files[fileidx].marked);
+ tns_mark(&tns, fileidx, !!(files[fileidx].flags & FF_MARK));
return true;
}
@@ -212,8 +212,8 @@ bool cg_reverse_marks(arg_t a)
int i;
for (i = 0; i < filecnt; i++) {
- files[i].marked = !files[i].marked;
- markcnt += files[i].marked ? 1 : -1;
+ files[i].flags ^= FF_MARK;
+ markcnt += files[i].flags & FF_MARK ? 1 : -1;
}
if (mode == MODE_THUMB)
tns.dirty = true;
@@ -225,7 +225,7 @@ bool cg_unmark_all(arg_t a)
int i;
for (i = 0; i < filecnt; i++)
- files[i].marked = false;
+ files[i].flags &= ~FF_MARK;
markcnt = 0;
if (mode == MODE_THUMB)
tns.dirty = true;
@@ -242,7 +242,7 @@ bool cg_navigate_marked(arg_t a)
n *= prefix;
d = n > 0 ? 1 : -1;
for (i = fileidx + d; n != 0 && i >= 0 && i < filecnt; i += d) {
- if (files[i].marked) {
+ if (files[i].flags & FF_MARK) {
n -= d;
new = i;
}