C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
UI Backend

Backend API for terminal UI library. More...

Files

file  ui_backend.h
 Backend API for terminal UI library.
file  ui_layout.h
 UI layout management.
file  ui_ncurses_internal.h
 Internal header for ncurses UI backend. This header defines internal structures and functions used by the ncurses implementation of the UI backend. It should not be included directly by external code.
file  ui_theme.h
 UI theme definitions.

Data Structures

struct  UiColor
 Structure representing a color in the UI. More...
struct  UiConfig
 Structure representing the configuration options for the UI runtime. More...
struct  UiEvent
 Structure representing an input event in the UI. More...
struct  UiFramedSurface
struct  UiRect
 Structure representing a rectangular area in the UI. More...
struct  UiRuntime
 Opaque structure representing the UI runtime environment. More...
struct  UiStyle
 Structure representing the style attributes for UI elements. More...
struct  UiSurface
 Opaque structure representing a drawable surface in the UI. More...

Enumerations

enum  UiBorderKind { UI_BORDER_NONE = 0 , UI_BORDER_ASCII , UI_BORDER_LIGHT , UI_BORDER_ROUNDED }
 Enumeration of possible border styles for UI surfaces. More...
enum  UiKey {
  UI_KEY_NONE = 0 , UI_KEY_CHAR , UI_KEY_ENTER , UI_KEY_ESCAPE ,
  UI_KEY_BACKSPACE , UI_KEY_TAB , UI_KEY_BTAB , UI_KEY_UP ,
  UI_KEY_DOWN , UI_KEY_LEFT , UI_KEY_RIGHT , UI_KEY_HOME ,
  UI_KEY_END , UI_KEY_PGUP , UI_KEY_PGDN , UI_KEY_INSERT ,
  UI_KEY_DELETE , UI_KEY_RESIZE , UI_KEY_MOUSE , UI_KEY_F1 ,
  UI_KEY_F2 , UI_KEY_F3 , UI_KEY_F4 , UI_KEY_F5 ,
  UI_KEY_F6 , UI_KEY_F7 , UI_KEY_F8 , UI_KEY_F9 ,
  UI_KEY_F10 , UI_KEY_F11 , UI_KEY_F12
}
 Enumeration of possible key events in the UI. More...
enum  UiMouseAction {
  UI_MOUSE_NONE = 0 , UI_MOUSE_PRESS , UI_MOUSE_RELEASE , UI_MOUSE_DRAG ,
  UI_MOUSE_SCROLL_UP , UI_MOUSE_SCROLL_DOWN
}
 Enumeration of possible mouse actions in the UI. More...
enum  UiRole {
  UI_ROLE_DEFAULT = 0 , UI_ROLE_NORMAL , UI_ROLE_NORMAL_REVERSE , UI_ROLE_NORMAL_HIGHLIGHT ,
  UI_ROLE_NORMAL_HIGHLIGHT_REVERSE , UI_ROLE_BOX , UI_ROLE_TITLE , UI_ROLE_LINENO ,
  UI_ROLE_CMDLINE , UI_ROLE_BOLD , UI_ROLE_FILL , UI_ROLE_BRACKET
}
 UI role definitions.These are used to identify the purpose of a UI element, and can be used to apply different styles to different elements. The default theme will use these roles to apply different colors and styles to different elements. More...

Functions

void ui_framed_surface_destroy (UiFramedSurface *fs)
 Destroys a framed surface and releases its resources.
UiFramedSurface ui_framed_surface_new (UiRuntime *ui, UiSurface *parent, UiRect rect)
 Creates a new framed surface with the specified parent and rectangle.
const UiStyleui_theme_style (const UiTheme *theme, UiRole role)
 Get the style for a given UI role.

Detailed Description

Backend API for terminal UI library.

This module defines the API for implementing a backend for the terminal UI library. It includes types and functions for managing the UI runtime, surfaces, drawing operations, input handling, and cursor control.

The backend is responsible for rendering the UI to the terminal, handling user input events, and managing the lifecycle of the UI runtime and surfaces.

To implement a backend, you need to define the functions declared in this header file according to the specifications provided in the function comments.

See also
ui_backend.h

Enumeration Type Documentation

◆ UiBorderKind

Enumeration of possible border styles for UI surfaces.

