Documentation ¶
Index ¶
- type FormScrollable
- func (f *FormScrollable) AddButton(label string, selected func()) *FormScrollable
- func (f *FormScrollable) AddCheckbox(label string, checked bool, changed func(checked bool)) *FormScrollable
- func (f *FormScrollable) AddDropDown(label string, options []string, initialOption int, ...) *FormScrollable
- func (f *FormScrollable) AddFormItem(item FormItem) *FormScrollable
- func (f *FormScrollable) AddImage(label string, image image.Image, width, height, colors int) *FormScrollable
- func (f *FormScrollable) AddInputField(label, value string, fieldWidth int, ...) *FormScrollable
- func (f *FormScrollable) AddPasswordField(label, value string, fieldWidth int, mask rune, changed func(text string)) *FormScrollable
- func (f *FormScrollable) AddTextArea(label, text string, fieldWidth, fieldHeight, maxLength int, ...) *FormScrollable
- func (f *FormScrollable) AddTextView(label, text string, fieldWidth, fieldHeight int, ...) *FormScrollable
- func (f *FormScrollable) Clear(includeButtons bool) *FormScrollable
- func (f *FormScrollable) ClearButtons() *FormScrollable
- func (f *FormScrollable) Draw(screen tcell.Screen)
- func (f *FormScrollable) Focus(delegate func(p Primitive))
- func (f *FormScrollable) GetButton(index int) *Button
- func (f *FormScrollable) GetButtonCount() int
- func (f *FormScrollable) GetButtonIndex(label string) int
- func (f *FormScrollable) GetFocusedItemIndex() (formItem, button int)
- func (f *FormScrollable) GetFormItem(index int) FormItem
- func (f *FormScrollable) GetFormItemByLabel(label string) FormItem
- func (f *FormScrollable) GetFormItemCount() int
- func (f *FormScrollable) GetFormItemIndex(label string) int
- func (f *FormScrollable) HasFocus() bool
- func (f *FormScrollable) InputHandler() func(event *tcell.EventKey, setFocus func(p Primitive))
- func (f *FormScrollable) MouseHandler() ...
- func (f *FormScrollable) PasteHandler() func(pastedText string, setFocus func(p Primitive))
- func (f *FormScrollable) RemoveButton(index int) *FormScrollable
- func (f *FormScrollable) RemoveFormItem(index int) *FormScrollable
- func (f *FormScrollable) SetButtonActivatedStyle(style tcell.Style) *FormScrollable
- func (f *FormScrollable) SetButtonBackgroundColor(color tcell.Color) *FormScrollable
- func (f *FormScrollable) SetButtonDisabledStyle(style tcell.Style) *FormScrollable
- func (f *FormScrollable) SetButtonStyle(style tcell.Style) *FormScrollable
- func (f *FormScrollable) SetButtonTextColor(color tcell.Color) *FormScrollable
- func (f *FormScrollable) SetButtonsAlign(align int) *FormScrollable
- func (f *FormScrollable) SetCancelFunc(callback func()) *FormScrollable
- func (f *FormScrollable) SetFieldBackgroundColor(color tcell.Color) *FormScrollable
- func (f *FormScrollable) SetFieldTextColor(color tcell.Color) *FormScrollable
- func (f *FormScrollable) SetFocus(index int) *FormScrollable
- func (f *FormScrollable) SetHorizontal(horizontal bool) *FormScrollable
- func (f *FormScrollable) SetItemPadding(padding int) *FormScrollable
- func (f *FormScrollable) SetLabelColor(color tcell.Color) *FormScrollable
- type NoneFocusableButton
- func (b *NoneFocusableButton) Blur()
- func (b *NoneFocusableButton) Focus(delegate func(p tview.Primitive))
- func (b *NoneFocusableButton) HasFocus() bool
- func (b *NoneFocusableButton) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))
- func (b *NoneFocusableButton) MouseHandler() ...
- func (b *NoneFocusableButton) PasteHandler() func(pastedText string, setFocus func(p tview.Primitive))
- func (b *NoneFocusableButton) SetClick(c func()) *NoneFocusableButton
- func (b *NoneFocusableButton) SetFocusable(f tview.Primitive) *NoneFocusableButton
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FormScrollable ¶
type FormScrollable struct { *Box // contains filtered or unexported fields }
FormScrollable is a form from original tview with two buttons which change elements focus by one item up an down. Also buttons show allowing scalable (will disabled when firs and last element in focus)
func NewFormScrollable ¶
func NewFormScrollable() *FormScrollable
NewFormScrollable returns a new form.
func (*FormScrollable) AddButton ¶
func (f *FormScrollable) AddButton(label string, selected func()) *FormScrollable
AddButton adds a new button to the form. The "selected" function is called when the user selects this button. It may be nil.
func (*FormScrollable) AddCheckbox ¶
func (f *FormScrollable) AddCheckbox(label string, checked bool, changed func(checked bool)) *FormScrollable
AddCheckbox adds a checkbox to the form. It has a label, an initial state, and an (optional) callback function which is invoked when the state of the checkbox was changed by the user.
func (*FormScrollable) AddDropDown ¶
func (f *FormScrollable) AddDropDown(label string, options []string, initialOption int, selected func(option string, optionIndex int)) *FormScrollable
AddDropDown adds a drop-down element to the form. It has a label, options, and an (optional) callback function which is invoked when an option was selected. The initial option may be a negative value to indicate that no option is currently selected.
func (*FormScrollable) AddFormItem ¶
func (f *FormScrollable) AddFormItem(item FormItem) *FormScrollable
AddFormItem adds a new item to the form. This can be used to add your own objects to the form. Note, however, that the Form class will override some of its attributes to make it work in the form context. Specifically, these are:
- The label width
- The label color
- The background color
- The field text color
- The field background color
func (*FormScrollable) AddImage ¶
func (f *FormScrollable) AddImage(label string, image image.Image, width, height, colors int) *FormScrollable
AddImage adds an image to the form. It has a label and the image will fit in the specified width and height (its aspect ratio is preserved). See [Image.SetColors] for a description of the "colors" parameter. Images are not interactive and are skipped over in a form. The "width" value may be 0 (adjust dynamically) but "height" should generally be a positive value.
func (*FormScrollable) AddInputField ¶
func (f *FormScrollable) AddInputField(label, value string, fieldWidth int, accept func(textToCheck string, lastChar rune) bool, changed func(text string)) *FormScrollable
AddInputField adds an input field to the form. It has a label, an optional initial value, a field width (a value of 0 extends it as far as possible), an optional accept function to validate the item's value (set to nil to accept any text), and an (optional) callback function which is invoked when the input field's text has changed.
func (*FormScrollable) AddPasswordField ¶
func (f *FormScrollable) AddPasswordField(label, value string, fieldWidth int, mask rune, changed func(text string)) *FormScrollable
AddPasswordField adds a password field to the form. This is similar to an input field except that the user's input not shown. Instead, a "mask" character is displayed. The password field has a label, an optional initial value, a field width (a value of 0 extends it as far as possible), and an (optional) callback function which is invoked when the input field's text has changed.
func (*FormScrollable) AddTextArea ¶
func (f *FormScrollable) AddTextArea(label, text string, fieldWidth, fieldHeight, maxLength int, changed func(text string)) *FormScrollable
AddTextArea adds a text area to the form. It has a label, an optional initial text, a size (width and height) referring to the actual input area (a fieldWidth of 0 extends it as far right as possible, a fieldHeight of 0 will cause it to be [DefaultFormFieldHeight]), and a maximum number of bytes of text allowed (0 means no limit).
The optional callback function is invoked when the content of the text area has changed. Note that especially for larger texts, this is an expensive operation due to technical constraints of the [TextArea] primitive (every key stroke leads to a new reallocation of the entire text).
func (*FormScrollable) AddTextView ¶
func (f *FormScrollable) AddTextView(label, text string, fieldWidth, fieldHeight int, dynamicColors, scrollable bool) *FormScrollable
AddTextView adds a text view to the form. It has a label and text, a size (width and height) referring to the actual text element (a fieldWidth of 0 extends it as far right as possible, a fieldHeight of 0 will cause it to be [DefaultFormFieldHeight]), a flag to turn on/off dynamic colors, and a flag to turn on/off scrolling. If scrolling is turned off, the text view will not receive focus.
func (*FormScrollable) Clear ¶
func (f *FormScrollable) Clear(includeButtons bool) *FormScrollable
Clear removes all input elements from the form, including the buttons if specified.
func (*FormScrollable) ClearButtons ¶
func (f *FormScrollable) ClearButtons() *FormScrollable
ClearButtons removes all buttons from the form.
func (*FormScrollable) Draw ¶
func (f *FormScrollable) Draw(screen tcell.Screen)
Draw draws this primitive onto the screen.
func (*FormScrollable) Focus ¶
func (f *FormScrollable) Focus(delegate func(p Primitive))
Focus is called by the application when the primitive receives focus.
func (*FormScrollable) GetButton ¶
func (f *FormScrollable) GetButton(index int) *Button
GetButton returns the button at the specified 0-based index. Note that buttons have been specially prepared for this form and modifying some of their attributes may have unintended side effects.
func (*FormScrollable) GetButtonCount ¶
func (f *FormScrollable) GetButtonCount() int
GetButtonCount returns the number of buttons in this form.
func (*FormScrollable) GetButtonIndex ¶
func (f *FormScrollable) GetButtonIndex(label string) int
GetButtonIndex returns the index of the button with the given label, starting with 0 for the button that was added first. If no such label was found, -1 is returned.
func (*FormScrollable) GetFocusedItemIndex ¶
func (f *FormScrollable) GetFocusedItemIndex() (formItem, button int)
GetFocusedItemIndex returns the indices of the form element or button which currently has focus. If they don't, -1 is returned respectively.
func (*FormScrollable) GetFormItem ¶
func (f *FormScrollable) GetFormItem(index int) FormItem
GetFormItem returns the form item at the given position, starting with index 0. Elements are referenced in the order they were added. Buttons are not included.
func (*FormScrollable) GetFormItemByLabel ¶
func (f *FormScrollable) GetFormItemByLabel(label string) FormItem
GetFormItemByLabel returns the first form element with the given label. If no such element is found, nil is returned. Buttons are not searched and will therefore not be returned.
func (*FormScrollable) GetFormItemCount ¶
func (f *FormScrollable) GetFormItemCount() int
GetFormItemCount returns the number of items in the form (not including the buttons).
func (*FormScrollable) GetFormItemIndex ¶
func (f *FormScrollable) GetFormItemIndex(label string) int
GetFormItemIndex returns the index of the first form element with the given label. If no such element is found, -1 is returned. Buttons are not searched and will therefore not be returned.
func (*FormScrollable) HasFocus ¶
func (f *FormScrollable) HasFocus() bool
HasFocus returns whether or not this primitive has focus.
func (*FormScrollable) InputHandler ¶
func (f *FormScrollable) InputHandler() func(event *tcell.EventKey, setFocus func(p Primitive))
InputHandler returns the handler for this primitive.
func (*FormScrollable) MouseHandler ¶
func (f *FormScrollable) MouseHandler() func(action MouseAction, event *tcell.EventMouse, setFocus func(p Primitive)) (consumed bool, capture Primitive)
MouseHandler returns the mouse handler for this primitive.
func (*FormScrollable) PasteHandler ¶
func (f *FormScrollable) PasteHandler() func(pastedText string, setFocus func(p Primitive))
PasteHandler returns the handler for this primitive.
func (*FormScrollable) RemoveButton ¶
func (f *FormScrollable) RemoveButton(index int) *FormScrollable
RemoveButton removes the button at the specified position, starting with 0 for the button that was added first.
func (*FormScrollable) RemoveFormItem ¶
func (f *FormScrollable) RemoveFormItem(index int) *FormScrollable
RemoveFormItem removes the form element at the given position, starting with index 0. Elements are referenced in the order they were added. Buttons are not included.
func (*FormScrollable) SetButtonActivatedStyle ¶
func (f *FormScrollable) SetButtonActivatedStyle(style tcell.Style) *FormScrollable
SetButtonActivatedStyle sets the style of the buttons when they are focused.
func (*FormScrollable) SetButtonBackgroundColor ¶
func (f *FormScrollable) SetButtonBackgroundColor(color tcell.Color) *FormScrollable
SetButtonBackgroundColor sets the background color of the buttons. This is also the text color of the buttons when they are focused.
func (*FormScrollable) SetButtonDisabledStyle ¶
func (f *FormScrollable) SetButtonDisabledStyle(style tcell.Style) *FormScrollable
SetButtonDisabledStyle sets the style of the buttons when they are disabled.
func (*FormScrollable) SetButtonStyle ¶
func (f *FormScrollable) SetButtonStyle(style tcell.Style) *FormScrollable
SetButtonStyle sets the style of the buttons when they are not focused.
func (*FormScrollable) SetButtonTextColor ¶
func (f *FormScrollable) SetButtonTextColor(color tcell.Color) *FormScrollable
SetButtonTextColor sets the color of the button texts. This is also the background of the buttons when they are focused.
func (*FormScrollable) SetButtonsAlign ¶
func (f *FormScrollable) SetButtonsAlign(align int) *FormScrollable
SetButtonsAlign sets how the buttons align horizontally, one of AlignLeft (the default), AlignCenter, and AlignRight. This is only
func (*FormScrollable) SetCancelFunc ¶
func (f *FormScrollable) SetCancelFunc(callback func()) *FormScrollable
SetCancelFunc sets a handler which is called when the user hits the Escape key.
func (*FormScrollable) SetFieldBackgroundColor ¶
func (f *FormScrollable) SetFieldBackgroundColor(color tcell.Color) *FormScrollable
SetFieldBackgroundColor sets the background color of the input areas.
func (*FormScrollable) SetFieldTextColor ¶
func (f *FormScrollable) SetFieldTextColor(color tcell.Color) *FormScrollable
SetFieldTextColor sets the text color of the input areas.
func (*FormScrollable) SetFocus ¶
func (f *FormScrollable) SetFocus(index int) *FormScrollable
SetFocus shifts the focus to the form element with the given index, counting non-button items first and buttons last. Note that this index is only used when the form itself receives focus.
func (*FormScrollable) SetHorizontal ¶
func (f *FormScrollable) SetHorizontal(horizontal bool) *FormScrollable
SetHorizontal sets the direction the form elements are laid out. If set to true, instead of positioning them from top to bottom (the default), they are positioned from left to right, moving into the next row if there is not enough space.
func (*FormScrollable) SetItemPadding ¶
func (f *FormScrollable) SetItemPadding(padding int) *FormScrollable
SetItemPadding sets the number of empty rows between form items for vertical layouts and the number of empty cells between form items for horizontal layouts.
func (*FormScrollable) SetLabelColor ¶
func (f *FormScrollable) SetLabelColor(color tcell.Color) *FormScrollable
SetLabelColor sets the color of the labels.
type NoneFocusableButton ¶
NoneFocusableButton delegate focus to another element when button was clicked
func NewNoneFocusableButton ¶
func NewNoneFocusableButton(l string) *NoneFocusableButton
NewNoneFocusableButton returns a NoneFocusableButton without a border.
func (*NoneFocusableButton) Blur ¶
func (b *NoneFocusableButton) Blur()
Blur is called when this primitive loses focus.
func (*NoneFocusableButton) Focus ¶
func (b *NoneFocusableButton) Focus(delegate func(p tview.Primitive))
Focus is called when this primitive receives focus.
func (*NoneFocusableButton) HasFocus ¶
func (b *NoneFocusableButton) HasFocus() bool
HasFocus returns whether or not this primitive has focus.
func (*NoneFocusableButton) InputHandler ¶
func (b *NoneFocusableButton) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))
InputHandler returns nil. NoneFocusableButton has no default input handling.
func (*NoneFocusableButton) MouseHandler ¶
func (b *NoneFocusableButton) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)
MouseHandler returns nil. NoneFocusableButton has no default mouse handling.
func (*NoneFocusableButton) PasteHandler ¶
func (b *NoneFocusableButton) PasteHandler() func(pastedText string, setFocus func(p tview.Primitive))
PasteHandler returns nil. NoneFocusableButton has no default paste handling.
func (*NoneFocusableButton) SetClick ¶
func (b *NoneFocusableButton) SetClick(c func()) *NoneFocusableButton
Draw draws this primitive onto the screen.
func (*NoneFocusableButton) SetFocusable ¶
func (b *NoneFocusableButton) SetFocusable(f tview.Primitive) *NoneFocusableButton
Draw draws this primitive onto the screen.
Directories ¶
Path | Synopsis |
---|---|
demos
|
|
formscrollable
Demo code for the Form primitive.
|
Demo code for the Form primitive. |