59 Commits
Author SHA1 Message Date
Liu 90dbba2cdd feat(widgets): migrate textinput editing to the stb_textedit kernel
- vendor stb_textedit and add the textedit core with canonical text
- map edit indices to pd_text layout for caret, selection and hit testing
- support caret movement, selection, clipboard, undo/redo, password,
  read-only and multiline editing
- render selections with the accent color and configurable text color
- fix caret scaling, input-group repaint and zero-size reflow regressions
- add integration tests, a preview page and internals notes
2026-11-22 20:11:20 +08:00
Liu b0c031f8dc feat: add window icon support
- Add ptk_window_set_icons with Win32 WM_SETICON, X11 _NET_WM_ICON and fb no-op.

- Add LCUI window/default icon APIs, DPI-aware HICON selection and pre-rendered built-in icon assets.

- Add pandagl memory image readers and fix bilinear zoom edge sampling.

- Cover file/data icons, defaults and high-DPI sizes with integration tests.
2026-11-21 23:26:34 +08:00
Liu a9d94e2188 fix(font): use the resolved family name for fontconfig aliases
lcui_fc_fonts_init used the candidate name for aliases. When fontconfig falls back (for example no Ubuntu Mono on CI), the alias pointed at a family that was never loaded, so monospace/sans-serif/serif resolved to -2 and text rendering was empty. Query FC_FAMILY and use the actual loaded family.
2026-11-21 15:58:53 +08:00
Liu a9de756541 test(css): identify properties and cursor values in assertions 2026-11-21 15:58:52 +08:00
Liu 7404070d5e fix(pandagl): release fontconfig global caches on shutdown
FcInitLoadConfigAndFonts() leaves fontconfig global configuration and caches allocated; FcConfigDestroy() only releases the per-call config. Call FcFini() when the font library is destroyed.
2026-11-20 00:15:26 +08:00
Liu 7449e6fb4a feat(pandagl): add quiet font loading for optional fonts
pd_font_try_load_file() reports failures at debug level so platform probes, test candidates and CSS @font-face no longer spam errors for missing system fonts. pd_font_load_file() and XML font resources still report errors, and initialization warns once when no usable default font exists.
2026-11-19 23:37:21 +08:00
Liu ed25199836 fix(pandagl): zero glyph bitmap metrics on init
pd_glyph_bitmap_init() only cleared the bitmap fields. When glyph rendering failed and fell back to .notdef, the cached bitmap kept uninitialised metrics, so pd_text_update_line_size() read garbage (valgrind: conditional jump on uninitialised value) and text widths became nondeterministic.
2026-11-19 22:38:10 +08:00
Liu 464eed1402 build: centralize package versions and standardize on C11
versions.json is now the single source of truth; scripts/sync-versions.mjs keeps xmake descriptors, tracked version headers and package.json in sync. Sub-library versions are aligned with the published 1.0.0 packages. C11 is set at the project level, and _GNU_SOURCE is defined on POSIX so strict C11 still exposes clock_gettime, strdup and recursive pthread mutexes.
2026-11-19 22:03:59 +08:00
Liu 9217b1ca3a feat(styles): add light and dark theme support
- share shadcn neutral color tokens between both Tailwind configs
- rewrite Tailwind dark selectors into LCUI-compatible descendant selectors
- theme style-nova components and doc-viewer surfaces for dark mode
- generate GitHub Light and GitHub Dark syntax line pairs for code blocks
- support alpha channels in text style tag colors
- keep focus rings and scrollbars visible on dark surfaces
- use a neutral code surface instead of GitHub's blue-tinted background
2026-11-15 23:40:42 +08:00
Liu ad0ce709ee feat(pandagl): add pd_canvas_rotate and pd_canvas_mask_composite 2026-10-18 15:42:20 +08:00
Liu 218f900a58 feat(pandagl): support variable fonts and fix font fallback
Expand variable fonts into static weight instances via the wght axis so font-weight resolves to a real face.

Add pd_font_get_glyph_index and skip faces lacking a glyph during family fallback, so a missing glyph keeps falling back instead of stopping at a cached .notdef.

Fix an off-by-one in find_bolder_weight/find_lighter_weight (must index weights[weight-1]), which dereferenced NULL and crashed on sparse-weight families.

