Skip to content

Class TerminalUI

An interface: a tree of elements, the element with keyboard focus, and the routing of input to them. It draws into a DarkEffekt.Terminal.CellSurface and takes input as events, so it runs unchanged as a surface program (DarkEffekt.Terminal.UI.UISurfaceProgram) or over escape sequences (DarkEffekt.Terminal.UI.UIAnsiProgram).

Tab and Shift+Tab move focus. A key goes to the focused element and then up through its ancestors until one uses it; a pointer event goes to the element under it the same way.

Declaration
public sealed class TerminalUI : ITerminalInput

Implements:
DarkEffekt.Terminal.ITerminalInput

Declaration
public UIColors Colors { get; set; }

The glyphs every scroll bar draws unless it sets its own.

Declaration
public ScrollBarStyle ScrollBarStyle { get; set; }
Declaration
public Element Root { get; set; }

The element with keyboard focus, or null.

Declaration
public Element Focus { get; }

True when something changed since the last Render.

Declaration
public bool NeedsRender { get; }

A key no element used. Return true to stop the default Tab handling.

Declaration
public Func<TermKeyEvent, bool> UnhandledKey { get; set; }

Close the interface on Esc, when no element and no UnhandledKey has used the key.

Declaration
public bool CloseOnEscape { get; set; }
Declaration
public void Invalidate()

Asks the host to end the program.

Declaration
public void Close()
Declaration
public void Update(float deltaSeconds)
Type Name
System.Single deltaSeconds

Gives an element keyboard focus. Null clears it.

Declaration
public void SetFocus(Element element)
Type Name
DarkEffekt.Terminal.UI.Element element

Lays the tree out for a grid of this size and draws it.

Declaration
public void Render(CellSurface surface)
Type Name
DarkEffekt.Terminal.CellSurface surface

Adds the rectangle of every visible DarkEffekt.Terminal.UI.TextureView to the list.

Declaration
public void GetSlots(List<SurfaceSlot> into)
Type Name
System.Collections.Generic.List<DarkEffekt.Terminal.SurfaceSlot> into

Records that the host shows a texture in the slot of this name, so the view there draws no caption.

Declaration
public void SetSlotBound(string name, bool bound)
Type Name
System.String name
System.Boolean bound
Declaration
public bool IsSlotBound(string name)

System.Boolean

Type Name
System.String name

Moves focus forward (1) or back (-1) through the focusable elements, in tree order.

Declaration
public void FocusNext(int direction)
Type Name
System.Int32 direction

A non-text key: arrows, function keys, Enter, Tab, and the rest of DarkEffekt.Terminal.TermKey.

Declaration
public void OnKey(in TermKeyEvent e)
Type Name
DarkEffekt.Terminal.TermKeyEvent e

A typed character, or a letter held with Ctrl or Alt.

Declaration
public void OnChar(char c, TermModifiers modifiers)
Type Name
System.Char c
DarkEffekt.Terminal.TermModifiers modifiers

Text pasted from the clipboard.

Declaration
public void OnPaste(string text)
Type Name
System.String text

The terminal gained or lost keyboard focus.

Declaration
public void OnFocus(bool focused)
Type Name
System.Boolean focused
Declaration
public void OnMouse(in TermMouseEvent e)
Type Name
DarkEffekt.Terminal.TermMouseEvent e

Called every frame with the seconds since the last, before drawing. Animate here.

Declaration
public event Action<float> Tick

System.Action<System.Single>

Raised by DarkEffekt.Terminal.UI.TerminalUI.Close(), for the program hosting the interface to end.

Declaration
public event Action Closed

System.Action