From e6637e81cccd2c729bd5e32f8ae2723971b81847 Mon Sep 17 00:00:00 2001 From: Nick Black Date: Tue, 18 Feb 2020 12:36:16 -0500 Subject: [PATCH] Prep for serious rusting #101 (#354) * CMake: add USE_PANDOC, USE_DOXYGEN options #101 * README: mention rust * start integrating rust into build #101 * CMake: add USE_NETWORK option for cargo * Debian: build-dep on doxygen * rust: colloquy checks in Cargo.lock * extract NCKEY defines into their own include * colloquy: use clap to parse CLI args * CMake: unify option namespace * Python: update include path * Rust: fix up --frozen workings for -DUSE_NETWORK=off * CMake: abstract out colloquy a little * Sync direct.hh to the New Way --- .gitignore | 1 + CMakeLists.txt | 158 ++++++++++++++++-------- README.md | 15 +-- debian/control | 3 + doc/Doxyfile | 2 +- doc/man/man1/notcurses-demo.1.md | 9 ++ include/ncpp/Cell.hh | 2 +- include/ncpp/CellStyle.hh | 2 +- include/ncpp/Direct.hh | 2 +- include/ncpp/Menu.hh | 2 +- include/ncpp/NCAlign.hh | 2 +- include/ncpp/NCBox.hh | 2 +- include/ncpp/NCKey.hh | 2 +- include/ncpp/NCLogLevel.hh | 2 +- include/ncpp/NCScale.hh | 2 +- include/ncpp/NotCurses.hh | 2 +- include/ncpp/Plane.hh | 4 +- include/ncpp/Reel.hh | 2 +- include/ncpp/Root.hh | 2 +- include/ncpp/Selector.hh | 2 +- include/ncpp/Tablet.hh | 2 +- include/ncpp/Visual.hh | 2 +- include/notcurses/nckeys.h | 121 ++++++++++++++++++ include/{ => notcurses}/notcurses.h | 122 +----------------- python/src/notcurses/build_notcurses.py | 2 +- src/colloquy/Cargo.lock | 129 +++++++++++++++++++ src/colloquy/Cargo.toml | 10 ++ src/colloquy/src/cli.yml | 9 ++ src/colloquy/src/main.rs | 5 + src/demo/demo.c | 18 +-- src/demo/demo.h | 5 +- src/demo/fallin.c | 44 +------ src/demo/luigi.c | 2 + src/demo/reel.c | 1 - src/demo/sliding.c | 1 - src/demo/view.c | 1 - src/lib/egcpool.h | 2 +- src/lib/internal.h | 9 +- src/lib/libav.c | 5 +- src/lib/metric.c | 2 +- src/lib/notcurses.c | 8 +- src/lib/reel.c | 1 - src/lib/selector.c | 1 - src/poc/direct.c | 2 +- src/poc/dirgb.c | 2 +- src/poc/geom.c | 2 +- src/poc/menu.c | 2 +- src/poc/rgb.c | 2 +- src/poc/rgbbg.c | 2 +- src/poc/selector.c | 2 +- src/poc/sgr.c | 2 +- src/poc/visual.cpp | 2 +- tests/cell.cpp | 3 +- tests/channel.cpp | 1 - tests/direct.cpp | 2 - tests/egcpool.cpp | 3 +- tests/fills.cpp | 1 - tests/main.h | 3 +- tests/ncplane.cpp | 3 +- tests/notcurses.cpp | 3 +- tests/palette.cpp | 1 - tests/visual.cpp | 6 +- tools/version.h.in | 2 +- 63 files changed, 479 insertions(+), 287 deletions(-) create mode 100644 include/notcurses/nckeys.h rename include/{ => notcurses}/notcurses.h (95%) create mode 100644 src/colloquy/Cargo.lock create mode 100644 src/colloquy/Cargo.toml create mode 100644 src/colloquy/src/cli.yml create mode 100644 src/colloquy/src/main.rs diff --git a/.gitignore b/.gitignore index 59cbcdae0..33ec06f29 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,6 @@ python/dist/ python/src/notcurses.egg-info/ python/src/_notcurses.so rust/*/target +src/colloquy/target/ *.pyc *.so diff --git a/CMakeLists.txt b/CMakeLists.txt index be8336676..1d3da04cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,21 +12,27 @@ set(CMAKE_CXX_VISIBILITY_PRESET hidden) include(GNUInstallDirs) set(NOTCURSES_SHARE ${CMAKE_INSTALL_PREFIX}/share/notcurses) -option(DISABLE_FFMPEG "Disable FFmpeg image/video support" OFF) -option(BUILD_PYTHON "Build Python wrappers" ON) -option(DFSG_BUILD "DFSG build (no non-free media)" OFF) +###################### USER-SELECTABLE OPTIONS ########################### +option(DFSG_BUILD "DFSG build (no non-free media/code)" OFF) +option(USE_DOXYGEN "Build HTML cross reference with doxygen" ON) +option(USE_FFMPEG "Disable FFmpeg image/video support (recommended)" ON) +option(USE_NETWORK "Allow cargo to use the network" OFF) +option(USE_PANDOC "Build man pages and HTML reference with pandoc" ON) +option(USE_PYTHON "Build Python wrappers" ON) +option(USE_RUST "Build Rust wrappers/colloquy (experimental)" OFF) +############## END (additional) USER-SELECTABLE OPTIONS ################## find_package(PkgConfig REQUIRED) find_package(Threads REQUIRED) pkg_check_modules(TERMINFO REQUIRED tinfo>=6.1) -if(NOT "${DISABLE_FFMPEG}") +if(${USE_FFMPEG}) pkg_check_modules(AVCODEC REQUIRED libavcodec>=57.0) pkg_check_modules(AVFORMAT REQUIRED libavformat>=57.0) pkg_check_modules(AVUTIL REQUIRED libavutil>=56.0) pkg_check_modules(SWSCALE REQUIRED libswscale>=5.0) endif() find_library(LIBRT rt) -find_package(doctest REQUIRED) +find_package(doctest 2.3.6 REQUIRED) # libnotcurses file(GLOB NCSRCS CONFIGURE_DEPENDS src/lib/*.c) @@ -78,7 +84,7 @@ target_link_directories(notcurses-static "${TERMINFO_STATIC_LIBRARY_DIRS}" ) -if(NOT "${DISABLE_FFMPEG}") +if(${USE_FFMPEG}) target_include_directories(notcurses PUBLIC "${AVCODEC_INCLUDE_DIRS}" @@ -312,7 +318,7 @@ target_compile_options(notcurses-demo ) target_compile_definitions(notcurses-demo PRIVATE - FORTIFY_SOURCE=2 _GNU_SOURCE + FORTIFY_SOURCE=2 _GNU_SOURCE ) # tiny proofs of concept, one binary per source file @@ -331,47 +337,71 @@ foreach(f ${POCSRCS}) ) endforeach() -# Documentation -file(GLOB MANSOURCE1 CONFIGURE_DEPENDS doc/man/man1/*.md) -file(GLOB MANSOURCE3 CONFIGURE_DEPENDS doc/man/man3/*.md) -FIND_PROGRAM(PANDOC pandoc) -iF(NOT PANDOC) - message(WARNING "pandoc not found, won't generate documentation") -else() - foreach(m ${MANSOURCE3} ${MANSOURCE1}) - get_filename_component(me ${m} NAME_WLE) +# Pandoc documentation (man pages, HTML reference) +if(USE_PANDOC) + file(GLOB MANSOURCE1 CONFIGURE_DEPENDS doc/man/man1/*.md) + file(GLOB MANSOURCE3 CONFIGURE_DEPENDS doc/man/man3/*.md) + find_program(PANDOC pandoc) + if(NOT PANDOC) + message(FATAL_ERROR "pandoc not found. USE_PANDOC=OFF to disable.") + else() + foreach(m ${MANSOURCE3} ${MANSOURCE1}) + get_filename_component(me ${m} NAME_WLE) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${me} + DEPENDS ${m} + COMMAND ${PANDOC} + ARGS --to man --standalone ${m} > ${CMAKE_CURRENT_BINARY_DIR}/${me} + COMMENT "Building man page ${me}" + ) + add_custom_target(${me}.man + ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${me} + ) + file(GLOB ANALHTML doc/analytics-header.html) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${me}.html + DEPENDS ${m} ${ANALHTML} + COMMAND ${PANDOC} + ARGS -H ${ANALHTML} --to html --standalone ${m} > ${CMAKE_CURRENT_BINARY_DIR}/${me}.html + COMMENT "Building HTML5 ${me}.html" + ) + add_custom_target(${me}.html5 + ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${me}.html + ) + endforeach() + foreach(m ${MANSOURCE3}) + get_filename_component(me ${m} NAME_WLE) + set(MANPAGES3 ${MANPAGES3} ${CMAKE_CURRENT_BINARY_DIR}/${me}) + endforeach() + foreach(m ${MANSOURCE1}) + get_filename_component(me ${m} NAME_WLE) + set(MANPAGES1 ${MANPAGES1} ${CMAKE_CURRENT_BINARY_DIR}/${me}) + endforeach() + endif() +endif() + +# Doxygen +if(USE_DOXYGEN) + find_package(Doxygen REQUIRED dot dia) + if(NOT ${DOXYGEN_FOUND}) + message(FATAL_ERROR "doxygen not found. USE_DOXYGEN=OFF to disable.") + else() + set(DOXYFILE ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile) + # FIXME should dep on all source, i suppose, yuck add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${me} - DEPENDS ${m} - COMMAND ${PANDOC} - ARGS --to man --standalone ${m} > ${CMAKE_CURRENT_BINARY_DIR}/${me} - COMMENT "Building man page ${me}" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/index.html" + DEPENDS ${DOXYFILE} + COMMAND Doxygen::doxygen + ARGS ${DOXYFILE} + COMMENT "Running doxygen" ) - add_custom_target(${me}.man + add_custom_target(doxygen ALL - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${me} + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/index.html" ) - file(GLOB ANALHTML doc/analytics-header.html) - add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${me}.html - DEPENDS ${m} ${ANALHTML} - COMMAND ${PANDOC} - ARGS -H ${ANALHTML} --to html --standalone ${m} > ${CMAKE_CURRENT_BINARY_DIR}/${me}.html - COMMENT "Building HTML5 ${me}.html" - ) - add_custom_target(${me}.html5 - ALL - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${me}.html - ) - endforeach() - foreach(m ${MANSOURCE3}) - get_filename_component(me ${m} NAME_WLE) - set(MANPAGES3 ${MANPAGES3} ${CMAKE_CURRENT_BINARY_DIR}/${me}) - endforeach() - foreach(m ${MANSOURCE1}) - get_filename_component(me ${m} NAME_WLE) - set(MANPAGES1 ${MANPAGES1} ${CMAKE_CURRENT_BINARY_DIR}/${me}) - endforeach() + endif() endif() # notcurses-input @@ -418,7 +448,7 @@ target_compile_definitions(notcurses-ncreel # notcurses-view file(GLOB VIEWSRCS CONFIGURE_DEPENDS src/view/*.cpp) -if(NOT "${DISABLE_FFMPEG}") +if(${USE_FFMPEG}) add_executable(notcurses-view ${VIEWSRCS}) target_include_directories(notcurses-view PRIVATE @@ -513,7 +543,7 @@ write_basic_package_version_file( ) # Python bindings -if(${BUILD_PYTHON}) +if(${USE_PYTHON}) find_package(Python3 COMPONENTS Development Interpreter REQUIRED) file(GLOB PYSRC CONFIGURE_DEPENDS python/src/notcurses/*.py) file(COPY python/src/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/python/src) @@ -546,6 +576,36 @@ if(${BUILD_PYTHON}) ) endif() +# Rust bindings +if(${USE_RUST}) + file(GLOB RUSTSRC CONFIGURE_DEPENDS src/colloquy/*.rs) + file(GLOB COLLOQUYSRC CONFIGURE_DEPENDS rust/src/*.rs rust/src/*.yaml) + set(COLLOQUY ${CMAKE_CURRENT_BINARY_DIR}/rust/debug/colloquy) + find_program(CARGO cargo REQUIRED) + set(CARGO_ARGS "--verbose") + if(NOT ${USE_NETWORK}) + set(CARGO_ARGS "${CARGO_ARGS}" --frozen) + endif() + add_custom_command( + OUTPUT + ${COLLOQUY} + COMMAND + CARGO_HOME=${CMAKE_CURRENT_BINARY_DIR}/rust CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR}/rust ${CARGO} build ${CARGO_ARGS} + DEPENDS + ${COLLOQUYSRC} + COMMENT "Building colloquy" + WORKING_DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR}/src/colloquy + ) + add_custom_target(colloquy ALL + DEPENDS + ${COLLOQUY} + ) + set_target_properties(colloquy + PROPERTIES LOCATION ${CMAKE_CURRENT_BINARY_DIR} + ) +endif() + # Installation install(FILES ${CMAKE_CURRENT_BINARY_DIR}/notcursesConfig.cmake @@ -577,7 +637,7 @@ install(TARGETS notcurses-demo DESTINATION bin) install(TARGETS notcurses-input DESTINATION bin) install(TARGETS notcurses-ncreel DESTINATION bin) install(TARGETS notcurses-tester DESTINATION bin) -if(NOT "${DISABLE_FFMPEG}") +if(${USE_FFMPEG}) install(TARGETS notcurses-view DESTINATION bin) endif() install(TARGETS notcurses notcurses-static @@ -586,10 +646,10 @@ install(TARGETS notcurses notcurses-static COMPONENT Libraries NAMELINK_COMPONENT Development PUBLIC_HEADER - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/notcurses COMPONENT Development ) -if(${BUILD_PYTHON}) +if(${USE_PYTHON}) # if DFSG_BUILD has been selected, assume we're building debs. debian/rules # has its own python install logic after many hours wasted, so we don't # install from here for a deb build. diff --git a/README.md b/README.md index 96bd28bc8..34180956c 100644 --- a/README.md +++ b/README.md @@ -109,13 +109,14 @@ that fine library. ## Requirements -* A C11 and a C++17 compiler -* CMake 3.14.0+ -* From NCURSES: terminfo 6.1+ -* [Doctest](https://github.com/onqtam/doctest) (header file only) -* (OPTIONAL) From FFMpeg: libswscale 5.0+, libavformat 57.0+, libavutil 56.0+ -* (documentation) [pandoc](https://pandoc.org/index.html) 1.19.2+ -* (Python bindings): Python + CFFI +* (build) A C11 and a C++17 compiler +* (build) CMake 3.14.0+ +* (build+runtime) From NCURSES: terminfo 6.1+ +* (OPTIONAL) (build+runtime) From FFMpeg: libswscale 5.0+, libavformat 57.0+, libavutil 56.0+ +* (OPTIONAL) (testing) [Doctest](https://github.com/onqtam/doctest) 2.3.6+ +* (OPTIONAL) (documentation) [pandoc](https://pandoc.org/index.html) 1.19.2+ +* (OPTIONAL) (python bindings): Python 3.7+, CFFI 1.13.2+ +* (OPTIONAL) (rust bindings, colloquy): rust 1.40.0+, cargo 0.40.0+, cmake-rs 0.1.42+ ### Building diff --git a/debian/control b/debian/control index 772564f77..94491855c 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,10 @@ Build-Depends: cmake, debhelper-compat (= 12), dh-python (>= 4.20191017), dh-sequence-python3, + dia, doctest-dev, + doxygen (>= 1.8.16), + graphviz (>= 2.42.2), libavformat-dev (>= 7:4.2.1), libavutil-dev (>= 7:4.2.1), libncurses-dev, diff --git a/doc/Doxyfile b/doc/Doxyfile index b5f6e0625..09d0821be 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -2463,7 +2463,7 @@ DOT_IMAGE_FORMAT = png # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. -INTERACTIVE_SVG = NO +INTERACTIVE_SVG = YES # The DOT_PATH tag can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. diff --git a/doc/man/man1/notcurses-demo.1.md b/doc/man/man1/notcurses-demo.1.md index c0c9dcc5f..21cc84749 100644 --- a/doc/man/man1/notcurses-demo.1.md +++ b/doc/man/man1/notcurses-demo.1.md @@ -79,6 +79,15 @@ are unavailable through the Debian package. If notcurses is built without FFmpeg, the **chunli**, **eagle**, **fallin'**, **outro**, **view**, and **xray** demos will be unavailable. +The following keypresses are recognized (and are also available from the menu): + +* **Ctrl-U**: Toggle the help screen. +* **H**: Toggle the HUD. The HUD shows the most recent and current demos' + runtime and number of rendered frames. It can be grabbed and moved + with the mouse. +* **Ctrl-R**: Restart the demo. +* **q**: Quit. + # BUGS # AUTHORS diff --git a/include/ncpp/Cell.hh b/include/ncpp/Cell.hh index 43c61e9aa..1c398b7cb 100644 --- a/include/ncpp/Cell.hh +++ b/include/ncpp/Cell.hh @@ -3,7 +3,7 @@ #include #include -#include +#include #include "Root.hh" #include "CellStyle.hh" diff --git a/include/ncpp/CellStyle.hh b/include/ncpp/CellStyle.hh index 593f79b99..86d927c8d 100644 --- a/include/ncpp/CellStyle.hh +++ b/include/ncpp/CellStyle.hh @@ -3,7 +3,7 @@ #include -#include +#include #include "_flag_enum_operator_helpers.hh" diff --git a/include/ncpp/Direct.hh b/include/ncpp/Direct.hh index e0c35668f..49a65587d 100644 --- a/include/ncpp/Direct.hh +++ b/include/ncpp/Direct.hh @@ -2,7 +2,7 @@ #define __NCPP_DIRECT_HH #include -#include +#include #include "Root.hh" #include "Cell.hh" diff --git a/include/ncpp/Menu.hh b/include/ncpp/Menu.hh index 69403af7c..e9c1c2cb4 100644 --- a/include/ncpp/Menu.hh +++ b/include/ncpp/Menu.hh @@ -1,7 +1,7 @@ #ifndef __NCPP_MENU_HH #define __NCPP_MENU_HH -#include +#include #include "Root.hh" diff --git a/include/ncpp/NCAlign.hh b/include/ncpp/NCAlign.hh index 01b1848e2..f15f8814e 100644 --- a/include/ncpp/NCAlign.hh +++ b/include/ncpp/NCAlign.hh @@ -1,7 +1,7 @@ #ifndef __NCPP_NCALIGN_HH #define __NCPP_NCALIGN_HH -#include +#include namespace ncpp { diff --git a/include/ncpp/NCBox.hh b/include/ncpp/NCBox.hh index 96ab74fdc..5e202bf08 100644 --- a/include/ncpp/NCBox.hh +++ b/include/ncpp/NCBox.hh @@ -1,7 +1,7 @@ #ifndef __NCPP_NCBOX_HH #define __NCPP_NCBOX_HH -#include +#include namespace ncpp { diff --git a/include/ncpp/NCKey.hh b/include/ncpp/NCKey.hh index af8b2614d..8efa812c0 100644 --- a/include/ncpp/NCKey.hh +++ b/include/ncpp/NCKey.hh @@ -2,7 +2,7 @@ #define __NCPP_NCKEY_HH #include -#include +#include namespace ncpp { diff --git a/include/ncpp/NCLogLevel.hh b/include/ncpp/NCLogLevel.hh index 5c7dcb429..810d1c712 100644 --- a/include/ncpp/NCLogLevel.hh +++ b/include/ncpp/NCLogLevel.hh @@ -1,7 +1,7 @@ #ifndef __NCPP_NCLOGLEVEL_HH #define __NCPP_NCLOGLEVEL_HH -#include +#include namespace ncpp { diff --git a/include/ncpp/NCScale.hh b/include/ncpp/NCScale.hh index 3767499f4..a2d15a2b9 100644 --- a/include/ncpp/NCScale.hh +++ b/include/ncpp/NCScale.hh @@ -1,7 +1,7 @@ #ifndef __NCPP_NCSCALE_HH #define __NCPP_NCSCALE_HH -#include +#include namespace ncpp { diff --git a/include/ncpp/NotCurses.hh b/include/ncpp/NotCurses.hh index 2b023c492..a51042ba8 100644 --- a/include/ncpp/NotCurses.hh +++ b/include/ncpp/NotCurses.hh @@ -6,7 +6,7 @@ #include #include -#include +#include #include "CellStyle.hh" #include "NCKey.hh" diff --git a/include/ncpp/Plane.hh b/include/ncpp/Plane.hh index c70e0b9b7..c4245ff8b 100644 --- a/include/ncpp/Plane.hh +++ b/include/ncpp/Plane.hh @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include "Root.hh" #include "Cell.hh" @@ -850,7 +850,7 @@ namespace ncpp static Plane* map_plane (ncplane *ncp, Plane *associated_plane = nullptr) noexcept; -#ifndef DISABLE_FFMPEG +#ifdef USE_FFMPEG bool blit_bgrx (int placey, int placex, int linesize, const unsigned char* data, int begy, int begx, int leny, int lenx) const noexcept { return ncblit_bgrx (plane, placey, placex, linesize, data, begy, begx, leny, lenx) >= 0; diff --git a/include/ncpp/Reel.hh b/include/ncpp/Reel.hh index 5a711f99e..3deafcbd7 100644 --- a/include/ncpp/Reel.hh +++ b/include/ncpp/Reel.hh @@ -2,7 +2,7 @@ #define __NCPP_REEL_HH #include -#include +#include #include "Tablet.hh" #include "Root.hh" diff --git a/include/ncpp/Root.hh b/include/ncpp/Root.hh index 0eb20926a..31009442c 100644 --- a/include/ncpp/Root.hh +++ b/include/ncpp/Root.hh @@ -1,7 +1,7 @@ #ifndef __NCPP_ROOT_HH #define __NCPP_ROOT_HH -#include +#include #include "_helpers.hh" #include "_exceptions.hh" diff --git a/include/ncpp/Selector.hh b/include/ncpp/Selector.hh index fec1a10aa..8cf61e95d 100644 --- a/include/ncpp/Selector.hh +++ b/include/ncpp/Selector.hh @@ -1,7 +1,7 @@ #ifndef __NCPP_SELECTOR_HH #define __NCPP_SELECTOR_HH -#include +#include #include "Root.hh" #include "NCAlign.hh" diff --git a/include/ncpp/Tablet.hh b/include/ncpp/Tablet.hh index 36fdb908c..8700a79a2 100644 --- a/include/ncpp/Tablet.hh +++ b/include/ncpp/Tablet.hh @@ -4,7 +4,7 @@ #include #include -#include +#include #include "Root.hh" diff --git a/include/ncpp/Visual.hh b/include/ncpp/Visual.hh index 5bd522ab4..9a8ba94d1 100644 --- a/include/ncpp/Visual.hh +++ b/include/ncpp/Visual.hh @@ -1,7 +1,7 @@ #ifndef __NCPP_VISUAL_HH #define __NCPP_VISUAL_HH -#include +#include #include "Root.hh" #include "NCScale.hh" diff --git a/include/notcurses/nckeys.h b/include/notcurses/nckeys.h new file mode 100644 index 000000000..b209c52a1 --- /dev/null +++ b/include/notcurses/nckeys.h @@ -0,0 +1,121 @@ +#ifndef NOTCURSES_NCKEYS +#define NOTCURSES_NCKEYS + +#ifdef __cplusplus +extern "C" { +#endif + +#define suppuabize(w) ((w) + 0x100000) + +// Special composed key defintions. These values are added to 0x100000. +#define NCKEY_INVALID suppuabize(0) +#define NCKEY_RESIZE suppuabize(1) // generated interally in response to SIGWINCH +#define NCKEY_UP suppuabize(2) +#define NCKEY_RIGHT suppuabize(3) +#define NCKEY_DOWN suppuabize(4) +#define NCKEY_LEFT suppuabize(5) +#define NCKEY_INS suppuabize(6) +#define NCKEY_DEL suppuabize(7) +#define NCKEY_BACKSPACE suppuabize(8) // backspace (sometimes) +#define NCKEY_PGDOWN suppuabize(9) +#define NCKEY_PGUP suppuabize(10) +#define NCKEY_HOME suppuabize(11) +#define NCKEY_END suppuabize(12) +#define NCKEY_F00 suppuabize(20) +#define NCKEY_F01 suppuabize(21) +#define NCKEY_F02 suppuabize(22) +#define NCKEY_F03 suppuabize(23) +#define NCKEY_F04 suppuabize(24) +#define NCKEY_F05 suppuabize(25) +#define NCKEY_F06 suppuabize(26) +#define NCKEY_F07 suppuabize(27) +#define NCKEY_F08 suppuabize(28) +#define NCKEY_F09 suppuabize(29) +#define NCKEY_F10 suppuabize(30) +#define NCKEY_F11 suppuabize(31) +#define NCKEY_F12 suppuabize(32) +#define NCKEY_F13 suppuabize(33) +#define NCKEY_F14 suppuabize(34) +#define NCKEY_F15 suppuabize(35) +#define NCKEY_F16 suppuabize(36) +#define NCKEY_F17 suppuabize(37) +#define NCKEY_F18 suppuabize(38) +#define NCKEY_F19 suppuabize(39) +#define NCKEY_F20 suppuabize(40) +#define NCKEY_F21 suppuabize(41) +#define NCKEY_F22 suppuabize(42) +#define NCKEY_F23 suppuabize(43) +#define NCKEY_F24 suppuabize(44) +#define NCKEY_F25 suppuabize(45) +#define NCKEY_F26 suppuabize(46) +#define NCKEY_F27 suppuabize(47) +#define NCKEY_F28 suppuabize(48) +#define NCKEY_F29 suppuabize(49) +#define NCKEY_F30 suppuabize(50) +#define NCKEY_F31 suppuabize(51) +#define NCKEY_F32 suppuabize(52) +#define NCKEY_F33 suppuabize(53) +#define NCKEY_F34 suppuabize(54) +#define NCKEY_F35 suppuabize(55) +#define NCKEY_F36 suppuabize(56) +#define NCKEY_F37 suppuabize(57) +#define NCKEY_F38 suppuabize(58) +#define NCKEY_F39 suppuabize(59) +#define NCKEY_F40 suppuabize(60) +#define NCKEY_F41 suppuabize(61) +#define NCKEY_F42 suppuabize(62) +#define NCKEY_F43 suppuabize(63) +#define NCKEY_F44 suppuabize(64) +#define NCKEY_F45 suppuabize(65) +#define NCKEY_F46 suppuabize(66) +#define NCKEY_F47 suppuabize(67) +#define NCKEY_F48 suppuabize(68) +#define NCKEY_F49 suppuabize(69) +#define NCKEY_F50 suppuabize(70) +#define NCKEY_F51 suppuabize(71) +#define NCKEY_F52 suppuabize(72) +#define NCKEY_F53 suppuabize(73) +#define NCKEY_F54 suppuabize(74) +#define NCKEY_F55 suppuabize(75) +#define NCKEY_F56 suppuabize(76) +#define NCKEY_F57 suppuabize(77) +#define NCKEY_F58 suppuabize(78) +#define NCKEY_F59 suppuabize(79) +#define NCKEY_F60 suppuabize(80) +// ... leave room for up to 100 function keys, egads +#define NCKEY_ENTER suppuabize(121) +#define NCKEY_CLS suppuabize(122) // "clear-screen or erase" +#define NCKEY_DLEFT suppuabize(123) // down + left on keypad +#define NCKEY_DRIGHT suppuabize(124) +#define NCKEY_ULEFT suppuabize(125) // up + left on keypad +#define NCKEY_URIGHT suppuabize(126) +#define NCKEY_CENTER suppuabize(127) // the most truly neutral of keypresses +#define NCKEY_BEGIN suppuabize(128) +#define NCKEY_CANCEL suppuabize(129) +#define NCKEY_CLOSE suppuabize(130) +#define NCKEY_COMMAND suppuabize(131) +#define NCKEY_COPY suppuabize(132) +#define NCKEY_EXIT suppuabize(133) +#define NCKEY_PRINT suppuabize(134) +#define NCKEY_REFRESH suppuabize(135) +// Mouse events. We try to encode some details into the char32_t (i.e. which +// button was pressed), but some is embedded in the ncinput event. The release +// event is generic across buttons; callers must maintain state, if they care. +#define NCKEY_BUTTON1 suppuabize(201) +#define NCKEY_BUTTON2 suppuabize(202) +#define NCKEY_BUTTON3 suppuabize(203) +#define NCKEY_BUTTON4 suppuabize(204) +#define NCKEY_BUTTON5 suppuabize(205) +#define NCKEY_BUTTON6 suppuabize(206) +#define NCKEY_BUTTON7 suppuabize(207) +#define NCKEY_BUTTON8 suppuabize(208) +#define NCKEY_BUTTON9 suppuabize(209) +#define NCKEY_BUTTON10 suppuabize(210) +#define NCKEY_BUTTON11 suppuabize(211) +#define NCKEY_RELEASE suppuabize(212) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif diff --git a/include/notcurses.h b/include/notcurses/notcurses.h similarity index 95% rename from include/notcurses.h rename to include/notcurses/notcurses.h index 3528b2ed7..f232efeac 100644 --- a/include/notcurses.h +++ b/include/notcurses/notcurses.h @@ -13,6 +13,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -264,115 +265,6 @@ API void notcurses_drop_planes(struct notcurses* nc); // returned to indicate that no input was available, but only by // notcurses_getc(). Otherwise (including on EOF) (char32_t)-1 is returned. -#define suppuabize(w) ((w) + 0x100000) - -// Special composed key definitions. These values are added to 0x100000. -#define NCKEY_INVALID suppuabize(0) -#define NCKEY_RESIZE suppuabize(1) // generated internally in response to SIGWINCH -#define NCKEY_UP suppuabize(2) -#define NCKEY_RIGHT suppuabize(3) -#define NCKEY_DOWN suppuabize(4) -#define NCKEY_LEFT suppuabize(5) -#define NCKEY_INS suppuabize(6) -#define NCKEY_DEL suppuabize(7) -#define NCKEY_BACKSPACE suppuabize(8) // backspace (sometimes) -#define NCKEY_PGDOWN suppuabize(9) -#define NCKEY_PGUP suppuabize(10) -#define NCKEY_HOME suppuabize(11) -#define NCKEY_END suppuabize(12) -#define NCKEY_F00 suppuabize(20) -#define NCKEY_F01 suppuabize(21) -#define NCKEY_F02 suppuabize(22) -#define NCKEY_F03 suppuabize(23) -#define NCKEY_F04 suppuabize(24) -#define NCKEY_F05 suppuabize(25) -#define NCKEY_F06 suppuabize(26) -#define NCKEY_F07 suppuabize(27) -#define NCKEY_F08 suppuabize(28) -#define NCKEY_F09 suppuabize(29) -#define NCKEY_F10 suppuabize(30) -#define NCKEY_F11 suppuabize(31) -#define NCKEY_F12 suppuabize(32) -#define NCKEY_F13 suppuabize(33) -#define NCKEY_F14 suppuabize(34) -#define NCKEY_F15 suppuabize(35) -#define NCKEY_F16 suppuabize(36) -#define NCKEY_F17 suppuabize(37) -#define NCKEY_F18 suppuabize(38) -#define NCKEY_F19 suppuabize(39) -#define NCKEY_F20 suppuabize(40) -#define NCKEY_F21 suppuabize(41) -#define NCKEY_F22 suppuabize(42) -#define NCKEY_F23 suppuabize(43) -#define NCKEY_F24 suppuabize(44) -#define NCKEY_F25 suppuabize(45) -#define NCKEY_F26 suppuabize(46) -#define NCKEY_F27 suppuabize(47) -#define NCKEY_F28 suppuabize(48) -#define NCKEY_F29 suppuabize(49) -#define NCKEY_F30 suppuabize(50) -#define NCKEY_F31 suppuabize(51) -#define NCKEY_F32 suppuabize(52) -#define NCKEY_F33 suppuabize(53) -#define NCKEY_F34 suppuabize(54) -#define NCKEY_F35 suppuabize(55) -#define NCKEY_F36 suppuabize(56) -#define NCKEY_F37 suppuabize(57) -#define NCKEY_F38 suppuabize(58) -#define NCKEY_F39 suppuabize(59) -#define NCKEY_F40 suppuabize(60) -#define NCKEY_F41 suppuabize(61) -#define NCKEY_F42 suppuabize(62) -#define NCKEY_F43 suppuabize(63) -#define NCKEY_F44 suppuabize(64) -#define NCKEY_F45 suppuabize(65) -#define NCKEY_F46 suppuabize(66) -#define NCKEY_F47 suppuabize(67) -#define NCKEY_F48 suppuabize(68) -#define NCKEY_F49 suppuabize(69) -#define NCKEY_F50 suppuabize(70) -#define NCKEY_F51 suppuabize(71) -#define NCKEY_F52 suppuabize(72) -#define NCKEY_F53 suppuabize(73) -#define NCKEY_F54 suppuabize(74) -#define NCKEY_F55 suppuabize(75) -#define NCKEY_F56 suppuabize(76) -#define NCKEY_F57 suppuabize(77) -#define NCKEY_F58 suppuabize(78) -#define NCKEY_F59 suppuabize(79) -#define NCKEY_F60 suppuabize(80) -// ... leave room for up to 100 function keys, egads -#define NCKEY_ENTER suppuabize(121) -#define NCKEY_CLS suppuabize(122) // "clear-screen or erase" -#define NCKEY_DLEFT suppuabize(123) // down + left on keypad -#define NCKEY_DRIGHT suppuabize(124) -#define NCKEY_ULEFT suppuabize(125) // up + left on keypad -#define NCKEY_URIGHT suppuabize(126) -#define NCKEY_CENTER suppuabize(127) // the most truly neutral of keypresses -#define NCKEY_BEGIN suppuabize(128) -#define NCKEY_CANCEL suppuabize(129) -#define NCKEY_CLOSE suppuabize(130) -#define NCKEY_COMMAND suppuabize(131) -#define NCKEY_COPY suppuabize(132) -#define NCKEY_EXIT suppuabize(133) -#define NCKEY_PRINT suppuabize(134) -#define NCKEY_REFRESH suppuabize(135) -// Mouse events. We try to encode some details into the char32_t (i.e. which -// button was pressed), but some is embedded in the ncinput event. The release -// event is generic across buttons; callers must maintain state, if they care. -#define NCKEY_BUTTON1 suppuabize(201) -#define NCKEY_BUTTON2 suppuabize(202) -#define NCKEY_BUTTON3 suppuabize(203) -#define NCKEY_BUTTON4 suppuabize(204) -#define NCKEY_BUTTON5 suppuabize(205) -#define NCKEY_BUTTON6 suppuabize(206) -#define NCKEY_BUTTON7 suppuabize(207) -#define NCKEY_BUTTON8 suppuabize(208) -#define NCKEY_BUTTON9 suppuabize(209) -#define NCKEY_BUTTON10 suppuabize(210) -#define NCKEY_BUTTON11 suppuabize(211) -#define NCKEY_RELEASE suppuabize(212) - // Is this char32_t a Supplementary Private Use Area-B codepoint? static inline bool nckey_supppuab_p(char32_t w){ @@ -446,7 +338,7 @@ API int notcurses_refresh(struct notcurses* n); // Get a reference to the standard plane (one matching our current idea of the // terminal size) for this terminal. The standard plane always exists, and its -// origin is always at the uppermost, leftmost cell of the screen. +// origin is always at the uppermost, leftmost cell of the terminal. API struct ncplane* notcurses_stdplane(struct notcurses* nc); // Retrieve the contents of the specified cell as last rendered. The EGC is @@ -1978,7 +1870,7 @@ API int ncblit_bgrx(struct ncplane* nc, int placey, int placex, int linesize, // subregion of the input can be specified with 'begy'x'begx' and 'leny'x'lenx'. API int ncblit_rgba(struct ncplane* nc, int placey, int placex, int linesize, const unsigned char* data, int begy, int begx, - int leny, int lenx); + int leny, int lenx); // An ncreel is a notcurses region devoted to displaying zero or more // line-oriented, contained panels between which the user may navigate. If at @@ -2040,9 +1932,7 @@ struct ncreel; // and columns can be enforced via popts. efd, if non-negative, is an eventfd // that ought be written to whenever ncreel_touch() updates a tablet (this // is useful in the case of nonblocking input). -API struct ncreel* ncreel_create(struct ncplane* nc, - const ncreel_options* popts, - int efd); +API struct ncreel* ncreel_create(struct ncplane* nc, const ncreel_options* popts, int efd); // Returns the ncplane on which this ncreel lives. API struct ncplane* ncreel_plane(struct ncreel* pr); @@ -2073,8 +1963,8 @@ typedef int (*tabletcb)(struct nctablet* t, int begx, int begy, int maxx, // resulting location, assuming it is valid (after->next == before->prev); if // it is not valid, or there is any other error, NULL will be returned. API struct nctablet* ncreel_add(struct ncreel* pr, struct nctablet* after, - struct nctablet* before, tabletcb cb, - void* opaque); + struct nctablet* before, tabletcb cb, + void* opaque); // Return the number of nctablets in the ncreel. API int ncreel_tabletcount(const struct ncreel* pr); diff --git a/python/src/notcurses/build_notcurses.py b/python/src/notcurses/build_notcurses.py index 9b7c421b1..a212ff144 100644 --- a/python/src/notcurses/build_notcurses.py +++ b/python/src/notcurses/build_notcurses.py @@ -4,7 +4,7 @@ ffibuild = FFI() ffibuild.set_source( "_notcurses", """ - #include + #include """, libraries=["notcurses"], ) diff --git a/src/colloquy/Cargo.lock b/src/colloquy/Cargo.lock new file mode 100644 index 000000000..d21e1859a --- /dev/null +++ b/src/colloquy/Cargo.lock @@ -0,0 +1,129 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "hermit-abi 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "clap" +version = "2.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "colloquy" +version = "0.1.0" +dependencies = [ + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "notcurses 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hermit-abi" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libc" +version = "0.2.66" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "notcurses" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "vec_map" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "yaml-rust" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +"checksum hermit-abi 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e2c55f143919fbc0bc77e427fe2d74cf23786d7c1875666f2fde3ac3c659bb67" +"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" +"checksum notcurses 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5922082c807aad44b9c62b337c18ba525aa836ac9d7e47b65879dfe3f734f262" +"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +"checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" +"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" diff --git a/src/colloquy/Cargo.toml b/src/colloquy/Cargo.toml new file mode 100644 index 000000000..0fe8b83b5 --- /dev/null +++ b/src/colloquy/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "colloquy" +version = "0.1.0" +authors = ["nick black "] +edition = "2018" +repository = "https://github.com/dankamongmen/notcurses" + +[dependencies] +notcurses = ">= 1.2.0" +clap = {version = ">= 2.33.0", features = ["yaml", "color", "suggestions"]} diff --git a/src/colloquy/src/cli.yml b/src/colloquy/src/cli.yml new file mode 100644 index 000000000..ac472c21b --- /dev/null +++ b/src/colloquy/src/cli.yml @@ -0,0 +1,9 @@ +name: colloquy +version: "0.1.0" +about: Attractive UI widgets from the shell +author: Nick Black +args: + - verbose: + long: verbose + short: v + help: Verbose mode diff --git a/src/colloquy/src/main.rs b/src/colloquy/src/main.rs new file mode 100644 index 000000000..5413be7e8 --- /dev/null +++ b/src/colloquy/src/main.rs @@ -0,0 +1,5 @@ +fn main() { + use clap::{load_yaml, App}; + let yaml = load_yaml!("cli.yml"); + let matches = App::from_yaml(yaml).get_matches(); +} diff --git a/src/demo/demo.c b/src/demo/demo.c index 754d20469..2bcfb6289 100644 --- a/src/demo/demo.c +++ b/src/demo/demo.c @@ -8,8 +8,6 @@ #include #include #include -#include -#include "version.h" #include "demo.h" // ansi terminal definition-4-life @@ -20,11 +18,13 @@ static int democount; static demoresult* results; static char datadir[PATH_MAX]; -#ifdef DISABLE_FFMPEG -static const char DEFAULT_DEMO[] = "ithbgrwus"; +// yes, these are in different orders in different configurations on purpose +// (since some transition into the next) +#ifndef USE_FFMPEG +static const char DEFAULT_DEMO[] = "itfhbrgswu"; #else #ifdef DFSG_BUILD -static const char DEFAULT_DEMO[] = "ixthbgrwuso"; +static const char DEFAULT_DEMO[] = "ixtfhbrgslwuo"; #else static const char DEFAULT_DEMO[] = "ixethbcgrwuvlfsjo"; #endif @@ -84,9 +84,9 @@ struct timespec demodelay = { }; // anything that's dfsg non-free requires ncvisual (i.e. it's all multimedia), -// so also check for FFMPEG_DISABLE here in DFSG_BUILD +// so also check for USE_FFMPEG here in DFSG_BUILD #ifndef DFSG_BUILD -#ifndef DISABLE_FFMPEG +#ifdef USE_FFMPEG #define NONFREE(name, fxn) { name, fxn, } #endif #endif @@ -94,7 +94,7 @@ struct timespec demodelay = { #define NONFREE(name, fxn) { NULL, NULL, } #endif -#ifndef DISABLE_FFMPEG +#ifdef USE_FFMPEG #define FREEFFMPEG(name, fxn) { name, fxn, } #else #define FREEFFMPEG(name, fxn) { NULL, NULL, } @@ -111,7 +111,7 @@ static struct { NONFREE("chunli", chunli_demo), { NULL, NULL, }, NONFREE("eagle", eagle_demo), - NONFREE("fallin'", fallin_demo), + { "fallin'", fallin_demo, }, { "grid", grid_demo, }, { "highcon", highcontrast_demo, }, { "intro", intro, }, diff --git a/src/demo/demo.h b/src/demo/demo.h index d4bd9c971..b0225a6e0 100644 --- a/src/demo/demo.h +++ b/src/demo/demo.h @@ -6,8 +6,9 @@ #include #include #include -#include -#ifndef DISABLE_FFMPEG +#include +#include +#ifdef USE_FFMPEG #include #include #include // ffmpeg doesn't reliably "C"-guard itself diff --git a/src/demo/fallin.c b/src/demo/fallin.c index ce537155a..bcb32fd8d 100644 --- a/src/demo/fallin.c +++ b/src/demo/fallin.c @@ -1,31 +1,6 @@ #include "demo.h" #include -static bool done = false; -static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; - -static int -patentpulser(struct notcurses* nc, struct ncplane* ncp, void* curry){ - (void)ncp; - (void)curry; - DEMO_RENDER(nc); - bool donecheck; - pthread_mutex_lock(&lock); - donecheck = done; - pthread_mutex_unlock(&lock); - if(donecheck){ - return 2; - } - return 0; -} - -static void* -patentpulsar(void* n){ - struct notcurses* nc = n; - ncplane_pulse(notcurses_stdplane(nc), &demodelay, patentpulser, NULL); - return NULL; -} - static int drop_bricks(struct notcurses* nc, struct ncplane** arr, int arrcount){ if(arrcount == 0 || arr == NULL){ @@ -112,9 +87,6 @@ shuffle_in(struct ncplane** arr, int count, struct ncplane* n){ // ya playin' yourself int fallin_demo(struct notcurses* nc){ - if(!notcurses_canopen(nc)){ - return 0; - } int dimx, dimy; ncplane_dim_yx(notcurses_stdplane(nc), &dimy, &dimx); size_t usesize = sizeof(bool) * dimy * dimx; @@ -196,6 +168,7 @@ int fallin_demo(struct notcurses* nc){ } } free(usemap); +#ifdef USE_FFMPEG int averr = 0; char* path = find_data("lamepatents.jpg"); struct ncvisual* ncv = ncplane_visual_open(notcurses_stdplane(nc), path, &averr); @@ -211,19 +184,12 @@ int fallin_demo(struct notcurses* nc){ ncvisual_destroy(ncv); return -1; } - pthread_t tid; - if(pthread_create(&tid, NULL, patentpulsar, nc)){ - return -1; - } - int ret = drop_bricks(nc, arr, arrcount); - pthread_mutex_lock(&lock); - done = true; - pthread_mutex_unlock(&lock); - if(pthread_join(tid, NULL)){ - return -1; - } assert(ncvisual_decode(ncv, &averr) == NULL); assert(averr == AVERROR_EOF); ncvisual_destroy(ncv); +#else + ncplane_erase(notcurses_stdplane(nc)); +#endif + int ret = drop_bricks(nc, arr, arrcount); return ret; } diff --git a/src/demo/luigi.c b/src/demo/luigi.c index c40467d60..f0ccb4af7 100644 --- a/src/demo/luigi.c +++ b/src/demo/luigi.c @@ -161,7 +161,9 @@ int luigi_demo(struct notcurses* nc){ return -1; } assert(ncvisual_decode(nv, &averr) == NULL); +#ifdef USE_FFMPEG assert(averr == AVERROR_EOF); +#endif int rows, cols; ncplane_dim_yx(n, &rows, &cols); // he should be walking on the platform ~4/5 of the way down diff --git a/src/demo/reel.c b/src/demo/reel.c index e5e0d8b48..97f9e8f9f 100644 --- a/src/demo/reel.c +++ b/src/demo/reel.c @@ -6,7 +6,6 @@ #include #include #include -#include #include "demo.h" #define INITIAL_TABLET_COUNT 4 diff --git a/src/demo/sliding.c b/src/demo/sliding.c index d8e908ce6..d8d129bad 100644 --- a/src/demo/sliding.c +++ b/src/demo/sliding.c @@ -1,6 +1,5 @@ #include #include -#include #include "demo.h" // FIXME do the bigger dimension on the screen's bigger dimension diff --git a/src/demo/view.c b/src/demo/view.c index b1fc1f2a2..6f1567658 100644 --- a/src/demo/view.c +++ b/src/demo/view.c @@ -1,4 +1,3 @@ -#include #include "demo.h" static int diff --git a/src/lib/egcpool.h b/src/lib/egcpool.h index 21969a3a7..8581c56bb 100644 --- a/src/lib/egcpool.h +++ b/src/lib/egcpool.h @@ -9,7 +9,7 @@ #include #include #include -#include "notcurses.h" +#include "notcurses/notcurses.h" #ifdef __cplusplus extern "C" { diff --git a/src/lib/internal.h b/src/lib/internal.h index b0eeb7749..416ad6215 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -1,7 +1,9 @@ #ifndef NOTCURSES_INTERNAL #define NOTCURSES_INTERNAL -#ifndef DISABLE_FFMPEG +#include "version.h" + +#ifdef USE_FFMPEG #include #include #include @@ -25,8 +27,7 @@ #include #include #include -#include "notcurses.h" -#include "version.h" +#include "notcurses/notcurses.h" #include "egcpool.h" #ifdef __cplusplus @@ -94,7 +95,7 @@ typedef struct ncvisual { int placex, placey; ncscale_e style; // none, scale, or stretch struct notcurses* ncobj; // set iff this ncvisual "owns" its ncplane -#ifndef DISABLE_FFMPEG +#ifdef USE_FFMPEG AVSubtitle subtitle; #endif } ncvisual; diff --git a/src/lib/libav.c b/src/lib/libav.c index 19cf3d694..678611d56 100644 --- a/src/lib/libav.c +++ b/src/lib/libav.c @@ -1,6 +1,5 @@ #include #include "version.h" -#include "notcurses.h" #include "internal.h" ncplane* ncvisual_plane(ncvisual* ncv){ @@ -9,7 +8,7 @@ ncplane* ncvisual_plane(ncvisual* ncv){ void ncvisual_destroy(ncvisual* ncv){ if(ncv){ -#ifndef DISABLE_FFMPEG +#ifdef USE_FFMPEG avcodec_close(ncv->codecctx); avcodec_free_context(&ncv->codecctx); av_frame_free(&ncv->frame); @@ -27,7 +26,7 @@ void ncvisual_destroy(ncvisual* ncv){ } } -#ifndef DISABLE_FFMPEG +#ifdef USE_FFMPEG bool notcurses_canopen(const notcurses* nc __attribute__ ((unused))){ return true; } diff --git a/src/lib/metric.c b/src/lib/metric.c index 4dc418873..7c33a92d3 100644 --- a/src/lib/metric.c +++ b/src/lib/metric.c @@ -1,7 +1,7 @@ #include #include #include -#include "notcurses.h" +#include "notcurses/notcurses.h" static const char* decisep; static pthread_once_t ponce = PTHREAD_ONCE_INIT; diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 0d4f8adc5..f16ca39d3 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -757,7 +757,7 @@ void notcurses_reset_stats(notcurses* nc, ncstats* stats){ // Convert a notcurses log level to its ffmpeg equivalent. static int ffmpeg_log_level(ncloglevel_e level){ -#ifndef DISABLE_FFMPEG +#ifdef USE_FFMPEG switch(level){ case NCLOGLEVEL_SILENT: return AV_LOG_QUIET; case NCLOGLEVEL_PANIC: return AV_LOG_PANIC; @@ -943,14 +943,14 @@ notcurses* notcurses_init(const notcurses_options* opts, FILE* outfp){ bprefix(ret->stats.fbbytes, 1, prefixbuf, 0), ret->colors, ret->RGBflag ? "direct" : "palette", __VERSION__, curses_version()); -#ifndef DISABLE_FFMPEG +#ifdef USE_FFMPEG fprintf(ret->ttyfp, " avformat %u.%u.%u\n avutil %u.%u.%u\n swscale %u.%u.%u\n", LIBAVFORMAT_VERSION_MAJOR, LIBAVFORMAT_VERSION_MINOR, LIBAVFORMAT_VERSION_MICRO, LIBAVUTIL_VERSION_MAJOR, LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO, LIBSWSCALE_VERSION_MAJOR, LIBSWSCALE_VERSION_MINOR, LIBSWSCALE_VERSION_MICRO); #else - putp(tiparm(ret->setaf, 3)); - fprintf(ret->ttyfp, " Warning! Built without ffmpeg support\n"); + term_fg_palindex(ret, ret->ttyfp, ret->colors <= 88 ? 1 % ret->colors : 0xcb); + fprintf(ret->ttyfp, "\n Warning! Notcurses was built without ffmpeg support\n"); #endif term_fg_palindex(ret, ret->ttyfp, ret->colors <= 88 ? 1 % ret->colors : 0xcb); if(!ret->RGBflag){ // FIXME diff --git a/src/lib/reel.c b/src/lib/reel.c index 0421ef77f..217ab6262 100644 --- a/src/lib/reel.c +++ b/src/lib/reel.c @@ -3,7 +3,6 @@ #include #include #include -#include "notcurses.h" #include "internal.h" // Tablets are the toplevel entitites within an ncreel. Each corresponds to diff --git a/src/lib/selector.c b/src/lib/selector.c index 294287787..ac3c35079 100644 --- a/src/lib/selector.c +++ b/src/lib/selector.c @@ -1,4 +1,3 @@ -#include "notcurses.h" #include "internal.h" // ideal body width given the ncselector's items and secondary/footer diff --git a/src/poc/direct.c b/src/poc/direct.c index a9b4b07ed..6a5f097b9 100644 --- a/src/poc/direct.c +++ b/src/poc/direct.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include // can we leave what was already on the screen there? (narrator: it seems not) int main(void){ diff --git a/src/poc/dirgb.c b/src/poc/dirgb.c index 96335329e..6b3c3d1b7 100644 --- a/src/poc/dirgb.c +++ b/src/poc/dirgb.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include static int print_b(struct ncdirect* nc, int r, int g, int total){ diff --git a/src/poc/geom.c b/src/poc/geom.c index ec080e2dc..1ccd44e59 100644 --- a/src/poc/geom.c +++ b/src/poc/geom.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include // fun with the Geometric Shapes int main(void){ diff --git a/src/poc/menu.c b/src/poc/menu.c index 8f2914840..df3f48770 100644 --- a/src/poc/menu.c +++ b/src/poc/menu.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include static int run_menu(struct notcurses* nc, struct ncmenu* ncm){ diff --git a/src/poc/rgb.c b/src/poc/rgb.c index 6aef7b5be..d3736f817 100644 --- a/src/poc/rgb.c +++ b/src/poc/rgb.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include int main(void){ if(!setlocale(LC_ALL, "")){ diff --git a/src/poc/rgbbg.c b/src/poc/rgbbg.c index 66e3316b0..1e3783284 100644 --- a/src/poc/rgbbg.c +++ b/src/poc/rgbbg.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include int main(void){ if(!setlocale(LC_ALL, "")){ diff --git a/src/poc/selector.c b/src/poc/selector.c index ca7f6c699..a1ac8851b 100644 --- a/src/poc/selector.c +++ b/src/poc/selector.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include static struct selector_item items[] = { { "first", "this is the first option", }, diff --git a/src/poc/sgr.c b/src/poc/sgr.c index 9ad5ab1e1..618075aa0 100644 --- a/src/poc/sgr.c +++ b/src/poc/sgr.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #define DISABLE_ALTCHARSET 1 diff --git a/src/poc/visual.cpp b/src/poc/visual.cpp index 84cd197e3..9a0acfc78 100644 --- a/src/poc/visual.cpp +++ b/src/poc/visual.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include int main(int argc, char** argv){ setlocale(LC_ALL, ""); diff --git a/tests/cell.cpp b/tests/cell.cpp index b92cb38bf..2d25406fe 100644 --- a/tests/cell.cpp +++ b/tests/cell.cpp @@ -1,6 +1,5 @@ -#include -#include "egcpool.h" #include "main.h" +#include "egcpool.h" TEST_CASE("MultibyteWidth") { if(!enforce_utf8()){ diff --git a/tests/channel.cpp b/tests/channel.cpp index f59da8689..7db99e4b0 100644 --- a/tests/channel.cpp +++ b/tests/channel.cpp @@ -1,4 +1,3 @@ -#include #include "main.h" TEST_CASE("ChannelGetRGB") { diff --git a/tests/direct.cpp b/tests/direct.cpp index 58b38ee0f..bfb273506 100644 --- a/tests/direct.cpp +++ b/tests/direct.cpp @@ -1,5 +1,3 @@ -#include -#include "egcpool.h" #include "main.h" TEST_CASE("DirectMode") { diff --git a/tests/egcpool.cpp b/tests/egcpool.cpp index 19edcad3c..619057edc 100644 --- a/tests/egcpool.cpp +++ b/tests/egcpool.cpp @@ -1,7 +1,6 @@ #include -#include -#include "egcpool.h" #include "main.h" +#include "egcpool.h" TEST_CASE("EGCpool") { diff --git a/tests/fills.cpp b/tests/fills.cpp index d67aaf9d4..aeaaed09a 100644 --- a/tests/fills.cpp +++ b/tests/fills.cpp @@ -1,6 +1,5 @@ #include #include -#include #include "internal.h" #include "main.h" diff --git a/tests/main.h b/tests/main.h index a95381c67..cad8cd4e5 100644 --- a/tests/main.h +++ b/tests/main.h @@ -2,8 +2,9 @@ #define NOTCURSES_TEST_MAIN #include -#include #include +#include "version.h" +#include char* find_data(const char* datum); diff --git a/tests/ncplane.cpp b/tests/ncplane.cpp index a6fd13380..b690dd88c 100644 --- a/tests/ncplane.cpp +++ b/tests/ncplane.cpp @@ -1,8 +1,7 @@ #include #include -#include -#include "internal.h" #include "main.h" +#include "internal.h" void BoxPermutationsRounded(struct notcurses* nc, struct ncplane* n, unsigned edges) { int dimx, dimy; diff --git a/tests/notcurses.cpp b/tests/notcurses.cpp index dc1611bb1..1fd4f5361 100644 --- a/tests/notcurses.cpp +++ b/tests/notcurses.cpp @@ -1,9 +1,8 @@ #include #include #include -#include -#include "internal.h" #include "main.h" +#include "internal.h" TEST_CASE("NotcursesBase") { diff --git a/tests/palette.cpp b/tests/palette.cpp index 37f60382e..4eb087cd5 100644 --- a/tests/palette.cpp +++ b/tests/palette.cpp @@ -1,4 +1,3 @@ -#include #include "main.h" TEST_CASE("Palette256") { diff --git a/tests/visual.cpp b/tests/visual.cpp index 28eeb56e0..676cbb68d 100644 --- a/tests/visual.cpp +++ b/tests/visual.cpp @@ -1,7 +1,5 @@ -#include -#include "version.h" #include "main.h" -#ifndef DISABLE_FFMPEG +#ifdef USE_FFMPEG #include #include #include @@ -21,7 +19,7 @@ TEST_CASE("Multimedia") { ncplane* ncp_ = notcurses_stdplane(nc_); REQUIRE(ncp_); -#ifdef DISABLE_FFMPEG +#ifndef USE_FFMPEG SUBCASE("LibavDisabled"){ REQUIRE(!notcurses_canopen(nc_)); } diff --git a/tools/version.h.in b/tools/version.h.in index 257a1ef87..493a0b90c 100644 --- a/tools/version.h.in +++ b/tools/version.h.in @@ -1,6 +1,6 @@ #define notcurses_VERSION_MAJOR "@notcurses_VERSION_MAJOR@" #define notcurses_VERSION_MINOR "@notcurses_VERSION_MINOR@" #define notcurses_VERSION_PATCH "@notcurses_VERSION_PATCH@" -#cmakedefine DISABLE_FFMPEG #cmakedefine DFSG_BUILD +#cmakedefine USE_FFMPEG #define NOTCURSES_SHARE "@NOTCURSES_SHARE@"