mirror of
https://github.com/nicbarker/clay.git
synced 2026-02-06 12:48:49 +00:00
Significantly enhances the Ncurses renderer capabilities and updates the example application.
Renderer Changes:
- Unicode Support:
- Implemented automatic UTF-8 locale detection and initialization.
- Switched to wide-character handling (`wchar_t`, `mvaddnwstr`) for correct rendering of multi-byte characters (e.g., Emojis).
- Used `wcwidth` for accurate string width measurement.
- Color Support:
- Upgraded from 3-bit (8 colors) to 256-color support (xterm-256color).
- Added `Clay_Ncurses_MatchColor` to map arbitrary RGB values to the nearest color in the standard 6x6x6 color cube.
- Added capability detection to fallback gracefully on simpler terminals.
- Visual Fidelity:
- Implemented background color inheritance (`Clay_Ncurses_GetBackgroundAt`) to simulate transparency.
- Text and borders now render on top of existing background colors instead of resetting to the terminal default.
- Build & POSIX:
- Added `_XOPEN_SOURCE_EXTENDED` and `_XOPEN_SOURCE=700` definitions for standard compliance.
Example Application (clay-ncurses-example):
- Theme:
- Updated to a modern dark theme (Uniform `{20, 20, 20}` background).
- Switched to saturated/bright foreground colors for better contrast.
- Fixes:
- Replaced obsolete `usleep` with POSIX-compliant `nanosleep`.
- Build:
- Updated CMakeLists.txt to enforce linking against `ncursesw` (wide version).
Verified with `clay-ncurses-example` on Linux (xterm-256color).
17 lines
505 B
CMake
17 lines
505 B
CMake
cmake_minimum_required(VERSION 3.27)
|
|
project(clay-ncurses-example C)
|
|
|
|
set(CURSES_NEED_WIDE TRUE)
|
|
find_package(Curses REQUIRED)
|
|
|
|
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})
|
|
|
|
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} ../../)
|