package lambda-term

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module LTerm_widgetSource

Widgets for creating applications

Base class

The base class. The parameter is the initial resource class. The resource class is the first part of all resource keys used by the widget.

For examples, buttons use the resources "button.focused.foreground", "button.unfocused.bold", ... so their resource class is "button".

Sourceclass t : string -> object ... end
Labels
Sourceclass label : string -> object ... end

A widget displaying a text.

Containers
Sourceexception Out_of_range
Sourceclass type box = object ... end

Type of widgets displaying a list of widget.

Sourceclass hbox : box

A widget displaying a list of widgets, listed horizontally.

Sourceclass vbox : box

A widget displaying a list of widgets, listed vertically.

Sourceclass frame : object ... end

A widget displayiing another widget in a box.

Sourceclass modal_frame : object ... end

A widget displaying a frame around child widget. Unlike frame, the child widget is not expanded to take all available space; instead the child is centered and frame is drawn around it. This is a utility class for creation of modal dialogs and similar widgets.

Sourceclass spacing : ?rows:int -> ?cols:int -> unit -> t

A widget used for layout control within boxes

Lines
Sourceclass hline : t

A horizontal line.

Sourceclass vline : t

A vertical line.

Buttons
Sourceclass button : ?brackets:(string * string) -> string -> object ... end

Normal button.

Sourceclass checkbutton : string -> bool -> object ... end

Checkbutton. A button that can be in active or inactive state.

Sourceclass type 'a radio = object ... end
Sourceclass 'a radiogroup : object ... end

Radio group.

Sourceclass 'a radiobutton : 'a radiogroup -> string -> 'a -> object ... end

Radiobutton. The button which implements radio object contract, so can be added to radiogroup.

Scrollbars
Sourceclass adjustment : object ... end

Adjustable integer value from (0..range-1)

Sourceclass type scrollable_adjustment = object ... end

Interface between an adjustment and a scrollbar widget.

Sourceclass type scrollable_document = object ... end
Sourceclass type scrollable_private = object ... end

Interface used by the scrollbar widget to configure the scrollbar and get parameters needed for rendering

Sourceclass scrollable : object ... end

Main object implementing scroll logic for coordination between a scrollable wigdet and a scrollbar widget.

Sourceclass type default_scroll_events = object ... end

Events exposed by scrollbar widgets. These may be applied to other widgets if required.

Sourceclass vscrollbar : ?rc:string -> ?default_event_handler:bool -> ?width:int -> scrollable -> object ... end

Vertical scrollbar widget.

Sourceclass hscrollbar : ?rc:string -> ?default_event_handler:bool -> ?height:int -> scrollable -> object ... end

Horizontal scrollbar widget.

Sourceclass vslider : int -> object ... end

Vertical slider widget.

Sourceclass hslider : int -> object ... end

Horizontal slider widget.

Running in a terminal
Sourceval run : LTerm.t -> ?save_state:bool -> ?load_resources:bool -> ?resources_file:string -> t -> 'a Lwt.t -> 'a Lwt.t

run term ?save_state widget w runs on the given terminal using widget as main widget. It returns when w terminates. If save_state is true (the default) then the state of the terminal is saved and restored when w terminates.

If load_resources is true (the default) then resources_file (which default to ".lambda-termrc" in the home directory) is loaded and the result is set to w.

Sourceval run_modal : LTerm.t -> ?save_state:bool -> ?load_resources:bool -> ?resources_file:string -> t Lwt_react.event -> unit Lwt_react.event -> t -> 'a Lwt.t -> 'a Lwt.t

This function works in the same way as run but also takes two Lwt_react.event parameters. The first one should contain LTerm_widget.t widget and makes it new topmost layer in UI. The second message removes the topmost level from UI. All layers are redrawn, from bottom to up, but only the topmost layer gets keyboard events delivered to it. This allows to implement things like modal dialogs.

Sourceval prepare_simple_run : unit -> (t -> 'a Lwt.t) * (t -> unit -> unit) * (?step:React.step -> unit -> unit) * ('a -> unit)

prepare_simple_run () returns a tuple (do_run, push_layer, pop_layer, exit) -- functions useful for creating simple UI.

do_run w where w is a widget runs the given widget in a terminal over stdout, loading resources from .lambda-termrc, saving state and restoring it on exit from ui. Example: do_run my_frame

push_layer w where w is a widget is a callback to add w as a new modal layer to UI. Example: button#on_click (push_layer my_modal_dialog).

pop_layer is a callback to destroy the topmost modal layer. Example: cancel_button#on_click pop_layer.

exit is a callback to exit the UI. Example: exit_button#on_click exit

OCaml

Innovation. Community. Security.