Count number of marked files
This commit is contained in:
parent
5b01c15176
commit
284be74927
10
commands.c
10
commands.c
@ -50,6 +50,7 @@ extern win_t win;
|
|||||||
extern fileinfo_t *files;
|
extern fileinfo_t *files;
|
||||||
extern int filecnt, fileidx;
|
extern int filecnt, fileidx;
|
||||||
extern int alternate;
|
extern int alternate;
|
||||||
|
extern int markcnt;
|
||||||
|
|
||||||
extern int prefix;
|
extern int prefix;
|
||||||
extern bool extprefix;
|
extern bool extprefix;
|
||||||
@ -62,7 +63,7 @@ bool cg_quit(arg_t a)
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (options->to_stdout) {
|
if (options->to_stdout && markcnt > 0) {
|
||||||
for (i = 0; i < filecnt; i++) {
|
for (i = 0; i < filecnt; i++) {
|
||||||
if (files[i].marked)
|
if (files[i].marked)
|
||||||
printf("%s\n", files[i].name);
|
printf("%s\n", files[i].name);
|
||||||
@ -195,6 +196,7 @@ bool cg_scroll_screen(arg_t a)
|
|||||||
bool cg_toggle_image_mark(arg_t a)
|
bool cg_toggle_image_mark(arg_t a)
|
||||||
{
|
{
|
||||||
files[fileidx].marked = !files[fileidx].marked;
|
files[fileidx].marked = !files[fileidx].marked;
|
||||||
|
markcnt += files[fileidx].marked ? 1 : -1;
|
||||||
if (mode == MODE_THUMB)
|
if (mode == MODE_THUMB)
|
||||||
tns_mark(&tns, fileidx, files[fileidx].marked);
|
tns_mark(&tns, fileidx, files[fileidx].marked);
|
||||||
return true;
|
return true;
|
||||||
@ -202,10 +204,12 @@ bool cg_toggle_image_mark(arg_t a)
|
|||||||
|
|
||||||
bool cg_reverse_marks(arg_t a)
|
bool cg_reverse_marks(arg_t a)
|
||||||
{
|
{
|
||||||
int i, cnt = mode == MODE_IMAGE ? filecnt : tns.cnt;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < cnt; i++)
|
for (i = 0; i < filecnt; i++) {
|
||||||
files[i].marked = !files[i].marked;
|
files[i].marked = !files[i].marked;
|
||||||
|
markcnt += files[i].marked ? 1 : -1;
|
||||||
|
}
|
||||||
if (mode == MODE_THUMB)
|
if (mode == MODE_THUMB)
|
||||||
tns.dirty = true;
|
tns.dirty = true;
|
||||||
return true;
|
return true;
|
||||||
|
4
main.c
4
main.c
@ -73,6 +73,7 @@ win_t win;
|
|||||||
fileinfo_t *files;
|
fileinfo_t *files;
|
||||||
int filecnt, fileidx;
|
int filecnt, fileidx;
|
||||||
int alternate;
|
int alternate;
|
||||||
|
int markcnt;
|
||||||
|
|
||||||
int prefix;
|
int prefix;
|
||||||
bool extprefix;
|
bool extprefix;
|
||||||
@ -168,6 +169,8 @@ void remove_file(int n, bool manual)
|
|||||||
cleanup();
|
cleanup();
|
||||||
exit(manual ? EXIT_SUCCESS : EXIT_FAILURE);
|
exit(manual ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
if (files[n].marked)
|
||||||
|
markcnt--;
|
||||||
|
|
||||||
if (files[n].path != files[n].name)
|
if (files[n].path != files[n].name)
|
||||||
free((void*) files[n].path);
|
free((void*) files[n].path);
|
||||||
@ -627,6 +630,7 @@ void on_buttonpress(XButtonEvent *bev)
|
|||||||
case Button3:
|
case Button3:
|
||||||
if ((sel = tns_translate(&tns, bev->x, bev->y)) >= 0) {
|
if ((sel = tns_translate(&tns, bev->x, bev->y)) >= 0) {
|
||||||
files[sel].marked = !files[sel].marked;
|
files[sel].marked = !files[sel].marked;
|
||||||
|
markcnt += files[sel].marked ? 1 : -1;
|
||||||
tns_mark(&tns, sel, files[sel].marked);
|
tns_mark(&tns, sel, files[sel].marked);
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user