diff options
| author | sinanmohd <pcmsinan@gmail.com> | 2022-07-15 19:52:44 +0530 | 
|---|---|---|
| committer | sinanmohd <pcmsinan@gmail.com> | 2022-07-15 19:52:44 +0530 | 
| commit | 99e5def4f4e939b5583eafefd25345cb58443a02 (patch) | |
| tree | 6619a55a76b5d979f1c10e5ab86ab91d19873b99 | |
| parent | 5cab2fb52520e6a24012351b936ebb9162494666 (diff) | |
| -rw-r--r-- | main.c | 2 | ||||
| -rw-r--r-- | nsxiv.h | 1 | ||||
| -rw-r--r-- | options.c | 11 | 
3 files changed, 12 insertions, 2 deletions
@@ -367,6 +367,8 @@ bool mark_image(int n, bool on)  		markcnt += on ? 1 : -1;  		if (mode == MODE_THUMB)  			tns_mark(&tns, n, on); +		if (options->to_stdout_count == markcnt) +			cg_quit(0);  		return true;  	}  	return false; @@ -228,6 +228,7 @@ struct opt {  	char **filenames;  	bool from_stdin;  	bool to_stdout; +	int to_stdout_count;  	bool using_null;  	bool recursive;  	int filecnt; @@ -30,7 +30,7 @@ const opt_t *options;  void print_usage(void)  {  	printf("usage: nsxiv [-abcfhiopqrtvZ0] [-A FRAMERATE] [-e WID] [-G GAMMA] " -	       "[-g GEOMETRY] [-N NAME] [-n NUM] [-S DELAY] [-s MODE] " +	       "[-g GEOMETRY] [-N NAME] [-n NUM]  [-S DELAY] [-s MODE] [-k NUM]"  	       "[-z ZOOM] FILES...\n");  } @@ -65,6 +65,7 @@ void parse_options(int argc, char **argv)  	_options.from_stdin = false;  	_options.to_stdout = false; +	_options.to_stdout_count = false;  	_options.using_null = false;  	_options.recursive = false;  	_options.startnum = 0; @@ -87,7 +88,7 @@ void parse_options(int argc, char **argv)  	_options.clean_cache = false;  	_options.private_mode = false; -	while ((opt = getopt(argc, argv, "A:abce:fG:g:hin:N:opqrS:s:T:tvZz:0")) != -1) { +	while ((opt = getopt(argc, argv, "A:abce:fG:g:hin:N:k:opqrS:s:T:tvZz:0")) != -1) {  		switch (opt) {  			case '?':  				print_usage(); @@ -143,6 +144,12 @@ void parse_options(int argc, char **argv)  			case 'o':  				_options.to_stdout = true;  				break; +                        case 'k' : +				n = strtol(optarg, &end, 0); +				if (*end != '\0' || n <= 0) +					error(EXIT_FAILURE, 0, "Invalid argument for option -k: %s", optarg); +				_options.to_stdout_count = atoi(optarg); +                                break;  			case 'p':  				_options.private_mode = true;  				break;  | 