Cover these with variable-font, CJK-fallback and weight-fallback tests.
2026-10-17 21:16:48 +08:00
Liu 11f8c66a65 feat(pandagl): add text underline render support 2026-10-17 21:16:42 +08:00
Liu 2b3c33a246 fix(pandagl): free unused fallback glyph bitmaps 2026-10-17 21:16:39 +08:00
rewine d212185924 fix: build for string-render example (#331) 2026-10-17 21:16:29 +08:00
Liu 8e539a9ccc fix(pandagl): nested [color] tags should use innermost tag's color 2026-10-17 21:16:28 +08:00
Liu 711296f718 fix(pandagl): unify text baseline across fallback fonts 2026-08-05 22:42:27 +08:00
Liu 3801fdc10f refactor(yutil): rename public APIs and migrate timer to ptk
- charset module renamed to encoding (decode/encode kept)
- time: get_time_ms → y_gettime, sleep_ms → y_sleep
- time: delete get_time_us, get_time_delta, sleep_s
- string: strdup2 → y_strdup, wcsdup2 → y_wcsdup
- string: strtolower → y_strlower, strtrim → y_strtrim
- string: wcstrim → y_wcstrim, strhash → y_strhash
- string: strreplace → y_strreplace, strsplit → y_strsplit
- string: delete wcsreplace, cmdsplit
- math: delete y_iround, y_pow2
- timer module migrated from yutil to ptk as internal timer_scheduler
- WinMain simplified to use __argc/__argv instead of cmdsplit

BREAKING CHANGE: all renamed yutil public APIs require downstream
  to update function names. Deleted APIs require code changes:
  - get_time_us: use y_gettime() for ms timestamps
  - get_time_delta: use y_gettime() - start instead
  - sleep_s: use y_sleep(ms) with millisecond argument
  - wcsreplace: no replacement, had zero callers
  - cmdsplit: WinMain now uses __argc/__argv from CRT
  - timer_list_*: migrated to ptk timer_scheduler_*;
    ptk_reset_timer still available for external use
2026-08-05 22:42:26 +08:00
Liu 4a79f417d3 feat(pandagl): add backslash escape for style tag brackets
Allow \[, \], and \\ to be used in style-tag-enabled text input
so users can include literal bracket characters without triggering
tag parsing. Add tests covering open/close bracket escapes,
backslash self-escape, mixed real and escaped tags, and verify
unrelated backslash sequences (e.g. \n) are left untouched.
2026-08-05 22:42:23 +08:00
Liu 6cd01b468e chore: update copyright comment 2026-08-05 22:42:22 +08:00
Liu 7f9f52b904 chore: update copyright and email 2026-08-05 22:42:16 +08:00
CopilotandLiu 45f16a95d7 refactor(pandagl): unify rounded border and crop corner rendering (#327)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Liu <lc-soft@live.cn>
2026-08-05 22:41:29 +08:00
Liu 3a867040d1 build(xmake): fix package name, target naming and example install
- 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.
2026-08-05 22:41:23 +08:00
Liu 296c62240e refactor(pandagl): split text.c and rename caret/text-IO API
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.
2026-08-05 22:41:21 +08:00
Liu 0ac4b46b19 refactor(pandagl): flatten glyph bitmap cache to hash + lru
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.
2026-08-05 22:41:20 +08:00
Liu d64fe6202b refactor(pandagl): rename font API to align with typeface/glyph concepts
The previous naming conflated multiple levels of the font model:
pd_font_t actually owned a single typeface resource (FT_Face), while
pd_font_bitmap_t represented a per-glyph bitmap. The pd_font_library_*
prefix was redundant under the pd_font_ namespace and resulted in
verbose call sites (up to 34 chars).

Type renames
- pd_font_t          -> pd_font_face_t
- pd_font_bitmap_t   -> pd_glyph_bitmap_t
- font_engine_t      -> pd_font_engine_t
- struct tags updated to match the typedef names.

API renames (grouped by sub-object)
- Face lifecycle:    pd_font_create/destroy -> pd_font_face_create/destroy
- Face registry:     pd_font_library_add_font     -> pd_font_register
                     pd_font_library_get_font     -> pd_font_get
                     pd_font_library_get_font_id  -> pd_font_get_id
                     pd_font_library_query        -> pd_font_query
                     pd_font_library_load_file    -> pd_font_load_file
                     pd_font_library_get_font_path-> pd_font_find_path
                     pd_font_library_get_default_font -> pd_font_get_default
                     pd_font_library_set_default_font -> pd_font_set_default
                     pd_font_library_set_font_family_alias
                                                  -> pd_font_family_set_alias
                     pd_font_library_update_font_weight
                                                  -> pd_font_replace_weight
                     pd_font_library_update_font_style
                                                  -> pd_font_replace_style
- Parsing helpers:   pd_font_library_detect_weight -> pd_font_parse_weight
                     pd_font_library_detect_style  -> pd_font_parse_style
- Glyph rendering:   pd_font_library_render_bitmap -> pd_font_render_glyph
                     pd_canvas_mix_font_bitmap     -> pd_canvas_mix_glyph_bitmap
                     pd_font_bitmap_init/destroy   -> pd_glyph_bitmap_init/destroy
- Glyph cache:       pd_font_library_add_bitmap    -> pd_font_cache_add_bitmap
                     pd_font_library_get_bitmap    -> pd_font_cache_get_bitmap

pd_font_library_init/destroy are kept as the module lifecycle entry
points, matching the FT_Init_FreeType / FT_Done_FreeType convention.

All call sites in lib/pandagl, lib/ui, lib/ui-xml, src/, tests/ and
examples/ are updated accordingly.
2026-08-05 22:41:19 +08:00
Liu 18a98e5bd6 fix(pandagl): text deletion crashes and pd_text_dump missing line breaks
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
2026-08-05 22:41:18 +08:00
Liu 890fb49536 fix(pandagl): implicit declaration of function ‘pd_rect’ 2026-08-05 22:41:16 +08:00
Liu 75dbca815d test: reorganize test suite with xmake test integration
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.
2026-08-05 22:41:12 +08:00
copilot-swe-agent[bot]andlc-soft 1beafdfd5b refactor: convert pd_image_readers to fixed-index array, O(1) get_methods
Agent-Logs-Url: https://github.com/lc-soft/LCUI/sessions/31fedd8b-88fb-48dd-b055-303325c02c73

Co-authored-by: lc-soft <1730073+lc-soft@users.noreply.github.com>
2026-04-29 22:25:53 +08:00
Liu 91895a0b19 chore(pandagl): update logger level 2025-04-16 00:16:30 +08:00
Liu 9510e2c2ef style: format code and delete unused files 2025-01-06 23:14:33 +08:00
Liu 940a0fc33a chore: update copyright 2025-01-05 23:29:56 +08:00
Liu 4ad7d8a4fb feat: font alias 2025-01-05 23:08:45 +08:00
Liu 5a866286c5 style: clear uninitialized warnings 2024-12-22 23:17:11 +08:00
Liu 6851e9aef3 refactor: change type naming style 2024-12-22 23:14:13 +08:00
Liu 34d373b4c6 fix(pandagl): correct character position calculation in text line drawing 2024-12-07 13:30:29 +08:00
Liu 375e03bd36 feat: replace custom bool type with bool type in stdbool.h 2024-12-07 13:30:28 +08:00
Liu 4839064800 feat(pandagl): increase canvas size limit 2024-09-19 00:06:04 +08:00
Liu 0064fc840f chore: update copyright statement 2024-05-13 22:49:23 +08:00
Liu 1534e4b1c3 feat(pandagl): update image reader to support reading one row of data 2024-05-13 22:49:22 +08:00
Liu d60ec9227d chore: update copyright year 2024-05-13 22:49:22 +08:00
Liu d30e9f71b0 feat(pandagl): calculate baseline position based on Ascender and BBox 2024-05-13 22:49:21 +08:00
Liu d683955090 build: do not default to building test programs 2024-05-13 22:49:20 +08:00
Liu 023b35e245 chore: add copyright header 2024-05-13 22:49:20 +08:00
Liu 59e3220370 style: euqal -> equal 2024-05-13 22:49:18 +08:00
Liu 62ca908c81 style: centent -> content 2024-05-13 22:49:18 +08:00
Liu 20d235e6b9 fix(pandagl): the default style should not be reset when clearing text 2024-05-13 22:49:17 +08:00
Liu c5d66f6357 fix(ui): background image not loaded 2023-05-14 21:36:22 +08:00
Liu 9c4f0e9391 refactor: RGB() -> pd_rgb() 2023-05-03 21:49:46 +08:00
Liu c2930907cb feat: add libui-router 2023-05-03 17:49:51 +08:00