# README
CLUI 
Command Line User Interface (Console UI inspired by TurboVision) with built-in theme support. Please see screenshots of working examples at the end of the README.
Installation
go get -u github.com/VladimirMarkelov/clui
Current version
The current version is 1.2.0. Please see details in changelog.
Applications that uses the library
- Terminal FB2 reader(termfb2): https://github.com/VladimirMarkelov/termfb2
Documentation
- Introduction
- Getting started
- Layout manager
- Basic standrd control methods and properties
- About Windows
- Predefined hotkeys
The list of available controls
- Window (Main control container - with maximize, window order and other window features)
- Label (Horizontal and Vertical with basic color control tags)
- Button (Simple push button control)
- EditField (One line text edit control with basic clipboard control)
- ListBox (string list control with vertical scroll)
- TextView (ListBox-alike control with vertical and horizontal scroll, and wordwrap mode)
- ProgressBar (Vertical and horizontal. The latter one supports custom text over control)
- Frame (A decorative control that can be a container for other controls as well)
- Scrollable frame
- CheckBox (Simple check box)
- Radio (Simple radio button. Useless alone - should be used along with RadioGroup)
- RadioGroup (Non-visual control to manage a group of a few RadioButtons)
- ConfirmationDialog (modal View to ask a user confirmation, button titles are custom)
- SelectDialog (modal View to ask a user to select an item from the list - list can be ListBox or RadioGroup)
- SelectEditDialog (modal View to ask a user to enter a value)
- BarChart (Horizontal bar chart without scroll)
- SparkChart (Show tabular data as a bar graph)
- GridView (Table to show structured data - only virtual and readonly mode with scroll support)
- FilePicker
- LoginDialog - a simple authorization dialog with two fields: Username and Password
- TextDisplay - a "virtual" text view control: it does not store any data, every time it needs to draw its line it requests the line from external source by line ID
Screenshots
The main demo (theme changing and radio group control)

The screencast of demo:

The library is in the very beginning but it can be used to create working utilities: below is the example of my Dilbert comix downloader:

