mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
tighten up include paths, libgpm connect #1986
This commit is contained in:
parent
0b67d67c8f
commit
b8c01eacc8
@ -202,6 +202,7 @@ set_target_properties(notcurses-core-static PROPERTIES
|
||||
OUTPUT_NAME notcurses-core
|
||||
)
|
||||
target_include_directories(notcurses-core
|
||||
BEFORE
|
||||
PRIVATE
|
||||
include
|
||||
src
|
||||
@ -211,6 +212,7 @@ target_include_directories(notcurses-core
|
||||
"${ZLIB_INCLUDE_DIRS}"
|
||||
)
|
||||
target_include_directories(notcurses-core-static
|
||||
BEFORE
|
||||
PRIVATE
|
||||
include
|
||||
src
|
||||
@ -225,6 +227,7 @@ target_link_libraries(notcurses-core
|
||||
"${TERMINFO_LIBRARIES}"
|
||||
"${LIBM}"
|
||||
"${unistring}"
|
||||
"${gpm}"
|
||||
PUBLIC
|
||||
Threads::Threads
|
||||
"${LIBRT_LIBRARIES}"
|
||||
@ -235,6 +238,7 @@ target_link_libraries(notcurses-core-static
|
||||
"${TERMINFO_STATIC_LIBRARIES}"
|
||||
"${LIBM}"
|
||||
"${unistring}"
|
||||
"${gpm}"
|
||||
PUBLIC
|
||||
Threads::Threads
|
||||
"${LIBRT_LIBRARIES}"
|
||||
@ -272,19 +276,19 @@ set_target_properties(notcurses-static PROPERTIES
|
||||
OUTPUT_NAME notcurses
|
||||
)
|
||||
target_include_directories(notcurses
|
||||
BEFORE
|
||||
PRIVATE
|
||||
include
|
||||
src
|
||||
src/lib
|
||||
"${CMAKE_REQUIRED_INCLUDES}"
|
||||
"${PROJECT_BINARY_DIR}/include"
|
||||
"${TERMINFO_INCLUDE_DIRS}"
|
||||
)
|
||||
target_include_directories(notcurses-static
|
||||
BEFORE
|
||||
PRIVATE
|
||||
include
|
||||
src
|
||||
src/lib
|
||||
"${CMAKE_REQUIRED_INCLUDES}"
|
||||
"${PROJECT_BINARY_DIR}/include"
|
||||
"${TERMINFO_INCLUDE_DIRS}"
|
||||
@ -410,16 +414,19 @@ set_target_properties(
|
||||
OUTPUT_NAME "notcurses++")
|
||||
|
||||
set(NCPP_INCLUDE_DIRS
|
||||
include
|
||||
"include"
|
||||
"src"
|
||||
"${PROJECT_BINARY_DIR}/include"
|
||||
"${TERMINFO_INCLUDE_DIRS}"
|
||||
)
|
||||
|
||||
target_include_directories(notcurses++
|
||||
BEFORE
|
||||
PRIVATE ${NCPP_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_include_directories(notcurses++-static
|
||||
BEFORE
|
||||
PRIVATE ${NCPP_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
@ -552,7 +559,6 @@ target_compile_definitions(notcurses-info
|
||||
target_include_directories(notcurses-info
|
||||
PRIVATE
|
||||
src
|
||||
src/lib
|
||||
include
|
||||
"${CMAKE_REQUIRED_INCLUDES}"
|
||||
"${PROJECT_BINARY_DIR}/include"
|
||||
@ -661,12 +667,12 @@ if(${USE_DOCTEST})
|
||||
file(GLOB TESTSRCS CONFIGURE_DEPENDS src/tests/*.cpp)
|
||||
add_executable(notcurses-tester ${TESTSRCS})
|
||||
target_include_directories(notcurses-tester
|
||||
BEFORE
|
||||
PRIVATE
|
||||
include
|
||||
src
|
||||
"${CMAKE_REQUIRED_INCLUDES}"
|
||||
"${PROJECT_BINARY_DIR}/include"
|
||||
src/lib
|
||||
"${TERMINFO_INCLUDE_DIRS}"
|
||||
)
|
||||
target_link_libraries(notcurses-tester
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <notcurses/notcurses.h>
|
||||
#include "internal.h" // internal headers
|
||||
#include "lib/internal.h" // internal headers
|
||||
|
||||
static inline wchar_t
|
||||
capboolbool(unsigned utf8, bool cap){
|
||||
|
52
src/lib/gpm.c
Normal file
52
src/lib/gpm.c
Normal file
@ -0,0 +1,52 @@
|
||||
#include "internal.h"
|
||||
#ifdef USE_GPM
|
||||
#undef buttons // defined by both term.h and gpm.h, ugh
|
||||
#include <lib/gpm.h>
|
||||
#include <gpm.h>
|
||||
|
||||
static Gpm_Connect gpmconn; // gpm server handle
|
||||
|
||||
int gpm_connect(tinfo* ti){
|
||||
(void)ti;
|
||||
gpm_zerobased = 1;
|
||||
gpmconn.eventMask = ~0;
|
||||
gpmconn.defaultMask = 0;
|
||||
gpmconn.minMod = 0;
|
||||
gpmconn.maxMod = ~0;
|
||||
if(Gpm_Open(&gpmconn, 0) == -1){
|
||||
logerror("couldn't connect to gpm");
|
||||
return -1;
|
||||
}
|
||||
loginfo("connected to gpm on %d\n", gpm_fd);
|
||||
return gpm_fd;
|
||||
}
|
||||
|
||||
int gpm_read(tinfo* ti, ncinput* ni){
|
||||
(void)ti;
|
||||
(void)ni;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int gpm_close(tinfo* ti){
|
||||
(void)ti;
|
||||
Gpm_Close();
|
||||
memset(&gpmconn, 0, sizeof(gpmconn));
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
int gpm_connect(tinfo* ti){
|
||||
(void)ti;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int gpm_read(tinfo* ti, ncinput* ni){
|
||||
(void)ti;
|
||||
(void)ni;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int gpm_close(tinfo* ti){
|
||||
(void)ti;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
30
src/lib/gpm.h
Normal file
30
src/lib/gpm.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef NOTCURSES_GPM
|
||||
#define NOTCURSES_GPM
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// internal header, not installed
|
||||
|
||||
struct tinfo;
|
||||
struct ncinput;
|
||||
|
||||
// GPM ("General Purpose Mouse") provides an interface to mice in the Linux
|
||||
// and FreeBSD consoles. The gpm server must be running; we do not attempt to
|
||||
// start it. We must have been built with -DUSE_GPM.
|
||||
|
||||
// Returns the poll()able file descriptor associated with gpm, or -1 on failure.
|
||||
int gpm_connect(struct tinfo* ti);
|
||||
|
||||
// Read from the gpm connection, which ought have been poll()ed. Translates
|
||||
// the libgpm input to an ncinput.
|
||||
int gpm_read(struct tinfo* ti, struct ncinput* ni);
|
||||
|
||||
int gpm_close(struct tinfo* ti);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -32,10 +32,11 @@ extern "C" {
|
||||
#ifndef __MINGW64__
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
#include "termdesc.h"
|
||||
#include "egcpool.h"
|
||||
#include "sprite.h"
|
||||
#include "fbuf.h"
|
||||
#include "lib/termdesc.h"
|
||||
#include "lib/egcpool.h"
|
||||
#include "lib/sprite.h"
|
||||
#include "lib/fbuf.h"
|
||||
#include "lib/gpm.h"
|
||||
|
||||
#define API __attribute__((visibility("default")))
|
||||
#define ALLOC __attribute__((malloc)) __attribute__((warn_unused_result))
|
||||
@ -1142,7 +1143,10 @@ coerce_styles(fbuf* f, const tinfo* ti, uint16_t* curstyle,
|
||||
#define SET_SGR_MODE_MOUSE "1006"
|
||||
|
||||
static inline int
|
||||
mouse_enable(FILE* out){
|
||||
mouse_enable(tinfo* ti, FILE* out){
|
||||
if(ti->qterm == TERMINAL_LINUX){
|
||||
return gpm_connect(ti);
|
||||
}
|
||||
// Sets the shift-escape option, allowing shift+mouse to override the standard
|
||||
// mouse protocol (mainly so copy-and-paste can still be performed).
|
||||
#define XTSHIFTESCAPE "\x1b[>1s"
|
||||
@ -1153,7 +1157,10 @@ mouse_enable(FILE* out){
|
||||
}
|
||||
|
||||
static inline int
|
||||
mouse_disable(fbuf* f){
|
||||
mouse_disable(tinfo* ti, fbuf* f){
|
||||
if(ti->qterm == TERMINAL_LINUX){
|
||||
return gpm_close(ti);
|
||||
}
|
||||
return fbuf_emit(f, "\x1b[?" SET_BTN_EVENT_MOUSE ";"
|
||||
/*SET_FOCUS_EVENT_MOUSE ";" */SET_SGR_MODE_MOUSE "l");
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ notcurses_stop_minimal(void* vnc){
|
||||
if(nc->tcache.pixel_shutdown){
|
||||
ret |= nc->tcache.pixel_shutdown(f);
|
||||
}
|
||||
ret |= mouse_disable(f);
|
||||
ret |= mouse_disable(&nc->tcache, f);
|
||||
ret |= reset_term_attributes(&nc->tcache, f);
|
||||
if(nc->tcache.ttyfd >= 0){
|
||||
if((esc = get_escape(&nc->tcache, ESCAPE_RMCUP))){
|
||||
@ -2262,7 +2262,7 @@ ncplane* ncplane_above(ncplane* n){
|
||||
}
|
||||
|
||||
int notcurses_mouse_enable(notcurses* n){
|
||||
if(mouse_enable(n->ttyfp)){
|
||||
if(mouse_enable(&n->tcache, n->ttyfp)){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@ -2275,7 +2275,7 @@ int notcurses_mouse_disable(notcurses* n){
|
||||
if(fbuf_init_small(&f)){
|
||||
return -1;
|
||||
}
|
||||
if(mouse_disable(&f)){
|
||||
if(mouse_disable(&n->tcache, &f)){
|
||||
fbuf_free(&f);
|
||||
return -1;
|
||||
}
|
||||
|
@ -664,7 +664,7 @@ macos_early_matches(void){
|
||||
int interrogate_terminfo(tinfo* ti, const char* termtype, FILE* out, unsigned utf8,
|
||||
unsigned noaltscreen, unsigned nocbreak, unsigned nonewfonts,
|
||||
int* cursor_y, int* cursor_x, ncsharedstats* stats){
|
||||
queried_terminals_e qterm = TERMINAL_UNKNOWN;
|
||||
ti->qterm = TERMINAL_UNKNOWN;
|
||||
memset(ti, 0, sizeof(*ti));
|
||||
// we don't need a controlling tty for everything we do; allow a failure here
|
||||
ti->ttyfd = get_tty_fd(out);
|
||||
@ -672,19 +672,19 @@ int interrogate_terminfo(tinfo* ti, const char* termtype, FILE* out, unsigned ut
|
||||
size_t tableused = 0;
|
||||
const char* tname = NULL;
|
||||
#ifdef __APPLE__
|
||||
qterm = macos_early_matches();
|
||||
ti->qterm = macos_early_matches();
|
||||
#elif defined(__MINGW64__)
|
||||
if(prepare_windows_terminal(ti, &tablelen, &tableused)){
|
||||
return -1;
|
||||
}
|
||||
qterm = TERMINAL_MSTERMINAL;
|
||||
ti->qterm = TERMINAL_MSTERMINAL;
|
||||
(void)termtype;
|
||||
#elif defined(__linux__)
|
||||
ti->linux_fb_fd = -1;
|
||||
ti->linux_fbuffer = MAP_FAILED;
|
||||
// we might or might not program quadrants into the console font
|
||||
if(is_linux_console(ti->ttyfd)){
|
||||
qterm = TERMINAL_LINUX;
|
||||
ti->qterm = TERMINAL_LINUX;
|
||||
}
|
||||
#endif
|
||||
#ifndef __MINGW64__
|
||||
@ -700,7 +700,7 @@ int interrogate_terminfo(tinfo* ti, const char* termtype, FILE* out, unsigned ut
|
||||
}
|
||||
// if we already know our terminal (e.g. on the linux console), there's no
|
||||
// need to send the identification queries. the controls are sufficient.
|
||||
bool minimal = (qterm != TERMINAL_UNKNOWN);
|
||||
bool minimal = (ti->qterm != TERMINAL_UNKNOWN);
|
||||
if(send_initial_queries(ti->ttyfd, minimal)){
|
||||
return -1;
|
||||
}
|
||||
@ -840,7 +840,7 @@ int interrogate_terminfo(tinfo* ti, const char* termtype, FILE* out, unsigned ut
|
||||
}
|
||||
*cursor_x = *cursor_y = -1;
|
||||
unsigned kittygraphs = 0;
|
||||
if(ncinputlayer_init(ti, stdin, &qterm, &appsync_advertised,
|
||||
if(ncinputlayer_init(ti, stdin, &ti->qterm, &appsync_advertised,
|
||||
cursor_y, cursor_x, stats, &kittygraphs)){
|
||||
goto err;
|
||||
}
|
||||
@ -863,7 +863,7 @@ int interrogate_terminfo(tinfo* ti, const char* termtype, FILE* out, unsigned ut
|
||||
}
|
||||
}
|
||||
bool invertsixel = false;
|
||||
if(apply_term_heuristics(ti, tname, qterm, &tablelen, &tableused,
|
||||
if(apply_term_heuristics(ti, tname, ti->qterm, &tablelen, &tableused,
|
||||
&invertsixel, nonewfonts)){
|
||||
ncinputlayer_stop(&ti->input);
|
||||
goto err;
|
||||
|
@ -7,6 +7,8 @@ extern "C" {
|
||||
|
||||
// internal header, not installed
|
||||
|
||||
#include "version.h"
|
||||
#include "builddef.h"
|
||||
#include "input.h"
|
||||
#include <stdint.h>
|
||||
#include <pthread.h>
|
||||
@ -185,6 +187,7 @@ typedef struct tinfo {
|
||||
int sprixel_scale_height; // sprixel must be a multiple of this many rows
|
||||
const char* termname; // terminal name from environment variables/init
|
||||
char* termversion; // terminal version (freeform) from query responses
|
||||
queried_terminals_e qterm;// detected terminal class
|
||||
#ifndef __MINGW64__
|
||||
struct termios tpreserved;// terminal state upon entry
|
||||
#endif
|
||||
|
@ -11,8 +11,8 @@
|
||||
#include <libswscale/version.h>
|
||||
#include <libavformat/version.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include "visual-details.h"
|
||||
#include "internal.h"
|
||||
#include "lib/visual-details.h"
|
||||
#include "lib/internal.h"
|
||||
|
||||
struct AVFormatContext;
|
||||
struct AVCodecContext;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "builddef.h"
|
||||
#ifdef USE_OIIO
|
||||
#include "visual-details.h"
|
||||
#include "internal.h"
|
||||
#include "lib/visual-details.h"
|
||||
#include "lib/internal.h"
|
||||
#include "oiio.h"
|
||||
|
||||
int oiio_blit_dispatch(struct ncplane* nc, const struct blitset* bset,
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <OpenImageIO/imageio.h>
|
||||
#include <OpenImageIO/imagebuf.h>
|
||||
#include <OpenImageIO/imagebufalgo.h>
|
||||
#include "visual-details.h"
|
||||
#include "lib/visual-details.h"
|
||||
#include "oiio.h"
|
||||
|
||||
typedef struct ncvisual_details {
|
||||
|
@ -5,7 +5,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "internal.h"
|
||||
#include "lib/internal.h"
|
||||
|
||||
int oiio_decode(ncvisual* nc);
|
||||
struct ncvisual_details* oiio_details_init(void);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "notcurses/direct.h"
|
||||
#include "internal.h"
|
||||
#include "lib/internal.h"
|
||||
|
||||
extern const ncvisual_implementation local_visual_implementation;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "main.h"
|
||||
#include "visual-details.h"
|
||||
#include "lib/visual-details.h"
|
||||
#include <vector>
|
||||
|
||||
TEST_CASE("Bitmaps") {
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "main.h"
|
||||
#include "egcpool.h"
|
||||
#include "lib/egcpool.h"
|
||||
|
||||
TEST_CASE("Cell") {
|
||||
auto nc_ = testing_notcurses();
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <vector>
|
||||
#include "main.h"
|
||||
#include "egcpool.h"
|
||||
#include "lib/egcpool.h"
|
||||
|
||||
TEST_CASE("EGCpool") {
|
||||
egcpool pool_{};
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "main.h"
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include "internal.h"
|
||||
|
||||
auto pulser(struct notcurses* nc, struct ncplane* ncp __attribute__ ((unused)),
|
||||
const struct timespec* ts __attribute__ ((unused)), void* curry) -> int {
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "main.h"
|
||||
#include "fbuf.h"
|
||||
#include "lib/fbuf.h"
|
||||
|
||||
TEST_CASE("Fbuf") {
|
||||
auto nc_ = testing_notcurses();
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <cstring>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "internal.h"
|
||||
#include <condition_variable>
|
||||
|
||||
static pthread_cond_t cond;
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "main.h"
|
||||
#include "internal.h"
|
||||
|
||||
TEST_CASE("Geometry") {
|
||||
auto nc_ = testing_notcurses();
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "main.h"
|
||||
#include "internal.h"
|
||||
|
||||
// some simple tests to ensure the libunistring we've compiled/linked against
|
||||
// behaves as expected.
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <notcurses/notcurses.h>
|
||||
#include <ncpp/NotCurses.hh>
|
||||
#include <ncpp/_exceptions.hh>
|
||||
#include "internal.h"
|
||||
#include "lib/internal.h"
|
||||
|
||||
struct free_deleter{
|
||||
template <typename T>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "main.h"
|
||||
#include "visual-details.h"
|
||||
#include "lib/visual-details.h"
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include "main.h"
|
||||
#include "internal.h"
|
||||
|
||||
TEST_CASE("NotcursesBase") {
|
||||
auto nc_ = testing_notcurses();
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include <cstdlib>
|
||||
#include "main.h"
|
||||
#include "internal.h"
|
||||
|
||||
void BoxPermutationsRounded(struct notcurses* nc, struct ncplane* n, unsigned edges) {
|
||||
int dimx, dimy;
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "main.h"
|
||||
#include <array>
|
||||
#include <cstdlib>
|
||||
#include "internal.h"
|
||||
|
||||
TEST_CASE("Scrolling") {
|
||||
auto nc_ = testing_notcurses();
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "main.h"
|
||||
#include "visual-details.h"
|
||||
#include "lib/visual-details.h"
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "main.h"
|
||||
#include "internal.h"
|
||||
|
||||
TEST_CASE("TextLayout") {
|
||||
auto nc_ = testing_notcurses();
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "main.h"
|
||||
#include "visual-details.h"
|
||||
#include "lib/visual-details.h"
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <array>
|
||||
#include <cstdlib>
|
||||
#include "main.h"
|
||||
#include "internal.h"
|
||||
|
||||
const char SNAKE[] = "\xf0\x9f\x90\x8d"; // U+1F40D SNAKE
|
||||
const char SCORPION[] = "\xf0\x9f\xa6\x82"; // U+1F982 SCORPION
|
||||
|
@ -1,5 +1,6 @@
|
||||
// Populated by CMake; not installed
|
||||
#cmakedefine DFSG_BUILD
|
||||
#cmakedefine USE_GPM
|
||||
#cmakedefine USE_QRCODEGEN
|
||||
#cmakedefine USE_READLINE
|
||||
// exclusive with USE_OIIO
|
||||
|
Loading…
x
Reference in New Issue
Block a user