- Remove per-lib set_project() calls that overrode the global lcui
project name; xmake show now correctly reports the project as lcui.
- Move per-lib set_version() into the corresponding target() block so
each sub-library keeps an independent version usable for standalone
packaging.
- Add set_default(false) and set_group(examples) to all pandagl
examples so they are no longer picked up by xmake package.
- Rename targets to use dashes for consistency:
pandagl_cairo_example -> pandagl-cairo-example
preview_block_layout -> preview-block-layout
preview_flex_layout -> preview-flex-layout
preview_scrollbar -> preview-scrollbar
preview_widget_opacity -> preview-widget-opacity
- Bump yutil submodule to drop its set_project() call as well.
Split lib/pandagl/src/text/text.c into four cohesive units backed
by a library-private header:
- text.c : type lifecycle, line storage, geometry,
dirty-rect bookkeeping, top-level update
- text_typeset.c : line breaking, merging, autowrap, alignment
- text_render.c : per-char bitmap refresh and drawing
- text_edit.c : caret, insert/delete/backspace, text I/O
- text_internal.h : library-private cross-file helpers
(not installed)
Drop the 'insert' overload that conflated 'cursor' with 'insertion
point' and align the field/API names with the cursor concept used
in mainstream GUI toolkits:
insert_x, insert_y -> caret.x, caret.y
(new pd_text_caret_t sub-struct)
pd_text_set_insert_position -> pd_text_set_caret
pd_text_set_insert_pixel_position -> pd_text_set_caret_pixel
pd_text_get_insert_pixel_position -> pd_text_get_caret_pixel
pd_text_get_char_pixel_position -> pd_text_get_char_pixel
Make text I/O symmetric and intent-revealing:
pd_text_dump -> pd_text_read
(mirrors pd_text_write)
pd_text_empty -> pd_text_clear
(the previous static helper
is renamed to pd_text_reset_lines)
pd_text_set_typeset_task -> pd_text_request_typeset
Add pd_text_to_wcs(text), which allocates and returns the full
buffer contents including line endings. It complements the
range-based pd_text_read for callers that just want the whole
text as a wide string.
Fix the mulitiline_enabled -> multiline_enabled typo while at it.
All call sites in lib/pandagl, src/widgets and the tests are
updated. test_text_edit.c gains two cases for pd_text_to_wcs
covering full-text round-trip and the empty-text edge case.
The previous bitmap cache was a three-level rbtree keyed by
(wchar_t, font_id, size), which had two problems:
1. The wchar_t key collapses Unicode codepoints that map to the
same glyph in a given face into separate cache slots, missing
real reuse opportunities and bloating memory under text-heavy
workloads.
2. There was no upper bound; long-running apps would grow the
cache without limit until pd_font_library_destroy.
Replace it with a flat hash table keyed by a packed 64-bit
(face_id, glyph_index, size) tuple, plus a doubly-linked LRU list
for O(1) eviction.
- pd_font_engine gets a new get_glyph_index hook; FreeType maps
via FT_Get_Char_Index, the in-core engine treats codepoints as
identity (no cmap).
- pd_font_cache_add_bitmap / pd_font_cache_get_bitmap now resolve
the glyph index via the engine before keying the cache, so the
same glyph reused across composed sequences hits the same entry.
- pd_font_cache_set_capacity / pd_font_cache_count expose the LRU
bound (default 8192 entries, 0 = unlimited) for runtime tuning
and tests. Shrinking the capacity evicts immediately.
- list_t is used with append at tail / evict from head so the
yutil tail.prev pointer stays consistent (list_link does not
update it).
Adds lib/pandagl/tests/test_font_cache.c covering hit identity,
size differentiation, unknown-codepoint fallback, and LRU eviction.
pd_text_delete_ex
- Use-after-free: in same-line branch, pd_text_delete_line(end_y) was
followed by pd_text_line_set_length / pd_text_update_line_size on the
freed line. Now returns immediately after delete_line in that path.
- Off-by-one: cross-line merge used j = end_x + 1, dropping one char
when end_x is mid-line. Now j = end_x, and the line-tail special
case resets end_x to 0 explicitly.
- OOB read: prev_line = text->lines[char_y - 1] without bounds check.
Now guarded with char_y > 0 ? ... : NULL.
- Memory leak: chars in the deleted range were never freed and
ownership transfer between lines could double-free on delete_line.
pd_text_line_set_length
- realloc-grown slots were not zeroed, leaving uninitialized pointer
values that could be misread as live pd_char_t *.
pd_text_dump
- col was not reset when advancing to the next line, so output was
truncated at the first line's length.
- Did not emit the line-ending characters recorded in line->eol, so
multi-line text was concatenated without separators.
Helpers
- Extract pd_text_line_erase / pd_text_line_move to centralize char
ownership transfer; reused in pd_text_merge_line.
Tests
- Add lib/pandagl/tests/test_text_edit.c with 11 cases covering the
original crash scenarios (backspace at last empty line, delete at
line end), boundary cases, and dump behavior.
Closes#270
Restructure the test infrastructure with these changes:
* Extend libctest with ctest_suite_t, ctest_parse_args, ctest_run_suites and CTEST_MAIN macro to standardize test entry points; support --grep / --grep= / --list / --interactive flags; add ctest-tests for self-tests.
* Regroup tests by lib boundary: sink unit tests into lib/<name>/tests/ with <lib>_<topic> entry function names, move fixtures into lib/<name>/tests/fixtures/, rename top-level tests/cases/ to tests/integration/ for cross-lib integration tests.
* Add tests/scenes/ for reusable widget tree builders shared by integration cases and visual preview binaries; add tests/previews/ with 4 diagnostic binaries (flex_layout, block_layout, widget_opacity, scrollbar).
* Rewrite all describe/equal description strings using 'should ...' style or noun topic names; drop redundant lcui_quit/lcui_main calls from integration cases.
* Integrate xmake test via add_tests(\default\) and a shared tests.runnable rule defined in the root xmake.lua; the rule wraps the test binary with drmemory (Windows) or valgrind (Linux) when option memcheck=y.
* Drop the lcui-tests aggregation: lcui-tests now contains only integration cases and scenes, not the union of lib tests. Use xmake test to run everything across libs.
* Fix .clang-format: InsertNewlineAtEndOfFile -> InsertNewlineAtEOF (correct key for clang-format 16+).
* Update AGENTS.md with the new test layout, naming rules, description style and run commands.
* Update CI to use xmake test and xmake f --memcheck=y instead of per-lib runs.
* refactor: redesign PandaGL library
* refactor: update rect and canvas API
* refactor(pandagl): renames the line drawing function
* refactor(pandagl): replace pd_painter_t with pd_context_t
* fixup! refactor: update rect and canvas API
* test(pandagl): add tests
* fixup! refactor: update rect and canvas API
* fixup! refactor: update rect and canvas API
* fixup! refactor: update rect and canvas API
* fixup! refactor: update rect and canvas API