libsixel support #639

This commit is contained in:
nick black 2021-03-17 01:30:44 -04:00
parent b13544122e
commit ae22e545bd
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
5 changed files with 22 additions and 8 deletions

View File

@ -24,6 +24,7 @@ cmake_dependent_option(
"${BUILD_TESTING}" OFF "${BUILD_TESTING}" OFF
) )
option(USE_DOXYGEN "Build HTML cross reference with doxygen" OFF) option(USE_DOXYGEN "Build HTML cross reference with doxygen" OFF)
option(USE_LIBSIXEL "Enable libsixel for improved Sixel graphics" OFF)
option(USE_PANDOC "Build man pages and HTML reference with pandoc" ON) option(USE_PANDOC "Build man pages and HTML reference with pandoc" ON)
option(USE_POC "Build small, uninstalled proof-of-concept binaries" ON) option(USE_POC "Build small, uninstalled proof-of-concept binaries" ON)
option(USE_QRCODEGEN "Disable libqrcodegen QR code support" ON) option(USE_QRCODEGEN "Disable libqrcodegen QR code support" ON)
@ -96,6 +97,10 @@ elseif(${USE_OIIO})
pkg_check_modules(OIIO REQUIRED OpenImageIO>=2.1) pkg_check_modules(OIIO REQUIRED OpenImageIO>=2.1)
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND OpenImageIO) set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND OpenImageIO)
endif() endif()
if(${USE_LIBSIXEL})
pkg_check_modules(LIBSIXEL REQUIRED libsixel>=1.8.6)
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND libsixel)
endif()
find_library(MATH_LIBRARIES m) find_library(MATH_LIBRARIES m)
if(${USE_DOCTEST}) if(${USE_DOCTEST})
find_package(doctest 2.3.5) find_package(doctest 2.3.5)
@ -147,8 +152,9 @@ target_include_directories(notcurses-core
src src
"${CMAKE_REQUIRED_INCLUDES}" "${CMAKE_REQUIRED_INCLUDES}"
"${PROJECT_BINARY_DIR}/include" "${PROJECT_BINARY_DIR}/include"
"${TERMINFO_INCLUDE_DIRS}" "${LIBSIXEL_INCLUDE_DIRS}"
"${READLINE_INCLUDE_DIRS}" "${READLINE_INCLUDE_DIRS}"
"${TERMINFO_INCLUDE_DIRS}"
) )
target_include_directories(notcurses-core-static target_include_directories(notcurses-core-static
PRIVATE PRIVATE
@ -156,13 +162,15 @@ target_include_directories(notcurses-core-static
src src
"${CMAKE_REQUIRED_INCLUDES}" "${CMAKE_REQUIRED_INCLUDES}"
"${PROJECT_BINARY_DIR}/include" "${PROJECT_BINARY_DIR}/include"
"${TERMINFO_STATIC_INCLUDE_DIRS}" "${LIBSIXEL_STATIC_INCLUDE_DIRS}"
"${READLINE_STATIC_INCLUDE_DIRS}" "${READLINE_STATIC_INCLUDE_DIRS}"
"${TERMINFO_STATIC_INCLUDE_DIRS}"
) )
target_link_libraries(notcurses-core target_link_libraries(notcurses-core
PRIVATE PRIVATE
"${TERMINFO_LIBRARIES}" "${LIBSIXEL_LIBRARIES}"
"${READLINE_LIBRARIES}" "${READLINE_LIBRARIES}"
"${TERMINFO_LIBRARIES}"
"${LIBRT}" "${LIBRT}"
unistring unistring
PUBLIC PUBLIC
@ -170,8 +178,9 @@ target_link_libraries(notcurses-core
) )
target_link_libraries(notcurses-core-static target_link_libraries(notcurses-core-static
PRIVATE PRIVATE
"${TERMINFO_STATIC_LIBRARIES}" "${LIBSIXEL_STATIC_LIBRARIES}"
"${READLINE_STATIC_LIBRARIES}" "${READLINE_STATIC_LIBRARIES}"
"${TERMINFO_STATIC_LIBRARIES}"
"${LIBRT}" "${LIBRT}"
unistring unistring
PUBLIC PUBLIC
@ -179,13 +188,15 @@ target_link_libraries(notcurses-core-static
) )
target_link_directories(notcurses-core target_link_directories(notcurses-core
PRIVATE PRIVATE
"${TERMINFO_LIBRARY_DIRS}" "${LIBSIXEL_LIBRARY_DIRS}"
"${READLINE_LIBRARY_DIRS}" "${READLINE_LIBRARY_DIRS}"
"${TERMINFO_LIBRARY_DIRS}"
) )
target_link_directories(notcurses-core-static target_link_directories(notcurses-core-static
PRIVATE PRIVATE
"${TERMINFO_STATIC_LIBRARY_DIRS}" "${LIBSIXEL_STATIC_LIBRARY_DIRS}"
"${READLINE_STATIC_LIBRARY_DIRS}" "${READLINE_STATIC_LIBRARY_DIRS}"
"${TERMINFO_STATIC_LIBRARY_DIRS}"
) )
# don't want these on freebsd/dragonfly/osx # don't want these on freebsd/dragonfly/osx
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")

View File

@ -111,6 +111,7 @@ may well be possible to use still older versions. Let me know of any successes!
* (OPTIONAL) (build+runtime) From QR-Code-generator: [libqrcodegen](https://github.com/nayuki/QR-Code-generator) 1.5.0+ * (OPTIONAL) (build+runtime) From QR-Code-generator: [libqrcodegen](https://github.com/nayuki/QR-Code-generator) 1.5.0+
* (OPTIONAL) (build+runtime) From [FFmpeg](https://www.ffmpeg.org/): libswscale 5.0+, libavformat 57.0+, libavutil 56.0+ * (OPTIONAL) (build+runtime) From [FFmpeg](https://www.ffmpeg.org/): libswscale 5.0+, libavformat 57.0+, libavutil 56.0+
* (OPTIONAL) (build+runtime) [OpenImageIO](https://github.com/OpenImageIO/oiio) 2.15.0+ * (OPTIONAL) (build+runtime) [OpenImageIO](https://github.com/OpenImageIO/oiio) 2.15.0+
* (OPTIONAL) (build+runtime) [libsixel](https://github.com/saitoha/libsixel) 1.8.6+
* (OPTIONAL) (testing) [Doctest](https://github.com/onqtam/doctest) 2.3.5+ * (OPTIONAL) (testing) [Doctest](https://github.com/onqtam/doctest) 2.3.5+
* (OPTIONAL) (documentation) [pandoc](https://pandoc.org/index.html) 1.19.2+ * (OPTIONAL) (documentation) [pandoc](https://pandoc.org/index.html) 1.19.2+
* (OPTIONAL) (python bindings): Python 3.7+, [CFFI](https://pypi.org/project/cffi/) 1.13.2+, [pypandoc](https://pypi.org/project/pypandoc/) 1.5+ * (OPTIONAL) (python bindings): Python 3.7+, [CFFI](https://pypi.org/project/cffi/) 1.13.2+, [pypandoc](https://pypi.org/project/pypandoc/) 1.5+

View File

@ -1328,9 +1328,10 @@ int sprite_kitty_cell_wipe(const notcurses* nc, sprixel* s, int y, int x);
int sixel_blit(ncplane* nc, int linesize, const void* data, int sixel_blit(ncplane* nc, int linesize, const void* data,
int leny, int lenx, const blitterargs* bargs); int leny, int lenx, const blitterargs* bargs);
int kitty_blit(ncplane* nc, int linesize, const void* data, int kitty_blit(ncplane* nc, int linesize, const void* data,
int leny, int lenx, const blitterargs* bargs); int leny, int lenx, const blitterargs* bargs);
int libsixel_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
int leny, int lenx, const blitterargs* bargs);
int term_fg_rgb8(bool RGBflag, const char* setaf, int colors, FILE* out, int term_fg_rgb8(bool RGBflag, const char* setaf, int colors, FILE* out,
unsigned r, unsigned g, unsigned b); unsigned r, unsigned g, unsigned b);

View File

@ -187,7 +187,7 @@ find_color(sixeltable* stab, unsigned char comps[static RGBSIZE]){
}else{ }else{
i = l; i = l;
} }
if(stab->colors == stab->colorregs){ if(stab->colors == stab->colorregs){ // used all our color registers
return -1; return -1;
} }
if(i < stab->colors){ if(i < stab->colors){

View File

@ -9,4 +9,5 @@
#if defined(USE_FFMPEG) || defined(USE_OIIO) #if defined(USE_FFMPEG) || defined(USE_OIIO)
#define NOTCURSES_USE_MULTIMEDIA #define NOTCURSES_USE_MULTIMEDIA
#endif #endif
#cmakedefine USE_LIBSIXEL
#define NOTCURSES_SHARE "@CMAKE_INSTALL_FULL_DATADIR@/notcurses" #define NOTCURSES_SHARE "@CMAKE_INSTALL_FULL_DATADIR@/notcurses"