CUI

Components / Inputs

Text area

A multi-line text field that wraps and scrolls.

Functions: cui_textarea

Text area

Usage

static char bio[512], body[4096];
cui_textarea(ui, "bio", bio, sizeof bio, .label = "Bio", .height = 120);
cui_textarea(ui, "body", body, sizeof body, .height = -1);   /* fill the available height */

Word wraps, scrolls with the wheel, Up and Down move between visual lines. Enter inserts a newline; Ctrl+Enter submits.

Returns the same flags as the text field: CUI_CHANGED on a frame the text changes, CUI_SUBMITTED when it is submitted, and CUI_FOCUSED and CUI_BLURRED on the frames it gains and loses the focus. bio is your buffer and the next argument its size in bytes, the terminating zero included. The library edits it in place, never writes past it, and drops what does not fit without cutting a UTF-8 character in half. Lines are separated by \n. height is in points and defaults to 96, and a negative value fills the height left in the container. It takes the options of the text field. For source code, use the code editor.

Keyboard

  • Word wraps, scrolls with the wheel, Up and Down move between visual lines.
  • Enter inserts a newline; Ctrl+Enter submits.

Options of cui_textarea

OptionTypeDefaultDescription
.labelconst char *label above the field
.placeholderconst char *Muted text shown while the field is empty.
.iconconst char *leading icon
.hintconst char *helper text below
.errorconst char *error text below (red)
.passwordboolshows dots instead of the text, with an eye button that reveals it
.disabledboolGreyed out, and takes no input.
.clearableboolx button when not empty
.autofocusboolTakes the keyboard focus when it first appears.
.read_onlyboolShows the value but does not let it be edited.
.sizecui_control_sizeOne of CUI_SIZE_MD, CUI_SIZE_SM or CUI_SIZE_LG.
.widthcui_sizeWidth: CUI_FILL, CUI_FIT, CUI_PX(n) or CUI_PCT(n); unset uses the component's own.
.heightfloattextarea: height in points; negative fills the space
.prefixconst char *muted text before the value, e.g. "$" or "https://"
.suffixconst char *muted text after the value, e.g. "USD" or "kg"

Related

  • Text field: A single-line field that edits text in a buffer you own, with a label, an icon, a hint and an error. The search field is a variant.
  • Code editor: An editable code field with syntax highlighting, for shader editors, script consoles and config files.
  • Number field: A field for a number in a range, typed or stepped with its buttons and the arrow keys.
  • Tag input: A field that turns typed words into removable chips, kept as a comma separated list.