mirror of
https://codeberg.org/nsxiv/nsxiv
synced 2024-11-15 12:13:10 +00:00
Added screen-wise scrolling for thumbnail mode
This commit is contained in:
parent
3e2523818b
commit
1cdbeb972a
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
|||||||
VERSION = git-20111017
|
VERSION = git-20111027
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -ansi -Wall -pedantic -O2
|
CFLAGS = -ansi -Wall -pedantic -O2
|
||||||
|
@ -102,6 +102,7 @@ The following general key commands are available:
|
|||||||
The following additional key commands are available in *thumbnail mode*:
|
The following additional key commands are available in *thumbnail mode*:
|
||||||
|
|
||||||
h,j,k,l Move selection left/down/up/right
|
h,j,k,l Move selection left/down/up/right
|
||||||
|
Ctrl-j,k Scroll thumbnail grid one window height down/up
|
||||||
|
|
||||||
The following additional key commands are available in *image mode*:
|
The following additional key commands are available in *image mode*:
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ bool i_toggle_animation(arg_t a) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool it_move(arg_t a) {
|
bool it_scroll_move(arg_t a) {
|
||||||
direction_t dir = (direction_t) a;
|
direction_t dir = (direction_t) a;
|
||||||
|
|
||||||
if (mode == MODE_IMAGE)
|
if (mode == MODE_IMAGE)
|
||||||
@ -197,16 +197,16 @@ bool it_move(arg_t a) {
|
|||||||
return tns_move_selection(&tns, dir);
|
return tns_move_selection(&tns, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool i_pan_screen(arg_t a) {
|
bool it_scroll_screen(arg_t a) {
|
||||||
direction_t dir = (direction_t) a;
|
direction_t dir = (direction_t) a;
|
||||||
|
|
||||||
if (mode == MODE_IMAGE)
|
if (mode == MODE_IMAGE)
|
||||||
return img_pan(&img, dir, -1);
|
return img_pan(&img, dir, -1);
|
||||||
else
|
else
|
||||||
return false;
|
return tns_scroll(&tns, dir, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool i_pan_edge(arg_t a) {
|
bool i_scroll_to_edge(arg_t a) {
|
||||||
direction_t dir = (direction_t) a;
|
direction_t dir = (direction_t) a;
|
||||||
|
|
||||||
if (mode == MODE_IMAGE)
|
if (mode == MODE_IMAGE)
|
||||||
|
@ -51,9 +51,9 @@ 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_move(arg_t);
|
bool it_scroll_move(arg_t);
|
||||||
bool i_pan_screen(arg_t);
|
bool it_scroll_screen(arg_t);
|
||||||
bool i_pan_edge(arg_t);
|
bool i_scroll_to_edge(arg_t);
|
||||||
bool i_drag(arg_t);
|
bool i_drag(arg_t);
|
||||||
bool i_zoom(arg_t);
|
bool i_zoom(arg_t);
|
||||||
bool i_set_zoom(arg_t);
|
bool i_set_zoom(arg_t);
|
||||||
|
48
config.def.h
48
config.def.h
@ -85,28 +85,28 @@ 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_h, it_move, (arg_t) DIR_LEFT },
|
{ false, XK_h, it_scroll_move, (arg_t) DIR_LEFT },
|
||||||
{ false, XK_Left, it_move, (arg_t) DIR_LEFT },
|
{ false, XK_Left, it_scroll_move, (arg_t) DIR_LEFT },
|
||||||
{ false, XK_j, it_move, (arg_t) DIR_DOWN },
|
{ false, XK_j, it_scroll_move, (arg_t) DIR_DOWN },
|
||||||
{ false, XK_Down, it_move, (arg_t) DIR_DOWN },
|
{ false, XK_Down, it_scroll_move, (arg_t) DIR_DOWN },
|
||||||
{ false, XK_k, it_move, (arg_t) DIR_UP },
|
{ false, XK_k, it_scroll_move, (arg_t) DIR_UP },
|
||||||
{ false, XK_Up, it_move, (arg_t) DIR_UP },
|
{ false, XK_Up, it_scroll_move, (arg_t) DIR_UP },
|
||||||
{ false, XK_l, it_move, (arg_t) DIR_RIGHT },
|
{ false, XK_l, it_scroll_move, (arg_t) DIR_RIGHT },
|
||||||
{ false, XK_Right, it_move, (arg_t) DIR_RIGHT },
|
{ false, XK_Right, it_scroll_move, (arg_t) DIR_RIGHT },
|
||||||
|
|
||||||
{ true, XK_h, i_pan_screen, (arg_t) DIR_LEFT },
|
{ true, XK_h, it_scroll_screen, (arg_t) DIR_LEFT },
|
||||||
{ true, XK_Left, i_pan_screen, (arg_t) DIR_LEFT },
|
{ true, XK_Left, it_scroll_screen, (arg_t) DIR_LEFT },
|
||||||
{ true, XK_j, i_pan_screen, (arg_t) DIR_DOWN },
|
{ true, XK_j, it_scroll_screen, (arg_t) DIR_DOWN },
|
||||||
{ true, XK_Down, i_pan_screen, (arg_t) DIR_DOWN },
|
{ true, XK_Down, it_scroll_screen, (arg_t) DIR_DOWN },
|
||||||
{ true, XK_k, i_pan_screen, (arg_t) DIR_UP },
|
{ true, XK_k, it_scroll_screen, (arg_t) DIR_UP },
|
||||||
{ true, XK_Up, i_pan_screen, (arg_t) DIR_UP },
|
{ true, XK_Up, it_scroll_screen, (arg_t) DIR_UP },
|
||||||
{ true, XK_l, i_pan_screen, (arg_t) DIR_RIGHT },
|
{ true, XK_l, it_scroll_screen, (arg_t) DIR_RIGHT },
|
||||||
{ true, XK_Right, i_pan_screen, (arg_t) DIR_RIGHT },
|
{ true, XK_Right, it_scroll_screen, (arg_t) DIR_RIGHT },
|
||||||
|
|
||||||
{ false, XK_H, i_pan_edge, (arg_t) DIR_LEFT },
|
{ false, XK_H, i_scroll_to_edge, (arg_t) DIR_LEFT },
|
||||||
{ false, XK_J, i_pan_edge, (arg_t) DIR_DOWN },
|
{ false, XK_J, i_scroll_to_edge, (arg_t) DIR_DOWN },
|
||||||
{ false, XK_K, i_pan_edge, (arg_t) DIR_UP },
|
{ false, XK_K, i_scroll_to_edge, (arg_t) DIR_UP },
|
||||||
{ false, XK_L, i_pan_edge, (arg_t) DIR_RIGHT },
|
{ false, XK_L, i_scroll_to_edge, (arg_t) DIR_RIGHT },
|
||||||
|
|
||||||
{ false, XK_plus, i_zoom, (arg_t) +1 },
|
{ false, XK_plus, i_zoom, (arg_t) +1 },
|
||||||
{ false, XK_KP_Add, i_zoom, (arg_t) +1 },
|
{ false, XK_KP_Add, i_zoom, (arg_t) +1 },
|
||||||
@ -147,10 +147,10 @@ static const button_t buttons[] = {
|
|||||||
{ false, false, Button1, i_navigate, (arg_t) +1 },
|
{ false, false, Button1, i_navigate, (arg_t) +1 },
|
||||||
{ false, false, Button3, i_navigate, (arg_t) -1 },
|
{ false, false, Button3, i_navigate, (arg_t) -1 },
|
||||||
{ false, false, Button2, i_drag, (arg_t) None },
|
{ false, false, Button2, i_drag, (arg_t) None },
|
||||||
{ false, false, Button4, it_move, (arg_t) DIR_UP },
|
{ false, false, Button4, it_scroll_move, (arg_t) DIR_UP },
|
||||||
{ false, false, Button5, it_move, (arg_t) DIR_DOWN },
|
{ false, false, Button5, it_scroll_move, (arg_t) DIR_DOWN },
|
||||||
{ false, true, Button4, it_move, (arg_t) DIR_LEFT },
|
{ false, true, Button4, it_scroll_move, (arg_t) DIR_LEFT },
|
||||||
{ false, true, Button5, it_move, (arg_t) DIR_RIGHT },
|
{ false, true, Button5, it_scroll_move, (arg_t) DIR_RIGHT },
|
||||||
{ true, false, Button4, i_zoom, (arg_t) +1 },
|
{ true, false, Button4, i_zoom, (arg_t) +1 },
|
||||||
{ true, false, Button5, i_zoom, (arg_t) -1 },
|
{ true, false, Button5, i_zoom, (arg_t) -1 },
|
||||||
};
|
};
|
||||||
|
3
main.c
3
main.c
@ -394,7 +394,8 @@ void on_buttonpress(XButtonEvent *bev) {
|
|||||||
break;
|
break;
|
||||||
case Button4:
|
case Button4:
|
||||||
case Button5:
|
case Button5:
|
||||||
if (tns_scroll(&tns, bev->button == Button4 ? DIR_UP : DIR_DOWN))
|
if (tns_scroll(&tns, bev->button == Button4 ? DIR_UP : DIR_DOWN,
|
||||||
|
(bev->state & ControlMask) != 0))
|
||||||
redraw();
|
redraw();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
6
sxiv.1
6
sxiv.1
@ -127,6 +127,12 @@ Move selection up.
|
|||||||
.TP
|
.TP
|
||||||
.BR l ", " Right
|
.BR l ", " Right
|
||||||
Move selection right.
|
Move selection right.
|
||||||
|
.TP
|
||||||
|
.BR Ctrl-j ", " Ctrl-Down
|
||||||
|
Scroll thumbnail grid one window height down.
|
||||||
|
.TP
|
||||||
|
.BR Ctrl-k ", " Ctrl-Up
|
||||||
|
Scroll thumbnail grid one window height up.
|
||||||
.SH IMAGE KEYBOARD COMMANDS
|
.SH IMAGE KEYBOARD COMMANDS
|
||||||
The following keyboard commands are only available in image mode:
|
The following keyboard commands are only available in image mode:
|
||||||
.SS Navigate image list
|
.SS Navigate image list
|
||||||
|
21
thumbs.c
21
thumbs.c
@ -430,20 +430,25 @@ bool tns_move_selection(tns_t *tns, direction_t dir) {
|
|||||||
return tns->sel != old;
|
return tns->sel != old;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tns_scroll(tns_t *tns, direction_t dir) {
|
bool tns_scroll(tns_t *tns, direction_t dir, bool screen) {
|
||||||
int old;
|
int d, max, old;
|
||||||
|
|
||||||
if (tns == NULL)
|
if (tns == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
old = tns->first;
|
old = tns->first;
|
||||||
|
d = tns->cols * (screen ? tns->rows : 1);
|
||||||
|
|
||||||
if (dir == DIR_DOWN && tns->first + tns->cols * tns->rows < tns->cnt) {
|
if (dir == DIR_DOWN) {
|
||||||
tns->first += tns->cols;
|
max = tns->cnt - tns->cols * tns->rows;
|
||||||
tns_check_view(tns, true);
|
if (tns->cnt % tns->cols != 0)
|
||||||
tns->dirty = true;
|
max += tns->cols - tns->cnt % tns->cols;
|
||||||
} else if (dir == DIR_UP && tns->first >= tns->cols) {
|
tns->first = MIN(tns->first + d, max);
|
||||||
tns->first -= tns->cols;
|
} else if (dir == DIR_UP) {
|
||||||
|
tns->first = MAX(tns->first - d, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tns->first != old) {
|
||||||
tns_check_view(tns, true);
|
tns_check_view(tns, true);
|
||||||
tns->dirty = true;
|
tns->dirty = true;
|
||||||
}
|
}
|
||||||
|
2
thumbs.h
2
thumbs.h
@ -62,7 +62,7 @@ void tns_render(tns_t*);
|
|||||||
void tns_highlight(tns_t*, int, bool);
|
void tns_highlight(tns_t*, int, bool);
|
||||||
|
|
||||||
bool tns_move_selection(tns_t*, direction_t);
|
bool tns_move_selection(tns_t*, direction_t);
|
||||||
bool tns_scroll(tns_t*, direction_t);
|
bool tns_scroll(tns_t*, direction_t, bool);
|
||||||
|
|
||||||
int tns_translate(tns_t*, int, int);
|
int tns_translate(tns_t*, int, int);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user