mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-10-31 15:20:13 +00:00
add ncplane_destroy() #26
This commit is contained in:
parent
5dfb07183c
commit
8dfd050ab7
@ -16,6 +16,7 @@ find_package(PkgConfig REQUIRED)
|
|||||||
pkg_check_modules(TERMINFO REQUIRED tinfo>=6.1)
|
pkg_check_modules(TERMINFO REQUIRED tinfo>=6.1)
|
||||||
pkg_check_modules(AVUTIL REQUIRED libavutil)
|
pkg_check_modules(AVUTIL REQUIRED libavutil)
|
||||||
pkg_check_modules(AVFORMAT REQUIRED libavformat)
|
pkg_check_modules(AVFORMAT REQUIRED libavformat)
|
||||||
|
pkg_check_modules(SWSCALE REQUIRED libswscale)
|
||||||
find_library(LIBRT rt)
|
find_library(LIBRT rt)
|
||||||
|
|
||||||
file(GLOB LIBSRCS CONFIGURE_DEPENDS src/lib/*.c)
|
file(GLOB LIBSRCS CONFIGURE_DEPENDS src/lib/*.c)
|
||||||
@ -26,11 +27,13 @@ target_include_directories(notcurses
|
|||||||
"${PROJECT_BINARY_DIR}/include"
|
"${PROJECT_BINARY_DIR}/include"
|
||||||
"${TERMINFO_INCLUDE_DIR}"
|
"${TERMINFO_INCLUDE_DIR}"
|
||||||
"${AVFORMAT_INCLUDE_DIR}"
|
"${AVFORMAT_INCLUDE_DIR}"
|
||||||
|
"${SWSCALE_INCLUDE_DIR}"
|
||||||
)
|
)
|
||||||
target_link_libraries(notcurses
|
target_link_libraries(notcurses
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"${TERMINFO_LIBRARIES}"
|
"${TERMINFO_LIBRARIES}"
|
||||||
"${AVFORMAT_LIBRARIES}"
|
"${AVFORMAT_LIBRARIES}"
|
||||||
|
"${SWSCALE_LIBRARIES}"
|
||||||
"${LIBRT}"
|
"${LIBRT}"
|
||||||
)
|
)
|
||||||
set_target_properties(notcurses PROPERTIES
|
set_target_properties(notcurses PROPERTIES
|
||||||
|
@ -325,6 +325,16 @@ const ncplane* notcurses_stdplane_const(const notcurses* nc){
|
|||||||
return nc->stdscr;
|
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
|
static int
|
||||||
interrogate_terminfo(notcurses* nc, const notcurses_options* opts){
|
interrogate_terminfo(notcurses* nc, const notcurses_options* opts){
|
||||||
char* longname_term = longname();
|
char* longname_term = longname();
|
||||||
|
@ -14,7 +14,7 @@ void usage(std::ostream& o, const char* name, int exitcode){
|
|||||||
exit(exitcode);
|
exit(exitcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ncview(struct ncvisual* ncv, const notcurses_options* opts){
|
int ncview(struct ncvisual* ncv){
|
||||||
AVFrame* avf;
|
AVFrame* avf;
|
||||||
if((avf = ncvisual_decode(ncv)) == nullptr){
|
if((avf = ncvisual_decode(ncv)) == nullptr){
|
||||||
return -1;
|
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",
|
printf("%s: %dx%d aspect %d:%d %d\n", avf->key_frame ? "Keyframe" : "Frame",
|
||||||
avf->height, avf->width, avf->sample_aspect_ratio.num,
|
avf->height, avf->width, avf->sample_aspect_ratio.num,
|
||||||
avf->sample_aspect_ratio.den, avf->format);
|
avf->sample_aspect_ratio.den, avf->format);
|
||||||
auto nc = notcurses_init(opts);
|
return 0;
|
||||||
if(nc == nullptr){
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ncvisual_destroy(ncv);
|
|
||||||
return notcurses_stop(nc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv){
|
int main(int argc, char** argv){
|
||||||
@ -37,15 +32,24 @@ int main(int argc, char** argv){
|
|||||||
notcurses_options opts{};
|
notcurses_options opts{};
|
||||||
opts.outfp = stdout;
|
opts.outfp = stdout;
|
||||||
bool success = true;
|
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){
|
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){
|
if(ncv == nullptr){
|
||||||
success = false;
|
success = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(ncview(ncv, &opts)){
|
if(ncview(ncv)){
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
ncvisual_destroy(ncv);
|
||||||
|
}
|
||||||
|
if(notcurses_stop(nc)){
|
||||||
|
success = false;
|
||||||
}
|
}
|
||||||
if(!success){
|
if(!success){
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
Loading…
Reference in New Issue
Block a user