|
|
@ -1,4 +1,5 @@
|
|
|
|
#include <array>
|
|
|
|
#include <array>
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <clocale>
|
|
|
|
#include <clocale>
|
|
|
|
#include <sstream>
|
|
|
|
#include <sstream>
|
|
|
@ -18,7 +19,10 @@ static void usage(std::ostream& os, const char* name, int exitcode)
|
|
|
|
__attribute__ ((noreturn));
|
|
|
|
__attribute__ ((noreturn));
|
|
|
|
|
|
|
|
|
|
|
|
void usage(std::ostream& o, const char* name, int exitcode){
|
|
|
|
void usage(std::ostream& o, const char* name, int exitcode){
|
|
|
|
o << "usage: " << name << " [ -h ] [ -l loglevel ] [ -d mult ] files" << '\n';
|
|
|
|
o << "usage: " << name << " [ -h ] [ -l loglevel ] [ -d mult ] [ -s scaletype ] files" << '\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: positive floating point scale for frame time" << std::endl;
|
|
|
|
exit(exitcode);
|
|
|
|
exit(exitcode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -68,14 +72,25 @@ int perframe(struct notcurses* nc, struct ncvisual* ncv, void* vframecount){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// can exit() directly. returns index in argv of first non-option param.
|
|
|
|
// can exit() directly. returns index in argv of first non-option param.
|
|
|
|
int handle_opts(int argc, char** argv, notcurses_options* opts, float* timescale) {
|
|
|
|
int handle_opts(int argc, char** argv, notcurses_options* opts, float* timescale,
|
|
|
|
|
|
|
|
ncscale_e *scalemode) {
|
|
|
|
*timescale = 1.0;
|
|
|
|
*timescale = 1.0;
|
|
|
|
|
|
|
|
*scalemode = NCSCALE_SCALE;
|
|
|
|
int c;
|
|
|
|
int c;
|
|
|
|
while((c = getopt(argc, argv, "hl:d:")) != -1){
|
|
|
|
while((c = getopt(argc, argv, "hl:d:s:")) != -1){
|
|
|
|
switch(c){
|
|
|
|
switch(c){
|
|
|
|
case 'h':
|
|
|
|
case 'h':
|
|
|
|
usage(std::cout, argv[0], EXIT_SUCCESS);
|
|
|
|
usage(std::cout, argv[0], EXIT_SUCCESS);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 's':
|
|
|
|
|
|
|
|
if(strcmp(optarg, "stretch") == 0){
|
|
|
|
|
|
|
|
*scalemode = NCSCALE_STRETCH;
|
|
|
|
|
|
|
|
}else if(strcmp(optarg, "scale") == 0){
|
|
|
|
|
|
|
|
*scalemode = NCSCALE_SCALE;
|
|
|
|
|
|
|
|
}else if(strcmp(optarg, "none") == 0){
|
|
|
|
|
|
|
|
*scalemode = NCSCALE_NONE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 'd':{
|
|
|
|
case 'd':{
|
|
|
|
std::stringstream ss;
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << optarg;
|
|
|
|
ss << optarg;
|
|
|
@ -118,7 +133,8 @@ int main(int argc, char** argv){
|
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
notcurses_options opts{};
|
|
|
|
notcurses_options opts{};
|
|
|
|
float timescale;
|
|
|
|
float timescale;
|
|
|
|
auto nonopt = handle_opts(argc, argv, &opts, ×cale);
|
|
|
|
ncscale_e stretchmode;
|
|
|
|
|
|
|
|
auto nonopt = handle_opts(argc, argv, &opts, ×cale, &stretchmode);
|
|
|
|
auto nc = notcurses_init(&opts, stdout);
|
|
|
|
auto nc = notcurses_init(&opts, stdout);
|
|
|
|
if(nc == nullptr){
|
|
|
|
if(nc == nullptr){
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
return EXIT_FAILURE;
|
|
|
@ -135,7 +151,8 @@ int main(int argc, char** argv){
|
|
|
|
std::array<char, 128> errbuf;
|
|
|
|
std::array<char, 128> errbuf;
|
|
|
|
int frames = 0;
|
|
|
|
int frames = 0;
|
|
|
|
int averr;
|
|
|
|
int averr;
|
|
|
|
auto ncv = ncplane_visual_open(ncp, argv[i], &averr);
|
|
|
|
auto ncv = ncvisual_open_plane(nc, argv[i], &averr,
|
|
|
|
|
|
|
|
0, 0, stretchmode);
|
|
|
|
if(ncv == nullptr){
|
|
|
|
if(ncv == nullptr){
|
|
|
|
av_make_error_string(errbuf.data(), errbuf.size(), averr);
|
|
|
|
av_make_error_string(errbuf.data(), errbuf.size(), averr);
|
|
|
|
notcurses_stop(nc);
|
|
|
|
notcurses_stop(nc);
|
|
|
@ -161,7 +178,7 @@ int main(int argc, char** argv){
|
|
|
|
notcurses_stop(nc);
|
|
|
|
notcurses_stop(nc);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(ncplane_resize_simple(ncp, dimy, dimx)){
|
|
|
|
if(ncplane_resize_simple(ncvisual_plane(ncv), dimy, dimx)){
|
|
|
|
notcurses_stop(nc);
|
|
|
|
notcurses_stop(nc);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|