The UiBorderKind enumeration defines the various border styles that can be applied to UI surfaces. This includes no border, ASCII borders, light borders, and rounded borders. Each border style is represented by a unique value in the enumeration, allowing for easy selection and application of borders when drawing UI elements. The chosen border style will affect the appearance of the surface's edges when rendered.

See also
ui_draw_border
Enumerator
UI_BORDER_NONE 
UI_BORDER_ASCII 
UI_BORDER_LIGHT 
UI_BORDER_ROUNDED 

Definition at line 115 of file ui_backend.h.

115 {
116 UI_BORDER_NONE = 0,
@ UI_BORDER_ROUNDED
Definition ui_backend.h:119
@ UI_BORDER_ASCII
Definition ui_backend.h:117
@ UI_BORDER_LIGHT
Definition ui_backend.h:118
@ UI_BORDER_NONE
Definition ui_backend.h:116
UiBorderKind
Enumeration of possible border styles for UI surfaces.
Definition ui_backend.h:115

◆ UiKey

enum UiKey

Enumeration of possible key events in the UI.

The UiKey enumeration defines the various key events that can be captured in the UI. This includes character input, special keys (like Enter, Escape, Arrow keys), function keys (F1-F12), and mouse events. Each key event is represented by a unique value in the enumeration, allowing for easy identification and handling of user input. When a key event occurs, it is captured in a UiEvent structure, which includes additional information such as modifier keys (Alt, Ctrl, Shift) and mouse actions.

See also
UiEvent
Enumerator
UI_KEY_NONE 
UI_KEY_CHAR 
UI_KEY_ENTER 
UI_KEY_ESCAPE 
UI_KEY_BACKSPACE 
UI_KEY_TAB 
UI_KEY_BTAB 
UI_KEY_UP 
UI_KEY_DOWN 
UI_KEY_LEFT 
UI_KEY_RIGHT 
UI_KEY_HOME 
UI_KEY_END 
UI_KEY_PGUP 
UI_KEY_PGDN 
UI_KEY_INSERT 
UI_KEY_DELETE 
UI_KEY_RESIZE 
UI_KEY_MOUSE 
UI_KEY_F1 
UI_KEY_F2 
UI_KEY_F3 
UI_KEY_F4 
UI_KEY_F5 
UI_KEY_F6 
UI_KEY_F7 
UI_KEY_F8 
UI_KEY_F9 
UI_KEY_F10 
UI_KEY_F11 
UI_KEY_F12 

Definition at line 58 of file ui_backend.h.

58 {
59 UI_KEY_NONE = 0,
90} UiKey;
@ UI_KEY_F8
Definition ui_backend.h:85
@ UI_KEY_BACKSPACE
Definition ui_backend.h:63
@ UI_KEY_F9
Definition ui_backend.h:86
@ UI_KEY_TAB
Definition ui_backend.h:64
@ UI_KEY_F2
Definition ui_backend.h:79
@ UI_KEY_F7
Definition ui_backend.h:84
@ UI_KEY_DELETE
Definition ui_backend.h:75
@ UI_KEY_CHAR
Definition ui_backend.h:60
@ UI_KEY_MOUSE
Definition ui_backend.h:77
@ UI_KEY_F11
Definition ui_backend.h:88
@ UI_KEY_DOWN
Definition ui_backend.h:67
@ UI_KEY_F4
Definition ui_backend.h:81
@ UI_KEY_F3
Definition ui_backend.h:80
@ UI_KEY_HOME
Definition ui_backend.h:70
@ UI_KEY_F6
Definition ui_backend.h:83
@ UI_KEY_PGDN
Definition ui_backend.h:73
@ UI_KEY_PGUP
Definition ui_backend.h:72
@ UI_KEY_NONE
Definition ui_backend.h:59
@ UI_KEY_BTAB
Definition ui_backend.h:65
@ UI_KEY_END
Definition ui_backend.h:71
@ UI_KEY_F5
Definition ui_backend.h:82
@ UI_KEY_ESCAPE
Definition ui_backend.h:62
@ UI_KEY_LEFT
Definition ui_backend.h:68
@ UI_KEY_F1
Definition ui_backend.h:78
@ UI_KEY_ENTER
Definition ui_backend.h:61
@ UI_KEY_UP
Definition ui_backend.h:66
@ UI_KEY_F12
Definition ui_backend.h:89
@ UI_KEY_RESIZE
Definition ui_backend.h:76
@ UI_KEY_INSERT
Definition ui_backend.h:74
@ UI_KEY_RIGHT
Definition ui_backend.h:69
@ UI_KEY_F10
Definition ui_backend.h:87
UiKey
Enumeration of possible key events in the UI.
Definition ui_backend.h:58

◆ UiMouseAction

Enumeration of possible mouse actions in the UI.

The UiMouseAction enumeration defines the various mouse actions that can be captured in the UI. This includes mouse button presses, releases, drags, and scroll events. Each mouse action is represented by a unique value in the enumeration, allowing for easy identification and handling of mouse input. When a mouse event occurs, it is captured in a UiEvent structure, which includes additional information such as the position of the mouse and any modifier keys (Alt, Ctrl, Shift) that were active at the time of the event.

See also
UiEvent
Enumerator
UI_MOUSE_NONE 
UI_MOUSE_PRESS 
UI_MOUSE_RELEASE 
UI_MOUSE_DRAG 
UI_MOUSE_SCROLL_UP 
UI_MOUSE_SCROLL_DOWN 

Definition at line 99 of file ui_backend.h.

99 {
100 UI_MOUSE_NONE = 0,
@ UI_MOUSE_SCROLL_DOWN
Definition ui_backend.h:105
@ UI_MOUSE_PRESS
Definition ui_backend.h:101
@ UI_MOUSE_SCROLL_UP
Definition ui_backend.h:104
@ UI_MOUSE_NONE
Definition ui_backend.h:100
@ UI_MOUSE_DRAG
Definition ui_backend.h:103
@ UI_MOUSE_RELEASE
Definition ui_backend.h:102
UiMouseAction
Enumeration of possible mouse actions in the UI.
Definition ui_backend.h:99

◆ UiRole

enum UiRole

UI role definitions.These are used to identify the purpose of a UI element, and can be used to apply different styles to different elements. The default theme will use these roles to apply different colors and styles to different elements.

Enumerator
UI_ROLE_DEFAULT 
UI_ROLE_NORMAL 
UI_ROLE_NORMAL_REVERSE 
UI_ROLE_NORMAL_HIGHLIGHT 
UI_ROLE_NORMAL_HIGHLIGHT_REVERSE 
UI_ROLE_BOX 
UI_ROLE_TITLE 
UI_ROLE_LINENO 
UI_ROLE_CMDLINE 
UI_ROLE_BOLD 
UI_ROLE_FILL 
UI_ROLE_BRACKET 

Definition at line 16 of file ui_theme.h.

16 {
29} UiRole;
UiRole
UI role definitions.These are used to identify the purpose of a UI element, and can be used to apply ...
Definition ui_theme.h:16
@ UI_ROLE_BOX
Definition ui_theme.h:22
@ UI_ROLE_BRACKET
Definition ui_theme.h:28
@ UI_ROLE_NORMAL_HIGHLIGHT
Definition ui_theme.h:20
@ UI_ROLE_NORMAL_REVERSE
Definition ui_theme.h:19
@ UI_ROLE_BOLD
Definition ui_theme.h:26
@ UI_ROLE_DEFAULT
Definition ui_theme.h:17
@ UI_ROLE_NORMAL
Definition ui_theme.h:18
@ UI_ROLE_CMDLINE
Definition ui_theme.h:25
@ UI_ROLE_FILL
Definition ui_theme.h:27
@ UI_ROLE_LINENO
Definition ui_theme.h:24
@ UI_ROLE_NORMAL_HIGHLIGHT_REVERSE
Definition ui_theme.h:21
@ UI_ROLE_TITLE
Definition ui_theme.h:23

Function Documentation

◆ ui_framed_surface_destroy()

void ui_framed_surface_destroy ( UiFramedSurface * fs)

Destroys a framed surface and releases its resources.

Parameters
fsThe UiFramedSurface to destroy.

◆ ui_framed_surface_new()

UiFramedSurface ui_framed_surface_new ( UiRuntime * ui,
UiSurface * parent,
UiRect rect )

Creates a new framed surface with the specified parent and rectangle.

Parameters
uiThe UI runtime context.
parentThe parent surface to which the framed surface will be attached.
rectThe rectangle defining the position and size of the framed surface.
Returns
A new UiFramedSurface instance, or NULL on failure.

◆ ui_theme_style()

const UiStyle * ui_theme_style ( const UiTheme * theme,
UiRole role )

Get the style for a given UI role.

Parameters
themeThe UI theme to get the style from.
roleThe UI role to get the style for.
Returns
The style for the given UI role.