License
CLUI is dual-licensed under MIT OR BSD-2-Clause
# Packages
No description provided by the author
# Functions
ActivateControl makes control active and disables all other children of the parent.
ActiveControl returns the active child of the parent or nil if no child is active.
AddWindow constucts a new Window, adds it to the composer automatically, and makes it active posX and posY are top left coordinates of the Window width and height are Window size title is a Window title.
AlignColorizedText does the same as AlignText does but it preserves the color of the letters by adding correct color tags to the line beginning.
AlignText calculates the initial position of the text output depending on str length and available width.
No description provided by the author
CalcClipper calculates the clipper size based on the control's size, position and paddings.
ChildAt returns the children of parent control that is at absolute coordinates x, y.
ClippedParent finds the first c parent with clipped flag.
ClipRect returns the current clipping rectangle.
ColorToString returns string representation of the attribute.
ControlInRect returns true if c is within a given rect.
CreateAlertDialog creates a new alert dialog.
CreateBarChart creates a new bar chart.
NewButton creates a new Button.
NewButton creates a new Button_NoShadow.
CreateCheckBox creates a new CheckBox control.
CreateConfirmationDialog creates new confirmation dialog.
No description provided by the author
NewEditField creates a new EditField control view - is a View that manages the control parent - is container that keeps the control.
CreateFileSelectDialog creates a new file select dialog.
NewFrame creates a new frame.
NewLabel creates a new label.
CreateListBox creates a new frame.
LoginDialog creates a new login dialog * title - custom dialog title * userName - initial username.
CreateProgressBar creates a new ProgressBar.
CreateRadio creates a new radio button.
CreateRadioGroup creates a new RadioGroup.
NewSelectDialog creates new dialog to select an item from list.
CreateSparkChart creates a new spark chart.
CreateTableView creates a new frame.
No description provided by the author
No description provided by the author
CreateTextView creates a new frame.
No description provided by the author
CurrentTheme returns name of the current theme.
CutText makes a text no longer than maxWidth.
DeactivateControls makes all children of parent inactive.
Close closes console management and makes a console cursor visible.
DrawFrame paints the frame without changing area inside it.
DrawHorizontalLine draws the part of the horizontal line that is inside current clipping rectangle.
DrawRawText draws the part of text that is inside the current clipping rectangle.
DrawRawTextVertical draws the part of text that is inside the current clipping rectangle.
DrawScrollBar displays a scrollbar.
DrawText draws the part of text that is inside the current clipping rectangle.
DrawTextVertical draws the part of text that is inside the current clipping rectangle.
DrawVerticalLine draws the part of the vertical line that is inside current clipping rectangle.
Ellipsize truncates text to maxWidth by replacing a substring in the middle with ellipsis and keeping the beginning and ending of the string untouched.
FillRect paints the area with r character using the current colors.
FindChild returns control if it is a child of the parent and nil otherwise.
FindFirstActiveControl returns the first active control of a parent.
FindFirstControl returns the first child for that fn returns true.
FindLastControl returns the first child for that fn returns true.
Flush makes termbox to draw everything to screen.
GetColorMap returns the color map (id is the color name, value its code).
GrabEvents makes control c as the exclusive event reciever.
InClipRect returns true if x and y position is inside current clipping rectangle.
No description provided by the author
No description provided by the author
IsDeadKey returns true if the pressed key is the first key in the key sequence understood by composer.
IsMouseClickEvent returns if a user action can be treated as mouse click.
ItemByThumbPosition calculates item number by scrollbar thumb position.
No description provided by the author
MainLoop starts the main application event loop.
No description provided by the author
NewColorParser creates a new string parser.
NextControl returns the next or previous child (depends on next parameter) that has tab-stop feature on.
PopAttributes restores saved with PushAttributes colors.
PopClip restores saved with PushClip clipping window.
No description provided by the author
PushAttributes saves the current back and fore colors.
PushClip saves the current clipping window.
PutChar sets value for the Canvas cell: rune and its colors.
PutEvent send event to a Composer directly.
RealColor returns attribute that should be applied to an object.
Repaints everything on the screen.
ReleaseEvents stops a control being exclusive evetn reciever and backs all to normal event processing.
ReloadTheme refresh cache entry for the theme with new data loaded from file.
Reset reinitializes canvas: set clipping rectangle to the whole terminal window, clears clip and color saved data, sets colors to default ones.
Size returns current Canvas size.
SendEventToChild tries to find a child control that should recieve the evetn For mouse click events it looks for a control at coordinates of event, makes it active, and then sends the event to it.
SetBackColor changes current background color.
SetClipRect defines a new clipping rect.
SetColorMap sets a custom color map (id is the color name, value its code).
SetCurrentTheme changes the current theme.
SetCursorPos sets text caret position.
SetSize sets the new Canvas size.
SetTextColor changes current text color.
SetThemePath changes the directory that contains themes.
SliceColorized returns a slice of text with correct color tags.
Stop sends termination event to Composer.
StringToColor returns attribute by its string description.
Symbol returns the character and its attributes by its coordinates.
SysColor returns attribute by its id for the current theme.
SysObject returns object look by its id for the current theme.
No description provided by the author
TextExtent calculates the width and the height of the text.
ThemeInfo returns detailed info about theme.
ThemeNames returns the list of short theme names (file names).
ThemePath returns the current directory with theme inside it.
ThemeReset removes all loaded themes from cache and reinitialize the default theme.
ThumbPosition returns a scrollbar thumb position depending on currently active item(itemNo), total number of items (itemCount), and length/height of the scrollbar(length) including arrows.
UnColorizeText removes all color-related tags from the string.
WindowManager returns main Window manager (that is Composer).
# Constants
Alignment constants.
Alignment constants.
Alignment constants.
AutoSize is used only in constructors.
BorderStyle constants.
BorderStyle constants.
BorderStyle constants.
BorderStyle constants.
ButtonBottom - move Window to bottom of the View stack.
ButtonClose - button to close View.
ButtonDefault - no button.
ButtonMaximaize - maximize and restore View.
general colors.
barchart colors.
Available color identifiers that can be used in themes.
Color predefined values.
Color predefined values.
Color predefined values.
Color predefined values.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
button control.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
window-like controls (button, radiogroup...).
Color predefined values.
Color predefined values.
Color predefined values.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
editable & listbox-like controls.
Available color identifiers that can be used in themes.
Color predefined values.
Color predefined values.
Color predefined values.
Color predefined values.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
progressbar colors.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Color predefined values.
Color predefined values.
Available color identifiers that can be used in themes.
scroll control.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
sparkchart colors.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
tableview colors.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Available color identifiers that can be used in themes.
Window back and fore colors (inner area & border).
Available color identifiers that can be used in themes.
Color predefined values.
Color predefined values.
Color predefined values.
Color predefined values.
DialogAlive - a user does not close the dialog yet, exit code is unavailable.
DialogButton1 - a user clicked the first button in the dialog (by default, it is 'Yes' or 'OK').
DialogButton2 - a user clicked the second button in the dialog.
DialogButton3 - a user clicked the third button in the dialog.
DialogClosed - a user clicked close button on the dialog title.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ElemBackColor - the item sets new background color.
ElemEndOfText - the string parsing has complited.
ElemLineBreak - line break.
ElemPrintable - the item is a rune.
ElemTextColor - the item sets new text color.
Notify an object when it is activated or deactivated.
A scroll-able control's child has been activated, then notify its parent to handle the scrolling.
control events
*/ Content of a control changed.
Button_NoShadow event - button was clicked.
an object that receives the event should close and destroys itself.
Close top window - or application is there is only one window.
dialog closed.
Something bad happened.
EventType is event that window or control may process Note: Do not change events from EventKey to EventNone - they correspond to the same named events in termbox library.
a key pressed.
Make a control (Target field of Event structure) to recalculate and reposition all its children.
Mouse button clicked.
An object changes its position.
EventType is event that window or control may process Note: Do not change events from EventKey to EventNone - they correspond to the same named events in termbox library.
Close application.
EventType is event that window or control may process Note: Do not change events from EventKey to EventNone - they correspond to the same named events in termbox library.
Asks an object to redraw.
an object or console size changed.
Fixed means 'never change size of the object when its parent resizes'.
HitResult constants.
HitResult constants.
HitResult constants.
HitResult constants.
HitResult constants.
HitResult constants.
HitResult constants.
HitResult constants.
HitResult constants.
HitResult constants.
HitResult constants.
HitResult constants.
HitResult constants.
HitResult constants.
Output direction Used for Label text output direction and for Radio items distribution, and for container controls.
KeepSize is used as a placeholder when you want to change only one value and keep other ones untouched.
No description provided by the author
No description provided by the author
No description provided by the author
Available object identifiers that can be used in themes.
Available object identifiers that can be used in themes.
Available object identifiers that can be used in themes.
Available object identifiers that can be used in themes.
Available object identifiers that can be used in themes.
Available object identifiers that can be used in themes.
Available object identifiers that can be used in themes.
Available object identifiers that can be used in themes.
Available object identifiers that can be used in themes.
Available object identifiers that can be used in themes.
Available object identifiers that can be used in themes.
Available object identifiers that can be used in themes.
SelectDialogEdit - Creates an editbox for user input.
SelectDialogList - all items are displayed in a ListBox.
SelectDialogRadio - all items are displayed in a RadioGroup.
Basic button shadow.
Half-symbols are used to draw a shadow that makes it slimmer.
No shadow and button turns a flat one.
Sort ascending.
Sort descending.
Do not sort.
A user pressed Delete key in TableView.
A user pressed F2 or Enter key in TableView.
A user pressed Insert key in TableView.
A user clicked on a column header in TableView.
Output direction Used for Label text output direction and for Radio items distribution, and for container controls.
# Variables
Predefined sets of the buttons for ConfirmationDialog and SelectDialog.
Predefined sets of the buttons for ConfirmationDialog and SelectDialog.
Predefined sets of the buttons for ConfirmationDialog and SelectDialog.
# Structs
BarChart is a chart that represents grouped data with
rectangular bars.
BarData is info about one bar in the chart.
BarDataCell is used in callback to user to draw with customized colors and runes.
BaseControl is a base for all visible controls.
Button is a simpe push button control.
Button_NoShadow is a simple push button control.
Canvas is a 'graphical' engine to draw primitives.
CheckBox control.
ColorParser is a string parser to process a text with color tags inside the string.
Column is a information about a table column.
ColumnDrawInfo is a structure used in OnDrawCell event.
Composer is a service object that manages Views and console, processes events, and provides service methods.
ConfirmationDialog is a simple dialog to get a user choice or confirmation.
EditField is a single-line text edit contol.
Event is structure used by Views and controls to communicate with Composer and vice versa.
FileSelectDialog is a dialog to select a file or directory.
Frame is a decorative control and container - frame with optional title.
Label is a decorative control that can display text in horizontal
or vertical direction.
ListBox is control to display a list of items and allow to user to select any of them.
LoginDialog is a login dialog with fields to enter user name and password Public properties: * Username - login entered by a user * Password - password entered by a user * Action - how the dialog was closed: - LoginOk - button "OK" was clicked - LoginCanceled - button "Cancel" was clicked or dialog was dismissed - LoginInvalid - invalid credentials were entered.
ProgressBar control visualizes the progression of extended operation.
Radio button control.
RadioGroup is non-interactive invisible object.
SelectDialog allows to user to select an item from the list.
SparkChart is a chart that represents a live data that
is continuously added to the chart.
TableEvent is structure to describe the common action that a TableView ask for while a user is interacting with the table.
TableView is control to display a list of items in a table(grid).
No description provided by the author
TextElement is currently parsed text element.
TextView is control to display a read-only text.
ThemeDesc is a detailed information about theme: title, author, version number.
ThemeManager support for controls.
Window is an implementation of View managed by Composer.
# Interfaces
Control is an interface that every visible control should implement.
# Type aliases
Predefined types.
Predefined types.
Predefined types.
Predefined types.
Predefined types.
Predefined types.
Predefined types.
Predefined types.
Predefined types.
Predefined types.
Predefined types.
TextElementType type of the parsed element of the string.
TextReader is deprecated due to its confusing name.
Predefined types.