Added file marks; fixes issue #94
- Command it_toggle_image_mark (bound to 'm') toggles mark of current image - Command it_navigate_marked (bound to 'N'/'P') can be used to go to the next/previous marked image - When option -o is given, all marked files get printed
This commit is contained in:
parent
84d77b1732
commit
7d878bd16d
|
@ -79,7 +79,7 @@ of small previews is displayed, making it easy to choose an image to open.
|
||||||
-i Read file list from stdin
|
-i Read file list from stdin
|
||||||
-n NUM Start at picture NUM
|
-n NUM Start at picture NUM
|
||||||
-N NAME Set X window resource name to NAME
|
-N NAME Set X window resource name to NAME
|
||||||
-o Write file list to stdout when quitting
|
-o Write list of marked/all files to stdout when quitting
|
||||||
-p Pixelize, i.e. turn off image anti-aliasing
|
-p Pixelize, i.e. turn off image anti-aliasing
|
||||||
-q Be quiet, disable warnings
|
-q Be quiet, disable warnings
|
||||||
-r Search given directories recursively for images
|
-r Search given directories recursively for images
|
||||||
|
@ -108,6 +108,10 @@ of small previews is displayed, making it easy to choose an image to open.
|
||||||
R Reload all thumbnails
|
R Reload all thumbnails
|
||||||
D Remove image from file list and go to next image
|
D Remove image from file list and go to next image
|
||||||
|
|
||||||
|
m Mark/unmark current image
|
||||||
|
N Go [count] marked images forward
|
||||||
|
P Go [count] marked images backward
|
||||||
|
|
||||||
*Thumbnail mode:*
|
*Thumbnail mode:*
|
||||||
|
|
||||||
h,j,k,l Move selection left/down/up/right [count] times
|
h,j,k,l Move selection left/down/up/right [count] times
|
||||||
|
|
47
commands.c
47
commands.c
|
@ -48,6 +48,7 @@ extern win_t win;
|
||||||
|
|
||||||
extern fileinfo_t *files;
|
extern fileinfo_t *files;
|
||||||
extern int filecnt, fileidx;
|
extern int filecnt, fileidx;
|
||||||
|
extern int markcnt;
|
||||||
extern int alternate;
|
extern int alternate;
|
||||||
|
|
||||||
extern int prefix;
|
extern int prefix;
|
||||||
|
@ -61,8 +62,10 @@ bool it_quit(arg_t a)
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (options->to_stdout) {
|
if (options->to_stdout) {
|
||||||
for (i = 0; i < filecnt; i++)
|
for (i = 0; i < filecnt; i++) {
|
||||||
printf("%s\n", files[i].name);
|
if (!markcnt || files[i].marked)
|
||||||
|
printf("%s\n", files[i].name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cleanup();
|
cleanup();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
@ -237,6 +240,46 @@ bool i_toggle_animation(arg_t a)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool it_toggle_image_mark(arg_t a)
|
||||||
|
{
|
||||||
|
int sel = mode == MODE_IMAGE ? fileidx : tns.sel;
|
||||||
|
|
||||||
|
files[sel].marked = !files[sel].marked;
|
||||||
|
markcnt += files[sel].marked ? 1 : -1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool it_navigate_marked(arg_t a)
|
||||||
|
{
|
||||||
|
long n = (long) a;
|
||||||
|
int d, i, cnt, sel, new;
|
||||||
|
|
||||||
|
if (mode == MODE_IMAGE)
|
||||||
|
cnt = filecnt, sel = new = fileidx;
|
||||||
|
else
|
||||||
|
cnt = tns.cnt, sel = new = tns.sel;
|
||||||
|
if (prefix > 0)
|
||||||
|
n *= prefix;
|
||||||
|
d = n > 0 ? 1 : -1;
|
||||||
|
for (i = sel + d; n != 0 && i >= 0 && i < cnt; i += d) {
|
||||||
|
if (files[i].marked) {
|
||||||
|
n -= d;
|
||||||
|
new = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (new != sel) {
|
||||||
|
if (mode == MODE_IMAGE) {
|
||||||
|
load_image(new);
|
||||||
|
} else {
|
||||||
|
tns.sel = new;
|
||||||
|
tns.dirty = true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool it_scroll_move(arg_t a)
|
bool it_scroll_move(arg_t a)
|
||||||
{
|
{
|
||||||
direction_t dir = (direction_t) a;
|
direction_t dir = (direction_t) a;
|
||||||
|
|
|
@ -54,6 +54,8 @@ bool it_first(arg_t);
|
||||||
bool it_n_or_last(arg_t);
|
bool it_n_or_last(arg_t);
|
||||||
bool i_navigate_frame(arg_t);
|
bool i_navigate_frame(arg_t);
|
||||||
bool i_toggle_animation(arg_t);
|
bool i_toggle_animation(arg_t);
|
||||||
|
bool it_toggle_image_mark(arg_t);
|
||||||
|
bool it_navigate_marked(arg_t);
|
||||||
bool it_scroll_move(arg_t);
|
bool it_scroll_move(arg_t);
|
||||||
bool it_scroll_screen(arg_t);
|
bool it_scroll_screen(arg_t);
|
||||||
bool i_scroll_to_edge(arg_t);
|
bool i_scroll_to_edge(arg_t);
|
||||||
|
|
|
@ -81,6 +81,10 @@ static const keymap_t keys[] = {
|
||||||
{ true, XK_p, i_navigate_frame, (arg_t) -1 },
|
{ true, XK_p, i_navigate_frame, (arg_t) -1 },
|
||||||
{ true, XK_space, i_toggle_animation, (arg_t) None },
|
{ true, XK_space, i_toggle_animation, (arg_t) None },
|
||||||
|
|
||||||
|
{ false, XK_m, it_toggle_image_mark, (arg_t) None },
|
||||||
|
{ false, XK_N, it_navigate_marked, (arg_t) +1 },
|
||||||
|
{ false, XK_P, it_navigate_marked, (arg_t) -1 },
|
||||||
|
|
||||||
{ false, XK_h, it_scroll_move, (arg_t) DIR_LEFT },
|
{ false, XK_h, it_scroll_move, (arg_t) DIR_LEFT },
|
||||||
{ false, XK_Left, it_scroll_move, (arg_t) DIR_LEFT },
|
{ false, XK_Left, it_scroll_move, (arg_t) DIR_LEFT },
|
||||||
{ false, XK_j, it_scroll_move, (arg_t) DIR_DOWN },
|
{ false, XK_j, it_scroll_move, (arg_t) DIR_DOWN },
|
||||||
|
|
7
main.c
7
main.c
|
@ -65,6 +65,7 @@ win_t win;
|
||||||
|
|
||||||
fileinfo_t *files;
|
fileinfo_t *files;
|
||||||
int filecnt, fileidx;
|
int filecnt, fileidx;
|
||||||
|
int markcnt;
|
||||||
int alternate;
|
int alternate;
|
||||||
|
|
||||||
int prefix;
|
int prefix;
|
||||||
|
@ -312,6 +313,7 @@ void update_info(void)
|
||||||
unsigned int i, fn, fw, n;
|
unsigned int i, fn, fw, n;
|
||||||
unsigned int llen = sizeof(win.bar.l), rlen = sizeof(win.bar.r);
|
unsigned int llen = sizeof(win.bar.l), rlen = sizeof(win.bar.r);
|
||||||
char *lt = win.bar.l, *rt = win.bar.r, title[TITLE_LEN];
|
char *lt = win.bar.l, *rt = win.bar.r, title[TITLE_LEN];
|
||||||
|
const char * mark;
|
||||||
bool ow_info;
|
bool ow_info;
|
||||||
|
|
||||||
for (fw = 0, i = filecnt; i > 0; fw++, i /= 10);
|
for (fw = 0, i = filecnt; i > 0; fw++, i /= 10);
|
||||||
|
@ -328,9 +330,10 @@ void update_info(void)
|
||||||
/* update bar contents */
|
/* update bar contents */
|
||||||
if (win.bar.h == 0)
|
if (win.bar.h == 0)
|
||||||
return;
|
return;
|
||||||
|
mark = files[sel].marked ? "* " : "";
|
||||||
if (mode == MODE_THUMB) {
|
if (mode == MODE_THUMB) {
|
||||||
if (tns.cnt == filecnt) {
|
if (tns.cnt == filecnt) {
|
||||||
n = snprintf(rt, rlen, "%0*d/%d", fw, sel + 1, filecnt);
|
n = snprintf(rt, rlen, "%s%0*d/%d", mark, fw, sel + 1, filecnt);
|
||||||
ow_info = true;
|
ow_info = true;
|
||||||
} else {
|
} else {
|
||||||
snprintf(lt, llen, "Loading... %0*d/%d", fw, tns.cnt, filecnt);
|
snprintf(lt, llen, "Loading... %0*d/%d", fw, tns.cnt, filecnt);
|
||||||
|
@ -338,7 +341,7 @@ void update_info(void)
|
||||||
ow_info = false;
|
ow_info = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
n = snprintf(rt, rlen, "%3d%% | ", (int) (img.zoom * 100.0));
|
n = snprintf(rt, rlen, "%s%3d%% | ", mark, (int) (img.zoom * 100.0));
|
||||||
if (img.multi.cnt > 0) {
|
if (img.multi.cnt > 0) {
|
||||||
for (fn = 0, i = img.multi.cnt; i > 0; fn++, i /= 10);
|
for (fn = 0, i = img.multi.cnt; i > 0; fn++, i /= 10);
|
||||||
n += snprintf(rt + n, rlen - n, "%0*d/%d | ",
|
n += snprintf(rt + n, rlen - n, "%0*d/%d | ",
|
||||||
|
|
16
sxiv.1
16
sxiv.1
|
@ -62,7 +62,8 @@ Print brief usage information to standard output and exit.
|
||||||
Read names of files to open from standard input.
|
Read names of files to open from standard input.
|
||||||
.TP
|
.TP
|
||||||
.B \-o
|
.B \-o
|
||||||
Write list of opened files to standard output when quitting. If combined with
|
Write list of all marked files, or all opened files if no files are marked, to
|
||||||
|
standard output when quitting. If combined with
|
||||||
.IR \-i ,
|
.IR \-i ,
|
||||||
then sxiv acts as a visual filter/pipe.
|
then sxiv acts as a visual filter/pipe.
|
||||||
.TP
|
.TP
|
||||||
|
@ -128,6 +129,19 @@ Reload all thumbnails.
|
||||||
.TP
|
.TP
|
||||||
.B D
|
.B D
|
||||||
Remove current image from file list and go to next image.
|
Remove current image from file list and go to next image.
|
||||||
|
.TP
|
||||||
|
.B m
|
||||||
|
Mark/unmark the current image.
|
||||||
|
.TP
|
||||||
|
.B N
|
||||||
|
Go
|
||||||
|
.I count
|
||||||
|
marked images forward.
|
||||||
|
.TP
|
||||||
|
.B P
|
||||||
|
Go
|
||||||
|
.I count
|
||||||
|
marked images backward.
|
||||||
.SH THUMBNAIL KEYBOARD COMMANDS
|
.SH THUMBNAIL KEYBOARD COMMANDS
|
||||||
The following keyboard commands are only available in thumbnail mode:
|
The following keyboard commands are only available in thumbnail mode:
|
||||||
.TP
|
.TP
|
||||||
|
|
1
types.h
1
types.h
|
@ -69,6 +69,7 @@ typedef struct {
|
||||||
const char *path; /* always absolute */
|
const char *path; /* always absolute */
|
||||||
const char *base;
|
const char *base;
|
||||||
bool loaded;
|
bool loaded;
|
||||||
|
bool marked;
|
||||||
} fileinfo_t;
|
} fileinfo_t;
|
||||||
|
|
||||||
/* timeouts in milliseconds: */
|
/* timeouts in milliseconds: */
|
||||||
|
|
Loading…
Reference in New Issue