Configuration#
CEUI’s buffers and limits are fixed sizes, so it never allocates memory. You can change them with -D in your
program’s CFLAGS, set before include vendor/ceui/ui.mk:
CFLAGS = -Wall -Wextra -Oz -DUI_COMMANDS=4096 -DUI_SLOTS=20
include vendor/ceui/ui.mk
include $(shell cedev-config --makefile)
The same values are used by CEUI’s sources and by your theme, so always set them in CFLAGS, never with a #define
in one file.
Macro |
Default |
Meaning |
|---|---|---|
|
16 |
Palette entries CEUI owns, at the top of the palette. Raise it to get your own slots |
|
3072 |
Bytes per page of the base command stream. There are two pages |
|
1024 |
Bytes per page of the overlay stream (modals, menus, toasts). There are two pages |
|
48 |
Focusable widgets per frame. Widgets past this number cannot be reached with the arrows |
|
8 |
Container nesting, the screen included |
|
8 |
Columns per row |
|
4 |
Modals and menus open at once |
|
8 |
Scroll areas per frame |
|
4 |
Entries in |
|
4 |
Buffers |
|
64 |
Bytes per |
|
2000 |
How long a toast stays, in milliseconds |
|
48 |
Bytes of toast text, terminator included |
|
400 |
Time a key is held before it starts to repeat |
|
60 |
Time between repeats |
|
off |
Prints each frame’s buffer use and dirty rectangles through |
Sizing the command buffers#
Every widget records a few commands into the command stream: a frame, its text, a glyph. Text is copied into the command, so long paragraphs use more. Commands outside the current clip, like lines of a scroll area that are not visible, are not recorded.
When a buffer fills up, the rest of that stream is dropped for the frame and the next frame is redrawn in full. A
screen that loses its last widgets, or redraws in full on every key, has run out of command buffer. Build with
-DUI_DEBUG and run it in CEmu or CEbox to see how full the buffers get. Each frame prints lines like these to the
emulator’s debug console:
frame base=2148 over=0 rects=2
0,18 320x32
0,50 320x16
base and over are the bytes used in the base and overlay streams, and each following line is a rectangle that
was redrawn. Raise UI_COMMANDS or UI_OVERLAY_COMMANDS until the largest screen fits with room to spare. Remove
UI_DEBUG for release builds.
RAM#
Buffer |
Default size |
|---|---|
Command pages, base and overlay |
2 × (3072 + 1024) = 8 KB |
Focus table |
About 1 KB |
Everything else |
About 2 KB |
That is 11.1 KB of .bss in total with the defaults, and no heap. The back buffer CEUI draws into is the second
half of video memory, which 8 bits per pixel mode leaves free, so it costs no RAM.