Page
Library
Module
Module type
Parameter
Class
Class type
Source
Nottui.Ui
SourcePrinting UI element
The type of layout specifications.
For each axis, layout is specified as a pair of integers:
Printing layout specification
Get the layout spec for an UI element
Primitive surface that displays a Notty image
Void space of dimensions x,y
. Useful for padding and interstitial space.
An event is propagated until it gets handled. Handler functions return a value of type may_handle
to indicate whether the event was handled or not.
type mouse_handler =
x:int ->
y:int ->
Notty.Unescape.button ->
[ may_handle | `Grab of (x:int -> y:int -> unit) * (x:int -> y:int -> unit) ]
The type of handlers for mouse events. They receive the (absolute) coordinates of the mouse, the button that was clicked.
In return they indicate whether the event was handled or if the mouse is "grabbed".
When grabbed, two functions on_move
and on_release
should be provided. The on_move
function will be called when the mouse move while the button is pressed and the on_release
function is called when the button is released.
During that time, no other mouse input events can be dispatched.
Key handlers normally reacts to keyboard input but a few special keys are defined to represent higher-level actions. Copy and paste, as well as focus movements.
type key =
[ Notty.Unescape.special
| `Uchar of Uchar.t
| `ASCII of char
| semantic_key ]
* Notty.Unescape.mods
A key is the pair of a main key and a list of modifiers
Specification of mouse inputs, taken from Notty
Handle mouse events that happens over an ui.
Define a focus receiver, handle keyboard events over the focused area
Check if this UI has focus, either directly (it is a focused keyboard_area
), or inherited (one of the child is a focused keyboard_area
).
val event_filter :
?focus:Focus.status ->
([ `Key of key | `Mouse of mouse ] -> may_handle) ->
t ->
t
A hook that intercepts and can interrupt events when they reach a sub-part of the UI.
Sensors are used to observe the physical dimensions after layout has been resolved.
The size sensor callback tells you the w
idth and h
eight of UI. The sensor is invoked only when the UI is visible.
Attach a size sensor to an image
The frame sensor callback gives you the whole rectangle where the widget is displayed.
The first for components are applied during before visiting children, the last unit is applied after visiting children.
Attach a transient frame sensor: the callback will be invoked only once, on next frame.
Attach a permanent sensor: the callback will be invoked on every frame. Note that this can have a significant impact on performance.
val resize :
?w:int ->
?h:int ->
?sw:int ->
?sh:int ->
?pad:Gravity.t ->
?crop:Gravity.t ->
?bg:Notty.attr ->
t ->
t
Override the layout specification of an image with provided w
, h
, sw
or sh
.
pad
and crop
are used to determine how to align the UI when there is too much or not enough space.
bg
is used to fill the padded background.
Shift the contents of a UI by a certain amount. Positive values crop the image while negative values pad.
This primitive is used to implement scrolling.
Horizontal concatenation monoid
Vertical concatenation monoid
Superposition monoid