mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
[ncls] accept -s for scaling mode #1411
This commit is contained in:
parent
9728e79396
commit
ede7594971
@ -8,7 +8,7 @@ ncls - List paths with rendering of multimedia
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**ncls** [**-h**|**--help**] [**-V**|**--version**] [**-d**] [**-l**] [**-L**] [**-R**] [**-a**|**--align** ***type***] [**-b** ***blitter***] [ paths ]
|
||||
**ncls** [**-h**|**--help**] [**-V**|**--version**] [**-d**] [**-l**] [**-L**] [**-R**] [**-a**|**--align** ***type***] [**-b**|**--blitter** ***blitter***] [**-s**|**--scale** ***scale***] [ paths ]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@ -33,6 +33,8 @@ ncls - List paths with rendering of multimedia
|
||||
|
||||
**-b**|**--blitter** ***blitter***: Blitter, one of **ascii**, **half**, **quad**, **sex**, **braille**, or **pixel**.
|
||||
|
||||
**-s**|**--scale** ***scalemode***: Scaling mode, one of **none**, **hires**, **scale**, **scalehi**, or **stretch**.
|
||||
|
||||
paths: Run on the specified paths. If none are supplied, run on the current
|
||||
directory.
|
||||
|
||||
|
@ -26,6 +26,7 @@ void usage(std::ostream& os, const char* name, int code){
|
||||
os << " -R: list subdirectories recursively\n";
|
||||
os << " -a|--align type: 'left', 'right', or 'center'\n";
|
||||
os << " -b|--blitter blitter: 'ascii', 'half', 'quad', 'sex', 'braille', or 'pixel'\n";
|
||||
os << " -s|--scale scaling: one of 'none', 'hires', 'scale', 'scalehi', or 'stretch'\n";
|
||||
os << " -h: print usage information\n";
|
||||
os << " -V: print version information\n";
|
||||
os << std::flush;
|
||||
@ -52,6 +53,7 @@ struct lsContext {
|
||||
bool dereflinks;
|
||||
ncpp::NCAlign alignment;
|
||||
ncblitter_e blitter;
|
||||
ncscale_e scaling;
|
||||
};
|
||||
|
||||
int handle_path(int dirfd, std::filesystem::path& dir, const char* p, const lsContext& ctx, bool toplevel);
|
||||
@ -145,7 +147,7 @@ void ncls_thread(const lsContext* ctx) {
|
||||
work.pop();
|
||||
pthread_mutex_unlock(&mtx);
|
||||
auto s = j.dir / j.p;
|
||||
auto faken = ctx->nc.prep_image(s.c_str(), ctx->blitter, NCSCALE_SCALE_HIRES, -1, -1);
|
||||
auto faken = ctx->nc.prep_image(s.c_str(), ctx->blitter, ctx->scaling, -1, -1);
|
||||
pthread_mutex_lock(&outmtx);
|
||||
std::cout << j.p << '\n';
|
||||
if(faken){
|
||||
@ -184,15 +186,17 @@ int main(int argc, char* const * argv){
|
||||
bool dereflinks = false;
|
||||
ncpp::NCAlign alignment = ncpp::NCAlign::Right;
|
||||
ncblitter_e blitter = NCBLIT_DEFAULT;
|
||||
ncscale_e scale = NCSCALE_SCALE_HIRES;
|
||||
const struct option opts[] = {
|
||||
{ "align", 1, nullptr, 'a' },
|
||||
{ "blitter", 1, nullptr, 'b' },
|
||||
{ "scale", 1, nullptr, 's' },
|
||||
{ "help", 0, nullptr, 'h' },
|
||||
{ "version", 0, nullptr, 'V' },
|
||||
{ nullptr, 0, nullptr, 0 },
|
||||
};
|
||||
int c, lidx;
|
||||
while((c = getopt_long(argc, argv, "Va:b:dhlLR", opts, &lidx)) != -1){
|
||||
while((c = getopt_long(argc, argv, "Va:b:s:dhlLR", opts, &lidx)) != -1){
|
||||
switch(c){
|
||||
case 'V':
|
||||
printf("ncls version %s\n", notcurses_version());
|
||||
@ -216,6 +220,13 @@ int main(int argc, char* const * argv){
|
||||
usage(std::cerr, argv[0], EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
if(notcurses_lex_scalemode(optarg, &scale)){
|
||||
std::cerr << "Invalid scaling specification (got "
|
||||
<< optarg << ")" << std::endl;
|
||||
usage(std::cerr, argv[0], EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
directories = true;
|
||||
break;
|
||||
@ -252,6 +263,7 @@ int main(int argc, char* const * argv){
|
||||
dereflinks,
|
||||
alignment,
|
||||
blitter,
|
||||
scale,
|
||||
};
|
||||
ctx.nc.check_pixel_support();
|
||||
keep_working = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user