瀏覽代碼

Count number of marked files

master
Bert Münnich 10 年之前
父節點
當前提交
284be74927
共有 2 個文件被更改,包括 11 次插入3 次删除
  1. +7
    -3
      commands.c
  2. +4
    -0
      main.c

+ 7
- 3
commands.c 查看文件

@@ -50,6 +50,7 @@ extern win_t win;
extern fileinfo_t *files;
extern int filecnt, fileidx;
extern int alternate;
extern int markcnt;

extern int prefix;
extern bool extprefix;
@@ -62,7 +63,7 @@ bool cg_quit(arg_t a)
{
unsigned int i;

if (options->to_stdout) {
if (options->to_stdout && markcnt > 0) {
for (i = 0; i < filecnt; i++) {
if (files[i].marked)
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)
{
files[fileidx].marked = !files[fileidx].marked;
markcnt += files[fileidx].marked ? 1 : -1;
if (mode == MODE_THUMB)
tns_mark(&tns, fileidx, files[fileidx].marked);
return true;
@@ -202,10 +204,12 @@ bool cg_toggle_image_mark(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;
markcnt += files[i].marked ? 1 : -1;
}
if (mode == MODE_THUMB)
tns.dirty = true;
return true;


+ 4
- 0
main.c 查看文件

@@ -73,6 +73,7 @@ win_t win;
fileinfo_t *files;
int filecnt, fileidx;
int alternate;
int markcnt;

int prefix;
bool extprefix;
@@ -168,6 +169,8 @@ void remove_file(int n, bool manual)
cleanup();
exit(manual ? EXIT_SUCCESS : EXIT_FAILURE);
}
if (files[n].marked)
markcnt--;

if (files[n].path != files[n].name)
free((void*) files[n].path);
@@ -627,6 +630,7 @@ void on_buttonpress(XButtonEvent *bev)
case Button3:
if ((sel = tns_translate(&tns, bev->x, bev->y)) >= 0) {
files[sel].marked = !files[sel].marked;
markcnt += files[sel].marked ? 1 : -1;
tns_mark(&tns, sel, files[sel].marked);
redraw();
}


Loading…
取消
儲存