add ncplane_destroy() #26

This commit is contained in:
nick black 2019-11-27 17:22:35 -05:00 committed by Nick Black
parent 5dfb07183c
commit 8dfd050ab7
3 changed files with 26 additions and 9 deletions

View File

@ -16,6 +16,7 @@ find_package(PkgConfig REQUIRED)
pkg_check_modules(TERMINFO REQUIRED tinfo>=6.1)
pkg_check_modules(AVUTIL REQUIRED libavutil)
pkg_check_modules(AVFORMAT REQUIRED libavformat)
pkg_check_modules(SWSCALE REQUIRED libswscale)
find_library(LIBRT rt)
file(GLOB LIBSRCS CONFIGURE_DEPENDS src/lib/*.c)
@ -26,11 +27,13 @@ target_include_directories(notcurses
"${PROJECT_BINARY_DIR}/include"
"${TERMINFO_INCLUDE_DIR}"
"${AVFORMAT_INCLUDE_DIR}"
"${SWSCALE_INCLUDE_DIR}"
)
target_link_libraries(notcurses
PRIVATE
"${TERMINFO_LIBRARIES}"
"${AVFORMAT_LIBRARIES}"
"${SWSCALE_LIBRARIES}"
"${LIBRT}"
)
set_target_properties(notcurses PROPERTIES

View File

@ -325,6 +325,16 @@ const ncplane* notcurses_stdplane_const(const notcurses* nc){
return nc->stdscr;
}
int ncplane_destroy(notcurses* nc, ncplane* ncp){
if(ncp){
if(nc->stdscr == ncp){
return -1;
}
// FIXME close it up
}
return 0;
}
static int
interrogate_terminfo(notcurses* nc, const notcurses_options* opts){
char* longname_term = longname();

View File

@ -14,7 +14,7 @@ void usage(std::ostream& o, const char* name, int exitcode){
exit(exitcode);
}
int ncview(struct ncvisual* ncv, const notcurses_options* opts){
int ncview(struct ncvisual* ncv){
AVFrame* avf;
if((avf = ncvisual_decode(ncv)) == nullptr){
return -1;
@ -22,12 +22,7 @@ int ncview(struct ncvisual* ncv, const notcurses_options* opts){
printf("%s: %dx%d aspect %d:%d %d\n", avf->key_frame ? "Keyframe" : "Frame",
avf->height, avf->width, avf->sample_aspect_ratio.num,
avf->sample_aspect_ratio.den, avf->format);
auto nc = notcurses_init(opts);
if(nc == nullptr){
return -1;
}
ncvisual_destroy(ncv);
return notcurses_stop(nc);
return 0;
}
int main(int argc, char** argv){
@ -37,15 +32,24 @@ int main(int argc, char** argv){
notcurses_options opts{};
opts.outfp = stdout;
bool success = true;
auto nc = notcurses_init(&opts);
if(nc == nullptr){
return -1;
}
auto ncp = notcurses_stdplane(nc);
for(int i = 1 ; i < argc ; ++i){
auto ncv = notcurses_visual_open(nullptr, argv[i]);
auto ncv = ncplane_visual_open(ncp, argv[i]);
if(ncv == nullptr){
success = false;
continue;
}
if(ncview(ncv, &opts)){
if(ncview(ncv)){
success = false;
}
ncvisual_destroy(ncv);
}
if(notcurses_stop(nc)){
success = false;
}
if(!success){
return EXIT_FAILURE;