mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
add new notcurses-input binary #8
This commit is contained in:
parent
b3a0b2ed6b
commit
a037cdfe5a
@ -63,6 +63,22 @@ target_compile_options(notcurses-demo
|
|||||||
-Wall -Wextra -W -Wshadow
|
-Wall -Wextra -W -Wshadow
|
||||||
)
|
)
|
||||||
|
|
||||||
|
file(GLOB INPUTSRCS CONFIGURE_DEPENDS src/input/*.cpp)
|
||||||
|
add_executable(notcurses-input ${INPUTSRCS})
|
||||||
|
target_include_directories(notcurses-input
|
||||||
|
PRIVATE
|
||||||
|
include
|
||||||
|
"${PROJECT_BINARY_DIR}/include"
|
||||||
|
)
|
||||||
|
target_link_libraries(notcurses-input
|
||||||
|
PRIVATE
|
||||||
|
notcurses
|
||||||
|
)
|
||||||
|
target_compile_options(notcurses-input
|
||||||
|
PRIVATE
|
||||||
|
-Wall -Wextra -W -Wshadow
|
||||||
|
)
|
||||||
|
|
||||||
file(GLOB VIEWSRCS CONFIGURE_DEPENDS src/view/*.cpp)
|
file(GLOB VIEWSRCS CONFIGURE_DEPENDS src/view/*.cpp)
|
||||||
add_executable(notcurses-view ${VIEWSRCS})
|
add_executable(notcurses-view ${VIEWSRCS})
|
||||||
target_include_directories(notcurses-view
|
target_include_directories(notcurses-view
|
||||||
@ -135,6 +151,7 @@ install(FILES
|
|||||||
|
|
||||||
install(TARGETS notcurses-demo DESTINATION bin)
|
install(TARGETS notcurses-demo DESTINATION bin)
|
||||||
install(TARGETS notcurses-view DESTINATION bin)
|
install(TARGETS notcurses-view DESTINATION bin)
|
||||||
|
install(TARGETS notcurses-input DESTINATION bin)
|
||||||
install(TARGETS notcurses
|
install(TARGETS notcurses
|
||||||
LIBRARY
|
LIBRARY
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
@ -174,10 +174,9 @@ API int ncplane_move_below(struct ncplane* RESTRICT n, struct ncplane* RESTRICT
|
|||||||
// Splice ncplane 'n' out of the z-buffer, and reinsert it above 'above'.
|
// Splice ncplane 'n' out of the z-buffer, and reinsert it above 'above'.
|
||||||
API int ncplane_move_above(struct ncplane* RESTRICT n, struct ncplane* RESTRICT above);
|
API int ncplane_move_above(struct ncplane* RESTRICT n, struct ncplane* RESTRICT above);
|
||||||
|
|
||||||
// Retrieve the topmost cell at this location on the screen, returning it in
|
// Retrieve the topmost cell at the cursor location on the specified plane,
|
||||||
// 'c'. If there is more than a byte of gcluster, it will be returned as a heap
|
// returning it in 'c'. This copy is safe to use until the ncplane is destroyed.
|
||||||
// allocation in '*gclust', and '*c' will be 0x80.
|
API void ncplane_at_cursor(const struct ncplane* n, cell* c);
|
||||||
API void notcurses_getc(const struct notcurses* n, cell* c, char** gclust);
|
|
||||||
|
|
||||||
// Manipulate the opaque user pointer associated with this plane.
|
// Manipulate the opaque user pointer associated with this plane.
|
||||||
// ncplane_set_userptr() returns the previous userptr after replacing
|
// ncplane_set_userptr() returns the previous userptr after replacing
|
||||||
@ -212,10 +211,18 @@ API void ncplane_cursor_yx(const struct ncplane* n, int* RESTRICT y,
|
|||||||
// On failure, -1 is returned.
|
// On failure, -1 is returned.
|
||||||
API int ncplane_putc(struct ncplane* n, const cell* c);
|
API int ncplane_putc(struct ncplane* n, const cell* c);
|
||||||
|
|
||||||
// Retrieve the cell under this plane's cursor, returning it in 'c'. If there
|
// Return an input from stdin, if one is available. Note that we do *not*
|
||||||
// is more than a byte of gcluster, it will be returned as a heap allocation in
|
// attempt to read an EGC in its entirety. 'c' will reference a single
|
||||||
// '*gclust', and '*c' will be 0x80. Returns -1 on error, 0 on success.
|
// UTF-8-encoded Unicode codepoint. This is a non-blocking operation. If no
|
||||||
API int ncplane_getc(const struct ncplane* n, cell* c, char** gclust);
|
// input is available, 0 is returned. On other errors, -1 is returned.
|
||||||
|
// Otherwise, the number of bytes in the UTF-8 character are returned.
|
||||||
|
API int ncplane_getc(const struct ncplane* n, cell* c);
|
||||||
|
|
||||||
|
// The same as ncplane_getc(), but blocking until input is read. It can still
|
||||||
|
// return early due to interruption by signal, in which case 0 is returned. On
|
||||||
|
// any other error, -1 is returned. Otherwise, the number of bytes in the UTF-8
|
||||||
|
// character are returned.
|
||||||
|
API int ncplane_getc_blocking(const struct ncplane* n, cell* c);
|
||||||
|
|
||||||
// Write a series of cells to the current location, using the current style.
|
// Write a series of cells to the current location, using the current style.
|
||||||
// They will be interpreted as a series of columns (according to the definition
|
// They will be interpreted as a series of columns (according to the definition
|
||||||
|
16
src/input/input.cpp
Normal file
16
src/input/input.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include <cstdlib>
|
||||||
|
#include <notcurses.h>
|
||||||
|
|
||||||
|
int main(void){
|
||||||
|
notcurses_options opts{};
|
||||||
|
opts.outfp = stdout;
|
||||||
|
struct notcurses* nc = notcurses_init(&opts);
|
||||||
|
if(nc == NULL){
|
||||||
|
return EXIT_FAILURE;;
|
||||||
|
}
|
||||||
|
// FIXME read input
|
||||||
|
if(notcurses_stop(nc)){
|
||||||
|
return EXIT_FAILURE;;
|
||||||
|
}
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
@ -1062,7 +1062,7 @@ int ncplane_putc(ncplane* n, const cell* c){
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ncplane_getc(const ncplane* n, cell* c, char** gclust){
|
int ncplane_cursor_at(const ncplane* n, cell* c, char** gclust){
|
||||||
if(n->y == n->leny && n->x == n->lenx){
|
if(n->y == n->leny && n->x == n->lenx){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1291,3 +1291,13 @@ void ncplane_erase(ncplane* n){
|
|||||||
n->channels = 0;
|
n->channels = 0;
|
||||||
n->attrword = 0;
|
n->attrword = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ncplane_getc(const struct ncplane* n, cell* c){
|
||||||
|
int r = getc(n->nc->ttyfp);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ncplane_getc_blocking(const struct ncplane* n, cell* c){
|
||||||
|
int r = getc(n->nc->ttyfp);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user