ncplayer: support multiframe in direct mode via streamfile #1515

This commit is contained in:
nick black 2021-04-14 18:59:23 -04:00 committed by Nick Black
parent 3555257afb
commit 53f92760dd
2 changed files with 25 additions and 4 deletions

View File

@ -87,10 +87,8 @@ fixed-width font with good coverage of the Unicode Block Drawing Characters.
# BUGS # BUGS
Direct mode (**-k**) does not yet support multiframe media. It'll read them Direct mode is kinda fundamentally suboptimal for multiframe media, and
just fine, but only show the first frame. This might or might not change in is not yet supported with **-L** nor **-d**.
the future. Direct mode is kinda fundamentally suboptimal for multiframe
media. Until that time, **-k** is exclusive with **-d** and **-L**.
# SEE ALSO # SEE ALSO

View File

@ -298,6 +298,16 @@ auto handle_opts(int argc, char** argv, notcurses_options& opts, bool* quiet,
return optind; return optind;
} }
int perframe_direct(struct ncvisual* ncv, struct ncvisual_options* vopts,
const struct timespec* abstime, void* vmarshal){
// FIXME probably want to reset cursor here?
(void)ncv;
(void)vopts;
(void)abstime;
(void)vmarshal;
return 0;
}
// argc/argv ought already be reduced to only the media arguments // argc/argv ought already be reduced to only the media arguments
int direct_mode_player(int argc, char** argv, ncscale_e scalemode, int direct_mode_player(int argc, char** argv, ncscale_e scalemode,
ncblitter_e blitter, int lmargin, int rmargin){ ncblitter_e blitter, int lmargin, int rmargin){
@ -313,15 +323,18 @@ int direct_mode_player(int argc, char** argv, ncscale_e scalemode,
} }
} }
for(auto i = 0 ; i < argc ; ++i){ for(auto i = 0 ; i < argc ; ++i){
/*
auto faken = dm.prep_image(argv[i], blitter, scalemode, -1, auto faken = dm.prep_image(argv[i], blitter, scalemode, -1,
dm.get_dim_x() - (lmargin + rmargin)); dm.get_dim_x() - (lmargin + rmargin));
if(!faken){ if(!faken){
failed = true; failed = true;
break; break;
} }
*/
// FIXME we want to honor the different left and right margins, but that // FIXME we want to honor the different left and right margins, but that
// would require raster_image() knowing how far over we were starting for // would require raster_image() knowing how far over we were starting for
// multiline cellular blittings... // multiline cellular blittings...
(void)rmargin;
ncpp::NCAlign a; ncpp::NCAlign a;
if(blitter == NCBLIT_PIXEL){ if(blitter == NCBLIT_PIXEL){
printf("%*.*s", lmargin, lmargin, ""); printf("%*.*s", lmargin, lmargin, "");
@ -329,15 +342,25 @@ int direct_mode_player(int argc, char** argv, ncscale_e scalemode,
}else{ }else{
a = NCAlign::Center; a = NCAlign::Center;
} }
/*
if(dm.raster_image(faken, a)){ if(dm.raster_image(faken, a)){
failed = true; failed = true;
break; break;
} }
*/
int y, x; int y, x;
dm.get_cursor_yx(&y, &x); dm.get_cursor_yx(&y, &x);
if(x){ if(x){
std::cout << std::endl; std::cout << std::endl;
} }
struct ncvisual_options vopts{};
vopts.blitter = blitter;
vopts.scaling = scalemode;
vopts.x = static_cast<int>(a);
vopts.flags = NCVISUAL_OPTION_HORALIGNED;
if(dm.streamfile(argv[i], perframe_direct, &vopts, NULL)){
failed = true;
}
} }
return failed ? -1 : 0; return failed ? -1 : 0;
} }