mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
[ncplayer] obey margins in direct mode #1411
This commit is contained in:
parent
1a1305faee
commit
9728e79396
@ -8,7 +8,7 @@ ncplayer - Render images and video to a terminal
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**ncplayer** [**-h**] [**-V**] [**-q**] [**-d** ***delaymult***] [**-l** ***loglevel***] [**-b** ***blitter***] [**-s** ***scalemode***] [**-k**] [**-L**] [**-a** ***align***] [**-t** ***seconds***] files
|
||||
**ncplayer** [**-h**] [**-V**] [**-q**] [**-d** ***delaymult***] [**-l** ***loglevel***] [**-b** ***blitter***] [**-s** ***scalemode***] [**-k**] [**-L**] [**-t** ***seconds***] files
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@ -33,8 +33,6 @@ be any non-negative number.
|
||||
|
||||
**-b** ***blitter***: Blitter, one of **ascii**, **half**, **quad**, **sex**, **braille**, or **pixel**.
|
||||
|
||||
**-a** ***type***: Align images on **left**, **center**, or **right**.
|
||||
|
||||
**-m margins**: Define rendering margins (see below).
|
||||
|
||||
**-L**: Loop frames until a key is pressed. Not supported with **-k**.
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "Root.hh"
|
||||
#include "Cell.hh"
|
||||
#include "NCAlign.hh"
|
||||
|
||||
namespace ncpp
|
||||
{
|
||||
@ -138,9 +139,9 @@ namespace ncpp
|
||||
return error_guard (ncdirect_cursor_disable (direct), -1);
|
||||
}
|
||||
|
||||
int render_image (const char* file, ncalign_e align, ncblitter_e blitter, ncscale_e scale) const noexcept
|
||||
int render_image (const char* file, NCAlign align, ncblitter_e blitter, ncscale_e scale) const noexcept
|
||||
{
|
||||
return ncdirect_render_image (direct, file, align, blitter, scale);
|
||||
return ncdirect_render_image (direct, file, static_cast<ncalign_e>(align), blitter, scale);
|
||||
}
|
||||
|
||||
ncdirectv* prep_image (const char* file, ncblitter_e blitter, ncscale_e scale, int maxy, int maxx) const noexcept
|
||||
@ -148,9 +149,9 @@ namespace ncpp
|
||||
return ncdirect_render_frame (direct, file, blitter, scale, maxy, maxx);
|
||||
}
|
||||
|
||||
int raster_image (ncdirectv* faken, ncalign_e align) const noexcept
|
||||
int raster_image (ncdirectv* faken, NCAlign align) const noexcept
|
||||
{
|
||||
return ncdirect_raster_frame (direct, faken, align);
|
||||
return ncdirect_raster_frame (direct, faken, static_cast<ncalign_e>(align));
|
||||
}
|
||||
|
||||
bool putstr (uint64_t channels, const char* utf8) const NOEXCEPT_MAYBE
|
||||
|
@ -50,7 +50,7 @@ struct lsContext {
|
||||
bool recursedirs;
|
||||
bool directories;
|
||||
bool dereflinks;
|
||||
ncalign_e alignment;
|
||||
ncpp::NCAlign alignment;
|
||||
ncblitter_e blitter;
|
||||
};
|
||||
|
||||
@ -182,7 +182,7 @@ int main(int argc, char* const * argv){
|
||||
bool recursedirs = false;
|
||||
bool longlisting = false;
|
||||
bool dereflinks = false;
|
||||
ncalign_e alignment = NCALIGN_RIGHT;
|
||||
ncpp::NCAlign alignment = ncpp::NCAlign::Right;
|
||||
ncblitter_e blitter = NCBLIT_DEFAULT;
|
||||
const struct option opts[] = {
|
||||
{ "align", 1, nullptr, 'a' },
|
||||
@ -199,11 +199,11 @@ int main(int argc, char* const * argv){
|
||||
exit(EXIT_SUCCESS);
|
||||
case 'a':
|
||||
if(strcasecmp(optarg, "left") == 0){
|
||||
alignment = NCALIGN_LEFT;
|
||||
alignment = ncpp::NCAlign::Left;
|
||||
}else if(strcasecmp(optarg, "right") == 0){
|
||||
alignment = NCALIGN_RIGHT;
|
||||
alignment = ncpp::NCAlign::Right;
|
||||
}else if(strcasecmp(optarg, "center") == 0){
|
||||
alignment = NCALIGN_CENTER;
|
||||
alignment = ncpp::NCAlign::Center;
|
||||
}else{
|
||||
std::cerr << "Unknown alignment type: " << optarg << "\n";
|
||||
usage(std::cerr, argv[0], EXIT_FAILURE);
|
||||
|
@ -28,7 +28,6 @@ void usage(std::ostream& o, const char* name, int exitcode){
|
||||
o << " -t seconds: delay t seconds after each file\n";
|
||||
o << " -l loglevel: integer between 0 and 9, goes to stderr'\n";
|
||||
o << " -s scaling: one of 'none', 'hires', 'scale', 'scalehi', or 'stretch'\n";
|
||||
o << " -a type: 'left', 'right', or 'center'\n";
|
||||
o << " -b blitter: one of 'ascii', 'half', 'quad', 'sex', 'braille', or 'pixel'\n";
|
||||
o << " -m margins: margin, or 4 comma-separated margins\n";
|
||||
o << " -d mult: non-negative floating point scale for frame time" << std::endl;
|
||||
@ -302,7 +301,8 @@ int direct_mode_player(int argc, char** argv, ncscale_e scalemode,
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
if(dm.raster_image(faken, NCALIGN_RIGHT)){
|
||||
printf("%*.*s", lmargin, lmargin, "");
|
||||
if(dm.raster_image(faken, NCAlign::Left)){
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user