handle count prefix in thumbnail movements
This commit is contained in:
		
							parent
							
								
									4451f4a5eb
								
							
						
					
					
						commit
						c330b55de4
					
				| @ -99,7 +99,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 [count] times | ||||||
|     Ctrl-j,k     Scroll thumbnail grid one window height down/up |     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*: | ||||||
|  | |||||||
| @ -209,7 +209,7 @@ bool it_scroll_move(arg_t a) { | |||||||
| 	if (mode == MODE_IMAGE) | 	if (mode == MODE_IMAGE) | ||||||
| 		return img_pan(&img, dir, prefix); | 		return img_pan(&img, dir, prefix); | ||||||
| 	else | 	else | ||||||
| 		return tns_move_selection(&tns, dir); | 		return tns_move_selection(&tns, dir, prefix); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool it_scroll_screen(arg_t a) { | bool it_scroll_screen(arg_t a) { | ||||||
|  | |||||||
							
								
								
									
										16
									
								
								sxiv.1
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								sxiv.1
									
									
									
									
									
								
							| @ -126,16 +126,24 @@ Remove current image from file list and go to next image. | |||||||
| The following keyboard commands are only available in thumbnail mode: | The following keyboard commands are only available in thumbnail mode: | ||||||
| .TP | .TP | ||||||
| .BR h ", " Left | .BR h ", " Left | ||||||
| Move selection left. | Move selection left | ||||||
|  | .I count | ||||||
|  | times. | ||||||
| .TP | .TP | ||||||
| .BR j ", " Down | .BR j ", " Down | ||||||
| Move selection down. | Move selection down | ||||||
|  | .I count | ||||||
|  | times. | ||||||
| .TP | .TP | ||||||
| .BR k ", " Up | .BR k ", " Up | ||||||
| Move selection up. | Move selection up | ||||||
|  | .I count | ||||||
|  | times. | ||||||
| .TP | .TP | ||||||
| .BR l ", " Right | .BR l ", " Right | ||||||
| Move selection right. | Move selection right | ||||||
|  | .I count | ||||||
|  | times. | ||||||
| .TP | .TP | ||||||
| .BR Ctrl-j ", " Ctrl-Down | .BR Ctrl-j ", " Ctrl-Down | ||||||
| Scroll thumbnail grid one window height down. | Scroll thumbnail grid one window height down. | ||||||
|  | |||||||
							
								
								
									
										17
									
								
								thumbs.c
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								thumbs.c
									
									
									
									
									
								
							| @ -390,8 +390,9 @@ void tns_highlight(tns_t *tns, int n, bool hl) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool tns_move_selection(tns_t *tns, direction_t dir) { | bool tns_move_selection(tns_t *tns, direction_t dir, int count) { | ||||||
| 	int old; | 	int old; | ||||||
|  |     int c = (count > 0 ? count : 1); | ||||||
| 
 | 
 | ||||||
| 	if (tns == NULL || tns->thumbs == NULL) | 	if (tns == NULL || tns->thumbs == NULL) | ||||||
| 		return false; | 		return false; | ||||||
| @ -400,22 +401,16 @@ bool tns_move_selection(tns_t *tns, direction_t dir) { | |||||||
| 
 | 
 | ||||||
| 	switch (dir) { | 	switch (dir) { | ||||||
| 		case DIR_UP: | 		case DIR_UP: | ||||||
| 			if (tns->sel >= tns->cols) |             tns->sel = MAX(tns->sel - c * tns->cols, tns->sel % tns->cols); | ||||||
| 				tns->sel -= tns->cols; |  | ||||||
| 			break; | 			break; | ||||||
| 		case DIR_DOWN: | 		case DIR_DOWN: | ||||||
| 			if (tns->sel + tns->cols < tns->cnt) |             tns->sel = MIN(tns->sel + c * tns->cols, tns->cols * ((tns->cnt - 1) / tns->cols) + MIN((tns->cnt - 1) % tns->cols, tns->sel % tns->cols)); | ||||||
| 				tns->sel += tns->cols; |  | ||||||
| 			else if (tns->sel < tns->cnt - tns->cnt % tns->cols) |  | ||||||
| 				tns->sel = tns->cnt - 1; |  | ||||||
| 			break; | 			break; | ||||||
| 		case DIR_LEFT: | 		case DIR_LEFT: | ||||||
| 			if (tns->sel > 0) |             tns->sel = MAX(tns->sel - c, 0); | ||||||
| 				tns->sel--; |  | ||||||
| 			break; | 			break; | ||||||
| 		case DIR_RIGHT: | 		case DIR_RIGHT: | ||||||
| 			if (tns->sel < tns->cnt - 1) | 			tns->sel = MIN(tns->sel + c, tns->cnt - 1); | ||||||
| 				tns->sel++; |  | ||||||
| 			break; | 			break; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								thumbs.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								thumbs.h
									
									
									
									
									
								
							| @ -61,7 +61,7 @@ bool tns_load(tns_t*, int, const fileinfo_t*, bool, bool); | |||||||
| void tns_render(tns_t*); | 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, int); | ||||||
| bool tns_scroll(tns_t*, direction_t, bool); | bool tns_scroll(tns_t*, direction_t, bool); | ||||||
| 
 | 
 | ||||||
| int tns_translate(tns_t*, int, int); | int tns_translate(tns_t*, int, int); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 baskerville
						baskerville