repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
sequence
docstring
stringlengths
6
2.61k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
rivo/tview
box.go
SetBorderColor
func (b *Box) SetBorderColor(color tcell.Color) *Box { b.borderColor = color return b }
go
func (b *Box) SetBorderColor(color tcell.Color) *Box { b.borderColor = color return b }
[ "func", "(", "b", "*", "Box", ")", "SetBorderColor", "(", "color", "tcell", ".", "Color", ")", "*", "Box", "{", "b", ".", "borderColor", "=", "color", "\n", "return", "b", "\n", "}" ]
// SetBorderColor sets the box's border color.
[ "SetBorderColor", "sets", "the", "box", "s", "border", "color", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/box.go#L201-L204
train
rivo/tview
box.go
SetTitle
func (b *Box) SetTitle(title string) *Box { b.title = title return b }
go
func (b *Box) SetTitle(title string) *Box { b.title = title return b }
[ "func", "(", "b", "*", "Box", ")", "SetTitle", "(", "title", "string", ")", "*", "Box", "{", "b", ".", "title", "=", "title", "\n", "return", "b", "\n", "}" ]
// SetTitle sets the box's title.
[ "SetTitle", "sets", "the", "box", "s", "title", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/box.go#L216-L219
train
rivo/tview
box.go
SetTitleColor
func (b *Box) SetTitleColor(color tcell.Color) *Box { b.titleColor = color return b }
go
func (b *Box) SetTitleColor(color tcell.Color) *Box { b.titleColor = color return b }
[ "func", "(", "b", "*", "Box", ")", "SetTitleColor", "(", "color", "tcell", ".", "Color", ")", "*", "Box", "{", "b", ".", "titleColor", "=", "color", "\n", "return", "b", "\n", "}" ]
// SetTitleColor sets the box's title color.
[ "SetTitleColor", "sets", "the", "box", "s", "title", "color", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/box.go#L222-L225
train
rivo/tview
box.go
SetTitleAlign
func (b *Box) SetTitleAlign(align int) *Box { b.titleAlign = align return b }
go
func (b *Box) SetTitleAlign(align int) *Box { b.titleAlign = align return b }
[ "func", "(", "b", "*", "Box", ")", "SetTitleAlign", "(", "align", "int", ")", "*", "Box", "{", "b", ".", "titleAlign", "=", "align", "\n", "return", "b", "\n", "}" ]
// SetTitleAlign sets the alignment of the title, one of AlignLeft, AlignCenter, // or AlignRight.
[ "SetTitleAlign", "sets", "the", "alignment", "of", "the", "title", "one", "of", "AlignLeft", "AlignCenter", "or", "AlignRight", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/box.go#L229-L232
train
rivo/tview
treeview.go
NewTreeNode
func NewTreeNode(text string) *TreeNode { return &TreeNode{ text: text, color: Styles.PrimaryTextColor, indent: 2, expanded: true, selectable: true, } }
go
func NewTreeNode(text string) *TreeNode { return &TreeNode{ text: text, color: Styles.PrimaryTextColor, indent: 2, expanded: true, selectable: true, } }
[ "func", "NewTreeNode", "(", "text", "string", ")", "*", "TreeNode", "{", "return", "&", "TreeNode", "{", "text", ":", "text", ",", "color", ":", "Styles", ".", "PrimaryTextColor", ",", "indent", ":", "2", ",", "expanded", ":", "true", ",", "selectable", ":", "true", ",", "}", "\n", "}" ]
// NewTreeNode returns a new tree node.
[ "NewTreeNode", "returns", "a", "new", "tree", "node", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L52-L60
train
rivo/tview
treeview.go
SetChildren
func (n *TreeNode) SetChildren(childNodes []*TreeNode) *TreeNode { n.children = childNodes return n }
go
func (n *TreeNode) SetChildren(childNodes []*TreeNode) *TreeNode { n.children = childNodes return n }
[ "func", "(", "n", "*", "TreeNode", ")", "SetChildren", "(", "childNodes", "[", "]", "*", "TreeNode", ")", "*", "TreeNode", "{", "n", ".", "children", "=", "childNodes", "\n", "return", "n", "\n", "}" ]
// SetChildren sets this node's child nodes.
[ "SetChildren", "sets", "this", "node", "s", "child", "nodes", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L103-L106
train
rivo/tview
treeview.go
AddChild
func (n *TreeNode) AddChild(node *TreeNode) *TreeNode { n.children = append(n.children, node) return n }
go
func (n *TreeNode) AddChild(node *TreeNode) *TreeNode { n.children = append(n.children, node) return n }
[ "func", "(", "n", "*", "TreeNode", ")", "AddChild", "(", "node", "*", "TreeNode", ")", "*", "TreeNode", "{", "n", ".", "children", "=", "append", "(", "n", ".", "children", ",", "node", ")", "\n", "return", "n", "\n", "}" ]
// AddChild adds a new child node to this node.
[ "AddChild", "adds", "a", "new", "child", "node", "to", "this", "node", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L125-L128
train
rivo/tview
treeview.go
SetSelectable
func (n *TreeNode) SetSelectable(selectable bool) *TreeNode { n.selectable = selectable return n }
go
func (n *TreeNode) SetSelectable(selectable bool) *TreeNode { n.selectable = selectable return n }
[ "func", "(", "n", "*", "TreeNode", ")", "SetSelectable", "(", "selectable", "bool", ")", "*", "TreeNode", "{", "n", ".", "selectable", "=", "selectable", "\n", "return", "n", "\n", "}" ]
// SetSelectable sets a flag indicating whether this node can be selected by // the user.
[ "SetSelectable", "sets", "a", "flag", "indicating", "whether", "this", "node", "can", "be", "selected", "by", "the", "user", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L132-L135
train
rivo/tview
treeview.go
SetExpanded
func (n *TreeNode) SetExpanded(expanded bool) *TreeNode { n.expanded = expanded return n }
go
func (n *TreeNode) SetExpanded(expanded bool) *TreeNode { n.expanded = expanded return n }
[ "func", "(", "n", "*", "TreeNode", ")", "SetExpanded", "(", "expanded", "bool", ")", "*", "TreeNode", "{", "n", ".", "expanded", "=", "expanded", "\n", "return", "n", "\n", "}" ]
// SetExpanded sets whether or not this node's child nodes should be displayed.
[ "SetExpanded", "sets", "whether", "or", "not", "this", "node", "s", "child", "nodes", "should", "be", "displayed", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L145-L148
train
rivo/tview
treeview.go
ExpandAll
func (n *TreeNode) ExpandAll() *TreeNode { n.Walk(func(node, parent *TreeNode) bool { node.expanded = true return true }) return n }
go
func (n *TreeNode) ExpandAll() *TreeNode { n.Walk(func(node, parent *TreeNode) bool { node.expanded = true return true }) return n }
[ "func", "(", "n", "*", "TreeNode", ")", "ExpandAll", "(", ")", "*", "TreeNode", "{", "n", ".", "Walk", "(", "func", "(", "node", ",", "parent", "*", "TreeNode", ")", "bool", "{", "node", ".", "expanded", "=", "true", "\n", "return", "true", "\n", "}", ")", "\n", "return", "n", "\n", "}" ]
// ExpandAll expands this node and all descendent nodes.
[ "ExpandAll", "expands", "this", "node", "and", "all", "descendent", "nodes", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L163-L169
train
rivo/tview
treeview.go
CollapseAll
func (n *TreeNode) CollapseAll() *TreeNode { n.Walk(func(node, parent *TreeNode) bool { n.expanded = false return true }) return n }
go
func (n *TreeNode) CollapseAll() *TreeNode { n.Walk(func(node, parent *TreeNode) bool { n.expanded = false return true }) return n }
[ "func", "(", "n", "*", "TreeNode", ")", "CollapseAll", "(", ")", "*", "TreeNode", "{", "n", ".", "Walk", "(", "func", "(", "node", ",", "parent", "*", "TreeNode", ")", "bool", "{", "n", ".", "expanded", "=", "false", "\n", "return", "true", "\n", "}", ")", "\n", "return", "n", "\n", "}" ]
// CollapseAll collapses this node and all descendent nodes.
[ "CollapseAll", "collapses", "this", "node", "and", "all", "descendent", "nodes", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L172-L178
train
rivo/tview
treeview.go
SetText
func (n *TreeNode) SetText(text string) *TreeNode { n.text = text return n }
go
func (n *TreeNode) SetText(text string) *TreeNode { n.text = text return n }
[ "func", "(", "n", "*", "TreeNode", ")", "SetText", "(", "text", "string", ")", "*", "TreeNode", "{", "n", ".", "text", "=", "text", "\n", "return", "n", "\n", "}" ]
// SetText sets the node's text which is displayed.
[ "SetText", "sets", "the", "node", "s", "text", "which", "is", "displayed", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L186-L189
train
rivo/tview
treeview.go
SetColor
func (n *TreeNode) SetColor(color tcell.Color) *TreeNode { n.color = color return n }
go
func (n *TreeNode) SetColor(color tcell.Color) *TreeNode { n.color = color return n }
[ "func", "(", "n", "*", "TreeNode", ")", "SetColor", "(", "color", "tcell", ".", "Color", ")", "*", "TreeNode", "{", "n", ".", "color", "=", "color", "\n", "return", "n", "\n", "}" ]
// SetColor sets the node's text color.
[ "SetColor", "sets", "the", "node", "s", "text", "color", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L197-L200
train
rivo/tview
treeview.go
SetIndent
func (n *TreeNode) SetIndent(indent int) *TreeNode { n.indent = indent return n }
go
func (n *TreeNode) SetIndent(indent int) *TreeNode { n.indent = indent return n }
[ "func", "(", "n", "*", "TreeNode", ")", "SetIndent", "(", "indent", "int", ")", "*", "TreeNode", "{", "n", ".", "indent", "=", "indent", "\n", "return", "n", "\n", "}" ]
// SetIndent sets an additional indentation for this node's text. A value of 0 // keeps the text as far left as possible with a minimum of line graphics. Any // value greater than that moves the text to the right.
[ "SetIndent", "sets", "an", "additional", "indentation", "for", "this", "node", "s", "text", ".", "A", "value", "of", "0", "keeps", "the", "text", "as", "far", "left", "as", "possible", "with", "a", "minimum", "of", "line", "graphics", ".", "Any", "value", "greater", "than", "that", "moves", "the", "text", "to", "the", "right", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L205-L208
train
rivo/tview
treeview.go
NewTreeView
func NewTreeView() *TreeView { return &TreeView{ Box: NewBox(), graphics: true, graphicsColor: Styles.GraphicsColor, } }
go
func NewTreeView() *TreeView { return &TreeView{ Box: NewBox(), graphics: true, graphicsColor: Styles.GraphicsColor, } }
[ "func", "NewTreeView", "(", ")", "*", "TreeView", "{", "return", "&", "TreeView", "{", "Box", ":", "NewBox", "(", ")", ",", "graphics", ":", "true", ",", "graphicsColor", ":", "Styles", ".", "GraphicsColor", ",", "}", "\n", "}" ]
// NewTreeView returns a new tree view.
[ "NewTreeView", "returns", "a", "new", "tree", "view", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L285-L291
train
rivo/tview
treeview.go
SetRoot
func (t *TreeView) SetRoot(root *TreeNode) *TreeView { t.root = root return t }
go
func (t *TreeView) SetRoot(root *TreeNode) *TreeView { t.root = root return t }
[ "func", "(", "t", "*", "TreeView", ")", "SetRoot", "(", "root", "*", "TreeNode", ")", "*", "TreeView", "{", "t", ".", "root", "=", "root", "\n", "return", "t", "\n", "}" ]
// SetRoot sets the root node of the tree.
[ "SetRoot", "sets", "the", "root", "node", "of", "the", "tree", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L294-L297
train
rivo/tview
treeview.go
SetCurrentNode
func (t *TreeView) SetCurrentNode(node *TreeNode) *TreeView { t.currentNode = node return t }
go
func (t *TreeView) SetCurrentNode(node *TreeNode) *TreeView { t.currentNode = node return t }
[ "func", "(", "t", "*", "TreeView", ")", "SetCurrentNode", "(", "node", "*", "TreeNode", ")", "*", "TreeView", "{", "t", ".", "currentNode", "=", "node", "\n", "return", "t", "\n", "}" ]
// SetCurrentNode sets the currently selected node. Provide nil to clear all // selections. Selected nodes must be visible and selectable, or else the // selection will be changed to the top-most selectable and visible node. // // This function does NOT trigger the "changed" callback.
[ "SetCurrentNode", "sets", "the", "currently", "selected", "node", ".", "Provide", "nil", "to", "clear", "all", "selections", ".", "Selected", "nodes", "must", "be", "visible", "and", "selectable", "or", "else", "the", "selection", "will", "be", "changed", "to", "the", "top", "-", "most", "selectable", "and", "visible", "node", ".", "This", "function", "does", "NOT", "trigger", "the", "changed", "callback", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L310-L313
train
rivo/tview
treeview.go
SetTopLevel
func (t *TreeView) SetTopLevel(topLevel int) *TreeView { t.topLevel = topLevel return t }
go
func (t *TreeView) SetTopLevel(topLevel int) *TreeView { t.topLevel = topLevel return t }
[ "func", "(", "t", "*", "TreeView", ")", "SetTopLevel", "(", "topLevel", "int", ")", "*", "TreeView", "{", "t", ".", "topLevel", "=", "topLevel", "\n", "return", "t", "\n", "}" ]
// SetTopLevel sets the first tree level that is visible with 0 referring to the // root, 1 to the root's child nodes, and so on. Nodes above the top level are // not displayed.
[ "SetTopLevel", "sets", "the", "first", "tree", "level", "that", "is", "visible", "with", "0", "referring", "to", "the", "root", "1", "to", "the", "root", "s", "child", "nodes", "and", "so", "on", ".", "Nodes", "above", "the", "top", "level", "are", "not", "displayed", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L324-L327
train
rivo/tview
treeview.go
SetAlign
func (t *TreeView) SetAlign(align bool) *TreeView { t.align = align return t }
go
func (t *TreeView) SetAlign(align bool) *TreeView { t.align = align return t }
[ "func", "(", "t", "*", "TreeView", ")", "SetAlign", "(", "align", "bool", ")", "*", "TreeView", "{", "t", ".", "align", "=", "align", "\n", "return", "t", "\n", "}" ]
// SetAlign controls the horizontal alignment of the node texts. If set to true, // all texts except that of top-level nodes will be placed in the same column. // If set to false, they will indent with the hierarchy.
[ "SetAlign", "controls", "the", "horizontal", "alignment", "of", "the", "node", "texts", ".", "If", "set", "to", "true", "all", "texts", "except", "that", "of", "top", "-", "level", "nodes", "will", "be", "placed", "in", "the", "same", "column", ".", "If", "set", "to", "false", "they", "will", "indent", "with", "the", "hierarchy", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L346-L349
train
rivo/tview
treeview.go
SetGraphics
func (t *TreeView) SetGraphics(showGraphics bool) *TreeView { t.graphics = showGraphics return t }
go
func (t *TreeView) SetGraphics(showGraphics bool) *TreeView { t.graphics = showGraphics return t }
[ "func", "(", "t", "*", "TreeView", ")", "SetGraphics", "(", "showGraphics", "bool", ")", "*", "TreeView", "{", "t", ".", "graphics", "=", "showGraphics", "\n", "return", "t", "\n", "}" ]
// SetGraphics sets a flag which determines whether or not line graphics are // drawn to illustrate the tree's hierarchy.
[ "SetGraphics", "sets", "a", "flag", "which", "determines", "whether", "or", "not", "line", "graphics", "are", "drawn", "to", "illustrate", "the", "tree", "s", "hierarchy", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L353-L356
train
rivo/tview
treeview.go
SetGraphicsColor
func (t *TreeView) SetGraphicsColor(color tcell.Color) *TreeView { t.graphicsColor = color return t }
go
func (t *TreeView) SetGraphicsColor(color tcell.Color) *TreeView { t.graphicsColor = color return t }
[ "func", "(", "t", "*", "TreeView", ")", "SetGraphicsColor", "(", "color", "tcell", ".", "Color", ")", "*", "TreeView", "{", "t", ".", "graphicsColor", "=", "color", "\n", "return", "t", "\n", "}" ]
// SetGraphicsColor sets the colors of the lines used to draw the tree structure.
[ "SetGraphicsColor", "sets", "the", "colors", "of", "the", "lines", "used", "to", "draw", "the", "tree", "structure", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L359-L362
train
rivo/tview
treeview.go
SetChangedFunc
func (t *TreeView) SetChangedFunc(handler func(node *TreeNode)) *TreeView { t.changed = handler return t }
go
func (t *TreeView) SetChangedFunc(handler func(node *TreeNode)) *TreeView { t.changed = handler return t }
[ "func", "(", "t", "*", "TreeView", ")", "SetChangedFunc", "(", "handler", "func", "(", "node", "*", "TreeNode", ")", ")", "*", "TreeView", "{", "t", ".", "changed", "=", "handler", "\n", "return", "t", "\n", "}" ]
// SetChangedFunc sets the function which is called when the user navigates to // a new tree node.
[ "SetChangedFunc", "sets", "the", "function", "which", "is", "called", "when", "the", "user", "navigates", "to", "a", "new", "tree", "node", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L366-L369
train
rivo/tview
treeview.go
SetSelectedFunc
func (t *TreeView) SetSelectedFunc(handler func(node *TreeNode)) *TreeView { t.selected = handler return t }
go
func (t *TreeView) SetSelectedFunc(handler func(node *TreeNode)) *TreeView { t.selected = handler return t }
[ "func", "(", "t", "*", "TreeView", ")", "SetSelectedFunc", "(", "handler", "func", "(", "node", "*", "TreeNode", ")", ")", "*", "TreeView", "{", "t", ".", "selected", "=", "handler", "\n", "return", "t", "\n", "}" ]
// SetSelectedFunc sets the function which is called when the user selects a // node by pressing Enter on the current selection.
[ "SetSelectedFunc", "sets", "the", "function", "which", "is", "called", "when", "the", "user", "selects", "a", "node", "by", "pressing", "Enter", "on", "the", "current", "selection", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/treeview.go#L373-L376
train
rivo/tview
ansi.go
ANSIWriter
func ANSIWriter(writer io.Writer) io.Writer { return &ansi{ Writer: writer, buffer: new(bytes.Buffer), csiParameter: new(bytes.Buffer), csiIntermediate: new(bytes.Buffer), state: ansiText, } }
go
func ANSIWriter(writer io.Writer) io.Writer { return &ansi{ Writer: writer, buffer: new(bytes.Buffer), csiParameter: new(bytes.Buffer), csiIntermediate: new(bytes.Buffer), state: ansiText, } }
[ "func", "ANSIWriter", "(", "writer", "io", ".", "Writer", ")", "io", ".", "Writer", "{", "return", "&", "ansi", "{", "Writer", ":", "writer", ",", "buffer", ":", "new", "(", "bytes", ".", "Buffer", ")", ",", "csiParameter", ":", "new", "(", "bytes", ".", "Buffer", ")", ",", "csiIntermediate", ":", "new", "(", "bytes", ".", "Buffer", ")", ",", "state", ":", "ansiText", ",", "}", "\n", "}" ]
// ANSIWriter returns an io.Writer which translates any ANSI escape codes // written to it into tview color tags. Other escape codes don't have an effect // and are simply removed. The translated text is written to the provided // writer.
[ "ANSIWriter", "returns", "an", "io", ".", "Writer", "which", "translates", "any", "ANSI", "escape", "codes", "written", "to", "it", "into", "tview", "color", "tags", ".", "Other", "escape", "codes", "don", "t", "have", "an", "effect", "and", "are", "simply", "removed", ".", "The", "translated", "text", "is", "written", "to", "the", "provided", "writer", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/ansi.go#L36-L44
train
rivo/tview
ansi.go
TranslateANSI
func TranslateANSI(text string) string { var buffer bytes.Buffer writer := ANSIWriter(&buffer) writer.Write([]byte(text)) return buffer.String() }
go
func TranslateANSI(text string) string { var buffer bytes.Buffer writer := ANSIWriter(&buffer) writer.Write([]byte(text)) return buffer.String() }
[ "func", "TranslateANSI", "(", "text", "string", ")", "string", "{", "var", "buffer", "bytes", ".", "Buffer", "\n", "writer", ":=", "ANSIWriter", "(", "&", "buffer", ")", "\n", "writer", ".", "Write", "(", "[", "]", "byte", "(", "text", ")", ")", "\n", "return", "buffer", ".", "String", "(", ")", "\n", "}" ]
// TranslateANSI replaces ANSI escape sequences found in the provided string // with tview's color tags and returns the resulting string.
[ "TranslateANSI", "replaces", "ANSI", "escape", "sequences", "found", "in", "the", "provided", "string", "with", "tview", "s", "color", "tags", "and", "returns", "the", "resulting", "string", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/ansi.go#L232-L237
train
rivo/tview
dropdown.go
NewDropDown
func NewDropDown() *DropDown { list := NewList().ShowSecondaryText(false) list.SetMainTextColor(Styles.PrimitiveBackgroundColor). SetSelectedTextColor(Styles.PrimitiveBackgroundColor). SetSelectedBackgroundColor(Styles.PrimaryTextColor). SetBackgroundColor(Styles.MoreContrastBackgroundColor) d := &DropDown{ Box: NewBox(), currentOption: -1, list: list, labelColor: Styles.SecondaryTextColor, fieldBackgroundColor: Styles.ContrastBackgroundColor, fieldTextColor: Styles.PrimaryTextColor, prefixTextColor: Styles.ContrastSecondaryTextColor, } d.focus = d return d }
go
func NewDropDown() *DropDown { list := NewList().ShowSecondaryText(false) list.SetMainTextColor(Styles.PrimitiveBackgroundColor). SetSelectedTextColor(Styles.PrimitiveBackgroundColor). SetSelectedBackgroundColor(Styles.PrimaryTextColor). SetBackgroundColor(Styles.MoreContrastBackgroundColor) d := &DropDown{ Box: NewBox(), currentOption: -1, list: list, labelColor: Styles.SecondaryTextColor, fieldBackgroundColor: Styles.ContrastBackgroundColor, fieldTextColor: Styles.PrimaryTextColor, prefixTextColor: Styles.ContrastSecondaryTextColor, } d.focus = d return d }
[ "func", "NewDropDown", "(", ")", "*", "DropDown", "{", "list", ":=", "NewList", "(", ")", ".", "ShowSecondaryText", "(", "false", ")", "\n", "list", ".", "SetMainTextColor", "(", "Styles", ".", "PrimitiveBackgroundColor", ")", ".", "SetSelectedTextColor", "(", "Styles", ".", "PrimitiveBackgroundColor", ")", ".", "SetSelectedBackgroundColor", "(", "Styles", ".", "PrimaryTextColor", ")", ".", "SetBackgroundColor", "(", "Styles", ".", "MoreContrastBackgroundColor", ")", "\n\n", "d", ":=", "&", "DropDown", "{", "Box", ":", "NewBox", "(", ")", ",", "currentOption", ":", "-", "1", ",", "list", ":", "list", ",", "labelColor", ":", "Styles", ".", "SecondaryTextColor", ",", "fieldBackgroundColor", ":", "Styles", ".", "ContrastBackgroundColor", ",", "fieldTextColor", ":", "Styles", ".", "PrimaryTextColor", ",", "prefixTextColor", ":", "Styles", ".", "ContrastSecondaryTextColor", ",", "}", "\n\n", "d", ".", "focus", "=", "d", "\n\n", "return", "d", "\n", "}" ]
// NewDropDown returns a new drop-down.
[ "NewDropDown", "returns", "a", "new", "drop", "-", "down", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/dropdown.go#L76-L96
train
rivo/tview
dropdown.go
GetCurrentOption
func (d *DropDown) GetCurrentOption() (int, string) { var text string if d.currentOption >= 0 && d.currentOption < len(d.options) { text = d.options[d.currentOption].Text } return d.currentOption, text }
go
func (d *DropDown) GetCurrentOption() (int, string) { var text string if d.currentOption >= 0 && d.currentOption < len(d.options) { text = d.options[d.currentOption].Text } return d.currentOption, text }
[ "func", "(", "d", "*", "DropDown", ")", "GetCurrentOption", "(", ")", "(", "int", ",", "string", ")", "{", "var", "text", "string", "\n", "if", "d", ".", "currentOption", ">=", "0", "&&", "d", ".", "currentOption", "<", "len", "(", "d", ".", "options", ")", "{", "text", "=", "d", ".", "options", "[", "d", ".", "currentOption", "]", ".", "Text", "\n", "}", "\n", "return", "d", ".", "currentOption", ",", "text", "\n", "}" ]
// GetCurrentOption returns the index of the currently selected option as well // as its text. If no option was selected, -1 and an empty string is returned.
[ "GetCurrentOption", "returns", "the", "index", "of", "the", "currently", "selected", "option", "as", "well", "as", "its", "text", ".", "If", "no", "option", "was", "selected", "-", "1", "and", "an", "empty", "string", "is", "returned", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/dropdown.go#L123-L129
train
rivo/tview
dropdown.go
SetFieldBackgroundColor
func (d *DropDown) SetFieldBackgroundColor(color tcell.Color) *DropDown { d.fieldBackgroundColor = color return d }
go
func (d *DropDown) SetFieldBackgroundColor(color tcell.Color) *DropDown { d.fieldBackgroundColor = color return d }
[ "func", "(", "d", "*", "DropDown", ")", "SetFieldBackgroundColor", "(", "color", "tcell", ".", "Color", ")", "*", "DropDown", "{", "d", ".", "fieldBackgroundColor", "=", "color", "\n", "return", "d", "\n", "}" ]
// SetFieldBackgroundColor sets the background color of the options area.
[ "SetFieldBackgroundColor", "sets", "the", "background", "color", "of", "the", "options", "area", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/dropdown.go#L156-L159
train
rivo/tview
dropdown.go
SetFieldTextColor
func (d *DropDown) SetFieldTextColor(color tcell.Color) *DropDown { d.fieldTextColor = color return d }
go
func (d *DropDown) SetFieldTextColor(color tcell.Color) *DropDown { d.fieldTextColor = color return d }
[ "func", "(", "d", "*", "DropDown", ")", "SetFieldTextColor", "(", "color", "tcell", ".", "Color", ")", "*", "DropDown", "{", "d", ".", "fieldTextColor", "=", "color", "\n", "return", "d", "\n", "}" ]
// SetFieldTextColor sets the text color of the options area.
[ "SetFieldTextColor", "sets", "the", "text", "color", "of", "the", "options", "area", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/dropdown.go#L162-L165
train
rivo/tview
dropdown.go
SetPrefixTextColor
func (d *DropDown) SetPrefixTextColor(color tcell.Color) *DropDown { d.prefixTextColor = color return d }
go
func (d *DropDown) SetPrefixTextColor(color tcell.Color) *DropDown { d.prefixTextColor = color return d }
[ "func", "(", "d", "*", "DropDown", ")", "SetPrefixTextColor", "(", "color", "tcell", ".", "Color", ")", "*", "DropDown", "{", "d", ".", "prefixTextColor", "=", "color", "\n", "return", "d", "\n", "}" ]
// SetPrefixTextColor sets the color of the prefix string. The prefix string is // shown when the user starts typing text, which directly selects the first // option that starts with the typed string.
[ "SetPrefixTextColor", "sets", "the", "color", "of", "the", "prefix", "string", ".", "The", "prefix", "string", "is", "shown", "when", "the", "user", "starts", "typing", "text", "which", "directly", "selects", "the", "first", "option", "that", "starts", "with", "the", "typed", "string", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/dropdown.go#L170-L173
train
rivo/tview
dropdown.go
SetFieldWidth
func (d *DropDown) SetFieldWidth(width int) *DropDown { d.fieldWidth = width return d }
go
func (d *DropDown) SetFieldWidth(width int) *DropDown { d.fieldWidth = width return d }
[ "func", "(", "d", "*", "DropDown", ")", "SetFieldWidth", "(", "width", "int", ")", "*", "DropDown", "{", "d", ".", "fieldWidth", "=", "width", "\n", "return", "d", "\n", "}" ]
// SetFieldWidth sets the screen width of the options area. A value of 0 means // extend to as long as the longest option text.
[ "SetFieldWidth", "sets", "the", "screen", "width", "of", "the", "options", "area", ".", "A", "value", "of", "0", "means", "extend", "to", "as", "long", "as", "the", "longest", "option", "text", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/dropdown.go#L187-L190
train
rivo/tview
dropdown.go
GetFieldWidth
func (d *DropDown) GetFieldWidth() int { if d.fieldWidth > 0 { return d.fieldWidth } fieldWidth := 0 for _, option := range d.options { width := TaggedStringWidth(option.Text) if width > fieldWidth { fieldWidth = width } } return fieldWidth }
go
func (d *DropDown) GetFieldWidth() int { if d.fieldWidth > 0 { return d.fieldWidth } fieldWidth := 0 for _, option := range d.options { width := TaggedStringWidth(option.Text) if width > fieldWidth { fieldWidth = width } } return fieldWidth }
[ "func", "(", "d", "*", "DropDown", ")", "GetFieldWidth", "(", ")", "int", "{", "if", "d", ".", "fieldWidth", ">", "0", "{", "return", "d", ".", "fieldWidth", "\n", "}", "\n", "fieldWidth", ":=", "0", "\n", "for", "_", ",", "option", ":=", "range", "d", ".", "options", "{", "width", ":=", "TaggedStringWidth", "(", "option", ".", "Text", ")", "\n", "if", "width", ">", "fieldWidth", "{", "fieldWidth", "=", "width", "\n", "}", "\n", "}", "\n", "return", "fieldWidth", "\n", "}" ]
// GetFieldWidth returns this primitive's field screen width.
[ "GetFieldWidth", "returns", "this", "primitive", "s", "field", "screen", "width", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/dropdown.go#L193-L205
train
rivo/tview
dropdown.go
AddOption
func (d *DropDown) AddOption(text string, selected func()) *DropDown { d.options = append(d.options, &dropDownOption{Text: text, Selected: selected}) d.list.AddItem(text, "", 0, nil) return d }
go
func (d *DropDown) AddOption(text string, selected func()) *DropDown { d.options = append(d.options, &dropDownOption{Text: text, Selected: selected}) d.list.AddItem(text, "", 0, nil) return d }
[ "func", "(", "d", "*", "DropDown", ")", "AddOption", "(", "text", "string", ",", "selected", "func", "(", ")", ")", "*", "DropDown", "{", "d", ".", "options", "=", "append", "(", "d", ".", "options", ",", "&", "dropDownOption", "{", "Text", ":", "text", ",", "Selected", ":", "selected", "}", ")", "\n", "d", ".", "list", ".", "AddItem", "(", "text", ",", "\"", "\"", ",", "0", ",", "nil", ")", "\n", "return", "d", "\n", "}" ]
// AddOption adds a new selectable option to this drop-down. The "selected" // callback is called when this option was selected. It may be nil.
[ "AddOption", "adds", "a", "new", "selectable", "option", "to", "this", "drop", "-", "down", ".", "The", "selected", "callback", "is", "called", "when", "this", "option", "was", "selected", ".", "It", "may", "be", "nil", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/dropdown.go#L209-L213
train
rivo/tview
dropdown.go
SetOptions
func (d *DropDown) SetOptions(texts []string, selected func(text string, index int)) *DropDown { d.list.Clear() d.options = nil for index, text := range texts { func(t string, i int) { d.AddOption(text, nil) }(text, index) } d.selected = selected return d }
go
func (d *DropDown) SetOptions(texts []string, selected func(text string, index int)) *DropDown { d.list.Clear() d.options = nil for index, text := range texts { func(t string, i int) { d.AddOption(text, nil) }(text, index) } d.selected = selected return d }
[ "func", "(", "d", "*", "DropDown", ")", "SetOptions", "(", "texts", "[", "]", "string", ",", "selected", "func", "(", "text", "string", ",", "index", "int", ")", ")", "*", "DropDown", "{", "d", ".", "list", ".", "Clear", "(", ")", "\n", "d", ".", "options", "=", "nil", "\n", "for", "index", ",", "text", ":=", "range", "texts", "{", "func", "(", "t", "string", ",", "i", "int", ")", "{", "d", ".", "AddOption", "(", "text", ",", "nil", ")", "\n", "}", "(", "text", ",", "index", ")", "\n", "}", "\n", "d", ".", "selected", "=", "selected", "\n", "return", "d", "\n", "}" ]
// SetOptions replaces all current options with the ones provided and installs // one callback function which is called when one of the options is selected. // It will be called with the option's text and its index into the options // slice. The "selected" parameter may be nil.
[ "SetOptions", "replaces", "all", "current", "options", "with", "the", "ones", "provided", "and", "installs", "one", "callback", "function", "which", "is", "called", "when", "one", "of", "the", "options", "is", "selected", ".", "It", "will", "be", "called", "with", "the", "option", "s", "text", "and", "its", "index", "into", "the", "options", "slice", ".", "The", "selected", "parameter", "may", "be", "nil", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/dropdown.go#L219-L229
train
rivo/tview
dropdown.go
SetSelectedFunc
func (d *DropDown) SetSelectedFunc(handler func(text string, index int)) *DropDown { d.selected = handler return d }
go
func (d *DropDown) SetSelectedFunc(handler func(text string, index int)) *DropDown { d.selected = handler return d }
[ "func", "(", "d", "*", "DropDown", ")", "SetSelectedFunc", "(", "handler", "func", "(", "text", "string", ",", "index", "int", ")", ")", "*", "DropDown", "{", "d", ".", "selected", "=", "handler", "\n", "return", "d", "\n", "}" ]
// SetSelectedFunc sets a handler which is called when the user changes the // drop-down's option. This handler will be called in addition and prior to // an option's optional individual handler. The handler is provided with the // selected option's text and index. If "no option" was selected, these values // are an empty string and -1.
[ "SetSelectedFunc", "sets", "a", "handler", "which", "is", "called", "when", "the", "user", "changes", "the", "drop", "-", "down", "s", "option", ".", "This", "handler", "will", "be", "called", "in", "addition", "and", "prior", "to", "an", "option", "s", "optional", "individual", "handler", ".", "The", "handler", "is", "provided", "with", "the", "selected", "option", "s", "text", "and", "index", ".", "If", "no", "option", "was", "selected", "these", "values", "are", "an", "empty", "string", "and", "-", "1", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/dropdown.go#L236-L239
train
rivo/tview
util.go
init
func init() { // We'll use zero width joiners. runewidth.ZeroWidthJoiner = true // Initialize the predefined input field handlers. InputFieldInteger = func(text string, ch rune) bool { if text == "-" { return true } _, err := strconv.Atoi(text) return err == nil } InputFieldFloat = func(text string, ch rune) bool { if text == "-" || text == "." || text == "-." { return true } _, err := strconv.ParseFloat(text, 64) return err == nil } InputFieldMaxLength = func(maxLength int) func(text string, ch rune) bool { return func(text string, ch rune) bool { return len([]rune(text)) <= maxLength } } }
go
func init() { // We'll use zero width joiners. runewidth.ZeroWidthJoiner = true // Initialize the predefined input field handlers. InputFieldInteger = func(text string, ch rune) bool { if text == "-" { return true } _, err := strconv.Atoi(text) return err == nil } InputFieldFloat = func(text string, ch rune) bool { if text == "-" || text == "." || text == "-." { return true } _, err := strconv.ParseFloat(text, 64) return err == nil } InputFieldMaxLength = func(maxLength int) func(text string, ch rune) bool { return func(text string, ch rune) bool { return len([]rune(text)) <= maxLength } } }
[ "func", "init", "(", ")", "{", "// We'll use zero width joiners.", "runewidth", ".", "ZeroWidthJoiner", "=", "true", "\n\n", "// Initialize the predefined input field handlers.", "InputFieldInteger", "=", "func", "(", "text", "string", ",", "ch", "rune", ")", "bool", "{", "if", "text", "==", "\"", "\"", "{", "return", "true", "\n", "}", "\n", "_", ",", "err", ":=", "strconv", ".", "Atoi", "(", "text", ")", "\n", "return", "err", "==", "nil", "\n", "}", "\n", "InputFieldFloat", "=", "func", "(", "text", "string", ",", "ch", "rune", ")", "bool", "{", "if", "text", "==", "\"", "\"", "||", "text", "==", "\"", "\"", "||", "text", "==", "\"", "\"", "{", "return", "true", "\n", "}", "\n", "_", ",", "err", ":=", "strconv", ".", "ParseFloat", "(", "text", ",", "64", ")", "\n", "return", "err", "==", "nil", "\n", "}", "\n", "InputFieldMaxLength", "=", "func", "(", "maxLength", "int", ")", "func", "(", "text", "string", ",", "ch", "rune", ")", "bool", "{", "return", "func", "(", "text", "string", ",", "ch", "rune", ")", "bool", "{", "return", "len", "(", "[", "]", "rune", "(", "text", ")", ")", "<=", "maxLength", "\n", "}", "\n", "}", "\n", "}" ]
// Package initialization.
[ "Package", "initialization", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/util.go#L54-L78
train
rivo/tview
util.go
PrintSimple
func PrintSimple(screen tcell.Screen, text string, x, y int) { Print(screen, text, x, y, math.MaxInt32, AlignLeft, Styles.PrimaryTextColor) }
go
func PrintSimple(screen tcell.Screen, text string, x, y int) { Print(screen, text, x, y, math.MaxInt32, AlignLeft, Styles.PrimaryTextColor) }
[ "func", "PrintSimple", "(", "screen", "tcell", ".", "Screen", ",", "text", "string", ",", "x", ",", "y", "int", ")", "{", "Print", "(", "screen", ",", "text", ",", "x", ",", "y", ",", "math", ".", "MaxInt32", ",", "AlignLeft", ",", "Styles", ".", "PrimaryTextColor", ")", "\n", "}" ]
// PrintSimple prints white text to the screen at the given position.
[ "PrintSimple", "prints", "white", "text", "to", "the", "screen", "at", "the", "given", "position", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/util.go#L408-L410
train
rivo/tview
util.go
TaggedStringWidth
func TaggedStringWidth(text string) int { _, _, _, _, _, _, width := decomposeString(text, true, false) return width }
go
func TaggedStringWidth(text string) int { _, _, _, _, _, _, width := decomposeString(text, true, false) return width }
[ "func", "TaggedStringWidth", "(", "text", "string", ")", "int", "{", "_", ",", "_", ",", "_", ",", "_", ",", "_", ",", "_", ",", "width", ":=", "decomposeString", "(", "text", ",", "true", ",", "false", ")", "\n", "return", "width", "\n", "}" ]
// TaggedStringWidth returns the width of the given string needed to print it on // screen. The text may contain color tags which are not counted.
[ "TaggedStringWidth", "returns", "the", "width", "of", "the", "given", "string", "needed", "to", "print", "it", "on", "screen", ".", "The", "text", "may", "contain", "color", "tags", "which", "are", "not", "counted", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/util.go#L414-L417
train
rivo/tview
util.go
stringWidth
func stringWidth(text string) (width int) { g := uniseg.NewGraphemes(text) for g.Next() { var chWidth int for _, r := range g.Runes() { chWidth = runewidth.RuneWidth(r) if chWidth > 0 { break // Our best guess at this point is to use the width of the first non-zero-width rune. } } width += chWidth } return }
go
func stringWidth(text string) (width int) { g := uniseg.NewGraphemes(text) for g.Next() { var chWidth int for _, r := range g.Runes() { chWidth = runewidth.RuneWidth(r) if chWidth > 0 { break // Our best guess at this point is to use the width of the first non-zero-width rune. } } width += chWidth } return }
[ "func", "stringWidth", "(", "text", "string", ")", "(", "width", "int", ")", "{", "g", ":=", "uniseg", ".", "NewGraphemes", "(", "text", ")", "\n", "for", "g", ".", "Next", "(", ")", "{", "var", "chWidth", "int", "\n", "for", "_", ",", "r", ":=", "range", "g", ".", "Runes", "(", ")", "{", "chWidth", "=", "runewidth", ".", "RuneWidth", "(", "r", ")", "\n", "if", "chWidth", ">", "0", "{", "break", "// Our best guess at this point is to use the width of the first non-zero-width rune.", "\n", "}", "\n", "}", "\n", "width", "+=", "chWidth", "\n", "}", "\n", "return", "\n", "}" ]
// stringWidth returns the number of horizontal cells needed to print the given // text. It splits the text into its grapheme clusters, calculates each // cluster's width, and adds them up to a total.
[ "stringWidth", "returns", "the", "number", "of", "horizontal", "cells", "needed", "to", "print", "the", "given", "text", ".", "It", "splits", "the", "text", "into", "its", "grapheme", "clusters", "calculates", "each", "cluster", "s", "width", "and", "adds", "them", "up", "to", "a", "total", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/util.go#L422-L435
train
rivo/tview
inputfield.go
NewInputField
func NewInputField() *InputField { return &InputField{ Box: NewBox(), labelColor: Styles.SecondaryTextColor, fieldBackgroundColor: Styles.ContrastBackgroundColor, fieldTextColor: Styles.PrimaryTextColor, placeholderTextColor: Styles.ContrastSecondaryTextColor, } }
go
func NewInputField() *InputField { return &InputField{ Box: NewBox(), labelColor: Styles.SecondaryTextColor, fieldBackgroundColor: Styles.ContrastBackgroundColor, fieldTextColor: Styles.PrimaryTextColor, placeholderTextColor: Styles.ContrastSecondaryTextColor, } }
[ "func", "NewInputField", "(", ")", "*", "InputField", "{", "return", "&", "InputField", "{", "Box", ":", "NewBox", "(", ")", ",", "labelColor", ":", "Styles", ".", "SecondaryTextColor", ",", "fieldBackgroundColor", ":", "Styles", ".", "ContrastBackgroundColor", ",", "fieldTextColor", ":", "Styles", ".", "PrimaryTextColor", ",", "placeholderTextColor", ":", "Styles", ".", "ContrastSecondaryTextColor", ",", "}", "\n", "}" ]
// NewInputField returns a new input field.
[ "NewInputField", "returns", "a", "new", "input", "field", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/inputfield.go#L91-L99
train
rivo/tview
inputfield.go
SetText
func (i *InputField) SetText(text string) *InputField { i.text = text i.cursorPos = len(text) if i.changed != nil { i.changed(text) } return i }
go
func (i *InputField) SetText(text string) *InputField { i.text = text i.cursorPos = len(text) if i.changed != nil { i.changed(text) } return i }
[ "func", "(", "i", "*", "InputField", ")", "SetText", "(", "text", "string", ")", "*", "InputField", "{", "i", ".", "text", "=", "text", "\n", "i", ".", "cursorPos", "=", "len", "(", "text", ")", "\n", "if", "i", ".", "changed", "!=", "nil", "{", "i", ".", "changed", "(", "text", ")", "\n", "}", "\n", "return", "i", "\n", "}" ]
// SetText sets the current text of the input field.
[ "SetText", "sets", "the", "current", "text", "of", "the", "input", "field", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/inputfield.go#L102-L109
train
rivo/tview
inputfield.go
SetPlaceholder
func (i *InputField) SetPlaceholder(text string) *InputField { i.placeholder = text return i }
go
func (i *InputField) SetPlaceholder(text string) *InputField { i.placeholder = text return i }
[ "func", "(", "i", "*", "InputField", ")", "SetPlaceholder", "(", "text", "string", ")", "*", "InputField", "{", "i", ".", "placeholder", "=", "text", "\n", "return", "i", "\n", "}" ]
// SetPlaceholder sets the text to be displayed when the input text is empty.
[ "SetPlaceholder", "sets", "the", "text", "to", "be", "displayed", "when", "the", "input", "text", "is", "empty", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/inputfield.go#L135-L138
train
rivo/tview
inputfield.go
SetPlaceholderTextColor
func (i *InputField) SetPlaceholderTextColor(color tcell.Color) *InputField { i.placeholderTextColor = color return i }
go
func (i *InputField) SetPlaceholderTextColor(color tcell.Color) *InputField { i.placeholderTextColor = color return i }
[ "func", "(", "i", "*", "InputField", ")", "SetPlaceholderTextColor", "(", "color", "tcell", ".", "Color", ")", "*", "InputField", "{", "i", ".", "placeholderTextColor", "=", "color", "\n", "return", "i", "\n", "}" ]
// SetPlaceholderTextColor sets the text color of placeholder text.
[ "SetPlaceholderTextColor", "sets", "the", "text", "color", "of", "placeholder", "text", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/inputfield.go#L159-L162
train
rivo/tview
inputfield.go
SetFieldWidth
func (i *InputField) SetFieldWidth(width int) *InputField { i.fieldWidth = width return i }
go
func (i *InputField) SetFieldWidth(width int) *InputField { i.fieldWidth = width return i }
[ "func", "(", "i", "*", "InputField", ")", "SetFieldWidth", "(", "width", "int", ")", "*", "InputField", "{", "i", ".", "fieldWidth", "=", "width", "\n", "return", "i", "\n", "}" ]
// SetFieldWidth sets the screen width of the input area. A value of 0 means // extend as much as possible.
[ "SetFieldWidth", "sets", "the", "screen", "width", "of", "the", "input", "area", ".", "A", "value", "of", "0", "means", "extend", "as", "much", "as", "possible", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/inputfield.go#L176-L179
train
rivo/tview
inputfield.go
SetMaskCharacter
func (i *InputField) SetMaskCharacter(mask rune) *InputField { i.maskCharacter = mask return i }
go
func (i *InputField) SetMaskCharacter(mask rune) *InputField { i.maskCharacter = mask return i }
[ "func", "(", "i", "*", "InputField", ")", "SetMaskCharacter", "(", "mask", "rune", ")", "*", "InputField", "{", "i", ".", "maskCharacter", "=", "mask", "\n", "return", "i", "\n", "}" ]
// SetMaskCharacter sets a character that masks user input on a screen. A value // of 0 disables masking.
[ "SetMaskCharacter", "sets", "a", "character", "that", "masks", "user", "input", "on", "a", "screen", ".", "A", "value", "of", "0", "disables", "masking", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/inputfield.go#L188-L191
train
rivo/tview
demos/unicode/main.go
alert
func alert(pages *tview.Pages, id string, message string) *tview.Pages { return pages.AddPage( id, tview.NewModal(). SetText(message). AddButtons([]string{"确定"}). SetDoneFunc(func(buttonIndex int, buttonLabel string) { pages.HidePage(id).RemovePage(id) }), false, true, ) }
go
func alert(pages *tview.Pages, id string, message string) *tview.Pages { return pages.AddPage( id, tview.NewModal(). SetText(message). AddButtons([]string{"确定"}). SetDoneFunc(func(buttonIndex int, buttonLabel string) { pages.HidePage(id).RemovePage(id) }), false, true, ) }
[ "func", "alert", "(", "pages", "*", "tview", ".", "Pages", ",", "id", "string", ",", "message", "string", ")", "*", "tview", ".", "Pages", "{", "return", "pages", ".", "AddPage", "(", "id", ",", "tview", ".", "NewModal", "(", ")", ".", "SetText", "(", "message", ")", ".", "AddButtons", "(", "[", "]", "string", "{", "\"", "", "", "", "", "SetDoneFunc", "(", "func", "(", "buttonIndex", "int", ",", "buttonLabel", "string", ")", "{", "pages", ".", "HidePage", "(", "id", ")", ".", "RemovePage", "(", "id", ")", "\n", "}", ")", ",", "false", ",", "true", ",", ")", "\n", "}" ]
// alert shows a confirmation dialog.
[ "alert", "shows", "a", "confirmation", "dialog", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/demos/unicode/main.go#L37-L49
train
rivo/tview
button.go
NewButton
func NewButton(label string) *Button { box := NewBox().SetBackgroundColor(Styles.ContrastBackgroundColor) box.SetRect(0, 0, TaggedStringWidth(label)+4, 1) return &Button{ Box: box, label: label, labelColor: Styles.PrimaryTextColor, labelColorActivated: Styles.InverseTextColor, backgroundColorActivated: Styles.PrimaryTextColor, } }
go
func NewButton(label string) *Button { box := NewBox().SetBackgroundColor(Styles.ContrastBackgroundColor) box.SetRect(0, 0, TaggedStringWidth(label)+4, 1) return &Button{ Box: box, label: label, labelColor: Styles.PrimaryTextColor, labelColorActivated: Styles.InverseTextColor, backgroundColorActivated: Styles.PrimaryTextColor, } }
[ "func", "NewButton", "(", "label", "string", ")", "*", "Button", "{", "box", ":=", "NewBox", "(", ")", ".", "SetBackgroundColor", "(", "Styles", ".", "ContrastBackgroundColor", ")", "\n", "box", ".", "SetRect", "(", "0", ",", "0", ",", "TaggedStringWidth", "(", "label", ")", "+", "4", ",", "1", ")", "\n", "return", "&", "Button", "{", "Box", ":", "box", ",", "label", ":", "label", ",", "labelColor", ":", "Styles", ".", "PrimaryTextColor", ",", "labelColorActivated", ":", "Styles", ".", "InverseTextColor", ",", "backgroundColorActivated", ":", "Styles", ".", "PrimaryTextColor", ",", "}", "\n", "}" ]
// NewButton returns a new input field.
[ "NewButton", "returns", "a", "new", "input", "field", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/button.go#L34-L44
train
rivo/tview
button.go
SetLabel
func (b *Button) SetLabel(label string) *Button { b.label = label return b }
go
func (b *Button) SetLabel(label string) *Button { b.label = label return b }
[ "func", "(", "b", "*", "Button", ")", "SetLabel", "(", "label", "string", ")", "*", "Button", "{", "b", ".", "label", "=", "label", "\n", "return", "b", "\n", "}" ]
// SetLabel sets the button text.
[ "SetLabel", "sets", "the", "button", "text", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/button.go#L47-L50
train
rivo/tview
button.go
SetLabelColor
func (b *Button) SetLabelColor(color tcell.Color) *Button { b.labelColor = color return b }
go
func (b *Button) SetLabelColor(color tcell.Color) *Button { b.labelColor = color return b }
[ "func", "(", "b", "*", "Button", ")", "SetLabelColor", "(", "color", "tcell", ".", "Color", ")", "*", "Button", "{", "b", ".", "labelColor", "=", "color", "\n", "return", "b", "\n", "}" ]
// SetLabelColor sets the color of the button text.
[ "SetLabelColor", "sets", "the", "color", "of", "the", "button", "text", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/button.go#L58-L61
train
rivo/tview
button.go
SetLabelColorActivated
func (b *Button) SetLabelColorActivated(color tcell.Color) *Button { b.labelColorActivated = color return b }
go
func (b *Button) SetLabelColorActivated(color tcell.Color) *Button { b.labelColorActivated = color return b }
[ "func", "(", "b", "*", "Button", ")", "SetLabelColorActivated", "(", "color", "tcell", ".", "Color", ")", "*", "Button", "{", "b", ".", "labelColorActivated", "=", "color", "\n", "return", "b", "\n", "}" ]
// SetLabelColorActivated sets the color of the button text when the button is // in focus.
[ "SetLabelColorActivated", "sets", "the", "color", "of", "the", "button", "text", "when", "the", "button", "is", "in", "focus", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/button.go#L65-L68
train
rivo/tview
button.go
SetBackgroundColorActivated
func (b *Button) SetBackgroundColorActivated(color tcell.Color) *Button { b.backgroundColorActivated = color return b }
go
func (b *Button) SetBackgroundColorActivated(color tcell.Color) *Button { b.backgroundColorActivated = color return b }
[ "func", "(", "b", "*", "Button", ")", "SetBackgroundColorActivated", "(", "color", "tcell", ".", "Color", ")", "*", "Button", "{", "b", ".", "backgroundColorActivated", "=", "color", "\n", "return", "b", "\n", "}" ]
// SetBackgroundColorActivated sets the background color of the button text when // the button is in focus.
[ "SetBackgroundColorActivated", "sets", "the", "background", "color", "of", "the", "button", "text", "when", "the", "button", "is", "in", "focus", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/button.go#L72-L75
train
rivo/tview
demos/presentation/form.go
Form
func Form(nextSlide func()) (title string, content tview.Primitive) { f := tview.NewForm(). AddInputField("First name:", "", 20, nil, nil). AddInputField("Last name:", "", 20, nil, nil). AddDropDown("Role:", []string{"Engineer", "Manager", "Administration"}, 0, nil). AddCheckbox("On vacation:", false, nil). AddPasswordField("Password:", "", 10, '*', nil). AddButton("Save", nextSlide). AddButton("Cancel", nextSlide) f.SetBorder(true).SetTitle("Employee Information") return "Forms", Code(f, 36, 15, form) }
go
func Form(nextSlide func()) (title string, content tview.Primitive) { f := tview.NewForm(). AddInputField("First name:", "", 20, nil, nil). AddInputField("Last name:", "", 20, nil, nil). AddDropDown("Role:", []string{"Engineer", "Manager", "Administration"}, 0, nil). AddCheckbox("On vacation:", false, nil). AddPasswordField("Password:", "", 10, '*', nil). AddButton("Save", nextSlide). AddButton("Cancel", nextSlide) f.SetBorder(true).SetTitle("Employee Information") return "Forms", Code(f, 36, 15, form) }
[ "func", "Form", "(", "nextSlide", "func", "(", ")", ")", "(", "title", "string", ",", "content", "tview", ".", "Primitive", ")", "{", "f", ":=", "tview", ".", "NewForm", "(", ")", ".", "AddInputField", "(", "\"", "\"", ",", "\"", "\"", ",", "20", ",", "nil", ",", "nil", ")", ".", "AddInputField", "(", "\"", "\"", ",", "\"", "\"", ",", "20", ",", "nil", ",", "nil", ")", ".", "AddDropDown", "(", "\"", "\"", ",", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "0", ",", "nil", ")", ".", "AddCheckbox", "(", "\"", "\"", ",", "false", ",", "nil", ")", ".", "AddPasswordField", "(", "\"", "\"", ",", "\"", "\"", ",", "10", ",", "'*'", ",", "nil", ")", ".", "AddButton", "(", "\"", "\"", ",", "nextSlide", ")", ".", "AddButton", "(", "\"", "\"", ",", "nextSlide", ")", "\n", "f", ".", "SetBorder", "(", "true", ")", ".", "SetTitle", "(", "\"", "\"", ")", "\n", "return", "\"", "\"", ",", "Code", "(", "f", ",", "36", ",", "15", ",", "form", ")", "\n", "}" ]
// Form demonstrates forms.
[ "Form", "demonstrates", "forms", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/demos/presentation/form.go#L32-L43
train
rivo/tview
demos/presentation/grid.go
Grid
func Grid(nextSlide func()) (title string, content tview.Primitive) { modalShown := false pages := tview.NewPages() newPrimitive := func(text string) tview.Primitive { return tview.NewTextView(). SetTextAlign(tview.AlignCenter). SetText(text). SetDoneFunc(func(key tcell.Key) { if modalShown { nextSlide() modalShown = false } else { pages.ShowPage("modal") modalShown = true } }) } menu := newPrimitive("Menu") main := newPrimitive("Main content") sideBar := newPrimitive("Side Bar") grid := tview.NewGrid(). SetRows(3, 0, 3). SetColumns(0, -4, 0). SetBorders(true). AddItem(newPrimitive("Header"), 0, 0, 1, 3, 0, 0, true). AddItem(newPrimitive("Footer"), 2, 0, 1, 3, 0, 0, false) // Layout for screens narrower than 100 cells (menu and side bar are hidden). grid.AddItem(menu, 0, 0, 0, 0, 0, 0, false). AddItem(main, 1, 0, 1, 3, 0, 0, false). AddItem(sideBar, 0, 0, 0, 0, 0, 0, false) // Layout for screens wider than 100 cells. grid.AddItem(menu, 1, 0, 1, 1, 0, 100, false). AddItem(main, 1, 1, 1, 1, 0, 100, false). AddItem(sideBar, 1, 2, 1, 1, 0, 100, false) modal := tview.NewModal(). SetText("Resize the window to see how the grid layout adapts"). AddButtons([]string{"Ok"}).SetDoneFunc(func(buttonIndex int, buttonLabel string) { pages.HidePage("modal") }) pages.AddPage("grid", grid, true, true). AddPage("modal", modal, false, false) return "Grid", pages }
go
func Grid(nextSlide func()) (title string, content tview.Primitive) { modalShown := false pages := tview.NewPages() newPrimitive := func(text string) tview.Primitive { return tview.NewTextView(). SetTextAlign(tview.AlignCenter). SetText(text). SetDoneFunc(func(key tcell.Key) { if modalShown { nextSlide() modalShown = false } else { pages.ShowPage("modal") modalShown = true } }) } menu := newPrimitive("Menu") main := newPrimitive("Main content") sideBar := newPrimitive("Side Bar") grid := tview.NewGrid(). SetRows(3, 0, 3). SetColumns(0, -4, 0). SetBorders(true). AddItem(newPrimitive("Header"), 0, 0, 1, 3, 0, 0, true). AddItem(newPrimitive("Footer"), 2, 0, 1, 3, 0, 0, false) // Layout for screens narrower than 100 cells (menu and side bar are hidden). grid.AddItem(menu, 0, 0, 0, 0, 0, 0, false). AddItem(main, 1, 0, 1, 3, 0, 0, false). AddItem(sideBar, 0, 0, 0, 0, 0, 0, false) // Layout for screens wider than 100 cells. grid.AddItem(menu, 1, 0, 1, 1, 0, 100, false). AddItem(main, 1, 1, 1, 1, 0, 100, false). AddItem(sideBar, 1, 2, 1, 1, 0, 100, false) modal := tview.NewModal(). SetText("Resize the window to see how the grid layout adapts"). AddButtons([]string{"Ok"}).SetDoneFunc(func(buttonIndex int, buttonLabel string) { pages.HidePage("modal") }) pages.AddPage("grid", grid, true, true). AddPage("modal", modal, false, false) return "Grid", pages }
[ "func", "Grid", "(", "nextSlide", "func", "(", ")", ")", "(", "title", "string", ",", "content", "tview", ".", "Primitive", ")", "{", "modalShown", ":=", "false", "\n", "pages", ":=", "tview", ".", "NewPages", "(", ")", "\n\n", "newPrimitive", ":=", "func", "(", "text", "string", ")", "tview", ".", "Primitive", "{", "return", "tview", ".", "NewTextView", "(", ")", ".", "SetTextAlign", "(", "tview", ".", "AlignCenter", ")", ".", "SetText", "(", "text", ")", ".", "SetDoneFunc", "(", "func", "(", "key", "tcell", ".", "Key", ")", "{", "if", "modalShown", "{", "nextSlide", "(", ")", "\n", "modalShown", "=", "false", "\n", "}", "else", "{", "pages", ".", "ShowPage", "(", "\"", "\"", ")", "\n", "modalShown", "=", "true", "\n", "}", "\n", "}", ")", "\n", "}", "\n\n", "menu", ":=", "newPrimitive", "(", "\"", "\"", ")", "\n", "main", ":=", "newPrimitive", "(", "\"", "\"", ")", "\n", "sideBar", ":=", "newPrimitive", "(", "\"", "\"", ")", "\n\n", "grid", ":=", "tview", ".", "NewGrid", "(", ")", ".", "SetRows", "(", "3", ",", "0", ",", "3", ")", ".", "SetColumns", "(", "0", ",", "-", "4", ",", "0", ")", ".", "SetBorders", "(", "true", ")", ".", "AddItem", "(", "newPrimitive", "(", "\"", "\"", ")", ",", "0", ",", "0", ",", "1", ",", "3", ",", "0", ",", "0", ",", "true", ")", ".", "AddItem", "(", "newPrimitive", "(", "\"", "\"", ")", ",", "2", ",", "0", ",", "1", ",", "3", ",", "0", ",", "0", ",", "false", ")", "\n\n", "// Layout for screens narrower than 100 cells (menu and side bar are hidden).", "grid", ".", "AddItem", "(", "menu", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "false", ")", ".", "AddItem", "(", "main", ",", "1", ",", "0", ",", "1", ",", "3", ",", "0", ",", "0", ",", "false", ")", ".", "AddItem", "(", "sideBar", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "false", ")", "\n\n", "// Layout for screens wider than 100 cells.", "grid", ".", "AddItem", "(", "menu", ",", "1", ",", "0", ",", "1", ",", "1", ",", "0", ",", "100", ",", "false", ")", ".", "AddItem", "(", "main", ",", "1", ",", "1", ",", "1", ",", "1", ",", "0", ",", "100", ",", "false", ")", ".", "AddItem", "(", "sideBar", ",", "1", ",", "2", ",", "1", ",", "1", ",", "0", ",", "100", ",", "false", ")", "\n\n", "modal", ":=", "tview", ".", "NewModal", "(", ")", ".", "SetText", "(", "\"", "\"", ")", ".", "AddButtons", "(", "[", "]", "string", "{", "\"", "\"", "}", ")", ".", "SetDoneFunc", "(", "func", "(", "buttonIndex", "int", ",", "buttonLabel", "string", ")", "{", "pages", ".", "HidePage", "(", "\"", "\"", ")", "\n", "}", ")", "\n\n", "pages", ".", "AddPage", "(", "\"", "\"", ",", "grid", ",", "true", ",", "true", ")", ".", "AddPage", "(", "\"", "\"", ",", "modal", ",", "false", ",", "false", ")", "\n\n", "return", "\"", "\"", ",", "pages", "\n", "}" ]
// Grid demonstrates the grid layout.
[ "Grid", "demonstrates", "the", "grid", "layout", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/demos/presentation/grid.go#L9-L59
train
rivo/tview
modal.go
NewModal
func NewModal() *Modal { m := &Modal{ Box: NewBox(), textColor: Styles.PrimaryTextColor, } m.form = NewForm(). SetButtonsAlign(AlignCenter). SetButtonBackgroundColor(Styles.PrimitiveBackgroundColor). SetButtonTextColor(Styles.PrimaryTextColor) m.form.SetBackgroundColor(Styles.ContrastBackgroundColor).SetBorderPadding(0, 0, 0, 0) m.form.SetCancelFunc(func() { if m.done != nil { m.done(-1, "") } }) m.frame = NewFrame(m.form).SetBorders(0, 0, 1, 0, 0, 0) m.frame.SetBorder(true). SetBackgroundColor(Styles.ContrastBackgroundColor). SetBorderPadding(1, 1, 1, 1) m.focus = m return m }
go
func NewModal() *Modal { m := &Modal{ Box: NewBox(), textColor: Styles.PrimaryTextColor, } m.form = NewForm(). SetButtonsAlign(AlignCenter). SetButtonBackgroundColor(Styles.PrimitiveBackgroundColor). SetButtonTextColor(Styles.PrimaryTextColor) m.form.SetBackgroundColor(Styles.ContrastBackgroundColor).SetBorderPadding(0, 0, 0, 0) m.form.SetCancelFunc(func() { if m.done != nil { m.done(-1, "") } }) m.frame = NewFrame(m.form).SetBorders(0, 0, 1, 0, 0, 0) m.frame.SetBorder(true). SetBackgroundColor(Styles.ContrastBackgroundColor). SetBorderPadding(1, 1, 1, 1) m.focus = m return m }
[ "func", "NewModal", "(", ")", "*", "Modal", "{", "m", ":=", "&", "Modal", "{", "Box", ":", "NewBox", "(", ")", ",", "textColor", ":", "Styles", ".", "PrimaryTextColor", ",", "}", "\n", "m", ".", "form", "=", "NewForm", "(", ")", ".", "SetButtonsAlign", "(", "AlignCenter", ")", ".", "SetButtonBackgroundColor", "(", "Styles", ".", "PrimitiveBackgroundColor", ")", ".", "SetButtonTextColor", "(", "Styles", ".", "PrimaryTextColor", ")", "\n", "m", ".", "form", ".", "SetBackgroundColor", "(", "Styles", ".", "ContrastBackgroundColor", ")", ".", "SetBorderPadding", "(", "0", ",", "0", ",", "0", ",", "0", ")", "\n", "m", ".", "form", ".", "SetCancelFunc", "(", "func", "(", ")", "{", "if", "m", ".", "done", "!=", "nil", "{", "m", ".", "done", "(", "-", "1", ",", "\"", "\"", ")", "\n", "}", "\n", "}", ")", "\n", "m", ".", "frame", "=", "NewFrame", "(", "m", ".", "form", ")", ".", "SetBorders", "(", "0", ",", "0", ",", "1", ",", "0", ",", "0", ",", "0", ")", "\n", "m", ".", "frame", ".", "SetBorder", "(", "true", ")", ".", "SetBackgroundColor", "(", "Styles", ".", "ContrastBackgroundColor", ")", ".", "SetBorderPadding", "(", "1", ",", "1", ",", "1", ",", "1", ")", "\n", "m", ".", "focus", "=", "m", "\n", "return", "m", "\n", "}" ]
// NewModal returns a new modal message window.
[ "NewModal", "returns", "a", "new", "modal", "message", "window", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/modal.go#L33-L54
train
rivo/tview
modal.go
SetTextColor
func (m *Modal) SetTextColor(color tcell.Color) *Modal { m.textColor = color return m }
go
func (m *Modal) SetTextColor(color tcell.Color) *Modal { m.textColor = color return m }
[ "func", "(", "m", "*", "Modal", ")", "SetTextColor", "(", "color", "tcell", ".", "Color", ")", "*", "Modal", "{", "m", ".", "textColor", "=", "color", "\n", "return", "m", "\n", "}" ]
// SetTextColor sets the color of the message text.
[ "SetTextColor", "sets", "the", "color", "of", "the", "message", "text", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/modal.go#L57-L60
train
rivo/tview
modal.go
SetDoneFunc
func (m *Modal) SetDoneFunc(handler func(buttonIndex int, buttonLabel string)) *Modal { m.done = handler return m }
go
func (m *Modal) SetDoneFunc(handler func(buttonIndex int, buttonLabel string)) *Modal { m.done = handler return m }
[ "func", "(", "m", "*", "Modal", ")", "SetDoneFunc", "(", "handler", "func", "(", "buttonIndex", "int", ",", "buttonLabel", "string", ")", ")", "*", "Modal", "{", "m", ".", "done", "=", "handler", "\n", "return", "m", "\n", "}" ]
// SetDoneFunc sets a handler which is called when one of the buttons was // pressed. It receives the index of the button as well as its label text. The // handler is also called when the user presses the Escape key. The index will // then be negative and the label text an emptry string.
[ "SetDoneFunc", "sets", "a", "handler", "which", "is", "called", "when", "one", "of", "the", "buttons", "was", "pressed", ".", "It", "receives", "the", "index", "of", "the", "button", "as", "well", "as", "its", "label", "text", ".", "The", "handler", "is", "also", "called", "when", "the", "user", "presses", "the", "Escape", "key", ".", "The", "index", "will", "then", "be", "negative", "and", "the", "label", "text", "an", "emptry", "string", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/modal.go#L66-L69
train
rivo/tview
modal.go
SetText
func (m *Modal) SetText(text string) *Modal { m.text = text return m }
go
func (m *Modal) SetText(text string) *Modal { m.text = text return m }
[ "func", "(", "m", "*", "Modal", ")", "SetText", "(", "text", "string", ")", "*", "Modal", "{", "m", ".", "text", "=", "text", "\n", "return", "m", "\n", "}" ]
// SetText sets the message text of the window. The text may contain line // breaks. Note that words are wrapped, too, based on the final size of the // window.
[ "SetText", "sets", "the", "message", "text", "of", "the", "window", ".", "The", "text", "may", "contain", "line", "breaks", ".", "Note", "that", "words", "are", "wrapped", "too", "based", "on", "the", "final", "size", "of", "the", "window", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/modal.go#L74-L77
train
rivo/tview
modal.go
AddButtons
func (m *Modal) AddButtons(labels []string) *Modal { for index, label := range labels { func(i int, l string) { m.form.AddButton(label, func() { if m.done != nil { m.done(i, l) } }) button := m.form.GetButton(m.form.GetButtonCount() - 1) button.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { switch event.Key() { case tcell.KeyDown, tcell.KeyRight: return tcell.NewEventKey(tcell.KeyTab, 0, tcell.ModNone) case tcell.KeyUp, tcell.KeyLeft: return tcell.NewEventKey(tcell.KeyBacktab, 0, tcell.ModNone) } return event }) }(index, label) } return m }
go
func (m *Modal) AddButtons(labels []string) *Modal { for index, label := range labels { func(i int, l string) { m.form.AddButton(label, func() { if m.done != nil { m.done(i, l) } }) button := m.form.GetButton(m.form.GetButtonCount() - 1) button.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { switch event.Key() { case tcell.KeyDown, tcell.KeyRight: return tcell.NewEventKey(tcell.KeyTab, 0, tcell.ModNone) case tcell.KeyUp, tcell.KeyLeft: return tcell.NewEventKey(tcell.KeyBacktab, 0, tcell.ModNone) } return event }) }(index, label) } return m }
[ "func", "(", "m", "*", "Modal", ")", "AddButtons", "(", "labels", "[", "]", "string", ")", "*", "Modal", "{", "for", "index", ",", "label", ":=", "range", "labels", "{", "func", "(", "i", "int", ",", "l", "string", ")", "{", "m", ".", "form", ".", "AddButton", "(", "label", ",", "func", "(", ")", "{", "if", "m", ".", "done", "!=", "nil", "{", "m", ".", "done", "(", "i", ",", "l", ")", "\n", "}", "\n", "}", ")", "\n", "button", ":=", "m", ".", "form", ".", "GetButton", "(", "m", ".", "form", ".", "GetButtonCount", "(", ")", "-", "1", ")", "\n", "button", ".", "SetInputCapture", "(", "func", "(", "event", "*", "tcell", ".", "EventKey", ")", "*", "tcell", ".", "EventKey", "{", "switch", "event", ".", "Key", "(", ")", "{", "case", "tcell", ".", "KeyDown", ",", "tcell", ".", "KeyRight", ":", "return", "tcell", ".", "NewEventKey", "(", "tcell", ".", "KeyTab", ",", "0", ",", "tcell", ".", "ModNone", ")", "\n", "case", "tcell", ".", "KeyUp", ",", "tcell", ".", "KeyLeft", ":", "return", "tcell", ".", "NewEventKey", "(", "tcell", ".", "KeyBacktab", ",", "0", ",", "tcell", ".", "ModNone", ")", "\n", "}", "\n", "return", "event", "\n", "}", ")", "\n", "}", "(", "index", ",", "label", ")", "\n", "}", "\n", "return", "m", "\n", "}" ]
// AddButtons adds buttons to the window. There must be at least one button and // a "done" handler so the window can be closed again.
[ "AddButtons", "adds", "buttons", "to", "the", "window", ".", "There", "must", "be", "at", "least", "one", "button", "and", "a", "done", "handler", "so", "the", "window", "can", "be", "closed", "again", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/modal.go#L81-L102
train
rivo/tview
demos/presentation/center.go
Center
func Center(width, height int, p tview.Primitive) tview.Primitive { return tview.NewFlex(). AddItem(tview.NewBox(), 0, 1, false). AddItem(tview.NewFlex(). SetDirection(tview.FlexRow). AddItem(tview.NewBox(), 0, 1, false). AddItem(p, height, 1, true). AddItem(tview.NewBox(), 0, 1, false), width, 1, true). AddItem(tview.NewBox(), 0, 1, false) }
go
func Center(width, height int, p tview.Primitive) tview.Primitive { return tview.NewFlex(). AddItem(tview.NewBox(), 0, 1, false). AddItem(tview.NewFlex(). SetDirection(tview.FlexRow). AddItem(tview.NewBox(), 0, 1, false). AddItem(p, height, 1, true). AddItem(tview.NewBox(), 0, 1, false), width, 1, true). AddItem(tview.NewBox(), 0, 1, false) }
[ "func", "Center", "(", "width", ",", "height", "int", ",", "p", "tview", ".", "Primitive", ")", "tview", ".", "Primitive", "{", "return", "tview", ".", "NewFlex", "(", ")", ".", "AddItem", "(", "tview", ".", "NewBox", "(", ")", ",", "0", ",", "1", ",", "false", ")", ".", "AddItem", "(", "tview", ".", "NewFlex", "(", ")", ".", "SetDirection", "(", "tview", ".", "FlexRow", ")", ".", "AddItem", "(", "tview", ".", "NewBox", "(", ")", ",", "0", ",", "1", ",", "false", ")", ".", "AddItem", "(", "p", ",", "height", ",", "1", ",", "true", ")", ".", "AddItem", "(", "tview", ".", "NewBox", "(", ")", ",", "0", ",", "1", ",", "false", ")", ",", "width", ",", "1", ",", "true", ")", ".", "AddItem", "(", "tview", ".", "NewBox", "(", ")", ",", "0", ",", "1", ",", "false", ")", "\n", "}" ]
// Center returns a new primitive which shows the provided primitive in its // center, given the provided primitive's size.
[ "Center", "returns", "a", "new", "primitive", "which", "shows", "the", "provided", "primitive", "in", "its", "center", "given", "the", "provided", "primitive", "s", "size", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/demos/presentation/center.go#L7-L16
train
rivo/tview
demos/treeview/main.go
main
func main() { rootDir := "." root := tview.NewTreeNode(rootDir). SetColor(tcell.ColorRed) tree := tview.NewTreeView(). SetRoot(root). SetCurrentNode(root) // A helper function which adds the files and directories of the given path // to the given target node. add := func(target *tview.TreeNode, path string) { files, err := ioutil.ReadDir(path) if err != nil { panic(err) } for _, file := range files { node := tview.NewTreeNode(file.Name()). SetReference(filepath.Join(path, file.Name())). SetSelectable(file.IsDir()) if file.IsDir() { node.SetColor(tcell.ColorGreen) } target.AddChild(node) } } // Add the current directory to the root node. add(root, rootDir) // If a directory was selected, open it. tree.SetSelectedFunc(func(node *tview.TreeNode) { reference := node.GetReference() if reference == nil { return // Selecting the root node does nothing. } children := node.GetChildren() if len(children) == 0 { // Load and show files in this directory. path := reference.(string) add(node, path) } else { // Collapse if visible, expand if collapsed. node.SetExpanded(!node.IsExpanded()) } }) if err := tview.NewApplication().SetRoot(tree, true).Run(); err != nil { panic(err) } }
go
func main() { rootDir := "." root := tview.NewTreeNode(rootDir). SetColor(tcell.ColorRed) tree := tview.NewTreeView(). SetRoot(root). SetCurrentNode(root) // A helper function which adds the files and directories of the given path // to the given target node. add := func(target *tview.TreeNode, path string) { files, err := ioutil.ReadDir(path) if err != nil { panic(err) } for _, file := range files { node := tview.NewTreeNode(file.Name()). SetReference(filepath.Join(path, file.Name())). SetSelectable(file.IsDir()) if file.IsDir() { node.SetColor(tcell.ColorGreen) } target.AddChild(node) } } // Add the current directory to the root node. add(root, rootDir) // If a directory was selected, open it. tree.SetSelectedFunc(func(node *tview.TreeNode) { reference := node.GetReference() if reference == nil { return // Selecting the root node does nothing. } children := node.GetChildren() if len(children) == 0 { // Load and show files in this directory. path := reference.(string) add(node, path) } else { // Collapse if visible, expand if collapsed. node.SetExpanded(!node.IsExpanded()) } }) if err := tview.NewApplication().SetRoot(tree, true).Run(); err != nil { panic(err) } }
[ "func", "main", "(", ")", "{", "rootDir", ":=", "\"", "\"", "\n", "root", ":=", "tview", ".", "NewTreeNode", "(", "rootDir", ")", ".", "SetColor", "(", "tcell", ".", "ColorRed", ")", "\n", "tree", ":=", "tview", ".", "NewTreeView", "(", ")", ".", "SetRoot", "(", "root", ")", ".", "SetCurrentNode", "(", "root", ")", "\n\n", "// A helper function which adds the files and directories of the given path", "// to the given target node.", "add", ":=", "func", "(", "target", "*", "tview", ".", "TreeNode", ",", "path", "string", ")", "{", "files", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "for", "_", ",", "file", ":=", "range", "files", "{", "node", ":=", "tview", ".", "NewTreeNode", "(", "file", ".", "Name", "(", ")", ")", ".", "SetReference", "(", "filepath", ".", "Join", "(", "path", ",", "file", ".", "Name", "(", ")", ")", ")", ".", "SetSelectable", "(", "file", ".", "IsDir", "(", ")", ")", "\n", "if", "file", ".", "IsDir", "(", ")", "{", "node", ".", "SetColor", "(", "tcell", ".", "ColorGreen", ")", "\n", "}", "\n", "target", ".", "AddChild", "(", "node", ")", "\n", "}", "\n", "}", "\n\n", "// Add the current directory to the root node.", "add", "(", "root", ",", "rootDir", ")", "\n\n", "// If a directory was selected, open it.", "tree", ".", "SetSelectedFunc", "(", "func", "(", "node", "*", "tview", ".", "TreeNode", ")", "{", "reference", ":=", "node", ".", "GetReference", "(", ")", "\n", "if", "reference", "==", "nil", "{", "return", "// Selecting the root node does nothing.", "\n", "}", "\n", "children", ":=", "node", ".", "GetChildren", "(", ")", "\n", "if", "len", "(", "children", ")", "==", "0", "{", "// Load and show files in this directory.", "path", ":=", "reference", ".", "(", "string", ")", "\n", "add", "(", "node", ",", "path", ")", "\n", "}", "else", "{", "// Collapse if visible, expand if collapsed.", "node", ".", "SetExpanded", "(", "!", "node", ".", "IsExpanded", "(", ")", ")", "\n", "}", "\n", "}", ")", "\n\n", "if", "err", ":=", "tview", ".", "NewApplication", "(", ")", ".", "SetRoot", "(", "tree", ",", "true", ")", ".", "Run", "(", ")", ";", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "}" ]
// Show a navigable tree view of the current directory.
[ "Show", "a", "navigable", "tree", "view", "of", "the", "current", "directory", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/demos/treeview/main.go#L13-L62
train
rivo/tview
demos/presentation/textview.go
TextView1
func TextView1(nextSlide func()) (title string, content tview.Primitive) { textView := tview.NewTextView(). SetTextColor(tcell.ColorYellow). SetScrollable(false). SetDoneFunc(func(key tcell.Key) { nextSlide() }) textView.SetChangedFunc(func() { if textView.HasFocus() { app.Draw() } }) go func() { var n int for { n++ fmt.Fprintf(textView, "%d ", n) time.Sleep(200 * time.Millisecond) } }() textView.SetBorder(true).SetTitle("TextView implements io.Writer") return "Text 1", Code(textView, 36, 13, textView1) }
go
func TextView1(nextSlide func()) (title string, content tview.Primitive) { textView := tview.NewTextView(). SetTextColor(tcell.ColorYellow). SetScrollable(false). SetDoneFunc(func(key tcell.Key) { nextSlide() }) textView.SetChangedFunc(func() { if textView.HasFocus() { app.Draw() } }) go func() { var n int for { n++ fmt.Fprintf(textView, "%d ", n) time.Sleep(200 * time.Millisecond) } }() textView.SetBorder(true).SetTitle("TextView implements io.Writer") return "Text 1", Code(textView, 36, 13, textView1) }
[ "func", "TextView1", "(", "nextSlide", "func", "(", ")", ")", "(", "title", "string", ",", "content", "tview", ".", "Primitive", ")", "{", "textView", ":=", "tview", ".", "NewTextView", "(", ")", ".", "SetTextColor", "(", "tcell", ".", "ColorYellow", ")", ".", "SetScrollable", "(", "false", ")", ".", "SetDoneFunc", "(", "func", "(", "key", "tcell", ".", "Key", ")", "{", "nextSlide", "(", ")", "\n", "}", ")", "\n", "textView", ".", "SetChangedFunc", "(", "func", "(", ")", "{", "if", "textView", ".", "HasFocus", "(", ")", "{", "app", ".", "Draw", "(", ")", "\n", "}", "\n", "}", ")", "\n", "go", "func", "(", ")", "{", "var", "n", "int", "\n", "for", "{", "n", "++", "\n", "fmt", ".", "Fprintf", "(", "textView", ",", "\"", "\"", ",", "n", ")", "\n", "time", ".", "Sleep", "(", "200", "*", "time", ".", "Millisecond", ")", "\n", "}", "\n", "}", "(", ")", "\n", "textView", ".", "SetBorder", "(", "true", ")", ".", "SetTitle", "(", "\"", "\"", ")", "\n", "return", "\"", "\"", ",", "Code", "(", "textView", ",", "36", ",", "13", ",", "textView1", ")", "\n", "}" ]
// TextView1 demonstrates the basic text view.
[ "TextView1", "demonstrates", "the", "basic", "text", "view", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/demos/presentation/textview.go#L33-L55
train
rivo/tview
demos/presentation/textview.go
TextView2
func TextView2(nextSlide func()) (title string, content tview.Primitive) { codeView := tview.NewTextView(). SetWrap(false) fmt.Fprint(codeView, textView2) codeView.SetBorder(true).SetTitle("Buffer content") textView := tview.NewTextView() textView.SetDynamicColors(true). SetWrap(false). SetRegions(true). SetDoneFunc(func(key tcell.Key) { if key == tcell.KeyEscape { nextSlide() return } highlights := textView.GetHighlights() hasHighlights := len(highlights) > 0 switch key { case tcell.KeyEnter: if hasHighlights { textView.Highlight() } else { textView.Highlight("0"). ScrollToHighlight() } case tcell.KeyTab: if hasHighlights { current, _ := strconv.Atoi(highlights[0]) next := (current + 1) % 9 textView.Highlight(strconv.Itoa(next)). ScrollToHighlight() } case tcell.KeyBacktab: if hasHighlights { current, _ := strconv.Atoi(highlights[0]) next := (current - 1 + 9) % 9 textView.Highlight(strconv.Itoa(next)). ScrollToHighlight() } } }) fmt.Fprint(textView, textView2) textView.SetBorder(true).SetTitle("TextView output") return "Text 2", tview.NewFlex(). AddItem(textView, 0, 1, true). AddItem(codeView, 0, 1, false) }
go
func TextView2(nextSlide func()) (title string, content tview.Primitive) { codeView := tview.NewTextView(). SetWrap(false) fmt.Fprint(codeView, textView2) codeView.SetBorder(true).SetTitle("Buffer content") textView := tview.NewTextView() textView.SetDynamicColors(true). SetWrap(false). SetRegions(true). SetDoneFunc(func(key tcell.Key) { if key == tcell.KeyEscape { nextSlide() return } highlights := textView.GetHighlights() hasHighlights := len(highlights) > 0 switch key { case tcell.KeyEnter: if hasHighlights { textView.Highlight() } else { textView.Highlight("0"). ScrollToHighlight() } case tcell.KeyTab: if hasHighlights { current, _ := strconv.Atoi(highlights[0]) next := (current + 1) % 9 textView.Highlight(strconv.Itoa(next)). ScrollToHighlight() } case tcell.KeyBacktab: if hasHighlights { current, _ := strconv.Atoi(highlights[0]) next := (current - 1 + 9) % 9 textView.Highlight(strconv.Itoa(next)). ScrollToHighlight() } } }) fmt.Fprint(textView, textView2) textView.SetBorder(true).SetTitle("TextView output") return "Text 2", tview.NewFlex(). AddItem(textView, 0, 1, true). AddItem(codeView, 0, 1, false) }
[ "func", "TextView2", "(", "nextSlide", "func", "(", ")", ")", "(", "title", "string", ",", "content", "tview", ".", "Primitive", ")", "{", "codeView", ":=", "tview", ".", "NewTextView", "(", ")", ".", "SetWrap", "(", "false", ")", "\n", "fmt", ".", "Fprint", "(", "codeView", ",", "textView2", ")", "\n", "codeView", ".", "SetBorder", "(", "true", ")", ".", "SetTitle", "(", "\"", "\"", ")", "\n\n", "textView", ":=", "tview", ".", "NewTextView", "(", ")", "\n", "textView", ".", "SetDynamicColors", "(", "true", ")", ".", "SetWrap", "(", "false", ")", ".", "SetRegions", "(", "true", ")", ".", "SetDoneFunc", "(", "func", "(", "key", "tcell", ".", "Key", ")", "{", "if", "key", "==", "tcell", ".", "KeyEscape", "{", "nextSlide", "(", ")", "\n", "return", "\n", "}", "\n", "highlights", ":=", "textView", ".", "GetHighlights", "(", ")", "\n", "hasHighlights", ":=", "len", "(", "highlights", ")", ">", "0", "\n", "switch", "key", "{", "case", "tcell", ".", "KeyEnter", ":", "if", "hasHighlights", "{", "textView", ".", "Highlight", "(", ")", "\n", "}", "else", "{", "textView", ".", "Highlight", "(", "\"", "\"", ")", ".", "ScrollToHighlight", "(", ")", "\n", "}", "\n", "case", "tcell", ".", "KeyTab", ":", "if", "hasHighlights", "{", "current", ",", "_", ":=", "strconv", ".", "Atoi", "(", "highlights", "[", "0", "]", ")", "\n", "next", ":=", "(", "current", "+", "1", ")", "%", "9", "\n", "textView", ".", "Highlight", "(", "strconv", ".", "Itoa", "(", "next", ")", ")", ".", "ScrollToHighlight", "(", ")", "\n", "}", "\n", "case", "tcell", ".", "KeyBacktab", ":", "if", "hasHighlights", "{", "current", ",", "_", ":=", "strconv", ".", "Atoi", "(", "highlights", "[", "0", "]", ")", "\n", "next", ":=", "(", "current", "-", "1", "+", "9", ")", "%", "9", "\n", "textView", ".", "Highlight", "(", "strconv", ".", "Itoa", "(", "next", ")", ")", ".", "ScrollToHighlight", "(", ")", "\n", "}", "\n", "}", "\n", "}", ")", "\n", "fmt", ".", "Fprint", "(", "textView", ",", "textView2", ")", "\n", "textView", ".", "SetBorder", "(", "true", ")", ".", "SetTitle", "(", "\"", "\"", ")", "\n", "return", "\"", "\"", ",", "tview", ".", "NewFlex", "(", ")", ".", "AddItem", "(", "textView", ",", "0", ",", "1", ",", "true", ")", ".", "AddItem", "(", "codeView", ",", "0", ",", "1", ",", "false", ")", "\n", "}" ]
// TextView2 demonstrates the extended text view.
[ "TextView2", "demonstrates", "the", "extended", "text", "view", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/demos/presentation/textview.go#L105-L151
train
rivo/tview
frame.go
NewFrame
func NewFrame(primitive Primitive) *Frame { box := NewBox() f := &Frame{ Box: box, primitive: primitive, top: 1, bottom: 1, header: 1, footer: 1, left: 1, right: 1, } f.focus = f return f }
go
func NewFrame(primitive Primitive) *Frame { box := NewBox() f := &Frame{ Box: box, primitive: primitive, top: 1, bottom: 1, header: 1, footer: 1, left: 1, right: 1, } f.focus = f return f }
[ "func", "NewFrame", "(", "primitive", "Primitive", ")", "*", "Frame", "{", "box", ":=", "NewBox", "(", ")", "\n\n", "f", ":=", "&", "Frame", "{", "Box", ":", "box", ",", "primitive", ":", "primitive", ",", "top", ":", "1", ",", "bottom", ":", "1", ",", "header", ":", "1", ",", "footer", ":", "1", ",", "left", ":", "1", ",", "right", ":", "1", ",", "}", "\n\n", "f", ".", "focus", "=", "f", "\n\n", "return", "f", "\n", "}" ]
// NewFrame returns a new frame around the given primitive. The primitive's // size will be changed to fit within this frame.
[ "NewFrame", "returns", "a", "new", "frame", "around", "the", "given", "primitive", ".", "The", "primitive", "s", "size", "will", "be", "changed", "to", "fit", "within", "this", "frame", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/frame.go#L34-L51
train
rivo/tview
frame.go
AddText
func (f *Frame) AddText(text string, header bool, align int, color tcell.Color) *Frame { f.text = append(f.text, &frameText{ Text: text, Header: header, Align: align, Color: color, }) return f }
go
func (f *Frame) AddText(text string, header bool, align int, color tcell.Color) *Frame { f.text = append(f.text, &frameText{ Text: text, Header: header, Align: align, Color: color, }) return f }
[ "func", "(", "f", "*", "Frame", ")", "AddText", "(", "text", "string", ",", "header", "bool", ",", "align", "int", ",", "color", "tcell", ".", "Color", ")", "*", "Frame", "{", "f", ".", "text", "=", "append", "(", "f", ".", "text", ",", "&", "frameText", "{", "Text", ":", "text", ",", "Header", ":", "header", ",", "Align", ":", "align", ",", "Color", ":", "color", ",", "}", ")", "\n", "return", "f", "\n", "}" ]
// AddText adds text to the frame. Set "header" to true if the text is to appear // in the header, above the contained primitive. Set it to false for it to // appear in the footer, below the contained primitive. "align" must be one of // the Align constants. Rows in the header are printed top to bottom, rows in // the footer are printed bottom to top. Note that long text can overlap as // different alignments will be placed on the same row.
[ "AddText", "adds", "text", "to", "the", "frame", ".", "Set", "header", "to", "true", "if", "the", "text", "is", "to", "appear", "in", "the", "header", "above", "the", "contained", "primitive", ".", "Set", "it", "to", "false", "for", "it", "to", "appear", "in", "the", "footer", "below", "the", "contained", "primitive", ".", "align", "must", "be", "one", "of", "the", "Align", "constants", ".", "Rows", "in", "the", "header", "are", "printed", "top", "to", "bottom", "rows", "in", "the", "footer", "are", "printed", "bottom", "to", "top", ".", "Note", "that", "long", "text", "can", "overlap", "as", "different", "alignments", "will", "be", "placed", "on", "the", "same", "row", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/frame.go#L59-L67
train
rivo/tview
list.go
NewList
func NewList() *List { return &List{ Box: NewBox(), showSecondaryText: true, mainTextColor: Styles.PrimaryTextColor, secondaryTextColor: Styles.TertiaryTextColor, shortcutColor: Styles.SecondaryTextColor, selectedTextColor: Styles.PrimitiveBackgroundColor, selectedBackgroundColor: Styles.PrimaryTextColor, } }
go
func NewList() *List { return &List{ Box: NewBox(), showSecondaryText: true, mainTextColor: Styles.PrimaryTextColor, secondaryTextColor: Styles.TertiaryTextColor, shortcutColor: Styles.SecondaryTextColor, selectedTextColor: Styles.PrimitiveBackgroundColor, selectedBackgroundColor: Styles.PrimaryTextColor, } }
[ "func", "NewList", "(", ")", "*", "List", "{", "return", "&", "List", "{", "Box", ":", "NewBox", "(", ")", ",", "showSecondaryText", ":", "true", ",", "mainTextColor", ":", "Styles", ".", "PrimaryTextColor", ",", "secondaryTextColor", ":", "Styles", ".", "TertiaryTextColor", ",", "shortcutColor", ":", "Styles", ".", "SecondaryTextColor", ",", "selectedTextColor", ":", "Styles", ".", "PrimitiveBackgroundColor", ",", "selectedBackgroundColor", ":", "Styles", ".", "PrimaryTextColor", ",", "}", "\n", "}" ]
// NewList returns a new form.
[ "NewList", "returns", "a", "new", "form", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/list.go#L70-L80
train
rivo/tview
list.go
SetMainTextColor
func (l *List) SetMainTextColor(color tcell.Color) *List { l.mainTextColor = color return l }
go
func (l *List) SetMainTextColor(color tcell.Color) *List { l.mainTextColor = color return l }
[ "func", "(", "l", "*", "List", ")", "SetMainTextColor", "(", "color", "tcell", ".", "Color", ")", "*", "List", "{", "l", ".", "mainTextColor", "=", "color", "\n", "return", "l", "\n", "}" ]
// SetMainTextColor sets the color of the items' main text.
[ "SetMainTextColor", "sets", "the", "color", "of", "the", "items", "main", "text", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/list.go#L162-L165
train
rivo/tview
list.go
SetSecondaryTextColor
func (l *List) SetSecondaryTextColor(color tcell.Color) *List { l.secondaryTextColor = color return l }
go
func (l *List) SetSecondaryTextColor(color tcell.Color) *List { l.secondaryTextColor = color return l }
[ "func", "(", "l", "*", "List", ")", "SetSecondaryTextColor", "(", "color", "tcell", ".", "Color", ")", "*", "List", "{", "l", ".", "secondaryTextColor", "=", "color", "\n", "return", "l", "\n", "}" ]
// SetSecondaryTextColor sets the color of the items' secondary text.
[ "SetSecondaryTextColor", "sets", "the", "color", "of", "the", "items", "secondary", "text", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/list.go#L168-L171
train
rivo/tview
list.go
SetShortcutColor
func (l *List) SetShortcutColor(color tcell.Color) *List { l.shortcutColor = color return l }
go
func (l *List) SetShortcutColor(color tcell.Color) *List { l.shortcutColor = color return l }
[ "func", "(", "l", "*", "List", ")", "SetShortcutColor", "(", "color", "tcell", ".", "Color", ")", "*", "List", "{", "l", ".", "shortcutColor", "=", "color", "\n", "return", "l", "\n", "}" ]
// SetShortcutColor sets the color of the items' shortcut.
[ "SetShortcutColor", "sets", "the", "color", "of", "the", "items", "shortcut", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/list.go#L174-L177
train
rivo/tview
list.go
SetSelectedTextColor
func (l *List) SetSelectedTextColor(color tcell.Color) *List { l.selectedTextColor = color return l }
go
func (l *List) SetSelectedTextColor(color tcell.Color) *List { l.selectedTextColor = color return l }
[ "func", "(", "l", "*", "List", ")", "SetSelectedTextColor", "(", "color", "tcell", ".", "Color", ")", "*", "List", "{", "l", ".", "selectedTextColor", "=", "color", "\n", "return", "l", "\n", "}" ]
// SetSelectedTextColor sets the text color of selected items.
[ "SetSelectedTextColor", "sets", "the", "text", "color", "of", "selected", "items", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/list.go#L180-L183
train
rivo/tview
list.go
SetSelectedBackgroundColor
func (l *List) SetSelectedBackgroundColor(color tcell.Color) *List { l.selectedBackgroundColor = color return l }
go
func (l *List) SetSelectedBackgroundColor(color tcell.Color) *List { l.selectedBackgroundColor = color return l }
[ "func", "(", "l", "*", "List", ")", "SetSelectedBackgroundColor", "(", "color", "tcell", ".", "Color", ")", "*", "List", "{", "l", ".", "selectedBackgroundColor", "=", "color", "\n", "return", "l", "\n", "}" ]
// SetSelectedBackgroundColor sets the background color of selected items.
[ "SetSelectedBackgroundColor", "sets", "the", "background", "color", "of", "selected", "items", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/list.go#L186-L189
train
rivo/tview
list.go
SetSelectedFocusOnly
func (l *List) SetSelectedFocusOnly(focusOnly bool) *List { l.selectedFocusOnly = focusOnly return l }
go
func (l *List) SetSelectedFocusOnly(focusOnly bool) *List { l.selectedFocusOnly = focusOnly return l }
[ "func", "(", "l", "*", "List", ")", "SetSelectedFocusOnly", "(", "focusOnly", "bool", ")", "*", "List", "{", "l", ".", "selectedFocusOnly", "=", "focusOnly", "\n", "return", "l", "\n", "}" ]
// SetSelectedFocusOnly sets a flag which determines when the currently selected // list item is highlighted. If set to true, selected items are only highlighted // when the list has focus. If set to false, they are always highlighted.
[ "SetSelectedFocusOnly", "sets", "a", "flag", "which", "determines", "when", "the", "currently", "selected", "list", "item", "is", "highlighted", ".", "If", "set", "to", "true", "selected", "items", "are", "only", "highlighted", "when", "the", "list", "has", "focus", ".", "If", "set", "to", "false", "they", "are", "always", "highlighted", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/list.go#L194-L197
train
rivo/tview
list.go
SetHighlightFullLine
func (l *List) SetHighlightFullLine(highlight bool) *List { l.highlightFullLine = highlight return l }
go
func (l *List) SetHighlightFullLine(highlight bool) *List { l.highlightFullLine = highlight return l }
[ "func", "(", "l", "*", "List", ")", "SetHighlightFullLine", "(", "highlight", "bool", ")", "*", "List", "{", "l", ".", "highlightFullLine", "=", "highlight", "\n", "return", "l", "\n", "}" ]
// SetHighlightFullLine sets a flag which determines whether the colored // background of selected items spans the entire width of the view. If set to // true, the highlight spans the entire view. If set to false, only the text of // the selected item from beginning to end is highlighted.
[ "SetHighlightFullLine", "sets", "a", "flag", "which", "determines", "whether", "the", "colored", "background", "of", "selected", "items", "spans", "the", "entire", "width", "of", "the", "view", ".", "If", "set", "to", "true", "the", "highlight", "spans", "the", "entire", "view", ".", "If", "set", "to", "false", "only", "the", "text", "of", "the", "selected", "item", "from", "beginning", "to", "end", "is", "highlighted", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/list.go#L203-L206
train
rivo/tview
list.go
ShowSecondaryText
func (l *List) ShowSecondaryText(show bool) *List { l.showSecondaryText = show return l }
go
func (l *List) ShowSecondaryText(show bool) *List { l.showSecondaryText = show return l }
[ "func", "(", "l", "*", "List", ")", "ShowSecondaryText", "(", "show", "bool", ")", "*", "List", "{", "l", ".", "showSecondaryText", "=", "show", "\n", "return", "l", "\n", "}" ]
// ShowSecondaryText determines whether or not to show secondary item texts.
[ "ShowSecondaryText", "determines", "whether", "or", "not", "to", "show", "secondary", "item", "texts", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/list.go#L209-L212
train
rivo/tview
list.go
SetItemText
func (l *List) SetItemText(index int, main, secondary string) *List { item := l.items[index] item.MainText = main item.SecondaryText = secondary return l }
go
func (l *List) SetItemText(index int, main, secondary string) *List { item := l.items[index] item.MainText = main item.SecondaryText = secondary return l }
[ "func", "(", "l", "*", "List", ")", "SetItemText", "(", "index", "int", ",", "main", ",", "secondary", "string", ")", "*", "List", "{", "item", ":=", "l", ".", "items", "[", "index", "]", "\n", "item", ".", "MainText", "=", "main", "\n", "item", ".", "SecondaryText", "=", "secondary", "\n", "return", "l", "\n", "}" ]
// SetItemText sets an item's main and secondary text. Panics if the index is // out of range.
[ "SetItemText", "sets", "an", "item", "s", "main", "and", "secondary", "text", ".", "Panics", "if", "the", "index", "is", "out", "of", "range", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/list.go#L321-L326
train
rivo/tview
list.go
FindItems
func (l *List) FindItems(mainSearch, secondarySearch string, mustContainBoth, ignoreCase bool) (indices []int) { if mainSearch == "" && secondarySearch == "" { return } if ignoreCase { mainSearch = strings.ToLower(mainSearch) secondarySearch = strings.ToLower(secondarySearch) } for index, item := range l.items { mainText := item.MainText secondaryText := item.SecondaryText if ignoreCase { mainText = strings.ToLower(mainText) secondaryText = strings.ToLower(secondaryText) } // strings.Contains() always returns true for a "" search. mainContained := strings.Contains(mainText, mainSearch) secondaryContained := strings.Contains(secondaryText, secondarySearch) if mustContainBoth && mainContained && secondaryContained || !mustContainBoth && (mainText != "" && mainContained || secondaryText != "" && secondaryContained) { indices = append(indices, index) } } return }
go
func (l *List) FindItems(mainSearch, secondarySearch string, mustContainBoth, ignoreCase bool) (indices []int) { if mainSearch == "" && secondarySearch == "" { return } if ignoreCase { mainSearch = strings.ToLower(mainSearch) secondarySearch = strings.ToLower(secondarySearch) } for index, item := range l.items { mainText := item.MainText secondaryText := item.SecondaryText if ignoreCase { mainText = strings.ToLower(mainText) secondaryText = strings.ToLower(secondaryText) } // strings.Contains() always returns true for a "" search. mainContained := strings.Contains(mainText, mainSearch) secondaryContained := strings.Contains(secondaryText, secondarySearch) if mustContainBoth && mainContained && secondaryContained || !mustContainBoth && (mainText != "" && mainContained || secondaryText != "" && secondaryContained) { indices = append(indices, index) } } return }
[ "func", "(", "l", "*", "List", ")", "FindItems", "(", "mainSearch", ",", "secondarySearch", "string", ",", "mustContainBoth", ",", "ignoreCase", "bool", ")", "(", "indices", "[", "]", "int", ")", "{", "if", "mainSearch", "==", "\"", "\"", "&&", "secondarySearch", "==", "\"", "\"", "{", "return", "\n", "}", "\n\n", "if", "ignoreCase", "{", "mainSearch", "=", "strings", ".", "ToLower", "(", "mainSearch", ")", "\n", "secondarySearch", "=", "strings", ".", "ToLower", "(", "secondarySearch", ")", "\n", "}", "\n\n", "for", "index", ",", "item", ":=", "range", "l", ".", "items", "{", "mainText", ":=", "item", ".", "MainText", "\n", "secondaryText", ":=", "item", ".", "SecondaryText", "\n", "if", "ignoreCase", "{", "mainText", "=", "strings", ".", "ToLower", "(", "mainText", ")", "\n", "secondaryText", "=", "strings", ".", "ToLower", "(", "secondaryText", ")", "\n", "}", "\n\n", "// strings.Contains() always returns true for a \"\" search.", "mainContained", ":=", "strings", ".", "Contains", "(", "mainText", ",", "mainSearch", ")", "\n", "secondaryContained", ":=", "strings", ".", "Contains", "(", "secondaryText", ",", "secondarySearch", ")", "\n", "if", "mustContainBoth", "&&", "mainContained", "&&", "secondaryContained", "||", "!", "mustContainBoth", "&&", "(", "mainText", "!=", "\"", "\"", "&&", "mainContained", "||", "secondaryText", "!=", "\"", "\"", "&&", "secondaryContained", ")", "{", "indices", "=", "append", "(", "indices", ",", "index", ")", "\n", "}", "\n", "}", "\n\n", "return", "\n", "}" ]
// FindItems searches the main and secondary texts for the given strings and // returns a list of item indices in which those strings are found. One of the // two search strings may be empty, it will then be ignored. Indices are always // returned in ascending order. // // If mustContainBoth is set to true, mainSearch must be contained in the main // text AND secondarySearch must be contained in the secondary text. If it is // false, only one of the two search strings must be contained. // // Set ignoreCase to true for case-insensitive search.
[ "FindItems", "searches", "the", "main", "and", "secondary", "texts", "for", "the", "given", "strings", "and", "returns", "a", "list", "of", "item", "indices", "in", "which", "those", "strings", "are", "found", ".", "One", "of", "the", "two", "search", "strings", "may", "be", "empty", "it", "will", "then", "be", "ignored", ".", "Indices", "are", "always", "returned", "in", "ascending", "order", ".", "If", "mustContainBoth", "is", "set", "to", "true", "mainSearch", "must", "be", "contained", "in", "the", "main", "text", "AND", "secondarySearch", "must", "be", "contained", "in", "the", "secondary", "text", ".", "If", "it", "is", "false", "only", "one", "of", "the", "two", "search", "strings", "must", "be", "contained", ".", "Set", "ignoreCase", "to", "true", "for", "case", "-", "insensitive", "search", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/list.go#L338-L366
train
rivo/tview
list.go
Clear
func (l *List) Clear() *List { l.items = nil l.currentItem = 0 return l }
go
func (l *List) Clear() *List { l.items = nil l.currentItem = 0 return l }
[ "func", "(", "l", "*", "List", ")", "Clear", "(", ")", "*", "List", "{", "l", ".", "items", "=", "nil", "\n", "l", ".", "currentItem", "=", "0", "\n", "return", "l", "\n", "}" ]
// Clear removes all items from the list.
[ "Clear", "removes", "all", "items", "from", "the", "list", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/list.go#L369-L373
train
rivo/tview
flex.go
SetFullScreen
func (f *Flex) SetFullScreen(fullScreen bool) *Flex { f.fullScreen = fullScreen return f }
go
func (f *Flex) SetFullScreen(fullScreen bool) *Flex { f.fullScreen = fullScreen return f }
[ "func", "(", "f", "*", "Flex", ")", "SetFullScreen", "(", "fullScreen", "bool", ")", "*", "Flex", "{", "f", ".", "fullScreen", "=", "fullScreen", "\n", "return", "f", "\n", "}" ]
// SetFullScreen sets the flag which, when true, causes the flex layout to use // the entire screen space instead of whatever size it is currently assigned to.
[ "SetFullScreen", "sets", "the", "flag", "which", "when", "true", "causes", "the", "flex", "layout", "to", "use", "the", "entire", "screen", "space", "instead", "of", "whatever", "size", "it", "is", "currently", "assigned", "to", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/flex.go#L69-L72
train
rivo/tview
flex.go
RemoveItem
func (f *Flex) RemoveItem(p Primitive) *Flex { for index := len(f.items) - 1; index >= 0; index-- { if f.items[index].Item == p { f.items = append(f.items[:index], f.items[index+1:]...) } } return f }
go
func (f *Flex) RemoveItem(p Primitive) *Flex { for index := len(f.items) - 1; index >= 0; index-- { if f.items[index].Item == p { f.items = append(f.items[:index], f.items[index+1:]...) } } return f }
[ "func", "(", "f", "*", "Flex", ")", "RemoveItem", "(", "p", "Primitive", ")", "*", "Flex", "{", "for", "index", ":=", "len", "(", "f", ".", "items", ")", "-", "1", ";", "index", ">=", "0", ";", "index", "--", "{", "if", "f", ".", "items", "[", "index", "]", ".", "Item", "==", "p", "{", "f", ".", "items", "=", "append", "(", "f", ".", "items", "[", ":", "index", "]", ",", "f", ".", "items", "[", "index", "+", "1", ":", "]", "...", ")", "\n", "}", "\n", "}", "\n", "return", "f", "\n", "}" ]
// RemoveItem removes all items for the given primitive from the container, // keeping the order of the remaining items intact.
[ "RemoveItem", "removes", "all", "items", "for", "the", "given", "primitive", "from", "the", "container", "keeping", "the", "order", "of", "the", "remaining", "items", "intact", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/flex.go#L95-L102
train
rivo/tview
checkbox.go
NewCheckbox
func NewCheckbox() *Checkbox { return &Checkbox{ Box: NewBox(), labelColor: Styles.SecondaryTextColor, fieldBackgroundColor: Styles.ContrastBackgroundColor, fieldTextColor: Styles.PrimaryTextColor, } }
go
func NewCheckbox() *Checkbox { return &Checkbox{ Box: NewBox(), labelColor: Styles.SecondaryTextColor, fieldBackgroundColor: Styles.ContrastBackgroundColor, fieldTextColor: Styles.PrimaryTextColor, } }
[ "func", "NewCheckbox", "(", ")", "*", "Checkbox", "{", "return", "&", "Checkbox", "{", "Box", ":", "NewBox", "(", ")", ",", "labelColor", ":", "Styles", ".", "SecondaryTextColor", ",", "fieldBackgroundColor", ":", "Styles", ".", "ContrastBackgroundColor", ",", "fieldTextColor", ":", "Styles", ".", "PrimaryTextColor", ",", "}", "\n", "}" ]
// NewCheckbox returns a new input field.
[ "NewCheckbox", "returns", "a", "new", "input", "field", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/checkbox.go#L48-L55
train
rivo/tview
checkbox.go
SetChecked
func (c *Checkbox) SetChecked(checked bool) *Checkbox { c.checked = checked return c }
go
func (c *Checkbox) SetChecked(checked bool) *Checkbox { c.checked = checked return c }
[ "func", "(", "c", "*", "Checkbox", ")", "SetChecked", "(", "checked", "bool", ")", "*", "Checkbox", "{", "c", ".", "checked", "=", "checked", "\n", "return", "c", "\n", "}" ]
// SetChecked sets the state of the checkbox.
[ "SetChecked", "sets", "the", "state", "of", "the", "checkbox", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/checkbox.go#L58-L61
train
rivo/tview
checkbox.go
SetChangedFunc
func (c *Checkbox) SetChangedFunc(handler func(checked bool)) *Checkbox { c.changed = handler return c }
go
func (c *Checkbox) SetChangedFunc(handler func(checked bool)) *Checkbox { c.changed = handler return c }
[ "func", "(", "c", "*", "Checkbox", ")", "SetChangedFunc", "(", "handler", "func", "(", "checked", "bool", ")", ")", "*", "Checkbox", "{", "c", ".", "changed", "=", "handler", "\n", "return", "c", "\n", "}" ]
// SetChangedFunc sets a handler which is called when the checked state of this // checkbox was changed by the user. The handler function receives the new // state.
[ "SetChangedFunc", "sets", "a", "handler", "which", "is", "called", "when", "the", "checked", "state", "of", "this", "checkbox", "was", "changed", "by", "the", "user", ".", "The", "handler", "function", "receives", "the", "new", "state", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/checkbox.go#L122-L125
train
rivo/tview
demos/presentation/treeview.go
TreeView
func TreeView(nextSlide func()) (title string, content tview.Primitive) { treeNextSlide = nextSlide tree.SetBorder(true). SetTitle("TreeView") // Add nodes. var add func(target *node) *tview.TreeNode add = func(target *node) *tview.TreeNode { node := tview.NewTreeNode(target.text). SetSelectable(target.expand || target.selected != nil). SetExpanded(target == rootNode). SetReference(target) if target.expand { node.SetColor(tcell.ColorGreen) } else if target.selected != nil { node.SetColor(tcell.ColorRed) } for _, child := range target.children { node.AddChild(add(child)) } return node } root := add(rootNode) tree.SetRoot(root). SetCurrentNode(root). SetSelectedFunc(func(n *tview.TreeNode) { original := n.GetReference().(*node) if original.expand { n.SetExpanded(!n.IsExpanded()) } else if original.selected != nil { original.selected() } }) treeCode.SetText(strings.Replace(treeAllCode, "$$$", treeBasicCode, -1)). SetBorderPadding(1, 1, 2, 0) return "Tree", tview.NewFlex(). AddItem(tree, 0, 1, true). AddItem(treeCode, codeWidth, 1, false) }
go
func TreeView(nextSlide func()) (title string, content tview.Primitive) { treeNextSlide = nextSlide tree.SetBorder(true). SetTitle("TreeView") // Add nodes. var add func(target *node) *tview.TreeNode add = func(target *node) *tview.TreeNode { node := tview.NewTreeNode(target.text). SetSelectable(target.expand || target.selected != nil). SetExpanded(target == rootNode). SetReference(target) if target.expand { node.SetColor(tcell.ColorGreen) } else if target.selected != nil { node.SetColor(tcell.ColorRed) } for _, child := range target.children { node.AddChild(add(child)) } return node } root := add(rootNode) tree.SetRoot(root). SetCurrentNode(root). SetSelectedFunc(func(n *tview.TreeNode) { original := n.GetReference().(*node) if original.expand { n.SetExpanded(!n.IsExpanded()) } else if original.selected != nil { original.selected() } }) treeCode.SetText(strings.Replace(treeAllCode, "$$$", treeBasicCode, -1)). SetBorderPadding(1, 1, 2, 0) return "Tree", tview.NewFlex(). AddItem(tree, 0, 1, true). AddItem(treeCode, codeWidth, 1, false) }
[ "func", "TreeView", "(", "nextSlide", "func", "(", ")", ")", "(", "title", "string", ",", "content", "tview", ".", "Primitive", ")", "{", "treeNextSlide", "=", "nextSlide", "\n", "tree", ".", "SetBorder", "(", "true", ")", ".", "SetTitle", "(", "\"", "\"", ")", "\n\n", "// Add nodes.", "var", "add", "func", "(", "target", "*", "node", ")", "*", "tview", ".", "TreeNode", "\n", "add", "=", "func", "(", "target", "*", "node", ")", "*", "tview", ".", "TreeNode", "{", "node", ":=", "tview", ".", "NewTreeNode", "(", "target", ".", "text", ")", ".", "SetSelectable", "(", "target", ".", "expand", "||", "target", ".", "selected", "!=", "nil", ")", ".", "SetExpanded", "(", "target", "==", "rootNode", ")", ".", "SetReference", "(", "target", ")", "\n", "if", "target", ".", "expand", "{", "node", ".", "SetColor", "(", "tcell", ".", "ColorGreen", ")", "\n", "}", "else", "if", "target", ".", "selected", "!=", "nil", "{", "node", ".", "SetColor", "(", "tcell", ".", "ColorRed", ")", "\n", "}", "\n", "for", "_", ",", "child", ":=", "range", "target", ".", "children", "{", "node", ".", "AddChild", "(", "add", "(", "child", ")", ")", "\n", "}", "\n", "return", "node", "\n", "}", "\n", "root", ":=", "add", "(", "rootNode", ")", "\n", "tree", ".", "SetRoot", "(", "root", ")", ".", "SetCurrentNode", "(", "root", ")", ".", "SetSelectedFunc", "(", "func", "(", "n", "*", "tview", ".", "TreeNode", ")", "{", "original", ":=", "n", ".", "GetReference", "(", ")", ".", "(", "*", "node", ")", "\n", "if", "original", ".", "expand", "{", "n", ".", "SetExpanded", "(", "!", "n", ".", "IsExpanded", "(", ")", ")", "\n", "}", "else", "if", "original", ".", "selected", "!=", "nil", "{", "original", ".", "selected", "(", ")", "\n", "}", "\n", "}", ")", "\n\n", "treeCode", ".", "SetText", "(", "strings", ".", "Replace", "(", "treeAllCode", ",", "\"", "\"", ",", "treeBasicCode", ",", "-", "1", ")", ")", ".", "SetBorderPadding", "(", "1", ",", "1", ",", "2", ",", "0", ")", "\n\n", "return", "\"", "\"", ",", "tview", ".", "NewFlex", "(", ")", ".", "AddItem", "(", "tree", ",", "0", ",", "1", ",", "true", ")", ".", "AddItem", "(", "treeCode", ",", "codeWidth", ",", "1", ",", "false", ")", "\n", "}" ]
// TreeView demonstrates the tree view.
[ "TreeView", "demonstrates", "the", "tree", "view", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/demos/presentation/treeview.go#L109-L149
train
rivo/tview
table.go
SetText
func (c *TableCell) SetText(text string) *TableCell { c.Text = text return c }
go
func (c *TableCell) SetText(text string) *TableCell { c.Text = text return c }
[ "func", "(", "c", "*", "TableCell", ")", "SetText", "(", "text", "string", ")", "*", "TableCell", "{", "c", ".", "Text", "=", "text", "\n", "return", "c", "\n", "}" ]
// SetText sets the cell's text.
[ "SetText", "sets", "the", "cell", "s", "text", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L62-L65
train
rivo/tview
table.go
SetAlign
func (c *TableCell) SetAlign(align int) *TableCell { c.Align = align return c }
go
func (c *TableCell) SetAlign(align int) *TableCell { c.Align = align return c }
[ "func", "(", "c", "*", "TableCell", ")", "SetAlign", "(", "align", "int", ")", "*", "TableCell", "{", "c", ".", "Align", "=", "align", "\n", "return", "c", "\n", "}" ]
// SetAlign sets the cell's text alignment, one of AlignLeft, AlignCenter, or // AlignRight.
[ "SetAlign", "sets", "the", "cell", "s", "text", "alignment", "one", "of", "AlignLeft", "AlignCenter", "or", "AlignRight", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L69-L72
train
rivo/tview
table.go
SetMaxWidth
func (c *TableCell) SetMaxWidth(maxWidth int) *TableCell { c.MaxWidth = maxWidth return c }
go
func (c *TableCell) SetMaxWidth(maxWidth int) *TableCell { c.MaxWidth = maxWidth return c }
[ "func", "(", "c", "*", "TableCell", ")", "SetMaxWidth", "(", "maxWidth", "int", ")", "*", "TableCell", "{", "c", ".", "MaxWidth", "=", "maxWidth", "\n", "return", "c", "\n", "}" ]
// SetMaxWidth sets maximum width of the cell in screen space. This is used to // give a column a maximum width. Any cell text whose screen width exceeds this // width is cut off. Set to 0 if there is no maximum width.
[ "SetMaxWidth", "sets", "maximum", "width", "of", "the", "cell", "in", "screen", "space", ".", "This", "is", "used", "to", "give", "a", "column", "a", "maximum", "width", ".", "Any", "cell", "text", "whose", "screen", "width", "exceeds", "this", "width", "is", "cut", "off", ".", "Set", "to", "0", "if", "there", "is", "no", "maximum", "width", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L77-L80
train
rivo/tview
table.go
SetTextColor
func (c *TableCell) SetTextColor(color tcell.Color) *TableCell { c.Color = color return c }
go
func (c *TableCell) SetTextColor(color tcell.Color) *TableCell { c.Color = color return c }
[ "func", "(", "c", "*", "TableCell", ")", "SetTextColor", "(", "color", "tcell", ".", "Color", ")", "*", "TableCell", "{", "c", ".", "Color", "=", "color", "\n", "return", "c", "\n", "}" ]
// SetTextColor sets the cell's text color.
[ "SetTextColor", "sets", "the", "cell", "s", "text", "color", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L104-L107
train
rivo/tview
table.go
SetBackgroundColor
func (c *TableCell) SetBackgroundColor(color tcell.Color) *TableCell { c.BackgroundColor = color return c }
go
func (c *TableCell) SetBackgroundColor(color tcell.Color) *TableCell { c.BackgroundColor = color return c }
[ "func", "(", "c", "*", "TableCell", ")", "SetBackgroundColor", "(", "color", "tcell", ".", "Color", ")", "*", "TableCell", "{", "c", ".", "BackgroundColor", "=", "color", "\n", "return", "c", "\n", "}" ]
// SetBackgroundColor sets the cell's background color. Set to // tcell.ColorDefault to use the table's background color.
[ "SetBackgroundColor", "sets", "the", "cell", "s", "background", "color", ".", "Set", "to", "tcell", ".", "ColorDefault", "to", "use", "the", "table", "s", "background", "color", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L111-L114
train
rivo/tview
table.go
SetSelectable
func (c *TableCell) SetSelectable(selectable bool) *TableCell { c.NotSelectable = !selectable return c }
go
func (c *TableCell) SetSelectable(selectable bool) *TableCell { c.NotSelectable = !selectable return c }
[ "func", "(", "c", "*", "TableCell", ")", "SetSelectable", "(", "selectable", "bool", ")", "*", "TableCell", "{", "c", ".", "NotSelectable", "=", "!", "selectable", "\n", "return", "c", "\n", "}" ]
// SetSelectable sets whether or not this cell can be selected by the user.
[ "SetSelectable", "sets", "whether", "or", "not", "this", "cell", "can", "be", "selected", "by", "the", "user", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L133-L136
train
rivo/tview
table.go
NewTable
func NewTable() *Table { return &Table{ Box: NewBox(), bordersColor: Styles.GraphicsColor, separator: ' ', lastColumn: -1, } }
go
func NewTable() *Table { return &Table{ Box: NewBox(), bordersColor: Styles.GraphicsColor, separator: ' ', lastColumn: -1, } }
[ "func", "NewTable", "(", ")", "*", "Table", "{", "return", "&", "Table", "{", "Box", ":", "NewBox", "(", ")", ",", "bordersColor", ":", "Styles", ".", "GraphicsColor", ",", "separator", ":", "' '", ",", "lastColumn", ":", "-", "1", ",", "}", "\n", "}" ]
// NewTable returns a new table.
[ "NewTable", "returns", "a", "new", "table", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L270-L277
train
rivo/tview
table.go
Clear
func (t *Table) Clear() *Table { t.cells = nil t.lastColumn = -1 return t }
go
func (t *Table) Clear() *Table { t.cells = nil t.lastColumn = -1 return t }
[ "func", "(", "t", "*", "Table", ")", "Clear", "(", ")", "*", "Table", "{", "t", ".", "cells", "=", "nil", "\n", "t", ".", "lastColumn", "=", "-", "1", "\n", "return", "t", "\n", "}" ]
// Clear removes all table data.
[ "Clear", "removes", "all", "table", "data", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L280-L284
train
rivo/tview
table.go
SetBorders
func (t *Table) SetBorders(show bool) *Table { t.borders = show return t }
go
func (t *Table) SetBorders(show bool) *Table { t.borders = show return t }
[ "func", "(", "t", "*", "Table", ")", "SetBorders", "(", "show", "bool", ")", "*", "Table", "{", "t", ".", "borders", "=", "show", "\n", "return", "t", "\n", "}" ]
// SetBorders sets whether or not each cell in the table is surrounded by a // border.
[ "SetBorders", "sets", "whether", "or", "not", "each", "cell", "in", "the", "table", "is", "surrounded", "by", "a", "border", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L288-L291
train
rivo/tview
table.go
SetBordersColor
func (t *Table) SetBordersColor(color tcell.Color) *Table { t.bordersColor = color return t }
go
func (t *Table) SetBordersColor(color tcell.Color) *Table { t.bordersColor = color return t }
[ "func", "(", "t", "*", "Table", ")", "SetBordersColor", "(", "color", "tcell", ".", "Color", ")", "*", "Table", "{", "t", ".", "bordersColor", "=", "color", "\n", "return", "t", "\n", "}" ]
// SetBordersColor sets the color of the cell borders.
[ "SetBordersColor", "sets", "the", "color", "of", "the", "cell", "borders", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L294-L297
train
rivo/tview
table.go
SetFixed
func (t *Table) SetFixed(rows, columns int) *Table { t.fixedRows, t.fixedColumns = rows, columns return t }
go
func (t *Table) SetFixed(rows, columns int) *Table { t.fixedRows, t.fixedColumns = rows, columns return t }
[ "func", "(", "t", "*", "Table", ")", "SetFixed", "(", "rows", ",", "columns", "int", ")", "*", "Table", "{", "t", ".", "fixedRows", ",", "t", ".", "fixedColumns", "=", "rows", ",", "columns", "\n", "return", "t", "\n", "}" ]
// SetFixed sets the number of fixed rows and columns which are always visible // even when the rest of the cells are scrolled out of view. Rows are always the // top-most ones. Columns are always the left-most ones.
[ "SetFixed", "sets", "the", "number", "of", "fixed", "rows", "and", "columns", "which", "are", "always", "visible", "even", "when", "the", "rest", "of", "the", "cells", "are", "scrolled", "out", "of", "view", ".", "Rows", "are", "always", "the", "top", "-", "most", "ones", ".", "Columns", "are", "always", "the", "left", "-", "most", "ones", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L326-L329
train
rivo/tview
table.go
GetSelection
func (t *Table) GetSelection() (row, column int) { return t.selectedRow, t.selectedColumn }
go
func (t *Table) GetSelection() (row, column int) { return t.selectedRow, t.selectedColumn }
[ "func", "(", "t", "*", "Table", ")", "GetSelection", "(", ")", "(", "row", ",", "column", "int", ")", "{", "return", "t", ".", "selectedRow", ",", "t", ".", "selectedColumn", "\n", "}" ]
// GetSelection returns the position of the current selection. // If entire rows are selected, the column index is undefined. // Likewise for entire columns.
[ "GetSelection", "returns", "the", "position", "of", "the", "current", "selection", ".", "If", "entire", "rows", "are", "selected", "the", "column", "index", "is", "undefined", ".", "Likewise", "for", "entire", "columns", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L352-L354
train
rivo/tview
table.go
SetOffset
func (t *Table) SetOffset(row, column int) *Table { t.rowOffset, t.columnOffset = row, column t.trackEnd = false return t }
go
func (t *Table) SetOffset(row, column int) *Table { t.rowOffset, t.columnOffset = row, column t.trackEnd = false return t }
[ "func", "(", "t", "*", "Table", ")", "SetOffset", "(", "row", ",", "column", "int", ")", "*", "Table", "{", "t", ".", "rowOffset", ",", "t", ".", "columnOffset", "=", "row", ",", "column", "\n", "t", ".", "trackEnd", "=", "false", "\n", "return", "t", "\n", "}" ]
// SetOffset sets how many rows and columns should be skipped when drawing the // table. This is useful for large tables that do not fit on the screen. // Navigating a selection can change these values. // // Fixed rows and columns are never skipped.
[ "SetOffset", "sets", "how", "many", "rows", "and", "columns", "should", "be", "skipped", "when", "drawing", "the", "table", ".", "This", "is", "useful", "for", "large", "tables", "that", "do", "not", "fit", "on", "the", "screen", ".", "Navigating", "a", "selection", "can", "change", "these", "values", ".", "Fixed", "rows", "and", "columns", "are", "never", "skipped", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L369-L373
train
rivo/tview
table.go
GetOffset
func (t *Table) GetOffset() (row, column int) { return t.rowOffset, t.columnOffset }
go
func (t *Table) GetOffset() (row, column int) { return t.rowOffset, t.columnOffset }
[ "func", "(", "t", "*", "Table", ")", "GetOffset", "(", ")", "(", "row", ",", "column", "int", ")", "{", "return", "t", ".", "rowOffset", ",", "t", ".", "columnOffset", "\n", "}" ]
// GetOffset returns the current row and column offset. This indicates how many // rows and columns the table is scrolled down and to the right.
[ "GetOffset", "returns", "the", "current", "row", "and", "column", "offset", ".", "This", "indicates", "how", "many", "rows", "and", "columns", "the", "table", "is", "scrolled", "down", "and", "to", "the", "right", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L377-L379
train
rivo/tview
table.go
SetSelectionChangedFunc
func (t *Table) SetSelectionChangedFunc(handler func(row, column int)) *Table { t.selectionChanged = handler return t }
go
func (t *Table) SetSelectionChangedFunc(handler func(row, column int)) *Table { t.selectionChanged = handler return t }
[ "func", "(", "t", "*", "Table", ")", "SetSelectionChangedFunc", "(", "handler", "func", "(", "row", ",", "column", "int", ")", ")", "*", "Table", "{", "t", ".", "selectionChanged", "=", "handler", "\n", "return", "t", "\n", "}" ]
// SetSelectionChangedFunc sets a handler which is called whenever the user // navigates to a new selection. The handler receives the position of the new // selection. If entire rows are selected, the column index is undefined. // Likewise for entire columns.
[ "SetSelectionChangedFunc", "sets", "a", "handler", "which", "is", "called", "whenever", "the", "user", "navigates", "to", "a", "new", "selection", ".", "The", "handler", "receives", "the", "position", "of", "the", "new", "selection", ".", "If", "entire", "rows", "are", "selected", "the", "column", "index", "is", "undefined", ".", "Likewise", "for", "entire", "columns", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L394-L397
train
rivo/tview
table.go
GetCell
func (t *Table) GetCell(row, column int) *TableCell { if row >= len(t.cells) || column >= len(t.cells[row]) { return &TableCell{} } return t.cells[row][column] }
go
func (t *Table) GetCell(row, column int) *TableCell { if row >= len(t.cells) || column >= len(t.cells[row]) { return &TableCell{} } return t.cells[row][column] }
[ "func", "(", "t", "*", "Table", ")", "GetCell", "(", "row", ",", "column", "int", ")", "*", "TableCell", "{", "if", "row", ">=", "len", "(", "t", ".", "cells", ")", "||", "column", ">=", "len", "(", "t", ".", "cells", "[", "row", "]", ")", "{", "return", "&", "TableCell", "{", "}", "\n", "}", "\n", "return", "t", ".", "cells", "[", "row", "]", "[", "column", "]", "\n", "}" ]
// GetCell returns the contents of the cell at the specified position. A valid // TableCell object is always returned but it will be uninitialized if the cell // was not previously set. Such an uninitialized object will not automatically // be inserted. Therefore, repeated calls to this function may return different // pointers for uninitialized cells.
[ "GetCell", "returns", "the", "contents", "of", "the", "cell", "at", "the", "specified", "position", ".", "A", "valid", "TableCell", "object", "is", "always", "returned", "but", "it", "will", "be", "uninitialized", "if", "the", "cell", "was", "not", "previously", "set", ".", "Such", "an", "uninitialized", "object", "will", "not", "automatically", "be", "inserted", ".", "Therefore", "repeated", "calls", "to", "this", "function", "may", "return", "different", "pointers", "for", "uninitialized", "cells", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L446-L451
train
rivo/tview
table.go
RemoveRow
func (t *Table) RemoveRow(row int) *Table { if row < 0 || row >= len(t.cells) { return t } t.cells = append(t.cells[:row], t.cells[row+1:]...) return t }
go
func (t *Table) RemoveRow(row int) *Table { if row < 0 || row >= len(t.cells) { return t } t.cells = append(t.cells[:row], t.cells[row+1:]...) return t }
[ "func", "(", "t", "*", "Table", ")", "RemoveRow", "(", "row", "int", ")", "*", "Table", "{", "if", "row", "<", "0", "||", "row", ">=", "len", "(", "t", ".", "cells", ")", "{", "return", "t", "\n", "}", "\n\n", "t", ".", "cells", "=", "append", "(", "t", ".", "cells", "[", ":", "row", "]", ",", "t", ".", "cells", "[", "row", "+", "1", ":", "]", "...", ")", "\n\n", "return", "t", "\n", "}" ]
// RemoveRow removes the row at the given position from the table. If there is // no such row, this has no effect.
[ "RemoveRow", "removes", "the", "row", "at", "the", "given", "position", "from", "the", "table", ".", "If", "there", "is", "no", "such", "row", "this", "has", "no", "effect", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L455-L463
train
rivo/tview
table.go
RemoveColumn
func (t *Table) RemoveColumn(column int) *Table { for row := range t.cells { if column < 0 || column >= len(t.cells[row]) { continue } t.cells[row] = append(t.cells[row][:column], t.cells[row][column+1:]...) } return t }
go
func (t *Table) RemoveColumn(column int) *Table { for row := range t.cells { if column < 0 || column >= len(t.cells[row]) { continue } t.cells[row] = append(t.cells[row][:column], t.cells[row][column+1:]...) } return t }
[ "func", "(", "t", "*", "Table", ")", "RemoveColumn", "(", "column", "int", ")", "*", "Table", "{", "for", "row", ":=", "range", "t", ".", "cells", "{", "if", "column", "<", "0", "||", "column", ">=", "len", "(", "t", ".", "cells", "[", "row", "]", ")", "{", "continue", "\n", "}", "\n", "t", ".", "cells", "[", "row", "]", "=", "append", "(", "t", ".", "cells", "[", "row", "]", "[", ":", "column", "]", ",", "t", ".", "cells", "[", "row", "]", "[", "column", "+", "1", ":", "]", "...", ")", "\n", "}", "\n\n", "return", "t", "\n", "}" ]
// RemoveColumn removes the column at the given position from the table. If // there is no such column, this has no effect.
[ "RemoveColumn", "removes", "the", "column", "at", "the", "given", "position", "from", "the", "table", ".", "If", "there", "is", "no", "such", "column", "this", "has", "no", "effect", "." ]
90b4da1bd64ceee13d2e7d782b315b819190f7bf
https://github.com/rivo/tview/blob/90b4da1bd64ceee13d2e7d782b315b819190f7bf/table.go#L467-L476
train