view: support -k to inhibit alternate screen #551

This commit is contained in:
nick black 2020-04-29 03:08:21 -04:00
parent 92ea6bac6f
commit 6e8a0bebae
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 10 additions and 4 deletions

View File

@ -8,7 +8,7 @@ notcurses-view - Render images and video to the console
# SYNOPSIS
**notcurses-view** [**-h|--help**] [**-d delaymult**] [**-l loglevel**] [**-s scalemode**] files
**notcurses-view** [**-h|--help**] [**-d delaymult**] [**-l loglevel**] [**-s scalemode**] [**-k**] files
# DESCRIPTION
@ -23,6 +23,8 @@ and videos to the terminal. Media will be scaled to the terminal's size.
**-s scalemode**: Scaling mode, one of **none**, **scale**, or **stretch**.
**-k**: Inhibit use of the alternate screen. Necessary if you want the output left on your terminal after the program exits.
files: Select which files to render, and what order to render them in.
# NOTES

View File

@ -17,7 +17,8 @@ static void usage(std::ostream& os, const char* name, int exitcode)
__attribute__ ((noreturn));
void usage(std::ostream& o, const char* name, int exitcode){
o << "usage: " << name << " [ -h ] [ -l loglevel ] [ -d mult ] [ -s scaling ] files" << '\n';
o << "usage: " << name << " [ -h ] [ -l loglevel ] [ -d mult ] [ -s scaletype ] [ -k ] files" << '\n';
o << " -k: don't use the alternate screen\n";
o << " -l loglevel: integer between 0 and 9, goes to stderr'\n";
o << " -s scaletype: one of 'none', 'scale', or 'stretch'\n";
o << " -d mult: non-negative floating point scale for frame time" << std::endl;
@ -103,7 +104,7 @@ int handle_opts(int argc, char** argv, notcurses_options& opts, float* timescale
*timescale = 1.0;
*scalemode = NCScale::Scale;
int c;
while((c = getopt(argc, argv, "hl:d:s:")) != -1){
while((c = getopt(argc, argv, "hl:d:s:k")) != -1){
switch(c){
case 'h':
usage(std::cout, argv[0], EXIT_SUCCESS);
@ -117,7 +118,10 @@ int handle_opts(int argc, char** argv, notcurses_options& opts, float* timescale
*scalemode = NCScale::None;
}
break;
case 'd':{
case 'k':{
opts.inhibit_alternate_screen = true;
break;
}case 'd':{
std::stringstream ss;
ss << optarg;
float ts;