Fix Ncurses click handling and restore ncursesw build

This commit addresses issues with mouse interaction reliability and build configuration in the Ncurses renderer and example.

Renderer Changes:
- Enable explicit xterm 1003 mouse tracking (Any Event) via escape sequences to ensure reliable hover sensing from the first frame (though not so portable).
- Refactor `Clay_Ncurses_ProcessInput` to:
  - Correctly order `Clay_SetPointerState` calls to ensure the "Pressed" state is registered before the function returns.
  - Detect and return a new `CLAY_NCURSES_KEY_MOUSE_CLICK` event code for single, double, and triple clicks.
- Make `Clay_Ncurses_OnClick` as a semantic wrapper around `Clay_OnHover`.
- Add empty switch cases for `CLAY_RENDER_COMMAND_TYPE_IMAGE` and `CLAY_RENDER_COMMAND_TYPE_CUSTOM` to prevent unhandled enumeration warnings.

Example Application Changes:
- Update `main.c` to break the input processing loop immediately upon receiving `CLAY_NCURSES_KEY_MOUSE_CLICK`, ensuring the "Pressed" state is processed by the layout engine for that frame.

Build System:
- Update `CMakeLists.txt` to replace `FindCurses` with `find_library` and `find_path` for `ncursesw`.
This commit is contained in:
Seintian 2025-12-29 21:57:50 +01:00
parent e89f3d15e9
commit 8643a5d2d9
3 changed files with 49 additions and 38 deletions

View file

@ -1,17 +1,19 @@
cmake_minimum_required(VERSION 3.27)
project(clay-ncurses-example C)
set(CURSES_NEED_WIDE TRUE)
find_package(Curses REQUIRED)
# Find ncursesw explicitly
find_library(NCURSESW_LIB NAMES ncursesw REQUIRED)
find_path(NCURSESW_INCLUDE_DIR NAMES ncurses.h PATH_SUFFIXES ncursesw)
add_compile_definitions(_XOPEN_SOURCE_EXTENDED _XOPEN_SOURCE=700)
add_executable(clay-ncurses-example main.c)
target_link_libraries(clay-ncurses-example PRIVATE ${CURSES_LIBRARIES})
target_link_libraries(clay-ncurses-example PRIVATE ${NCURSESW_LIB})
if (CMAKE_SYSTEM_NAME STREQUAL Linux)
target_link_libraries(clay-ncurses-example PRIVATE m)
endif()
target_include_directories(clay-ncurses-example PRIVATE ${CURSES_INCLUDE_DIRS} ../../)
target_include_directories(clay-ncurses-example PRIVATE ${NCURSESW_INCLUDE_DIR} ../../)