id
int32
0
167k
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
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
22,200
gdamore/tcell
views/textbar.go
SetView
func (t *TextBar) SetView(view View) { t.initialize() t.view = view t.lview.SetView(view) t.rview.SetView(view) t.cview.SetView(view) t.changed = true }
go
func (t *TextBar) SetView(view View) { t.initialize() t.view = view t.lview.SetView(view) t.rview.SetView(view) t.cview.SetView(view) t.changed = true }
[ "func", "(", "t", "*", "TextBar", ")", "SetView", "(", "view", "View", ")", "{", "t", ".", "initialize", "(", ")", "\n", "t", ".", "view", "=", "view", "\n", "t", ".", "lview", ".", "SetView", "(", "view", ")", "\n", "t", ".", "rview", ".", "SetView", "(", "view", ")", "\n", "t", ".", "cview", ".", "SetView", "(", "view", ")", "\n", "t", ".", "changed", "=", "true", "\n", "}" ]
// SetView sets the View drawing context for this TextBar.
[ "SetView", "sets", "the", "View", "drawing", "context", "for", "this", "TextBar", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/textbar.go#L110-L117
22,201
gdamore/tcell
views/textbar.go
Draw
func (t *TextBar) Draw() { t.initialize() if t.changed { t.layout() } w, h := t.view.Size() for y := 0; y < h; y++ { for x := 0; x < w; x++ { t.view.SetContent(x, y, ' ', nil, t.style) } } // Draw in reverse order -- if we clip, we will clip at the // right side. t.right.Draw() t.center.Draw() t.left.Draw() }
go
func (t *TextBar) Draw() { t.initialize() if t.changed { t.layout() } w, h := t.view.Size() for y := 0; y < h; y++ { for x := 0; x < w; x++ { t.view.SetContent(x, y, ' ', nil, t.style) } } // Draw in reverse order -- if we clip, we will clip at the // right side. t.right.Draw() t.center.Draw() t.left.Draw() }
[ "func", "(", "t", "*", "TextBar", ")", "Draw", "(", ")", "{", "t", ".", "initialize", "(", ")", "\n", "if", "t", ".", "changed", "{", "t", ".", "layout", "(", ")", "\n", "}", "\n", "w", ",", "h", ":=", "t", ".", "view", ".", "Size", "(", ")", "\n", "for", "y", ":=", "0", ";", "y", "<", "h", ";", "y", "++", "{", "for", "x", ":=", "0", ";", "x", "<", "w", ";", "x", "++", "{", "t", ".", "view", ".", "SetContent", "(", "x", ",", "y", ",", "' '", ",", "nil", ",", "t", ".", "style", ")", "\n", "}", "\n", "}", "\n\n", "// Draw in reverse order -- if we clip, we will clip at the", "// right side.", "t", ".", "right", ".", "Draw", "(", ")", "\n", "t", ".", "center", ".", "Draw", "(", ")", "\n", "t", ".", "left", ".", "Draw", "(", ")", "\n", "}" ]
// Draw draws the TextBar into its View context.
[ "Draw", "draws", "the", "TextBar", "into", "its", "View", "context", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/textbar.go#L120-L138
22,202
gdamore/tcell
views/textbar.go
Resize
func (t *TextBar) Resize() { t.initialize() t.layout() t.left.Resize() t.center.Resize() t.right.Resize() t.PostEventWidgetResize(t) }
go
func (t *TextBar) Resize() { t.initialize() t.layout() t.left.Resize() t.center.Resize() t.right.Resize() t.PostEventWidgetResize(t) }
[ "func", "(", "t", "*", "TextBar", ")", "Resize", "(", ")", "{", "t", ".", "initialize", "(", ")", "\n", "t", ".", "layout", "(", ")", "\n\n", "t", ".", "left", ".", "Resize", "(", ")", "\n", "t", ".", "center", ".", "Resize", "(", ")", "\n", "t", ".", "right", ".", "Resize", "(", ")", "\n\n", "t", ".", "PostEventWidgetResize", "(", "t", ")", "\n", "}" ]
// Resize is called when the TextBar's View changes size, and // updates the layout.
[ "Resize", "is", "called", "when", "the", "TextBar", "s", "View", "changes", "size", "and", "updates", "the", "layout", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/textbar.go#L142-L151
22,203
gdamore/tcell
views/textbar.go
Size
func (t *TextBar) Size() (int, int) { w, h := 0, 0 ww, wh := t.left.Size() w += ww if wh > h { h = wh } ww, wh = t.center.Size() w += ww if wh > h { h = wh } ww, wh = t.right.Size() w += ww if wh > h { h = wh } return w, h }
go
func (t *TextBar) Size() (int, int) { w, h := 0, 0 ww, wh := t.left.Size() w += ww if wh > h { h = wh } ww, wh = t.center.Size() w += ww if wh > h { h = wh } ww, wh = t.right.Size() w += ww if wh > h { h = wh } return w, h }
[ "func", "(", "t", "*", "TextBar", ")", "Size", "(", ")", "(", "int", ",", "int", ")", "{", "w", ",", "h", ":=", "0", ",", "0", "\n\n", "ww", ",", "wh", ":=", "t", ".", "left", ".", "Size", "(", ")", "\n", "w", "+=", "ww", "\n", "if", "wh", ">", "h", "{", "h", "=", "wh", "\n", "}", "\n", "ww", ",", "wh", "=", "t", ".", "center", ".", "Size", "(", ")", "\n", "w", "+=", "ww", "\n", "if", "wh", ">", "h", "{", "h", "=", "wh", "\n", "}", "\n", "ww", ",", "wh", "=", "t", ".", "right", ".", "Size", "(", ")", "\n", "w", "+=", "ww", "\n", "if", "wh", ">", "h", "{", "h", "=", "wh", "\n", "}", "\n", "return", "w", ",", "h", "\n", "}" ]
// Size implements the Size method for Widget, returning the width // and height in character cells.
[ "Size", "implements", "the", "Size", "method", "for", "Widget", "returning", "the", "width", "and", "height", "in", "character", "cells", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/textbar.go#L155-L174
22,204
gdamore/tcell
views/textbar.go
HandleEvent
func (t *TextBar) HandleEvent(ev tcell.Event) bool { switch ev.(type) { case *EventWidgetContent: t.changed = true return true } return false }
go
func (t *TextBar) HandleEvent(ev tcell.Event) bool { switch ev.(type) { case *EventWidgetContent: t.changed = true return true } return false }
[ "func", "(", "t", "*", "TextBar", ")", "HandleEvent", "(", "ev", "tcell", ".", "Event", ")", "bool", "{", "switch", "ev", ".", "(", "type", ")", "{", "case", "*", "EventWidgetContent", ":", "t", ".", "changed", "=", "true", "\n", "return", "true", "\n", "}", "\n", "return", "false", "\n", "}" ]
// HandleEvent handles incoming events. The only events handled are // those for the Text objects; when those change, the TextBar adjusts // the layout to accommodate.
[ "HandleEvent", "handles", "incoming", "events", ".", "The", "only", "events", "handled", "are", "those", "for", "the", "Text", "objects", ";", "when", "those", "change", "the", "TextBar", "adjusts", "the", "layout", "to", "accommodate", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/textbar.go#L179-L186
22,205
gdamore/tcell
color.go
Hex
func (c Color) Hex() int32 { if c&ColorIsRGB != 0 { return (int32(c) & 0xffffff) } if v, ok := ColorValues[c]; ok { return v } return -1 }
go
func (c Color) Hex() int32 { if c&ColorIsRGB != 0 { return (int32(c) & 0xffffff) } if v, ok := ColorValues[c]; ok { return v } return -1 }
[ "func", "(", "c", "Color", ")", "Hex", "(", ")", "int32", "{", "if", "c", "&", "ColorIsRGB", "!=", "0", "{", "return", "(", "int32", "(", "c", ")", "&", "0xffffff", ")", "\n", "}", "\n", "if", "v", ",", "ok", ":=", "ColorValues", "[", "c", "]", ";", "ok", "{", "return", "v", "\n", "}", "\n", "return", "-", "1", "\n", "}" ]
// Hex returns the color's hexadecimal RGB 24-bit value with each component // consisting of a single byte, ala R << 16 | G << 8 | B. If the color // is unknown or unset, -1 is returned.
[ "Hex", "returns", "the", "color", "s", "hexadecimal", "RGB", "24", "-", "bit", "value", "with", "each", "component", "consisting", "of", "a", "single", "byte", "ala", "R", "<<", "16", "|", "G", "<<", "8", "|", "B", ".", "If", "the", "color", "is", "unknown", "or", "unset", "-", "1", "is", "returned", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/color.go#L975-L983
22,206
gdamore/tcell
color.go
NewRGBColor
func NewRGBColor(r, g, b int32) Color { return NewHexColor(((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)) }
go
func NewRGBColor(r, g, b int32) Color { return NewHexColor(((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)) }
[ "func", "NewRGBColor", "(", "r", ",", "g", ",", "b", "int32", ")", "Color", "{", "return", "NewHexColor", "(", "(", "(", "r", "&", "0xff", ")", "<<", "16", ")", "|", "(", "(", "g", "&", "0xff", ")", "<<", "8", ")", "|", "(", "b", "&", "0xff", ")", ")", "\n", "}" ]
// NewRGBColor returns a new color with the given red, green, and blue values. // Each value must be represented in the range 0-255.
[ "NewRGBColor", "returns", "a", "new", "color", "with", "the", "given", "red", "green", "and", "blue", "values", ".", "Each", "value", "must", "be", "represented", "in", "the", "range", "0", "-", "255", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/color.go#L998-L1000
22,207
gdamore/tcell
cell.go
Invalidate
func (cb *CellBuffer) Invalidate() { for i := range cb.cells { cb.cells[i].lastMain = rune(0) } }
go
func (cb *CellBuffer) Invalidate() { for i := range cb.cells { cb.cells[i].lastMain = rune(0) } }
[ "func", "(", "cb", "*", "CellBuffer", ")", "Invalidate", "(", ")", "{", "for", "i", ":=", "range", "cb", ".", "cells", "{", "cb", ".", "cells", "[", "i", "]", ".", "lastMain", "=", "rune", "(", "0", ")", "\n", "}", "\n", "}" ]
// Invalidate marks all characters within the buffer as dirty.
[ "Invalidate", "marks", "all", "characters", "within", "the", "buffer", "as", "dirty", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/cell.go#L87-L91
22,208
gdamore/tcell
cell.go
Dirty
func (cb *CellBuffer) Dirty(x, y int) bool { if x >= 0 && y >= 0 && x < cb.w && y < cb.h { c := &cb.cells[(y*cb.w)+x] if c.lastMain == rune(0) { return true } if c.lastMain != c.currMain { return true } if c.lastStyle != c.currStyle { return true } if len(c.lastComb) != len(c.currComb) { return true } for i := range c.lastComb { if c.lastComb[i] != c.currComb[i] { return true } } } return false }
go
func (cb *CellBuffer) Dirty(x, y int) bool { if x >= 0 && y >= 0 && x < cb.w && y < cb.h { c := &cb.cells[(y*cb.w)+x] if c.lastMain == rune(0) { return true } if c.lastMain != c.currMain { return true } if c.lastStyle != c.currStyle { return true } if len(c.lastComb) != len(c.currComb) { return true } for i := range c.lastComb { if c.lastComb[i] != c.currComb[i] { return true } } } return false }
[ "func", "(", "cb", "*", "CellBuffer", ")", "Dirty", "(", "x", ",", "y", "int", ")", "bool", "{", "if", "x", ">=", "0", "&&", "y", ">=", "0", "&&", "x", "<", "cb", ".", "w", "&&", "y", "<", "cb", ".", "h", "{", "c", ":=", "&", "cb", ".", "cells", "[", "(", "y", "*", "cb", ".", "w", ")", "+", "x", "]", "\n", "if", "c", ".", "lastMain", "==", "rune", "(", "0", ")", "{", "return", "true", "\n", "}", "\n", "if", "c", ".", "lastMain", "!=", "c", ".", "currMain", "{", "return", "true", "\n", "}", "\n", "if", "c", ".", "lastStyle", "!=", "c", ".", "currStyle", "{", "return", "true", "\n", "}", "\n", "if", "len", "(", "c", ".", "lastComb", ")", "!=", "len", "(", "c", ".", "currComb", ")", "{", "return", "true", "\n", "}", "\n", "for", "i", ":=", "range", "c", ".", "lastComb", "{", "if", "c", ".", "lastComb", "[", "i", "]", "!=", "c", ".", "currComb", "[", "i", "]", "{", "return", "true", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// Dirty checks if a character at the given location needs an // to be refreshed on the physical display. This returns true // if the cell content is different since the last time it was // marked clean.
[ "Dirty", "checks", "if", "a", "character", "at", "the", "given", "location", "needs", "an", "to", "be", "refreshed", "on", "the", "physical", "display", ".", "This", "returns", "true", "if", "the", "cell", "content", "is", "different", "since", "the", "last", "time", "it", "was", "marked", "clean", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/cell.go#L97-L119
22,209
gdamore/tcell
cell.go
Resize
func (cb *CellBuffer) Resize(w, h int) { if cb.h == h && cb.w == w { return } newc := make([]cell, w*h) for y := 0; y < h && y < cb.h; y++ { for x := 0; x < w && x < cb.w; x++ { oc := &cb.cells[(y*cb.w)+x] nc := &newc[(y*w)+x] nc.currMain = oc.currMain nc.currComb = oc.currComb nc.currStyle = oc.currStyle nc.width = oc.width nc.lastMain = rune(0) } } cb.cells = newc cb.h = h cb.w = w }
go
func (cb *CellBuffer) Resize(w, h int) { if cb.h == h && cb.w == w { return } newc := make([]cell, w*h) for y := 0; y < h && y < cb.h; y++ { for x := 0; x < w && x < cb.w; x++ { oc := &cb.cells[(y*cb.w)+x] nc := &newc[(y*w)+x] nc.currMain = oc.currMain nc.currComb = oc.currComb nc.currStyle = oc.currStyle nc.width = oc.width nc.lastMain = rune(0) } } cb.cells = newc cb.h = h cb.w = w }
[ "func", "(", "cb", "*", "CellBuffer", ")", "Resize", "(", "w", ",", "h", "int", ")", "{", "if", "cb", ".", "h", "==", "h", "&&", "cb", ".", "w", "==", "w", "{", "return", "\n", "}", "\n\n", "newc", ":=", "make", "(", "[", "]", "cell", ",", "w", "*", "h", ")", "\n", "for", "y", ":=", "0", ";", "y", "<", "h", "&&", "y", "<", "cb", ".", "h", ";", "y", "++", "{", "for", "x", ":=", "0", ";", "x", "<", "w", "&&", "x", "<", "cb", ".", "w", ";", "x", "++", "{", "oc", ":=", "&", "cb", ".", "cells", "[", "(", "y", "*", "cb", ".", "w", ")", "+", "x", "]", "\n", "nc", ":=", "&", "newc", "[", "(", "y", "*", "w", ")", "+", "x", "]", "\n", "nc", ".", "currMain", "=", "oc", ".", "currMain", "\n", "nc", ".", "currComb", "=", "oc", ".", "currComb", "\n", "nc", ".", "currStyle", "=", "oc", ".", "currStyle", "\n", "nc", ".", "width", "=", "oc", ".", "width", "\n", "nc", ".", "lastMain", "=", "rune", "(", "0", ")", "\n", "}", "\n", "}", "\n", "cb", ".", "cells", "=", "newc", "\n", "cb", ".", "h", "=", "h", "\n", "cb", ".", "w", "=", "w", "\n", "}" ]
// Resize is used to resize the cells array, with different dimensions, // while preserving the original contents. The cells will be invalidated // so that they can be redrawn.
[ "Resize", "is", "used", "to", "resize", "the", "cells", "array", "with", "different", "dimensions", "while", "preserving", "the", "original", "contents", ".", "The", "cells", "will", "be", "invalidated", "so", "that", "they", "can", "be", "redrawn", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/cell.go#L143-L164
22,210
gdamore/tcell
cell.go
Fill
func (cb *CellBuffer) Fill(r rune, style Style) { for i := range cb.cells { c := &cb.cells[i] c.currMain = r c.currComb = nil c.currStyle = style c.width = 1 } }
go
func (cb *CellBuffer) Fill(r rune, style Style) { for i := range cb.cells { c := &cb.cells[i] c.currMain = r c.currComb = nil c.currStyle = style c.width = 1 } }
[ "func", "(", "cb", "*", "CellBuffer", ")", "Fill", "(", "r", "rune", ",", "style", "Style", ")", "{", "for", "i", ":=", "range", "cb", ".", "cells", "{", "c", ":=", "&", "cb", ".", "cells", "[", "i", "]", "\n", "c", ".", "currMain", "=", "r", "\n", "c", ".", "currComb", "=", "nil", "\n", "c", ".", "currStyle", "=", "style", "\n", "c", ".", "width", "=", "1", "\n", "}", "\n", "}" ]
// Fill fills the entire cell buffer array with the specified character // and style. Normally choose ' ' to clear the screen. This API doesn't // support combining characters, or characters with a width larger than one.
[ "Fill", "fills", "the", "entire", "cell", "buffer", "array", "with", "the", "specified", "character", "and", "style", ".", "Normally", "choose", "to", "clear", "the", "screen", ".", "This", "API", "doesn", "t", "support", "combining", "characters", "or", "characters", "with", "a", "width", "larger", "than", "one", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/cell.go#L169-L177
22,211
gdamore/tcell
views/widget.go
Watch
func (ww *WidgetWatchers) Watch(handler tcell.EventHandler) { if ww.watchers == nil { ww.watchers = make(map[tcell.EventHandler]struct{}) } ww.watchers[handler] = struct{}{} }
go
func (ww *WidgetWatchers) Watch(handler tcell.EventHandler) { if ww.watchers == nil { ww.watchers = make(map[tcell.EventHandler]struct{}) } ww.watchers[handler] = struct{}{} }
[ "func", "(", "ww", "*", "WidgetWatchers", ")", "Watch", "(", "handler", "tcell", ".", "EventHandler", ")", "{", "if", "ww", ".", "watchers", "==", "nil", "{", "ww", ".", "watchers", "=", "make", "(", "map", "[", "tcell", ".", "EventHandler", "]", "struct", "{", "}", ")", "\n", "}", "\n", "ww", ".", "watchers", "[", "handler", "]", "=", "struct", "{", "}", "{", "}", "\n", "}" ]
// Watch monitors this WidgetWatcher, causing the handler to be fired // with EventWidget as they are occur on the watched Widget.
[ "Watch", "monitors", "this", "WidgetWatcher", "causing", "the", "handler", "to", "be", "fired", "with", "EventWidget", "as", "they", "are", "occur", "on", "the", "watched", "Widget", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/widget.go#L93-L98
22,212
gdamore/tcell
views/widget.go
Unwatch
func (ww *WidgetWatchers) Unwatch(handler tcell.EventHandler) { if ww.watchers != nil { delete(ww.watchers, handler) } }
go
func (ww *WidgetWatchers) Unwatch(handler tcell.EventHandler) { if ww.watchers != nil { delete(ww.watchers, handler) } }
[ "func", "(", "ww", "*", "WidgetWatchers", ")", "Unwatch", "(", "handler", "tcell", ".", "EventHandler", ")", "{", "if", "ww", ".", "watchers", "!=", "nil", "{", "delete", "(", "ww", ".", "watchers", ",", "handler", ")", "\n", "}", "\n", "}" ]
// Unwatch stops monitoring this WidgetWatcher. The handler will no longer // be fired for Widget events.
[ "Unwatch", "stops", "monitoring", "this", "WidgetWatcher", ".", "The", "handler", "will", "no", "longer", "be", "fired", "for", "Widget", "events", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/widget.go#L102-L106
22,213
gdamore/tcell
views/widget.go
PostEvent
func (ww *WidgetWatchers) PostEvent(wev EventWidget) { for watcher := range ww.watchers { // Deliver events to all listeners, ignoring return value. watcher.HandleEvent(wev) } }
go
func (ww *WidgetWatchers) PostEvent(wev EventWidget) { for watcher := range ww.watchers { // Deliver events to all listeners, ignoring return value. watcher.HandleEvent(wev) } }
[ "func", "(", "ww", "*", "WidgetWatchers", ")", "PostEvent", "(", "wev", "EventWidget", ")", "{", "for", "watcher", ":=", "range", "ww", ".", "watchers", "{", "// Deliver events to all listeners, ignoring return value.", "watcher", ".", "HandleEvent", "(", "wev", ")", "\n", "}", "\n", "}" ]
// PostEvent delivers the EventWidget to all registered watchers. It is // to be called by the Widget implementation.
[ "PostEvent", "delivers", "the", "EventWidget", "to", "all", "registered", "watchers", ".", "It", "is", "to", "be", "called", "by", "the", "Widget", "implementation", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/widget.go#L110-L115
22,214
gdamore/tcell
views/widget.go
PostEventWidgetContent
func (ww *WidgetWatchers) PostEventWidgetContent(w Widget) { ev := &EventWidgetContent{} ev.SetWidget(w) ev.SetEventNow() ww.PostEvent(ev) }
go
func (ww *WidgetWatchers) PostEventWidgetContent(w Widget) { ev := &EventWidgetContent{} ev.SetWidget(w) ev.SetEventNow() ww.PostEvent(ev) }
[ "func", "(", "ww", "*", "WidgetWatchers", ")", "PostEventWidgetContent", "(", "w", "Widget", ")", "{", "ev", ":=", "&", "EventWidgetContent", "{", "}", "\n", "ev", ".", "SetWidget", "(", "w", ")", "\n", "ev", ".", "SetEventNow", "(", ")", "\n", "ww", ".", "PostEvent", "(", "ev", ")", "\n", "}" ]
// PostEventWidgetContent is called by the Widget when its content is // changed, delivering EventWidgetContent to all watchers.
[ "PostEventWidgetContent", "is", "called", "by", "the", "Widget", "when", "its", "content", "is", "changed", "delivering", "EventWidgetContent", "to", "all", "watchers", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/widget.go#L119-L124
22,215
gdamore/tcell
views/widget.go
PostEventWidgetResize
func (ww *WidgetWatchers) PostEventWidgetResize(w Widget) { ev := &EventWidgetResize{} ev.SetWidget(w) ev.SetEventNow() ww.PostEvent(ev) }
go
func (ww *WidgetWatchers) PostEventWidgetResize(w Widget) { ev := &EventWidgetResize{} ev.SetWidget(w) ev.SetEventNow() ww.PostEvent(ev) }
[ "func", "(", "ww", "*", "WidgetWatchers", ")", "PostEventWidgetResize", "(", "w", "Widget", ")", "{", "ev", ":=", "&", "EventWidgetResize", "{", "}", "\n", "ev", ".", "SetWidget", "(", "w", ")", "\n", "ev", ".", "SetEventNow", "(", ")", "\n", "ww", ".", "PostEvent", "(", "ev", ")", "\n", "}" ]
// PostEventWidgetResize is called by the Widget when the underlying View // has resized, delivering EventWidgetResize to all watchers.
[ "PostEventWidgetResize", "is", "called", "by", "the", "Widget", "when", "the", "underlying", "View", "has", "resized", "delivering", "EventWidgetResize", "to", "all", "watchers", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/widget.go#L128-L133
22,216
gdamore/tcell
views/widget.go
PostEventWidgetMove
func (ww *WidgetWatchers) PostEventWidgetMove(w Widget) { ev := &EventWidgetMove{} ev.SetWidget(w) ev.SetEventNow() ww.PostEvent(ev) }
go
func (ww *WidgetWatchers) PostEventWidgetMove(w Widget) { ev := &EventWidgetMove{} ev.SetWidget(w) ev.SetEventNow() ww.PostEvent(ev) }
[ "func", "(", "ww", "*", "WidgetWatchers", ")", "PostEventWidgetMove", "(", "w", "Widget", ")", "{", "ev", ":=", "&", "EventWidgetMove", "{", "}", "\n", "ev", ".", "SetWidget", "(", "w", ")", "\n", "ev", ".", "SetEventNow", "(", ")", "\n", "ww", ".", "PostEvent", "(", "ev", ")", "\n", "}" ]
// PostEventWidgetMove is called by the Widget when it is moved to a new // location, delivering EventWidgetMove to all watchers.
[ "PostEventWidgetMove", "is", "called", "by", "the", "Widget", "when", "it", "is", "moved", "to", "a", "new", "location", "delivering", "EventWidgetMove", "to", "all", "watchers", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/widget.go#L137-L142
22,217
gdamore/tcell
views/textarea.go
SetLines
func (ta *TextArea) SetLines(lines []string) { ta.Init() m := ta.model m.width = 0 m.height = len(lines) m.lines = append([]string{}, lines...) for _, l := range lines { if len(l) > m.width { m.width = len(l) } } ta.CellView.SetModel(m) }
go
func (ta *TextArea) SetLines(lines []string) { ta.Init() m := ta.model m.width = 0 m.height = len(lines) m.lines = append([]string{}, lines...) for _, l := range lines { if len(l) > m.width { m.width = len(l) } } ta.CellView.SetModel(m) }
[ "func", "(", "ta", "*", "TextArea", ")", "SetLines", "(", "lines", "[", "]", "string", ")", "{", "ta", ".", "Init", "(", ")", "\n", "m", ":=", "ta", ".", "model", "\n", "m", ".", "width", "=", "0", "\n", "m", ".", "height", "=", "len", "(", "lines", ")", "\n", "m", ".", "lines", "=", "append", "(", "[", "]", "string", "{", "}", ",", "lines", "...", ")", "\n", "for", "_", ",", "l", ":=", "range", "lines", "{", "if", "len", "(", "l", ")", ">", "m", ".", "width", "{", "m", ".", "width", "=", "len", "(", "l", ")", "\n", "}", "\n", "}", "\n", "ta", ".", "CellView", ".", "SetModel", "(", "m", ")", "\n", "}" ]
// SetLines sets the content text to display.
[ "SetLines", "sets", "the", "content", "text", "to", "display", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/textarea.go#L91-L103
22,218
gdamore/tcell
views/textarea.go
EnableCursor
func (ta *TextArea) EnableCursor(on bool) { ta.Init() ta.model.cursor = on }
go
func (ta *TextArea) EnableCursor(on bool) { ta.Init() ta.model.cursor = on }
[ "func", "(", "ta", "*", "TextArea", ")", "EnableCursor", "(", "on", "bool", ")", "{", "ta", ".", "Init", "(", ")", "\n", "ta", ".", "model", ".", "cursor", "=", "on", "\n", "}" ]
// EnableCursor enables a soft cursor in the TextArea.
[ "EnableCursor", "enables", "a", "soft", "cursor", "in", "the", "TextArea", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/textarea.go#L111-L114
22,219
gdamore/tcell
views/textarea.go
HideCursor
func (ta *TextArea) HideCursor(on bool) { ta.Init() ta.model.hide = on }
go
func (ta *TextArea) HideCursor(on bool) { ta.Init() ta.model.hide = on }
[ "func", "(", "ta", "*", "TextArea", ")", "HideCursor", "(", "on", "bool", ")", "{", "ta", ".", "Init", "(", ")", "\n", "ta", ".", "model", ".", "hide", "=", "on", "\n", "}" ]
// HideCursor hides or shows the cursor in the TextArea. // If on is true, the cursor is hidden. Note that a cursor is only // shown if it is enabled.
[ "HideCursor", "hides", "or", "shows", "the", "cursor", "in", "the", "TextArea", ".", "If", "on", "is", "true", "the", "cursor", "is", "hidden", ".", "Note", "that", "a", "cursor", "is", "only", "shown", "if", "it", "is", "enabled", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/textarea.go#L119-L122
22,220
gdamore/tcell
views/textarea.go
SetContent
func (ta *TextArea) SetContent(text string) { ta.Init() lines := strings.Split(strings.Trim(text, "\n"), "\n") ta.SetLines(lines) }
go
func (ta *TextArea) SetContent(text string) { ta.Init() lines := strings.Split(strings.Trim(text, "\n"), "\n") ta.SetLines(lines) }
[ "func", "(", "ta", "*", "TextArea", ")", "SetContent", "(", "text", "string", ")", "{", "ta", ".", "Init", "(", ")", "\n", "lines", ":=", "strings", ".", "Split", "(", "strings", ".", "Trim", "(", "text", ",", "\"", "\\n", "\"", ")", ",", "\"", "\\n", "\"", ")", "\n", "ta", ".", "SetLines", "(", "lines", ")", "\n", "}" ]
// SetContent is used to set the textual content, passed as a // single string. Lines within the string are delimited by newlines.
[ "SetContent", "is", "used", "to", "set", "the", "textual", "content", "passed", "as", "a", "single", "string", ".", "Lines", "within", "the", "string", "are", "delimited", "by", "newlines", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/textarea.go#L126-L130
22,221
gdamore/tcell
views/textarea.go
Init
func (ta *TextArea) Init() { ta.once.Do(func() { lm := &linesModel{lines: []string{}, width: 0} ta.model = lm ta.CellView.Init() ta.CellView.SetModel(lm) }) }
go
func (ta *TextArea) Init() { ta.once.Do(func() { lm := &linesModel{lines: []string{}, width: 0} ta.model = lm ta.CellView.Init() ta.CellView.SetModel(lm) }) }
[ "func", "(", "ta", "*", "TextArea", ")", "Init", "(", ")", "{", "ta", ".", "once", ".", "Do", "(", "func", "(", ")", "{", "lm", ":=", "&", "linesModel", "{", "lines", ":", "[", "]", "string", "{", "}", ",", "width", ":", "0", "}", "\n", "ta", ".", "model", "=", "lm", "\n", "ta", ".", "CellView", ".", "Init", "(", ")", "\n", "ta", ".", "CellView", ".", "SetModel", "(", "lm", ")", "\n", "}", ")", "\n", "}" ]
// Init initializes the TextArea.
[ "Init", "initializes", "the", "TextArea", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/textarea.go#L133-L140
22,222
gdamore/tcell
views/text.go
calcY
func (t *Text) calcY(height int) int { if t.align&VAlignCenter != 0 { return (height - len(t.lengths)) / 2 } if t.align&VAlignBottom != 0 { return height - len(t.lengths) } return 0 }
go
func (t *Text) calcY(height int) int { if t.align&VAlignCenter != 0 { return (height - len(t.lengths)) / 2 } if t.align&VAlignBottom != 0 { return height - len(t.lengths) } return 0 }
[ "func", "(", "t", "*", "Text", ")", "calcY", "(", "height", "int", ")", "int", "{", "if", "t", ".", "align", "&", "VAlignCenter", "!=", "0", "{", "return", "(", "height", "-", "len", "(", "t", ".", "lengths", ")", ")", "/", "2", "\n", "}", "\n", "if", "t", ".", "align", "&", "VAlignBottom", "!=", "0", "{", "return", "height", "-", "len", "(", "t", ".", "lengths", ")", "\n", "}", "\n", "return", "0", "\n", "}" ]
// calcY figures the initial Y offset. Alignment is top by default.
[ "calcY", "figures", "the", "initial", "Y", "offset", ".", "Alignment", "is", "top", "by", "default", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/text.go#L51-L59
22,223
gdamore/tcell
views/text.go
calcX
func (t *Text) calcX(width, line int) int { if t.align&HAlignCenter != 0 { return (width - t.lengths[line]) / 2 } if t.align&HAlignRight != 0 { return width - t.lengths[line] } return 0 }
go
func (t *Text) calcX(width, line int) int { if t.align&HAlignCenter != 0 { return (width - t.lengths[line]) / 2 } if t.align&HAlignRight != 0 { return width - t.lengths[line] } return 0 }
[ "func", "(", "t", "*", "Text", ")", "calcX", "(", "width", ",", "line", "int", ")", "int", "{", "if", "t", ".", "align", "&", "HAlignCenter", "!=", "0", "{", "return", "(", "width", "-", "t", ".", "lengths", "[", "line", "]", ")", "/", "2", "\n", "}", "\n", "if", "t", ".", "align", "&", "HAlignRight", "!=", "0", "{", "return", "width", "-", "t", ".", "lengths", "[", "line", "]", "\n", "}", "\n", "return", "0", "\n", "}" ]
// calcX figures the initial X offset for the given line. // Alignment is left by default.
[ "calcX", "figures", "the", "initial", "X", "offset", "for", "the", "given", "line", ".", "Alignment", "is", "left", "by", "default", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/text.go#L63-L71
22,224
gdamore/tcell
views/text.go
Draw
func (t *Text) Draw() { v := t.view if v == nil { return } width, height := v.Size() if width == 0 || height == 0 { return } t.clear() // Note that we might wind up with a negative X if the width // is larger than the length. That's OK, and correct even. // The view will clip it properly in that case. // We align to the left & top by default. y := t.calcY(height) r := rune(0) w := 0 x := 0 var styl tcell.Style var comb []rune line := 0 newline := true for i, l := range t.text { if newline { x = t.calcX(width, line) newline = false } if l == '\n' { if w != 0 { v.SetContent(x, y, r, comb, styl) } newline = true w = 0 comb = nil line++ y++ continue } if t.widths[i] == 0 { comb = append(comb, l) continue } if w != 0 { v.SetContent(x, y, r, comb, styl) x += w } r = l w = t.widths[i] styl = t.styles[i] comb = nil } if w != 0 { v.SetContent(x, y, r, comb, styl) } }
go
func (t *Text) Draw() { v := t.view if v == nil { return } width, height := v.Size() if width == 0 || height == 0 { return } t.clear() // Note that we might wind up with a negative X if the width // is larger than the length. That's OK, and correct even. // The view will clip it properly in that case. // We align to the left & top by default. y := t.calcY(height) r := rune(0) w := 0 x := 0 var styl tcell.Style var comb []rune line := 0 newline := true for i, l := range t.text { if newline { x = t.calcX(width, line) newline = false } if l == '\n' { if w != 0 { v.SetContent(x, y, r, comb, styl) } newline = true w = 0 comb = nil line++ y++ continue } if t.widths[i] == 0 { comb = append(comb, l) continue } if w != 0 { v.SetContent(x, y, r, comb, styl) x += w } r = l w = t.widths[i] styl = t.styles[i] comb = nil } if w != 0 { v.SetContent(x, y, r, comb, styl) } }
[ "func", "(", "t", "*", "Text", ")", "Draw", "(", ")", "{", "v", ":=", "t", ".", "view", "\n", "if", "v", "==", "nil", "{", "return", "\n", "}", "\n\n", "width", ",", "height", ":=", "v", ".", "Size", "(", ")", "\n", "if", "width", "==", "0", "||", "height", "==", "0", "{", "return", "\n", "}", "\n\n", "t", ".", "clear", "(", ")", "\n\n", "// Note that we might wind up with a negative X if the width", "// is larger than the length. That's OK, and correct even.", "// The view will clip it properly in that case.", "// We align to the left & top by default.", "y", ":=", "t", ".", "calcY", "(", "height", ")", "\n", "r", ":=", "rune", "(", "0", ")", "\n", "w", ":=", "0", "\n", "x", ":=", "0", "\n", "var", "styl", "tcell", ".", "Style", "\n", "var", "comb", "[", "]", "rune", "\n", "line", ":=", "0", "\n", "newline", ":=", "true", "\n", "for", "i", ",", "l", ":=", "range", "t", ".", "text", "{", "if", "newline", "{", "x", "=", "t", ".", "calcX", "(", "width", ",", "line", ")", "\n", "newline", "=", "false", "\n", "}", "\n", "if", "l", "==", "'\\n'", "{", "if", "w", "!=", "0", "{", "v", ".", "SetContent", "(", "x", ",", "y", ",", "r", ",", "comb", ",", "styl", ")", "\n", "}", "\n", "newline", "=", "true", "\n", "w", "=", "0", "\n", "comb", "=", "nil", "\n", "line", "++", "\n", "y", "++", "\n", "continue", "\n", "}", "\n", "if", "t", ".", "widths", "[", "i", "]", "==", "0", "{", "comb", "=", "append", "(", "comb", ",", "l", ")", "\n", "continue", "\n", "}", "\n", "if", "w", "!=", "0", "{", "v", ".", "SetContent", "(", "x", ",", "y", ",", "r", ",", "comb", ",", "styl", ")", "\n", "x", "+=", "w", "\n", "}", "\n", "r", "=", "l", "\n", "w", "=", "t", ".", "widths", "[", "i", "]", "\n", "styl", "=", "t", ".", "styles", "[", "i", "]", "\n", "comb", "=", "nil", "\n", "}", "\n", "if", "w", "!=", "0", "{", "v", ".", "SetContent", "(", "x", ",", "y", ",", "r", ",", "comb", ",", "styl", ")", "\n", "}", "\n", "}" ]
// Draw draws the Text.
[ "Draw", "draws", "the", "Text", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/text.go#L74-L133
22,225
gdamore/tcell
views/text.go
Size
func (t *Text) Size() (int, int) { if len(t.text) != 0 { return t.width, t.height } return 0, 0 }
go
func (t *Text) Size() (int, int) { if len(t.text) != 0 { return t.width, t.height } return 0, 0 }
[ "func", "(", "t", "*", "Text", ")", "Size", "(", ")", "(", "int", ",", "int", ")", "{", "if", "len", "(", "t", ".", "text", ")", "!=", "0", "{", "return", "t", ".", "width", ",", "t", ".", "height", "\n", "}", "\n", "return", "0", ",", "0", "\n", "}" ]
// Size returns the width and height in character cells of the Text.
[ "Size", "returns", "the", "width", "and", "height", "in", "character", "cells", "of", "the", "Text", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/text.go#L136-L141
22,226
gdamore/tcell
views/text.go
SetAlignment
func (t *Text) SetAlignment(align Alignment) { if align != t.align { t.align = align t.PostEventWidgetContent(t) } }
go
func (t *Text) SetAlignment(align Alignment) { if align != t.align { t.align = align t.PostEventWidgetContent(t) } }
[ "func", "(", "t", "*", "Text", ")", "SetAlignment", "(", "align", "Alignment", ")", "{", "if", "align", "!=", "t", ".", "align", "{", "t", ".", "align", "=", "align", "\n", "t", ".", "PostEventWidgetContent", "(", "t", ")", "\n", "}", "\n", "}" ]
// SetAlignment sets the alignment. Negative values // indicate right justification, positive values are left, // and zero indicates center aligned.
[ "SetAlignment", "sets", "the", "alignment", ".", "Negative", "values", "indicate", "right", "justification", "positive", "values", "are", "left", "and", "zero", "indicates", "center", "aligned", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/text.go#L146-L151
22,227
gdamore/tcell
views/text.go
SetText
func (t *Text) SetText(s string) { t.width = 0 t.text = []rune(s) if len(t.widths) < len(t.text) { t.widths = make([]int, len(t.text)) } else { t.widths = t.widths[0:len(t.text)] } if len(t.styles) < len(t.text) { t.styles = make([]tcell.Style, len(t.text)) } else { t.styles = t.styles[0:len(t.text)] } t.lengths = []int{} length := 0 for i, r := range t.text { t.widths[i] = runewidth.RuneWidth(r) t.styles[i] = t.style if r == '\n' { t.lengths = append(t.lengths, length) if length > t.width { t.width = length length = 0 } } else if t.widths[i] == 0 && length == 0 { // If first character on line is combining, inject // a leading space. (Shame on the caller!) t.widths = append(t.widths, 0) copy(t.widths[i+1:], t.widths[i:]) t.widths[i] = 1 t.text = append(t.text, ' ') copy(t.text[i+1:], t.text[i:]) t.text[i] = ' ' t.styles = append(t.styles, t.style) copy(t.styles[i+1:], t.styles[i:]) t.styles[i] = t.style length++ } else { length += t.widths[i] } } if length > 0 { t.lengths = append(t.lengths, length) if length > t.width { t.width = length } } t.height = len(t.lengths) t.PostEventWidgetContent(t) }
go
func (t *Text) SetText(s string) { t.width = 0 t.text = []rune(s) if len(t.widths) < len(t.text) { t.widths = make([]int, len(t.text)) } else { t.widths = t.widths[0:len(t.text)] } if len(t.styles) < len(t.text) { t.styles = make([]tcell.Style, len(t.text)) } else { t.styles = t.styles[0:len(t.text)] } t.lengths = []int{} length := 0 for i, r := range t.text { t.widths[i] = runewidth.RuneWidth(r) t.styles[i] = t.style if r == '\n' { t.lengths = append(t.lengths, length) if length > t.width { t.width = length length = 0 } } else if t.widths[i] == 0 && length == 0 { // If first character on line is combining, inject // a leading space. (Shame on the caller!) t.widths = append(t.widths, 0) copy(t.widths[i+1:], t.widths[i:]) t.widths[i] = 1 t.text = append(t.text, ' ') copy(t.text[i+1:], t.text[i:]) t.text[i] = ' ' t.styles = append(t.styles, t.style) copy(t.styles[i+1:], t.styles[i:]) t.styles[i] = t.style length++ } else { length += t.widths[i] } } if length > 0 { t.lengths = append(t.lengths, length) if length > t.width { t.width = length } } t.height = len(t.lengths) t.PostEventWidgetContent(t) }
[ "func", "(", "t", "*", "Text", ")", "SetText", "(", "s", "string", ")", "{", "t", ".", "width", "=", "0", "\n", "t", ".", "text", "=", "[", "]", "rune", "(", "s", ")", "\n", "if", "len", "(", "t", ".", "widths", ")", "<", "len", "(", "t", ".", "text", ")", "{", "t", ".", "widths", "=", "make", "(", "[", "]", "int", ",", "len", "(", "t", ".", "text", ")", ")", "\n", "}", "else", "{", "t", ".", "widths", "=", "t", ".", "widths", "[", "0", ":", "len", "(", "t", ".", "text", ")", "]", "\n", "}", "\n", "if", "len", "(", "t", ".", "styles", ")", "<", "len", "(", "t", ".", "text", ")", "{", "t", ".", "styles", "=", "make", "(", "[", "]", "tcell", ".", "Style", ",", "len", "(", "t", ".", "text", ")", ")", "\n", "}", "else", "{", "t", ".", "styles", "=", "t", ".", "styles", "[", "0", ":", "len", "(", "t", ".", "text", ")", "]", "\n", "}", "\n", "t", ".", "lengths", "=", "[", "]", "int", "{", "}", "\n", "length", ":=", "0", "\n", "for", "i", ",", "r", ":=", "range", "t", ".", "text", "{", "t", ".", "widths", "[", "i", "]", "=", "runewidth", ".", "RuneWidth", "(", "r", ")", "\n", "t", ".", "styles", "[", "i", "]", "=", "t", ".", "style", "\n", "if", "r", "==", "'\\n'", "{", "t", ".", "lengths", "=", "append", "(", "t", ".", "lengths", ",", "length", ")", "\n", "if", "length", ">", "t", ".", "width", "{", "t", ".", "width", "=", "length", "\n", "length", "=", "0", "\n", "}", "\n\n", "}", "else", "if", "t", ".", "widths", "[", "i", "]", "==", "0", "&&", "length", "==", "0", "{", "// If first character on line is combining, inject", "// a leading space. (Shame on the caller!)", "t", ".", "widths", "=", "append", "(", "t", ".", "widths", ",", "0", ")", "\n", "copy", "(", "t", ".", "widths", "[", "i", "+", "1", ":", "]", ",", "t", ".", "widths", "[", "i", ":", "]", ")", "\n", "t", ".", "widths", "[", "i", "]", "=", "1", "\n\n", "t", ".", "text", "=", "append", "(", "t", ".", "text", ",", "' '", ")", "\n", "copy", "(", "t", ".", "text", "[", "i", "+", "1", ":", "]", ",", "t", ".", "text", "[", "i", ":", "]", ")", "\n", "t", ".", "text", "[", "i", "]", "=", "' '", "\n\n", "t", ".", "styles", "=", "append", "(", "t", ".", "styles", ",", "t", ".", "style", ")", "\n", "copy", "(", "t", ".", "styles", "[", "i", "+", "1", ":", "]", ",", "t", ".", "styles", "[", "i", ":", "]", ")", "\n", "t", ".", "styles", "[", "i", "]", "=", "t", ".", "style", "\n", "length", "++", "\n", "}", "else", "{", "length", "+=", "t", ".", "widths", "[", "i", "]", "\n", "}", "\n", "}", "\n", "if", "length", ">", "0", "{", "t", ".", "lengths", "=", "append", "(", "t", ".", "lengths", ",", "length", ")", "\n", "if", "length", ">", "t", ".", "width", "{", "t", ".", "width", "=", "length", "\n", "}", "\n", "}", "\n", "t", ".", "height", "=", "len", "(", "t", ".", "lengths", ")", "\n", "t", ".", "PostEventWidgetContent", "(", "t", ")", "\n", "}" ]
// SetText sets the text used for the string. Any previously set // styles on individual rune indices are reset, and the default style // for the widget is set.
[ "SetText", "sets", "the", "text", "used", "for", "the", "string", ".", "Any", "previously", "set", "styles", "on", "individual", "rune", "indices", "are", "reset", "and", "the", "default", "style", "for", "the", "widget", "is", "set", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/text.go#L171-L223
22,228
gdamore/tcell
views/text.go
SetStyle
func (t *Text) SetStyle(style tcell.Style) { t.style = style for i := 0; i < len(t.text); i++ { if t.widths[i] != 0 { t.styles[i] = t.style } } t.PostEventWidgetContent(t) }
go
func (t *Text) SetStyle(style tcell.Style) { t.style = style for i := 0; i < len(t.text); i++ { if t.widths[i] != 0 { t.styles[i] = t.style } } t.PostEventWidgetContent(t) }
[ "func", "(", "t", "*", "Text", ")", "SetStyle", "(", "style", "tcell", ".", "Style", ")", "{", "t", ".", "style", "=", "style", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "t", ".", "text", ")", ";", "i", "++", "{", "if", "t", ".", "widths", "[", "i", "]", "!=", "0", "{", "t", ".", "styles", "[", "i", "]", "=", "t", ".", "style", "\n", "}", "\n", "}", "\n", "t", ".", "PostEventWidgetContent", "(", "t", ")", "\n", "}" ]
// SetStyle sets the style used. This applies to every cell in the // in the text.
[ "SetStyle", "sets", "the", "style", "used", ".", "This", "applies", "to", "every", "cell", "in", "the", "in", "the", "text", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/text.go#L232-L240
22,229
gdamore/tcell
views/text.go
StyleAt
func (t *Text) StyleAt(pos int) tcell.Style { if pos < 0 || pos >= len(t.text) || t.widths[pos] < 1 { return tcell.StyleDefault } return t.styles[pos] }
go
func (t *Text) StyleAt(pos int) tcell.Style { if pos < 0 || pos >= len(t.text) || t.widths[pos] < 1 { return tcell.StyleDefault } return t.styles[pos] }
[ "func", "(", "t", "*", "Text", ")", "StyleAt", "(", "pos", "int", ")", "tcell", ".", "Style", "{", "if", "pos", "<", "0", "||", "pos", ">=", "len", "(", "t", ".", "text", ")", "||", "t", ".", "widths", "[", "pos", "]", "<", "1", "{", "return", "tcell", ".", "StyleDefault", "\n", "}", "\n", "return", "t", ".", "styles", "[", "pos", "]", "\n", "}" ]
// StyleAt gets the style at the given rune index. If an invalid // index is given, or the index is a combining character, then // tcell.StyleDefault is returned.
[ "StyleAt", "gets", "the", "style", "at", "the", "given", "rune", "index", ".", "If", "an", "invalid", "index", "is", "given", "or", "the", "index", "is", "a", "combining", "character", "then", "tcell", ".", "StyleDefault", "is", "returned", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/text.go#L264-L269
22,230
gdamore/tcell
views/sstextbar.go
SetCenter
func (s *SimpleStyledTextBar) SetCenter(m string) { s.initialize() s.center.SetMarkup(m) }
go
func (s *SimpleStyledTextBar) SetCenter(m string) { s.initialize() s.center.SetMarkup(m) }
[ "func", "(", "s", "*", "SimpleStyledTextBar", ")", "SetCenter", "(", "m", "string", ")", "{", "s", ".", "initialize", "(", ")", "\n", "s", ".", "center", ".", "SetMarkup", "(", "m", ")", "\n", "}" ]
// SetCenter sets the center text for the textbar. // It is always centered.
[ "SetCenter", "sets", "the", "center", "text", "for", "the", "textbar", ".", "It", "is", "always", "centered", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/sstextbar.go#L53-L56
22,231
gdamore/tcell
termbox/compat.go
Init
func Init() error { outMode = OutputNormal if s, e := tcell.NewScreen(); e != nil { return e } else if e = s.Init(); e != nil { return e } else { screen = s return nil } }
go
func Init() error { outMode = OutputNormal if s, e := tcell.NewScreen(); e != nil { return e } else if e = s.Init(); e != nil { return e } else { screen = s return nil } }
[ "func", "Init", "(", ")", "error", "{", "outMode", "=", "OutputNormal", "\n", "if", "s", ",", "e", ":=", "tcell", ".", "NewScreen", "(", ")", ";", "e", "!=", "nil", "{", "return", "e", "\n", "}", "else", "if", "e", "=", "s", ".", "Init", "(", ")", ";", "e", "!=", "nil", "{", "return", "e", "\n", "}", "else", "{", "screen", "=", "s", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Init initializes the screen for use.
[ "Init", "initializes", "the", "screen", "for", "use", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/termbox/compat.go#L29-L39
22,232
gdamore/tcell
termbox/compat.go
Clear
func Clear(fg, bg Attribute) { st := mkStyle(fg, bg) w, h := screen.Size() for row := 0; row < h; row++ { for col := 0; col < w; col++ { screen.SetContent(col, row, ' ', nil, st) } } }
go
func Clear(fg, bg Attribute) { st := mkStyle(fg, bg) w, h := screen.Size() for row := 0; row < h; row++ { for col := 0; col < w; col++ { screen.SetContent(col, row, ' ', nil, st) } } }
[ "func", "Clear", "(", "fg", ",", "bg", "Attribute", ")", "{", "st", ":=", "mkStyle", "(", "fg", ",", "bg", ")", "\n", "w", ",", "h", ":=", "screen", ".", "Size", "(", ")", "\n", "for", "row", ":=", "0", ";", "row", "<", "h", ";", "row", "++", "{", "for", "col", ":=", "0", ";", "col", "<", "w", ";", "col", "++", "{", "screen", ".", "SetContent", "(", "col", ",", "row", ",", "' '", ",", "nil", ",", "st", ")", "\n", "}", "\n", "}", "\n", "}" ]
// Clear clears the screen with the given attributes.
[ "Clear", "clears", "the", "screen", "with", "the", "given", "attributes", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/termbox/compat.go#L134-L142
22,233
gdamore/tcell
termbox/compat.go
SetOutputMode
func SetOutputMode(mode OutputMode) OutputMode { if screen.Colors() < 256 { mode = OutputNormal } switch mode { case OutputCurrent: return outMode case OutputNormal, Output256, Output216, OutputGrayscale: outMode = mode return mode default: return outMode } }
go
func SetOutputMode(mode OutputMode) OutputMode { if screen.Colors() < 256 { mode = OutputNormal } switch mode { case OutputCurrent: return outMode case OutputNormal, Output256, Output216, OutputGrayscale: outMode = mode return mode default: return outMode } }
[ "func", "SetOutputMode", "(", "mode", "OutputMode", ")", "OutputMode", "{", "if", "screen", ".", "Colors", "(", ")", "<", "256", "{", "mode", "=", "OutputNormal", "\n", "}", "\n", "switch", "mode", "{", "case", "OutputCurrent", ":", "return", "outMode", "\n", "case", "OutputNormal", ",", "Output256", ",", "Output216", ",", "OutputGrayscale", ":", "outMode", "=", "mode", "\n", "return", "mode", "\n", "default", ":", "return", "outMode", "\n", "}", "\n", "}" ]
// SetOutputMode is used to set the color palette used.
[ "SetOutputMode", "is", "used", "to", "set", "the", "color", "palette", "used", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/termbox/compat.go#L175-L188
22,234
gdamore/tcell
termbox/compat.go
ParseEvent
func ParseEvent(data []byte) Event { // Not supported return Event{Type: EventError, Err: errors.New("no raw events")} }
go
func ParseEvent(data []byte) Event { // Not supported return Event{Type: EventError, Err: errors.New("no raw events")} }
[ "func", "ParseEvent", "(", "data", "[", "]", "byte", ")", "Event", "{", "// Not supported", "return", "Event", "{", "Type", ":", "EventError", ",", "Err", ":", "errors", ".", "New", "(", "\"", "\"", ")", "}", "\n", "}" ]
// ParseEvent is not supported.
[ "ParseEvent", "is", "not", "supported", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/termbox/compat.go#L332-L335
22,235
gdamore/tcell
errors.go
NewEventError
func NewEventError(err error) *EventError { return &EventError{t: time.Now(), err: err} }
go
func NewEventError(err error) *EventError { return &EventError{t: time.Now(), err: err} }
[ "func", "NewEventError", "(", "err", "error", ")", "*", "EventError", "{", "return", "&", "EventError", "{", "t", ":", "time", ".", "Now", "(", ")", ",", "err", ":", "err", "}", "\n", "}" ]
// NewEventError creates an ErrorEvent with the given error payload.
[ "NewEventError", "creates", "an", "ErrorEvent", "with", "the", "given", "error", "payload", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/errors.go#L71-L73
22,236
gdamore/tcell
style.go
Foreground
func (s Style) Foreground(c Color) Style { if c == ColorDefault { return (s &^ (0x1ffffff00000000 | styleFgSet)) } return (s &^ Style(0x1ffffff00000000)) | ((Style(c) & 0x1ffffff) << 32) | styleFgSet }
go
func (s Style) Foreground(c Color) Style { if c == ColorDefault { return (s &^ (0x1ffffff00000000 | styleFgSet)) } return (s &^ Style(0x1ffffff00000000)) | ((Style(c) & 0x1ffffff) << 32) | styleFgSet }
[ "func", "(", "s", "Style", ")", "Foreground", "(", "c", "Color", ")", "Style", "{", "if", "c", "==", "ColorDefault", "{", "return", "(", "s", "&^", "(", "0x1ffffff00000000", "|", "styleFgSet", ")", ")", "\n", "}", "\n", "return", "(", "s", "&^", "Style", "(", "0x1ffffff00000000", ")", ")", "|", "(", "(", "Style", "(", "c", ")", "&", "0x1ffffff", ")", "<<", "32", ")", "|", "styleFgSet", "\n", "}" ]
// Foreground returns a new style based on s, with the foreground color set // as requested. ColorDefault can be used to select the global default.
[ "Foreground", "returns", "a", "new", "style", "based", "on", "s", "with", "the", "foreground", "color", "set", "as", "requested", ".", "ColorDefault", "can", "be", "used", "to", "select", "the", "global", "default", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/style.go#L50-L56
22,237
gdamore/tcell
style.go
Background
func (s Style) Background(c Color) Style { if c == ColorDefault { return (s &^ (0x1ffffff | styleBgSet)) } return (s &^ (0x1ffffff)) | (Style(c) & 0x1ffffff) | styleBgSet }
go
func (s Style) Background(c Color) Style { if c == ColorDefault { return (s &^ (0x1ffffff | styleBgSet)) } return (s &^ (0x1ffffff)) | (Style(c) & 0x1ffffff) | styleBgSet }
[ "func", "(", "s", "Style", ")", "Background", "(", "c", "Color", ")", "Style", "{", "if", "c", "==", "ColorDefault", "{", "return", "(", "s", "&^", "(", "0x1ffffff", "|", "styleBgSet", ")", ")", "\n", "}", "\n", "return", "(", "s", "&^", "(", "0x1ffffff", ")", ")", "|", "(", "Style", "(", "c", ")", "&", "0x1ffffff", ")", "|", "styleBgSet", "\n", "}" ]
// Background returns a new style based on s, with the background color set // as requested. ColorDefault can be used to select the global default.
[ "Background", "returns", "a", "new", "style", "based", "on", "s", "with", "the", "background", "color", "set", "as", "requested", ".", "ColorDefault", "can", "be", "used", "to", "select", "the", "global", "default", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/style.go#L60-L65
22,238
gdamore/tcell
style.go
Decompose
func (s Style) Decompose() (fg Color, bg Color, attr AttrMask) { if s&styleFgSet != 0 { fg = Color(s>>32) & 0x1ffffff } else { fg = ColorDefault } if s&styleBgSet != 0 { bg = Color(s & 0x1ffffff) } else { bg = ColorDefault } attr = AttrMask(s) & attrAll return fg, bg, attr }
go
func (s Style) Decompose() (fg Color, bg Color, attr AttrMask) { if s&styleFgSet != 0 { fg = Color(s>>32) & 0x1ffffff } else { fg = ColorDefault } if s&styleBgSet != 0 { bg = Color(s & 0x1ffffff) } else { bg = ColorDefault } attr = AttrMask(s) & attrAll return fg, bg, attr }
[ "func", "(", "s", "Style", ")", "Decompose", "(", ")", "(", "fg", "Color", ",", "bg", "Color", ",", "attr", "AttrMask", ")", "{", "if", "s", "&", "styleFgSet", "!=", "0", "{", "fg", "=", "Color", "(", "s", ">>", "32", ")", "&", "0x1ffffff", "\n", "}", "else", "{", "fg", "=", "ColorDefault", "\n", "}", "\n", "if", "s", "&", "styleBgSet", "!=", "0", "{", "bg", "=", "Color", "(", "s", "&", "0x1ffffff", ")", "\n", "}", "else", "{", "bg", "=", "ColorDefault", "\n", "}", "\n", "attr", "=", "AttrMask", "(", "s", ")", "&", "attrAll", "\n\n", "return", "fg", ",", "bg", ",", "attr", "\n", "}" ]
// Decompose breaks a style up, returning the foreground, background, // and other attributes.
[ "Decompose", "breaks", "a", "style", "up", "returning", "the", "foreground", "background", "and", "other", "attributes", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/style.go#L69-L83
22,239
gdamore/tcell
style.go
Bold
func (s Style) Bold(on bool) Style { return s.setAttrs(Style(AttrBold), on) }
go
func (s Style) Bold(on bool) Style { return s.setAttrs(Style(AttrBold), on) }
[ "func", "(", "s", "Style", ")", "Bold", "(", "on", "bool", ")", "Style", "{", "return", "s", ".", "setAttrs", "(", "Style", "(", "AttrBold", ")", ",", "on", ")", "\n", "}" ]
// Bold returns a new style based on s, with the bold attribute set // as requested.
[ "Bold", "returns", "a", "new", "style", "based", "on", "s", "with", "the", "bold", "attribute", "set", "as", "requested", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/style.go#L99-L101
22,240
gdamore/tcell
style.go
Blink
func (s Style) Blink(on bool) Style { return s.setAttrs(Style(AttrBlink), on) }
go
func (s Style) Blink(on bool) Style { return s.setAttrs(Style(AttrBlink), on) }
[ "func", "(", "s", "Style", ")", "Blink", "(", "on", "bool", ")", "Style", "{", "return", "s", ".", "setAttrs", "(", "Style", "(", "AttrBlink", ")", ",", "on", ")", "\n", "}" ]
// Blink returns a new style based on s, with the blink attribute set // as requested.
[ "Blink", "returns", "a", "new", "style", "based", "on", "s", "with", "the", "blink", "attribute", "set", "as", "requested", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/style.go#L105-L107
22,241
gdamore/tcell
style.go
Dim
func (s Style) Dim(on bool) Style { return s.setAttrs(Style(AttrDim), on) }
go
func (s Style) Dim(on bool) Style { return s.setAttrs(Style(AttrDim), on) }
[ "func", "(", "s", "Style", ")", "Dim", "(", "on", "bool", ")", "Style", "{", "return", "s", ".", "setAttrs", "(", "Style", "(", "AttrDim", ")", ",", "on", ")", "\n", "}" ]
// Dim returns a new style based on s, with the dim attribute set // as requested.
[ "Dim", "returns", "a", "new", "style", "based", "on", "s", "with", "the", "dim", "attribute", "set", "as", "requested", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/style.go#L111-L113
22,242
gdamore/tcell
style.go
Underline
func (s Style) Underline(on bool) Style { return s.setAttrs(Style(AttrUnderline), on) }
go
func (s Style) Underline(on bool) Style { return s.setAttrs(Style(AttrUnderline), on) }
[ "func", "(", "s", "Style", ")", "Underline", "(", "on", "bool", ")", "Style", "{", "return", "s", ".", "setAttrs", "(", "Style", "(", "AttrUnderline", ")", ",", "on", ")", "\n", "}" ]
// Underline returns a new style based on s, with the underline attribute set // as requested.
[ "Underline", "returns", "a", "new", "style", "based", "on", "s", "with", "the", "underline", "attribute", "set", "as", "requested", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/style.go#L124-L126
22,243
gdamore/tcell
key.go
Name
func (ev *EventKey) Name() string { s := "" m := []string{} if ev.mod&ModShift != 0 { m = append(m, "Shift") } if ev.mod&ModAlt != 0 { m = append(m, "Alt") } if ev.mod&ModMeta != 0 { m = append(m, "Meta") } if ev.mod&ModCtrl != 0 { m = append(m, "Ctrl") } ok := false if s, ok = KeyNames[ev.key]; !ok { if ev.key == KeyRune { s = "Rune[" + string(ev.ch) + "]" } else { s = fmt.Sprintf("Key[%d,%d]", ev.key, int(ev.ch)) } } if len(m) != 0 { if ev.mod&ModCtrl != 0 && strings.HasPrefix(s, "Ctrl-") { s = s[5:] } return fmt.Sprintf("%s+%s", strings.Join(m, "+"), s) } return s }
go
func (ev *EventKey) Name() string { s := "" m := []string{} if ev.mod&ModShift != 0 { m = append(m, "Shift") } if ev.mod&ModAlt != 0 { m = append(m, "Alt") } if ev.mod&ModMeta != 0 { m = append(m, "Meta") } if ev.mod&ModCtrl != 0 { m = append(m, "Ctrl") } ok := false if s, ok = KeyNames[ev.key]; !ok { if ev.key == KeyRune { s = "Rune[" + string(ev.ch) + "]" } else { s = fmt.Sprintf("Key[%d,%d]", ev.key, int(ev.ch)) } } if len(m) != 0 { if ev.mod&ModCtrl != 0 && strings.HasPrefix(s, "Ctrl-") { s = s[5:] } return fmt.Sprintf("%s+%s", strings.Join(m, "+"), s) } return s }
[ "func", "(", "ev", "*", "EventKey", ")", "Name", "(", ")", "string", "{", "s", ":=", "\"", "\"", "\n", "m", ":=", "[", "]", "string", "{", "}", "\n", "if", "ev", ".", "mod", "&", "ModShift", "!=", "0", "{", "m", "=", "append", "(", "m", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "ev", ".", "mod", "&", "ModAlt", "!=", "0", "{", "m", "=", "append", "(", "m", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "ev", ".", "mod", "&", "ModMeta", "!=", "0", "{", "m", "=", "append", "(", "m", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "ev", ".", "mod", "&", "ModCtrl", "!=", "0", "{", "m", "=", "append", "(", "m", ",", "\"", "\"", ")", "\n", "}", "\n\n", "ok", ":=", "false", "\n", "if", "s", ",", "ok", "=", "KeyNames", "[", "ev", ".", "key", "]", ";", "!", "ok", "{", "if", "ev", ".", "key", "==", "KeyRune", "{", "s", "=", "\"", "\"", "+", "string", "(", "ev", ".", "ch", ")", "+", "\"", "\"", "\n", "}", "else", "{", "s", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "ev", ".", "key", ",", "int", "(", "ev", ".", "ch", ")", ")", "\n", "}", "\n", "}", "\n", "if", "len", "(", "m", ")", "!=", "0", "{", "if", "ev", ".", "mod", "&", "ModCtrl", "!=", "0", "&&", "strings", ".", "HasPrefix", "(", "s", ",", "\"", "\"", ")", "{", "s", "=", "s", "[", "5", ":", "]", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "strings", ".", "Join", "(", "m", ",", "\"", "\"", ")", ",", "s", ")", "\n", "}", "\n", "return", "s", "\n", "}" ]
// Name returns a printable value or the key stroke. This can be used // when printing the event, for example.
[ "Name", "returns", "a", "printable", "value", "or", "the", "key", "stroke", ".", "This", "can", "be", "used", "when", "printing", "the", "event", "for", "example", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/key.go#L206-L237
22,244
gdamore/tcell
colorfit.go
FindColor
func FindColor(c Color, palette []Color) Color { match := ColorDefault dist := float64(0) r, g, b := c.RGB() c1 := colorful.Color{ R: float64(r) / 255.0, G: float64(g) / 255.0, B: float64(b) / 255.0, } for _, d := range palette { r, g, b = d.RGB() c2 := colorful.Color{ R: float64(r) / 255.0, G: float64(g) / 255.0, B: float64(b) / 255.0, } // CIE94 is more accurate, but really really expensive. nd := c1.DistanceCIE76(c2) if math.IsNaN(nd) { nd = math.Inf(1) } if match == ColorDefault || nd < dist { match = d dist = nd } } return match }
go
func FindColor(c Color, palette []Color) Color { match := ColorDefault dist := float64(0) r, g, b := c.RGB() c1 := colorful.Color{ R: float64(r) / 255.0, G: float64(g) / 255.0, B: float64(b) / 255.0, } for _, d := range palette { r, g, b = d.RGB() c2 := colorful.Color{ R: float64(r) / 255.0, G: float64(g) / 255.0, B: float64(b) / 255.0, } // CIE94 is more accurate, but really really expensive. nd := c1.DistanceCIE76(c2) if math.IsNaN(nd) { nd = math.Inf(1) } if match == ColorDefault || nd < dist { match = d dist = nd } } return match }
[ "func", "FindColor", "(", "c", "Color", ",", "palette", "[", "]", "Color", ")", "Color", "{", "match", ":=", "ColorDefault", "\n", "dist", ":=", "float64", "(", "0", ")", "\n", "r", ",", "g", ",", "b", ":=", "c", ".", "RGB", "(", ")", "\n", "c1", ":=", "colorful", ".", "Color", "{", "R", ":", "float64", "(", "r", ")", "/", "255.0", ",", "G", ":", "float64", "(", "g", ")", "/", "255.0", ",", "B", ":", "float64", "(", "b", ")", "/", "255.0", ",", "}", "\n", "for", "_", ",", "d", ":=", "range", "palette", "{", "r", ",", "g", ",", "b", "=", "d", ".", "RGB", "(", ")", "\n", "c2", ":=", "colorful", ".", "Color", "{", "R", ":", "float64", "(", "r", ")", "/", "255.0", ",", "G", ":", "float64", "(", "g", ")", "/", "255.0", ",", "B", ":", "float64", "(", "b", ")", "/", "255.0", ",", "}", "\n", "// CIE94 is more accurate, but really really expensive.", "nd", ":=", "c1", ".", "DistanceCIE76", "(", "c2", ")", "\n", "if", "math", ".", "IsNaN", "(", "nd", ")", "{", "nd", "=", "math", ".", "Inf", "(", "1", ")", "\n", "}", "\n", "if", "match", "==", "ColorDefault", "||", "nd", "<", "dist", "{", "match", "=", "d", "\n", "dist", "=", "nd", "\n", "}", "\n", "}", "\n", "return", "match", "\n", "}" ]
// FindColor attempts to find a given color, or the best match possible for it, // from the palette given. This is an expensive operation, so results should // be cached by the caller.
[ "FindColor", "attempts", "to", "find", "a", "given", "color", "or", "the", "best", "match", "possible", "for", "it", "from", "the", "palette", "given", ".", "This", "is", "an", "expensive", "operation", "so", "results", "should", "be", "cached", "by", "the", "caller", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/colorfit.go#L25-L52
22,245
gdamore/tcell
tscreen.go
buildAcsMap
func (t *tScreen) buildAcsMap() { acsstr := t.ti.AltChars t.acs = make(map[rune]string) for len(acsstr) > 2 { srcv := acsstr[0] dstv := string(acsstr[1]) if r, ok := vtACSNames[srcv]; ok { t.acs[r] = t.ti.EnterAcs + dstv + t.ti.ExitAcs } acsstr = acsstr[2:] } }
go
func (t *tScreen) buildAcsMap() { acsstr := t.ti.AltChars t.acs = make(map[rune]string) for len(acsstr) > 2 { srcv := acsstr[0] dstv := string(acsstr[1]) if r, ok := vtACSNames[srcv]; ok { t.acs[r] = t.ti.EnterAcs + dstv + t.ti.ExitAcs } acsstr = acsstr[2:] } }
[ "func", "(", "t", "*", "tScreen", ")", "buildAcsMap", "(", ")", "{", "acsstr", ":=", "t", ".", "ti", ".", "AltChars", "\n", "t", ".", "acs", "=", "make", "(", "map", "[", "rune", "]", "string", ")", "\n", "for", "len", "(", "acsstr", ")", ">", "2", "{", "srcv", ":=", "acsstr", "[", "0", "]", "\n", "dstv", ":=", "string", "(", "acsstr", "[", "1", "]", ")", "\n", "if", "r", ",", "ok", ":=", "vtACSNames", "[", "srcv", "]", ";", "ok", "{", "t", ".", "acs", "[", "r", "]", "=", "t", ".", "ti", ".", "EnterAcs", "+", "dstv", "+", "t", ".", "ti", ".", "ExitAcs", "\n", "}", "\n", "acsstr", "=", "acsstr", "[", "2", ":", "]", "\n", "}", "\n", "}" ]
// buildAcsMap builds a map of characters that we translate from Unicode to // alternate character encodings. To do this, we use the standard VT100 ACS // maps. This is only done if the terminal lacks support for Unicode; we // always prefer to emit Unicode glyphs when we are able.
[ "buildAcsMap", "builds", "a", "map", "of", "characters", "that", "we", "translate", "from", "Unicode", "to", "alternate", "character", "encodings", ".", "To", "do", "this", "we", "use", "the", "standard", "VT100", "ACS", "maps", ".", "This", "is", "only", "done", "if", "the", "terminal", "lacks", "support", "for", "Unicode", ";", "we", "always", "prefer", "to", "emit", "Unicode", "glyphs", "when", "we", "are", "able", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/tscreen.go#L846-L857
22,246
gdamore/tcell
tscreen.go
parseXtermMouse
func (t *tScreen) parseXtermMouse(buf *bytes.Buffer) (bool, bool) { b := buf.Bytes() state := 0 btn := 0 x := 0 y := 0 for i := range b { switch state { case 0: switch b[i] { case '\x1b': state = 1 case '\x9b': state = 2 default: return false, false } case 1: if b[i] != '[' { return false, false } state = 2 case 2: if b[i] != 'M' { return false, false } state++ case 3: btn = int(b[i]) state++ case 4: x = int(b[i]) - 32 - 1 state++ case 5: y = int(b[i]) - 32 - 1 for i >= 0 { buf.ReadByte() i-- } t.postMouseEvent(x, y, btn) return true, true } } return true, false }
go
func (t *tScreen) parseXtermMouse(buf *bytes.Buffer) (bool, bool) { b := buf.Bytes() state := 0 btn := 0 x := 0 y := 0 for i := range b { switch state { case 0: switch b[i] { case '\x1b': state = 1 case '\x9b': state = 2 default: return false, false } case 1: if b[i] != '[' { return false, false } state = 2 case 2: if b[i] != 'M' { return false, false } state++ case 3: btn = int(b[i]) state++ case 4: x = int(b[i]) - 32 - 1 state++ case 5: y = int(b[i]) - 32 - 1 for i >= 0 { buf.ReadByte() i-- } t.postMouseEvent(x, y, btn) return true, true } } return true, false }
[ "func", "(", "t", "*", "tScreen", ")", "parseXtermMouse", "(", "buf", "*", "bytes", ".", "Buffer", ")", "(", "bool", ",", "bool", ")", "{", "b", ":=", "buf", ".", "Bytes", "(", ")", "\n\n", "state", ":=", "0", "\n", "btn", ":=", "0", "\n", "x", ":=", "0", "\n", "y", ":=", "0", "\n\n", "for", "i", ":=", "range", "b", "{", "switch", "state", "{", "case", "0", ":", "switch", "b", "[", "i", "]", "{", "case", "'\\x1b'", ":", "state", "=", "1", "\n", "case", "'\\x9b'", ":", "state", "=", "2", "\n", "default", ":", "return", "false", ",", "false", "\n", "}", "\n", "case", "1", ":", "if", "b", "[", "i", "]", "!=", "'['", "{", "return", "false", ",", "false", "\n", "}", "\n", "state", "=", "2", "\n", "case", "2", ":", "if", "b", "[", "i", "]", "!=", "'M'", "{", "return", "false", ",", "false", "\n", "}", "\n", "state", "++", "\n", "case", "3", ":", "btn", "=", "int", "(", "b", "[", "i", "]", ")", "\n", "state", "++", "\n", "case", "4", ":", "x", "=", "int", "(", "b", "[", "i", "]", ")", "-", "32", "-", "1", "\n", "state", "++", "\n", "case", "5", ":", "y", "=", "int", "(", "b", "[", "i", "]", ")", "-", "32", "-", "1", "\n", "for", "i", ">=", "0", "{", "buf", ".", "ReadByte", "(", ")", "\n", "i", "--", "\n", "}", "\n", "t", ".", "postMouseEvent", "(", "x", ",", "y", ",", "btn", ")", "\n", "return", "true", ",", "true", "\n", "}", "\n", "}", "\n", "return", "true", ",", "false", "\n", "}" ]
// parseXtermMouse is like parseSgrMouse, but it parses a legacy // X11 mouse record.
[ "parseXtermMouse", "is", "like", "parseSgrMouse", "but", "it", "parses", "a", "legacy", "X11", "mouse", "record", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/tscreen.go#L1073-L1120
22,247
gdamore/tcell
views/boxlayout.go
Resize
func (b *BoxLayout) Resize() { b.layout() // Now also let the children know we resized. for i := range b.cells { b.cells[i].widget.Resize() } b.PostEventWidgetResize(b) }
go
func (b *BoxLayout) Resize() { b.layout() // Now also let the children know we resized. for i := range b.cells { b.cells[i].widget.Resize() } b.PostEventWidgetResize(b) }
[ "func", "(", "b", "*", "BoxLayout", ")", "Resize", "(", ")", "{", "b", ".", "layout", "(", ")", "\n\n", "// Now also let the children know we resized.", "for", "i", ":=", "range", "b", ".", "cells", "{", "b", ".", "cells", "[", "i", "]", ".", "widget", ".", "Resize", "(", ")", "\n", "}", "\n", "b", ".", "PostEventWidgetResize", "(", "b", ")", "\n", "}" ]
// Resize adjusts the layout when the underlying View changes size.
[ "Resize", "adjusts", "the", "layout", "when", "the", "underlying", "View", "changes", "size", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L188-L196
22,248
gdamore/tcell
views/boxlayout.go
Draw
func (b *BoxLayout) Draw() { if b.view == nil { return } if b.changed { b.layout() } b.view.Fill(' ', b.style) for i := range b.cells { b.cells[i].widget.Draw() } }
go
func (b *BoxLayout) Draw() { if b.view == nil { return } if b.changed { b.layout() } b.view.Fill(' ', b.style) for i := range b.cells { b.cells[i].widget.Draw() } }
[ "func", "(", "b", "*", "BoxLayout", ")", "Draw", "(", ")", "{", "if", "b", ".", "view", "==", "nil", "{", "return", "\n", "}", "\n", "if", "b", ".", "changed", "{", "b", ".", "layout", "(", ")", "\n", "}", "\n", "b", ".", "view", ".", "Fill", "(", "' '", ",", "b", ".", "style", ")", "\n", "for", "i", ":=", "range", "b", ".", "cells", "{", "b", ".", "cells", "[", "i", "]", ".", "widget", ".", "Draw", "(", ")", "\n", "}", "\n", "}" ]
// Draw is called to update the displayed content.
[ "Draw", "is", "called", "to", "update", "the", "displayed", "content", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L199-L211
22,249
gdamore/tcell
views/boxlayout.go
SetView
func (b *BoxLayout) SetView(view View) { b.changed = true b.view = view for _, c := range b.cells { c.view.SetView(view) } }
go
func (b *BoxLayout) SetView(view View) { b.changed = true b.view = view for _, c := range b.cells { c.view.SetView(view) } }
[ "func", "(", "b", "*", "BoxLayout", ")", "SetView", "(", "view", "View", ")", "{", "b", ".", "changed", "=", "true", "\n", "b", ".", "view", "=", "view", "\n", "for", "_", ",", "c", ":=", "range", "b", ".", "cells", "{", "c", ".", "view", ".", "SetView", "(", "view", ")", "\n", "}", "\n", "}" ]
// SetView sets the View object used for the text bar.
[ "SetView", "sets", "the", "View", "object", "used", "for", "the", "text", "bar", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L219-L225
22,250
gdamore/tcell
views/boxlayout.go
HandleEvent
func (b *BoxLayout) HandleEvent(ev tcell.Event) bool { switch ev.(type) { case *EventWidgetContent: // This can only have come from one of our children. b.changed = true b.PostEventWidgetContent(b) return true } for _, c := range b.cells { if c.widget.HandleEvent(ev) { return true } } return false }
go
func (b *BoxLayout) HandleEvent(ev tcell.Event) bool { switch ev.(type) { case *EventWidgetContent: // This can only have come from one of our children. b.changed = true b.PostEventWidgetContent(b) return true } for _, c := range b.cells { if c.widget.HandleEvent(ev) { return true } } return false }
[ "func", "(", "b", "*", "BoxLayout", ")", "HandleEvent", "(", "ev", "tcell", ".", "Event", ")", "bool", "{", "switch", "ev", ".", "(", "type", ")", "{", "case", "*", "EventWidgetContent", ":", "// This can only have come from one of our children.", "b", ".", "changed", "=", "true", "\n", "b", ".", "PostEventWidgetContent", "(", "b", ")", "\n", "return", "true", "\n", "}", "\n", "for", "_", ",", "c", ":=", "range", "b", ".", "cells", "{", "if", "c", ".", "widget", ".", "HandleEvent", "(", "ev", ")", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// HandleEvent implements a tcell.EventHandler. The only events // we care about are Widget change events from our children. We // watch for those so that if the child changes, we can arrange // to update our layout.
[ "HandleEvent", "implements", "a", "tcell", ".", "EventHandler", ".", "The", "only", "events", "we", "care", "about", "are", "Widget", "change", "events", "from", "our", "children", ".", "We", "watch", "for", "those", "so", "that", "if", "the", "child", "changes", "we", "can", "arrange", "to", "update", "our", "layout", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L231-L245
22,251
gdamore/tcell
views/boxlayout.go
AddWidget
func (b *BoxLayout) AddWidget(widget Widget, fill float64) { c := &boxLayoutCell{ widget: widget, fill: fill, view: NewViewPort(b.view, 0, 0, 0, 0), } widget.SetView(c.view) b.cells = append(b.cells, c) b.changed = true widget.Watch(b) b.layout() b.PostEventWidgetContent(b) }
go
func (b *BoxLayout) AddWidget(widget Widget, fill float64) { c := &boxLayoutCell{ widget: widget, fill: fill, view: NewViewPort(b.view, 0, 0, 0, 0), } widget.SetView(c.view) b.cells = append(b.cells, c) b.changed = true widget.Watch(b) b.layout() b.PostEventWidgetContent(b) }
[ "func", "(", "b", "*", "BoxLayout", ")", "AddWidget", "(", "widget", "Widget", ",", "fill", "float64", ")", "{", "c", ":=", "&", "boxLayoutCell", "{", "widget", ":", "widget", ",", "fill", ":", "fill", ",", "view", ":", "NewViewPort", "(", "b", ".", "view", ",", "0", ",", "0", ",", "0", ",", "0", ")", ",", "}", "\n", "widget", ".", "SetView", "(", "c", ".", "view", ")", "\n", "b", ".", "cells", "=", "append", "(", "b", ".", "cells", ",", "c", ")", "\n", "b", ".", "changed", "=", "true", "\n", "widget", ".", "Watch", "(", "b", ")", "\n", "b", ".", "layout", "(", ")", "\n", "b", ".", "PostEventWidgetContent", "(", "b", ")", "\n", "}" ]
// AddWidget adds a widget to the end of the BoxLayout.
[ "AddWidget", "adds", "a", "widget", "to", "the", "end", "of", "the", "BoxLayout", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L248-L260
22,252
gdamore/tcell
views/boxlayout.go
InsertWidget
func (b *BoxLayout) InsertWidget(index int, widget Widget, fill float64) { c := &boxLayoutCell{ widget: widget, fill: fill, view: NewViewPort(b.view, 0, 0, 0, 0), } c.widget.SetView(c.view) if index < 0 { index = 0 } if index > len(b.cells) { index = len(b.cells) } b.cells = append(b.cells, c) copy(b.cells[index+1:], b.cells[index:]) b.cells[index] = c widget.Watch(b) b.layout() b.PostEventWidgetContent(b) }
go
func (b *BoxLayout) InsertWidget(index int, widget Widget, fill float64) { c := &boxLayoutCell{ widget: widget, fill: fill, view: NewViewPort(b.view, 0, 0, 0, 0), } c.widget.SetView(c.view) if index < 0 { index = 0 } if index > len(b.cells) { index = len(b.cells) } b.cells = append(b.cells, c) copy(b.cells[index+1:], b.cells[index:]) b.cells[index] = c widget.Watch(b) b.layout() b.PostEventWidgetContent(b) }
[ "func", "(", "b", "*", "BoxLayout", ")", "InsertWidget", "(", "index", "int", ",", "widget", "Widget", ",", "fill", "float64", ")", "{", "c", ":=", "&", "boxLayoutCell", "{", "widget", ":", "widget", ",", "fill", ":", "fill", ",", "view", ":", "NewViewPort", "(", "b", ".", "view", ",", "0", ",", "0", ",", "0", ",", "0", ")", ",", "}", "\n", "c", ".", "widget", ".", "SetView", "(", "c", ".", "view", ")", "\n", "if", "index", "<", "0", "{", "index", "=", "0", "\n", "}", "\n", "if", "index", ">", "len", "(", "b", ".", "cells", ")", "{", "index", "=", "len", "(", "b", ".", "cells", ")", "\n", "}", "\n", "b", ".", "cells", "=", "append", "(", "b", ".", "cells", ",", "c", ")", "\n", "copy", "(", "b", ".", "cells", "[", "index", "+", "1", ":", "]", ",", "b", ".", "cells", "[", "index", ":", "]", ")", "\n", "b", ".", "cells", "[", "index", "]", "=", "c", "\n", "widget", ".", "Watch", "(", "b", ")", "\n", "b", ".", "layout", "(", ")", "\n", "b", ".", "PostEventWidgetContent", "(", "b", ")", "\n", "}" ]
// InsertWidget inserts a widget at the given offset. Offset 0 is the // front. If the index is longer than the number of widgets, then it // just gets appended to the end.
[ "InsertWidget", "inserts", "a", "widget", "at", "the", "given", "offset", ".", "Offset", "0", "is", "the", "front", ".", "If", "the", "index", "is", "longer", "than", "the", "number", "of", "widgets", "then", "it", "just", "gets", "appended", "to", "the", "end", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L265-L284
22,253
gdamore/tcell
views/boxlayout.go
RemoveWidget
func (b *BoxLayout) RemoveWidget(widget Widget) { changed := false for i := 0; i < len(b.cells); i++ { if b.cells[i].widget == widget { b.cells = append(b.cells[:i], b.cells[i+1:]...) changed = true } } if !changed { return } b.changed = true widget.Unwatch(b) b.layout() b.PostEventWidgetContent(b) }
go
func (b *BoxLayout) RemoveWidget(widget Widget) { changed := false for i := 0; i < len(b.cells); i++ { if b.cells[i].widget == widget { b.cells = append(b.cells[:i], b.cells[i+1:]...) changed = true } } if !changed { return } b.changed = true widget.Unwatch(b) b.layout() b.PostEventWidgetContent(b) }
[ "func", "(", "b", "*", "BoxLayout", ")", "RemoveWidget", "(", "widget", "Widget", ")", "{", "changed", ":=", "false", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "b", ".", "cells", ")", ";", "i", "++", "{", "if", "b", ".", "cells", "[", "i", "]", ".", "widget", "==", "widget", "{", "b", ".", "cells", "=", "append", "(", "b", ".", "cells", "[", ":", "i", "]", ",", "b", ".", "cells", "[", "i", "+", "1", ":", "]", "...", ")", "\n", "changed", "=", "true", "\n", "}", "\n", "}", "\n", "if", "!", "changed", "{", "return", "\n", "}", "\n", "b", ".", "changed", "=", "true", "\n", "widget", ".", "Unwatch", "(", "b", ")", "\n", "b", ".", "layout", "(", ")", "\n", "b", ".", "PostEventWidgetContent", "(", "b", ")", "\n", "}" ]
// RemoveWidget removes a Widget from the layout.
[ "RemoveWidget", "removes", "a", "Widget", "from", "the", "layout", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L287-L302
22,254
gdamore/tcell
views/boxlayout.go
Widgets
func (b *BoxLayout) Widgets() []Widget { w := make([]Widget, 0, len(b.cells)) for _, c := range b.cells { w = append(w, c.widget) } return w }
go
func (b *BoxLayout) Widgets() []Widget { w := make([]Widget, 0, len(b.cells)) for _, c := range b.cells { w = append(w, c.widget) } return w }
[ "func", "(", "b", "*", "BoxLayout", ")", "Widgets", "(", ")", "[", "]", "Widget", "{", "w", ":=", "make", "(", "[", "]", "Widget", ",", "0", ",", "len", "(", "b", ".", "cells", ")", ")", "\n", "for", "_", ",", "c", ":=", "range", "b", ".", "cells", "{", "w", "=", "append", "(", "w", ",", "c", ".", "widget", ")", "\n", "}", "\n", "return", "w", "\n", "}" ]
// Widgets returns the list of Widgets for this BoxLayout.
[ "Widgets", "returns", "the", "list", "of", "Widgets", "for", "this", "BoxLayout", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L305-L311
22,255
gdamore/tcell
views/boxlayout.go
SetOrientation
func (b *BoxLayout) SetOrientation(orient Orientation) { if b.orient != orient { b.orient = orient b.changed = true b.PostEventWidgetContent(b) } }
go
func (b *BoxLayout) SetOrientation(orient Orientation) { if b.orient != orient { b.orient = orient b.changed = true b.PostEventWidgetContent(b) } }
[ "func", "(", "b", "*", "BoxLayout", ")", "SetOrientation", "(", "orient", "Orientation", ")", "{", "if", "b", ".", "orient", "!=", "orient", "{", "b", ".", "orient", "=", "orient", "\n", "b", ".", "changed", "=", "true", "\n", "b", ".", "PostEventWidgetContent", "(", "b", ")", "\n", "}", "\n", "}" ]
// SetOrientation sets the orientation as either Horizontal or Vertical.
[ "SetOrientation", "sets", "the", "orientation", "as", "either", "Horizontal", "or", "Vertical", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L314-L320
22,256
gdamore/tcell
views/boxlayout.go
SetStyle
func (b *BoxLayout) SetStyle(style tcell.Style) { b.style = style b.PostEventWidgetContent(b) }
go
func (b *BoxLayout) SetStyle(style tcell.Style) { b.style = style b.PostEventWidgetContent(b) }
[ "func", "(", "b", "*", "BoxLayout", ")", "SetStyle", "(", "style", "tcell", ".", "Style", ")", "{", "b", ".", "style", "=", "style", "\n", "b", ".", "PostEventWidgetContent", "(", "b", ")", "\n", "}" ]
// SetStyle sets the style used.
[ "SetStyle", "sets", "the", "style", "used", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L323-L326
22,257
gdamore/tcell
console_win.go
mod2mask
func mod2mask(cks uint32) ModMask { mm := ModNone // Left or right control if (cks & (0x0008 | 0x0004)) != 0 { mm |= ModCtrl } // Left or right alt if (cks & (0x0002 | 0x0001)) != 0 { mm |= ModAlt } // Any shift if (cks & 0x0010) != 0 { mm |= ModShift } return mm }
go
func mod2mask(cks uint32) ModMask { mm := ModNone // Left or right control if (cks & (0x0008 | 0x0004)) != 0 { mm |= ModCtrl } // Left or right alt if (cks & (0x0002 | 0x0001)) != 0 { mm |= ModAlt } // Any shift if (cks & 0x0010) != 0 { mm |= ModShift } return mm }
[ "func", "mod2mask", "(", "cks", "uint32", ")", "ModMask", "{", "mm", ":=", "ModNone", "\n", "// Left or right control", "if", "(", "cks", "&", "(", "0x0008", "|", "0x0004", ")", ")", "!=", "0", "{", "mm", "|=", "ModCtrl", "\n", "}", "\n", "// Left or right alt", "if", "(", "cks", "&", "(", "0x0002", "|", "0x0001", ")", ")", "!=", "0", "{", "mm", "|=", "ModAlt", "\n", "}", "\n", "// Any shift", "if", "(", "cks", "&", "0x0010", ")", "!=", "0", "{", "mm", "|=", "ModShift", "\n", "}", "\n", "return", "mm", "\n", "}" ]
// Convert windows dwControlKeyState to modifier mask
[ "Convert", "windows", "dwControlKeyState", "to", "modifier", "mask" ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/console_win.go#L459-L474
22,258
gdamore/tcell
console_win.go
mapColor2RGB
func mapColor2RGB(c Color) uint16 { winLock.Lock() if v, ok := winColors[c]; ok { c = v } else { v = FindColor(c, winPalette) winColors[c] = v c = v } winLock.Unlock() if vc, ok := vgaColors[c]; ok { return vc } return 0 }
go
func mapColor2RGB(c Color) uint16 { winLock.Lock() if v, ok := winColors[c]; ok { c = v } else { v = FindColor(c, winPalette) winColors[c] = v c = v } winLock.Unlock() if vc, ok := vgaColors[c]; ok { return vc } return 0 }
[ "func", "mapColor2RGB", "(", "c", "Color", ")", "uint16", "{", "winLock", ".", "Lock", "(", ")", "\n", "if", "v", ",", "ok", ":=", "winColors", "[", "c", "]", ";", "ok", "{", "c", "=", "v", "\n", "}", "else", "{", "v", "=", "FindColor", "(", "c", ",", "winPalette", ")", "\n", "winColors", "[", "c", "]", "=", "v", "\n", "c", "=", "v", "\n", "}", "\n", "winLock", ".", "Unlock", "(", ")", "\n\n", "if", "vc", ",", "ok", ":=", "vgaColors", "[", "c", "]", ";", "ok", "{", "return", "vc", "\n", "}", "\n", "return", "0", "\n", "}" ]
// Windows uses RGB signals
[ "Windows", "uses", "RGB", "signals" ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/console_win.go#L652-L667
22,259
gdamore/tcell
console_win.go
mapStyle
func (s *cScreen) mapStyle(style Style) uint16 { f, b, a := style.Decompose() fa := s.oscreen.attrs & 0xf ba := (s.oscreen.attrs) >> 4 & 0xf if f != ColorDefault { fa = mapColor2RGB(f) } if b != ColorDefault { ba = mapColor2RGB(b) } var attr uint16 // We simulate reverse by doing the color swap ourselves. // Apparently windows cannot really do this except in DBCS // views. if a&AttrReverse != 0 { attr = ba attr |= (fa << 4) } else { attr = fa attr |= (ba << 4) } if a&AttrBold != 0 { attr |= 0x8 } if a&AttrDim != 0 { attr &^= 0x8 } if a&AttrUnderline != 0 { // Best effort -- doesn't seem to work though. attr |= 0x8000 } // Blink is unsupported return attr }
go
func (s *cScreen) mapStyle(style Style) uint16 { f, b, a := style.Decompose() fa := s.oscreen.attrs & 0xf ba := (s.oscreen.attrs) >> 4 & 0xf if f != ColorDefault { fa = mapColor2RGB(f) } if b != ColorDefault { ba = mapColor2RGB(b) } var attr uint16 // We simulate reverse by doing the color swap ourselves. // Apparently windows cannot really do this except in DBCS // views. if a&AttrReverse != 0 { attr = ba attr |= (fa << 4) } else { attr = fa attr |= (ba << 4) } if a&AttrBold != 0 { attr |= 0x8 } if a&AttrDim != 0 { attr &^= 0x8 } if a&AttrUnderline != 0 { // Best effort -- doesn't seem to work though. attr |= 0x8000 } // Blink is unsupported return attr }
[ "func", "(", "s", "*", "cScreen", ")", "mapStyle", "(", "style", "Style", ")", "uint16", "{", "f", ",", "b", ",", "a", ":=", "style", ".", "Decompose", "(", ")", "\n", "fa", ":=", "s", ".", "oscreen", ".", "attrs", "&", "0xf", "\n", "ba", ":=", "(", "s", ".", "oscreen", ".", "attrs", ")", ">>", "4", "&", "0xf", "\n", "if", "f", "!=", "ColorDefault", "{", "fa", "=", "mapColor2RGB", "(", "f", ")", "\n", "}", "\n", "if", "b", "!=", "ColorDefault", "{", "ba", "=", "mapColor2RGB", "(", "b", ")", "\n", "}", "\n", "var", "attr", "uint16", "\n", "// We simulate reverse by doing the color swap ourselves.", "// Apparently windows cannot really do this except in DBCS", "// views.", "if", "a", "&", "AttrReverse", "!=", "0", "{", "attr", "=", "ba", "\n", "attr", "|=", "(", "fa", "<<", "4", ")", "\n", "}", "else", "{", "attr", "=", "fa", "\n", "attr", "|=", "(", "ba", "<<", "4", ")", "\n", "}", "\n", "if", "a", "&", "AttrBold", "!=", "0", "{", "attr", "|=", "0x8", "\n", "}", "\n", "if", "a", "&", "AttrDim", "!=", "0", "{", "attr", "&^=", "0x8", "\n", "}", "\n", "if", "a", "&", "AttrUnderline", "!=", "0", "{", "// Best effort -- doesn't seem to work though.", "attr", "|=", "0x8000", "\n", "}", "\n", "// Blink is unsupported", "return", "attr", "\n", "}" ]
// Map a tcell style to Windows attributes
[ "Map", "a", "tcell", "style", "to", "Windows", "attributes" ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/console_win.go#L670-L703
22,260
gdamore/tcell
views/sstext.go
LookupStyle
func (t *SimpleStyledText) LookupStyle(r rune) tcell.Style { return t.styles[r] }
go
func (t *SimpleStyledText) LookupStyle(r rune) tcell.Style { return t.styles[r] }
[ "func", "(", "t", "*", "SimpleStyledText", ")", "LookupStyle", "(", "r", "rune", ")", "tcell", ".", "Style", "{", "return", "t", ".", "styles", "[", "r", "]", "\n", "}" ]
// LookupStyle returns the style registered for the given rune. // Returns tcell.StyleDefault if no style was previously registered // for the rune.
[ "LookupStyle", "returns", "the", "style", "registered", "for", "the", "given", "rune", ".", "Returns", "tcell", ".", "StyleDefault", "if", "no", "style", "was", "previously", "registered", "for", "the", "rune", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/sstext.go#L107-L109
22,261
gdamore/tcell
views/sstext.go
NewSimpleStyledText
func NewSimpleStyledText() *SimpleStyledText { ss := &SimpleStyledText{} // Create map and establish default styles. ss.styles = make(map[rune]tcell.Style) ss.styles['N'] = tcell.StyleDefault ss.styles['S'] = tcell.StyleDefault.Reverse(true) ss.styles['U'] = tcell.StyleDefault.Underline(true) ss.styles['B'] = tcell.StyleDefault.Bold(true) return ss }
go
func NewSimpleStyledText() *SimpleStyledText { ss := &SimpleStyledText{} // Create map and establish default styles. ss.styles = make(map[rune]tcell.Style) ss.styles['N'] = tcell.StyleDefault ss.styles['S'] = tcell.StyleDefault.Reverse(true) ss.styles['U'] = tcell.StyleDefault.Underline(true) ss.styles['B'] = tcell.StyleDefault.Bold(true) return ss }
[ "func", "NewSimpleStyledText", "(", ")", "*", "SimpleStyledText", "{", "ss", ":=", "&", "SimpleStyledText", "{", "}", "\n", "// Create map and establish default styles.", "ss", ".", "styles", "=", "make", "(", "map", "[", "rune", "]", "tcell", ".", "Style", ")", "\n", "ss", ".", "styles", "[", "'N'", "]", "=", "tcell", ".", "StyleDefault", "\n", "ss", ".", "styles", "[", "'S'", "]", "=", "tcell", ".", "StyleDefault", ".", "Reverse", "(", "true", ")", "\n", "ss", ".", "styles", "[", "'U'", "]", "=", "tcell", ".", "StyleDefault", ".", "Underline", "(", "true", ")", "\n", "ss", ".", "styles", "[", "'B'", "]", "=", "tcell", ".", "StyleDefault", ".", "Bold", "(", "true", ")", "\n", "return", "ss", "\n", "}" ]
// NewSimpleStyledText creates an empty Text.
[ "NewSimpleStyledText", "creates", "an", "empty", "Text", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/sstext.go#L117-L126
22,262
gdamore/tcell
views/panel.go
Draw
func (p *Panel) Draw() { p.BoxLayout.SetOrientation(Vertical) p.BoxLayout.Draw() }
go
func (p *Panel) Draw() { p.BoxLayout.SetOrientation(Vertical) p.BoxLayout.Draw() }
[ "func", "(", "p", "*", "Panel", ")", "Draw", "(", ")", "{", "p", ".", "BoxLayout", ".", "SetOrientation", "(", "Vertical", ")", "\n", "p", ".", "BoxLayout", ".", "Draw", "(", ")", "\n", "}" ]
// Draw draws the Panel.
[ "Draw", "draws", "the", "Panel", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/panel.go#L44-L47
22,263
gdamore/tcell
views/panel.go
SetTitle
func (p *Panel) SetTitle(w Widget) { if p.title != nil { p.RemoveWidget(p.title) } p.InsertWidget(0, w, 0.0) p.title = w }
go
func (p *Panel) SetTitle(w Widget) { if p.title != nil { p.RemoveWidget(p.title) } p.InsertWidget(0, w, 0.0) p.title = w }
[ "func", "(", "p", "*", "Panel", ")", "SetTitle", "(", "w", "Widget", ")", "{", "if", "p", ".", "title", "!=", "nil", "{", "p", ".", "RemoveWidget", "(", "p", ".", "title", ")", "\n", "}", "\n", "p", ".", "InsertWidget", "(", "0", ",", "w", ",", "0.0", ")", "\n", "p", ".", "title", "=", "w", "\n", "}" ]
// SetTitle sets the Widget to display in the title area.
[ "SetTitle", "sets", "the", "Widget", "to", "display", "in", "the", "title", "area", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/panel.go#L50-L56
22,264
gdamore/tcell
views/panel.go
SetMenu
func (p *Panel) SetMenu(w Widget) { index := 0 if p.title != nil { index++ } if p.menu != nil { p.RemoveWidget(p.menu) } p.InsertWidget(index, w, 0.0) p.menu = w }
go
func (p *Panel) SetMenu(w Widget) { index := 0 if p.title != nil { index++ } if p.menu != nil { p.RemoveWidget(p.menu) } p.InsertWidget(index, w, 0.0) p.menu = w }
[ "func", "(", "p", "*", "Panel", ")", "SetMenu", "(", "w", "Widget", ")", "{", "index", ":=", "0", "\n", "if", "p", ".", "title", "!=", "nil", "{", "index", "++", "\n", "}", "\n", "if", "p", ".", "menu", "!=", "nil", "{", "p", ".", "RemoveWidget", "(", "p", ".", "menu", ")", "\n", "}", "\n", "p", ".", "InsertWidget", "(", "index", ",", "w", ",", "0.0", ")", "\n", "p", ".", "menu", "=", "w", "\n", "}" ]
// SetMenu sets the Widget to display in the menu area, which is // just below the title.
[ "SetMenu", "sets", "the", "Widget", "to", "display", "in", "the", "menu", "area", "which", "is", "just", "below", "the", "title", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/panel.go#L60-L70
22,265
gdamore/tcell
views/panel.go
SetContent
func (p *Panel) SetContent(w Widget) { index := 0 if p.title != nil { index++ } if p.menu != nil { index++ } if p.content != nil { p.RemoveWidget(p.content) } p.InsertWidget(index, w, 1.0) p.content = w }
go
func (p *Panel) SetContent(w Widget) { index := 0 if p.title != nil { index++ } if p.menu != nil { index++ } if p.content != nil { p.RemoveWidget(p.content) } p.InsertWidget(index, w, 1.0) p.content = w }
[ "func", "(", "p", "*", "Panel", ")", "SetContent", "(", "w", "Widget", ")", "{", "index", ":=", "0", "\n", "if", "p", ".", "title", "!=", "nil", "{", "index", "++", "\n", "}", "\n", "if", "p", ".", "menu", "!=", "nil", "{", "index", "++", "\n", "}", "\n", "if", "p", ".", "content", "!=", "nil", "{", "p", ".", "RemoveWidget", "(", "p", ".", "content", ")", "\n", "}", "\n", "p", ".", "InsertWidget", "(", "index", ",", "w", ",", "1.0", ")", "\n", "p", ".", "content", "=", "w", "\n", "}" ]
// SetContent sets the Widget to display in the content area.
[ "SetContent", "sets", "the", "Widget", "to", "display", "in", "the", "content", "area", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/panel.go#L73-L86
22,266
gdamore/tcell
views/panel.go
SetStatus
func (p *Panel) SetStatus(w Widget) { index := 0 if p.title != nil { index++ } if p.menu != nil { index++ } if p.content != nil { index++ } if p.status != nil { p.RemoveWidget(p.status) } p.InsertWidget(index, w, 0.0) p.status = w }
go
func (p *Panel) SetStatus(w Widget) { index := 0 if p.title != nil { index++ } if p.menu != nil { index++ } if p.content != nil { index++ } if p.status != nil { p.RemoveWidget(p.status) } p.InsertWidget(index, w, 0.0) p.status = w }
[ "func", "(", "p", "*", "Panel", ")", "SetStatus", "(", "w", "Widget", ")", "{", "index", ":=", "0", "\n", "if", "p", ".", "title", "!=", "nil", "{", "index", "++", "\n", "}", "\n", "if", "p", ".", "menu", "!=", "nil", "{", "index", "++", "\n", "}", "\n", "if", "p", ".", "content", "!=", "nil", "{", "index", "++", "\n", "}", "\n", "if", "p", ".", "status", "!=", "nil", "{", "p", ".", "RemoveWidget", "(", "p", ".", "status", ")", "\n", "}", "\n", "p", ".", "InsertWidget", "(", "index", ",", "w", ",", "0.0", ")", "\n", "p", ".", "status", "=", "w", "\n", "}" ]
// SetStatus sets the Widget to display in the status area, which is at // the bottom of the panel.
[ "SetStatus", "sets", "the", "Widget", "to", "display", "in", "the", "status", "area", "which", "is", "at", "the", "bottom", "of", "the", "panel", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/panel.go#L90-L106
22,267
gdamore/tcell
views/cellarea.go
Draw
func (a *CellView) Draw() { port := a.port model := a.model port.Fill(' ', a.style) if a.view == nil { return } if model == nil { return } vw, vh := a.view.Size() for y := 0; y < vh; y++ { for x := 0; x < vw; x++ { a.view.SetContent(x, y, ' ', nil, a.style) } } ex, ey := model.GetBounds() vx, vy := port.Size() if ex < vx { ex = vx } if ey < vy { ey = vy } cx, cy, en, sh := a.model.GetCursor() for y := 0; y < ey; y++ { for x := 0; x < ex; x++ { ch, style, comb, wid := model.GetCell(x, y) if ch == 0 { ch = ' ' style = a.style } if en && x == cx && y == cy && sh { style = style.Reverse(true) } port.SetContent(x, y, ch, comb, style) x += wid - 1 } } }
go
func (a *CellView) Draw() { port := a.port model := a.model port.Fill(' ', a.style) if a.view == nil { return } if model == nil { return } vw, vh := a.view.Size() for y := 0; y < vh; y++ { for x := 0; x < vw; x++ { a.view.SetContent(x, y, ' ', nil, a.style) } } ex, ey := model.GetBounds() vx, vy := port.Size() if ex < vx { ex = vx } if ey < vy { ey = vy } cx, cy, en, sh := a.model.GetCursor() for y := 0; y < ey; y++ { for x := 0; x < ex; x++ { ch, style, comb, wid := model.GetCell(x, y) if ch == 0 { ch = ' ' style = a.style } if en && x == cx && y == cy && sh { style = style.Reverse(true) } port.SetContent(x, y, ch, comb, style) x += wid - 1 } } }
[ "func", "(", "a", "*", "CellView", ")", "Draw", "(", ")", "{", "port", ":=", "a", ".", "port", "\n", "model", ":=", "a", ".", "model", "\n", "port", ".", "Fill", "(", "' '", ",", "a", ".", "style", ")", "\n\n", "if", "a", ".", "view", "==", "nil", "{", "return", "\n", "}", "\n", "if", "model", "==", "nil", "{", "return", "\n", "}", "\n", "vw", ",", "vh", ":=", "a", ".", "view", ".", "Size", "(", ")", "\n", "for", "y", ":=", "0", ";", "y", "<", "vh", ";", "y", "++", "{", "for", "x", ":=", "0", ";", "x", "<", "vw", ";", "x", "++", "{", "a", ".", "view", ".", "SetContent", "(", "x", ",", "y", ",", "' '", ",", "nil", ",", "a", ".", "style", ")", "\n", "}", "\n", "}", "\n\n", "ex", ",", "ey", ":=", "model", ".", "GetBounds", "(", ")", "\n", "vx", ",", "vy", ":=", "port", ".", "Size", "(", ")", "\n", "if", "ex", "<", "vx", "{", "ex", "=", "vx", "\n", "}", "\n", "if", "ey", "<", "vy", "{", "ey", "=", "vy", "\n", "}", "\n\n", "cx", ",", "cy", ",", "en", ",", "sh", ":=", "a", ".", "model", ".", "GetCursor", "(", ")", "\n", "for", "y", ":=", "0", ";", "y", "<", "ey", ";", "y", "++", "{", "for", "x", ":=", "0", ";", "x", "<", "ex", ";", "x", "++", "{", "ch", ",", "style", ",", "comb", ",", "wid", ":=", "model", ".", "GetCell", "(", "x", ",", "y", ")", "\n", "if", "ch", "==", "0", "{", "ch", "=", "' '", "\n", "style", "=", "a", ".", "style", "\n", "}", "\n", "if", "en", "&&", "x", "==", "cx", "&&", "y", "==", "cy", "&&", "sh", "{", "style", "=", "style", ".", "Reverse", "(", "true", ")", "\n", "}", "\n", "port", ".", "SetContent", "(", "x", ",", "y", ",", "ch", ",", "comb", ",", "style", ")", "\n", "x", "+=", "wid", "-", "1", "\n", "}", "\n", "}", "\n", "}" ]
// Draw draws the content.
[ "Draw", "draws", "the", "content", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L51-L94
22,268
gdamore/tcell
views/cellarea.go
MakeCursorVisible
func (a *CellView) MakeCursorVisible() { if a.model == nil { return } x, y, enabled, _ := a.model.GetCursor() if enabled { a.MakeVisible(x, y) } }
go
func (a *CellView) MakeCursorVisible() { if a.model == nil { return } x, y, enabled, _ := a.model.GetCursor() if enabled { a.MakeVisible(x, y) } }
[ "func", "(", "a", "*", "CellView", ")", "MakeCursorVisible", "(", ")", "{", "if", "a", ".", "model", "==", "nil", "{", "return", "\n", "}", "\n", "x", ",", "y", ",", "enabled", ",", "_", ":=", "a", ".", "model", ".", "GetCursor", "(", ")", "\n", "if", "enabled", "{", "a", ".", "MakeVisible", "(", "x", ",", "y", ")", "\n", "}", "\n", "}" ]
// MakeCursorVisible ensures that the cursor is visible, panning the ViewPort // as necessary, if the cursor is enabled.
[ "MakeCursorVisible", "ensures", "that", "the", "cursor", "is", "visible", "panning", "the", "ViewPort", "as", "necessary", "if", "the", "cursor", "is", "enabled", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L176-L184
22,269
gdamore/tcell
views/cellarea.go
HandleEvent
func (a *CellView) HandleEvent(e tcell.Event) bool { if a.model == nil { return false } switch e := e.(type) { case *tcell.EventKey: switch e.Key() { case tcell.KeyUp, tcell.KeyCtrlP: a.keyUp() return true case tcell.KeyDown, tcell.KeyCtrlN: a.keyDown() return true case tcell.KeyRight, tcell.KeyCtrlF: a.keyRight() return true case tcell.KeyLeft, tcell.KeyCtrlB: a.keyLeft() return true case tcell.KeyPgDn: a.keyPgDn() return true case tcell.KeyPgUp: a.keyPgUp() return true case tcell.KeyEnd: a.keyEnd() return true case tcell.KeyHome: a.keyHome() return true } } return false }
go
func (a *CellView) HandleEvent(e tcell.Event) bool { if a.model == nil { return false } switch e := e.(type) { case *tcell.EventKey: switch e.Key() { case tcell.KeyUp, tcell.KeyCtrlP: a.keyUp() return true case tcell.KeyDown, tcell.KeyCtrlN: a.keyDown() return true case tcell.KeyRight, tcell.KeyCtrlF: a.keyRight() return true case tcell.KeyLeft, tcell.KeyCtrlB: a.keyLeft() return true case tcell.KeyPgDn: a.keyPgDn() return true case tcell.KeyPgUp: a.keyPgUp() return true case tcell.KeyEnd: a.keyEnd() return true case tcell.KeyHome: a.keyHome() return true } } return false }
[ "func", "(", "a", "*", "CellView", ")", "HandleEvent", "(", "e", "tcell", ".", "Event", ")", "bool", "{", "if", "a", ".", "model", "==", "nil", "{", "return", "false", "\n", "}", "\n", "switch", "e", ":=", "e", ".", "(", "type", ")", "{", "case", "*", "tcell", ".", "EventKey", ":", "switch", "e", ".", "Key", "(", ")", "{", "case", "tcell", ".", "KeyUp", ",", "tcell", ".", "KeyCtrlP", ":", "a", ".", "keyUp", "(", ")", "\n", "return", "true", "\n", "case", "tcell", ".", "KeyDown", ",", "tcell", ".", "KeyCtrlN", ":", "a", ".", "keyDown", "(", ")", "\n", "return", "true", "\n", "case", "tcell", ".", "KeyRight", ",", "tcell", ".", "KeyCtrlF", ":", "a", ".", "keyRight", "(", ")", "\n", "return", "true", "\n", "case", "tcell", ".", "KeyLeft", ",", "tcell", ".", "KeyCtrlB", ":", "a", ".", "keyLeft", "(", ")", "\n", "return", "true", "\n", "case", "tcell", ".", "KeyPgDn", ":", "a", ".", "keyPgDn", "(", ")", "\n", "return", "true", "\n", "case", "tcell", ".", "KeyPgUp", ":", "a", ".", "keyPgUp", "(", ")", "\n", "return", "true", "\n", "case", "tcell", ".", "KeyEnd", ":", "a", ".", "keyEnd", "(", ")", "\n", "return", "true", "\n", "case", "tcell", ".", "KeyHome", ":", "a", ".", "keyHome", "(", ")", "\n", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// HandleEvent handles events. In particular, it handles certain key events // to move the cursor or pan the view.
[ "HandleEvent", "handles", "events", ".", "In", "particular", "it", "handles", "certain", "key", "events", "to", "move", "the", "cursor", "or", "pan", "the", "view", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L188-L222
22,270
gdamore/tcell
views/cellarea.go
Size
func (a *CellView) Size() (int, int) { // We always return a minimum of two rows, and two columns. w, h := a.model.GetBounds() // Clip to a 2x2 minimum square; we can scroll within that. if w > 2 { w = 2 } if h > 2 { h = 2 } return w, h }
go
func (a *CellView) Size() (int, int) { // We always return a minimum of two rows, and two columns. w, h := a.model.GetBounds() // Clip to a 2x2 minimum square; we can scroll within that. if w > 2 { w = 2 } if h > 2 { h = 2 } return w, h }
[ "func", "(", "a", "*", "CellView", ")", "Size", "(", ")", "(", "int", ",", "int", ")", "{", "// We always return a minimum of two rows, and two columns.", "w", ",", "h", ":=", "a", ".", "model", ".", "GetBounds", "(", ")", "\n", "// Clip to a 2x2 minimum square; we can scroll within that.", "if", "w", ">", "2", "{", "w", "=", "2", "\n", "}", "\n", "if", "h", ">", "2", "{", "h", "=", "2", "\n", "}", "\n", "return", "w", ",", "h", "\n", "}" ]
// Size returns the content size, based on the model.
[ "Size", "returns", "the", "content", "size", "based", "on", "the", "model", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L225-L236
22,271
gdamore/tcell
views/cellarea.go
SetModel
func (a *CellView) SetModel(model CellModel) { w, h := model.GetBounds() model.SetCursor(0, 0) a.model = model a.port.SetContentSize(w, h, true) a.port.ValidateView() a.PostEventWidgetContent(a) }
go
func (a *CellView) SetModel(model CellModel) { w, h := model.GetBounds() model.SetCursor(0, 0) a.model = model a.port.SetContentSize(w, h, true) a.port.ValidateView() a.PostEventWidgetContent(a) }
[ "func", "(", "a", "*", "CellView", ")", "SetModel", "(", "model", "CellModel", ")", "{", "w", ",", "h", ":=", "model", ".", "GetBounds", "(", ")", "\n", "model", ".", "SetCursor", "(", "0", ",", "0", ")", "\n", "a", ".", "model", "=", "model", "\n", "a", ".", "port", ".", "SetContentSize", "(", "w", ",", "h", ",", "true", ")", "\n", "a", ".", "port", ".", "ValidateView", "(", ")", "\n", "a", ".", "PostEventWidgetContent", "(", "a", ")", "\n", "}" ]
// SetModel sets the model for this CellView.
[ "SetModel", "sets", "the", "model", "for", "this", "CellView", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L239-L246
22,272
gdamore/tcell
views/cellarea.go
SetView
func (a *CellView) SetView(view View) { port := a.port port.SetView(view) a.view = view if view == nil { return } width, height := view.Size() a.port.Resize(0, 0, width, height) if a.model != nil { w, h := a.model.GetBounds() a.port.SetContentSize(w, h, true) } a.Resize() }
go
func (a *CellView) SetView(view View) { port := a.port port.SetView(view) a.view = view if view == nil { return } width, height := view.Size() a.port.Resize(0, 0, width, height) if a.model != nil { w, h := a.model.GetBounds() a.port.SetContentSize(w, h, true) } a.Resize() }
[ "func", "(", "a", "*", "CellView", ")", "SetView", "(", "view", "View", ")", "{", "port", ":=", "a", ".", "port", "\n", "port", ".", "SetView", "(", "view", ")", "\n", "a", ".", "view", "=", "view", "\n", "if", "view", "==", "nil", "{", "return", "\n", "}", "\n", "width", ",", "height", ":=", "view", ".", "Size", "(", ")", "\n", "a", ".", "port", ".", "Resize", "(", "0", ",", "0", ",", "width", ",", "height", ")", "\n", "if", "a", ".", "model", "!=", "nil", "{", "w", ",", "h", ":=", "a", ".", "model", ".", "GetBounds", "(", ")", "\n", "a", ".", "port", ".", "SetContentSize", "(", "w", ",", "h", ",", "true", ")", "\n", "}", "\n", "a", ".", "Resize", "(", ")", "\n", "}" ]
// SetView sets the View context.
[ "SetView", "sets", "the", "View", "context", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L249-L263
22,273
gdamore/tcell
views/cellarea.go
Resize
func (a *CellView) Resize() { // We might want to reflow text width, height := a.view.Size() a.port.Resize(0, 0, width, height) a.port.ValidateView() a.MakeCursorVisible() }
go
func (a *CellView) Resize() { // We might want to reflow text width, height := a.view.Size() a.port.Resize(0, 0, width, height) a.port.ValidateView() a.MakeCursorVisible() }
[ "func", "(", "a", "*", "CellView", ")", "Resize", "(", ")", "{", "// We might want to reflow text", "width", ",", "height", ":=", "a", ".", "view", ".", "Size", "(", ")", "\n", "a", ".", "port", ".", "Resize", "(", "0", ",", "0", ",", "width", ",", "height", ")", "\n", "a", ".", "port", ".", "ValidateView", "(", ")", "\n", "a", ".", "MakeCursorVisible", "(", ")", "\n", "}" ]
// Resize is called when the View is resized. It will ensure that the // cursor is visible, if present.
[ "Resize", "is", "called", "when", "the", "View", "is", "resized", ".", "It", "will", "ensure", "that", "the", "cursor", "is", "visible", "if", "present", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L267-L273
22,274
gdamore/tcell
views/cellarea.go
SetCursor
func (a *CellView) SetCursor(x, y int) { a.cursorX = x a.cursorY = y a.model.SetCursor(x, y) }
go
func (a *CellView) SetCursor(x, y int) { a.cursorX = x a.cursorY = y a.model.SetCursor(x, y) }
[ "func", "(", "a", "*", "CellView", ")", "SetCursor", "(", "x", ",", "y", "int", ")", "{", "a", ".", "cursorX", "=", "x", "\n", "a", ".", "cursorY", "=", "y", "\n", "a", ".", "model", ".", "SetCursor", "(", "x", ",", "y", ")", "\n", "}" ]
// SetCursor sets the the cursor position.
[ "SetCursor", "sets", "the", "the", "cursor", "position", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L276-L280
22,275
gdamore/tcell
views/cellarea.go
SetCursorX
func (a *CellView) SetCursorX(x int) { a.SetCursor(x, a.cursorY) }
go
func (a *CellView) SetCursorX(x int) { a.SetCursor(x, a.cursorY) }
[ "func", "(", "a", "*", "CellView", ")", "SetCursorX", "(", "x", "int", ")", "{", "a", ".", "SetCursor", "(", "x", ",", "a", ".", "cursorY", ")", "\n", "}" ]
// SetCursorX sets the the cursor column.
[ "SetCursorX", "sets", "the", "the", "cursor", "column", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L283-L285
22,276
gdamore/tcell
views/cellarea.go
SetCursorY
func (a *CellView) SetCursorY(y int) { a.SetCursor(a.cursorX, y) }
go
func (a *CellView) SetCursorY(y int) { a.SetCursor(a.cursorX, y) }
[ "func", "(", "a", "*", "CellView", ")", "SetCursorY", "(", "y", "int", ")", "{", "a", ".", "SetCursor", "(", "a", ".", "cursorX", ",", "y", ")", "\n", "}" ]
// SetCursorY sets the the cursor row.
[ "SetCursorY", "sets", "the", "the", "cursor", "row", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L288-L290
22,277
gdamore/tcell
views/cellarea.go
MakeVisible
func (a *CellView) MakeVisible(x, y int) { a.port.MakeVisible(x, y) }
go
func (a *CellView) MakeVisible(x, y int) { a.port.MakeVisible(x, y) }
[ "func", "(", "a", "*", "CellView", ")", "MakeVisible", "(", "x", ",", "y", "int", ")", "{", "a", ".", "port", ".", "MakeVisible", "(", "x", ",", "y", ")", "\n", "}" ]
// MakeVisible makes the given coordinates visible, if they are not already. // It does this by moving the ViewPort for the CellView.
[ "MakeVisible", "makes", "the", "given", "coordinates", "visible", "if", "they", "are", "not", "already", ".", "It", "does", "this", "by", "moving", "the", "ViewPort", "for", "the", "CellView", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L294-L296
22,278
gdamore/tcell
views/cellarea.go
Init
func (a *CellView) Init() { a.once.Do(func() { a.port = NewViewPort(nil, 0, 0, 0, 0) a.style = tcell.StyleDefault }) }
go
func (a *CellView) Init() { a.once.Do(func() { a.port = NewViewPort(nil, 0, 0, 0, 0) a.style = tcell.StyleDefault }) }
[ "func", "(", "a", "*", "CellView", ")", "Init", "(", ")", "{", "a", ".", "once", ".", "Do", "(", "func", "(", ")", "{", "a", ".", "port", "=", "NewViewPort", "(", "nil", ",", "0", ",", "0", ",", "0", ",", "0", ")", "\n", "a", ".", "style", "=", "tcell", ".", "StyleDefault", "\n", "}", ")", "\n", "}" ]
// Init initializes a new CellView for use.
[ "Init", "initializes", "a", "new", "CellView", "for", "use", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L304-L309
22,279
gdamore/tcell
simulation.go
NewSimulationScreen
func NewSimulationScreen(charset string) SimulationScreen { if charset == "" { charset = "UTF-8" } s := &simscreen{charset: charset} return s }
go
func NewSimulationScreen(charset string) SimulationScreen { if charset == "" { charset = "UTF-8" } s := &simscreen{charset: charset} return s }
[ "func", "NewSimulationScreen", "(", "charset", "string", ")", "SimulationScreen", "{", "if", "charset", "==", "\"", "\"", "{", "charset", "=", "\"", "\"", "\n", "}", "\n", "s", ":=", "&", "simscreen", "{", "charset", ":", "charset", "}", "\n", "return", "s", "\n", "}" ]
// NewSimulationScreen returns a SimulationScreen. Note that // SimulationScreen is also a Screen.
[ "NewSimulationScreen", "returns", "a", "SimulationScreen", ".", "Note", "that", "SimulationScreen", "is", "also", "a", "Screen", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/simulation.go#L26-L32
22,280
gdamore/tcell
resize.go
NewEventResize
func NewEventResize(width, height int) *EventResize { return &EventResize{t: time.Now(), w: width, h: height} }
go
func NewEventResize(width, height int) *EventResize { return &EventResize{t: time.Now(), w: width, h: height} }
[ "func", "NewEventResize", "(", "width", ",", "height", "int", ")", "*", "EventResize", "{", "return", "&", "EventResize", "{", "t", ":", "time", ".", "Now", "(", ")", ",", "w", ":", "width", ",", "h", ":", "height", "}", "\n", "}" ]
// NewEventResize creates an EventResize with the new updated window size, // which is given in character cells.
[ "NewEventResize", "creates", "an", "EventResize", "with", "the", "new", "updated", "window", "size", "which", "is", "given", "in", "character", "cells", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/resize.go#L30-L32
22,281
gdamore/tcell
terminfo/terminfo.go
End
func (pb *paramsBuffer) End() string { s := pb.out.String() pb.lk.Unlock() return s }
go
func (pb *paramsBuffer) End() string { s := pb.out.String() pb.lk.Unlock() return s }
[ "func", "(", "pb", "*", "paramsBuffer", ")", "End", "(", ")", "string", "{", "s", ":=", "pb", ".", "out", ".", "String", "(", ")", "\n", "pb", ".", "lk", ".", "Unlock", "(", ")", "\n", "return", "s", "\n", "}" ]
// End returns the final output from TParam, but it also releases the lock.
[ "End", "returns", "the", "final", "output", "from", "TParam", "but", "it", "also", "releases", "the", "lock", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/terminfo/terminfo.go#L325-L329
22,282
gdamore/tcell
terminfo/terminfo.go
TGoto
func (t *Terminfo) TGoto(col, row int) string { return t.TParm(t.SetCursor, row, col) }
go
func (t *Terminfo) TGoto(col, row int) string { return t.TParm(t.SetCursor, row, col) }
[ "func", "(", "t", "*", "Terminfo", ")", "TGoto", "(", "col", ",", "row", "int", ")", "string", "{", "return", "t", ".", "TParm", "(", "t", ".", "SetCursor", ",", "row", ",", "col", ")", "\n", "}" ]
// TGoto returns a string suitable for addressing the cursor at the given // row and column. The origin 0, 0 is in the upper left corner of the screen.
[ "TGoto", "returns", "a", "string", "suitable", "for", "addressing", "the", "cursor", "at", "the", "given", "row", "and", "column", ".", "The", "origin", "0", "0", "is", "in", "the", "upper", "left", "corner", "of", "the", "screen", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/terminfo/terminfo.go#L675-L677
22,283
gdamore/tcell
terminfo/terminfo.go
TColor
func (t *Terminfo) TColor(fi, bi int) string { rv := "" // As a special case, we map bright colors to lower versions if the // color table only holds 8. For the remaining 240 colors, the user // is out of luck. Someday we could create a mapping table, but its // not worth it. if t.Colors == 8 { if fi > 7 && fi < 16 { fi -= 8 } if bi > 7 && bi < 16 { bi -= 8 } } if t.Colors > fi && fi >= 0 { rv += t.TParm(t.SetFg, fi) } if t.Colors > bi && bi >= 0 { rv += t.TParm(t.SetBg, bi) } return rv }
go
func (t *Terminfo) TColor(fi, bi int) string { rv := "" // As a special case, we map bright colors to lower versions if the // color table only holds 8. For the remaining 240 colors, the user // is out of luck. Someday we could create a mapping table, but its // not worth it. if t.Colors == 8 { if fi > 7 && fi < 16 { fi -= 8 } if bi > 7 && bi < 16 { bi -= 8 } } if t.Colors > fi && fi >= 0 { rv += t.TParm(t.SetFg, fi) } if t.Colors > bi && bi >= 0 { rv += t.TParm(t.SetBg, bi) } return rv }
[ "func", "(", "t", "*", "Terminfo", ")", "TColor", "(", "fi", ",", "bi", "int", ")", "string", "{", "rv", ":=", "\"", "\"", "\n", "// As a special case, we map bright colors to lower versions if the", "// color table only holds 8. For the remaining 240 colors, the user", "// is out of luck. Someday we could create a mapping table, but its", "// not worth it.", "if", "t", ".", "Colors", "==", "8", "{", "if", "fi", ">", "7", "&&", "fi", "<", "16", "{", "fi", "-=", "8", "\n", "}", "\n", "if", "bi", ">", "7", "&&", "bi", "<", "16", "{", "bi", "-=", "8", "\n", "}", "\n", "}", "\n", "if", "t", ".", "Colors", ">", "fi", "&&", "fi", ">=", "0", "{", "rv", "+=", "t", ".", "TParm", "(", "t", ".", "SetFg", ",", "fi", ")", "\n", "}", "\n", "if", "t", ".", "Colors", ">", "bi", "&&", "bi", ">=", "0", "{", "rv", "+=", "t", ".", "TParm", "(", "t", ".", "SetBg", ",", "bi", ")", "\n", "}", "\n", "return", "rv", "\n", "}" ]
// TColor returns a string corresponding to the given foreground and background // colors. Either fg or bg can be set to -1 to elide.
[ "TColor", "returns", "a", "string", "corresponding", "to", "the", "given", "foreground", "and", "background", "colors", ".", "Either", "fg", "or", "bg", "can", "be", "set", "to", "-", "1", "to", "elide", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/terminfo/terminfo.go#L681-L702
22,284
gdamore/tcell
terminfo/terminfo.go
AddTerminfo
func AddTerminfo(t *Terminfo) { dblock.Lock() terminfos[t.Name] = t for _, x := range t.Aliases { terminfos[x] = t } dblock.Unlock() }
go
func AddTerminfo(t *Terminfo) { dblock.Lock() terminfos[t.Name] = t for _, x := range t.Aliases { terminfos[x] = t } dblock.Unlock() }
[ "func", "AddTerminfo", "(", "t", "*", "Terminfo", ")", "{", "dblock", ".", "Lock", "(", ")", "\n", "terminfos", "[", "t", ".", "Name", "]", "=", "t", "\n", "for", "_", ",", "x", ":=", "range", "t", ".", "Aliases", "{", "terminfos", "[", "x", "]", "=", "t", "\n", "}", "\n", "dblock", ".", "Unlock", "(", ")", "\n", "}" ]
// AddTerminfo can be called to register a new Terminfo entry.
[ "AddTerminfo", "can", "be", "called", "to", "register", "a", "new", "Terminfo", "entry", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/terminfo/terminfo.go#L711-L718
22,285
gdamore/tcell
screen.go
NewScreen
func NewScreen() (Screen, error) { // Windows is happier if we try for a console screen first. if s, _ := NewConsoleScreen(); s != nil { return s, nil } else if s, e := NewTerminfoScreen(); s != nil { return s, nil } else { return nil, e } }
go
func NewScreen() (Screen, error) { // Windows is happier if we try for a console screen first. if s, _ := NewConsoleScreen(); s != nil { return s, nil } else if s, e := NewTerminfoScreen(); s != nil { return s, nil } else { return nil, e } }
[ "func", "NewScreen", "(", ")", "(", "Screen", ",", "error", ")", "{", "// Windows is happier if we try for a console screen first.", "if", "s", ",", "_", ":=", "NewConsoleScreen", "(", ")", ";", "s", "!=", "nil", "{", "return", "s", ",", "nil", "\n", "}", "else", "if", "s", ",", "e", ":=", "NewTerminfoScreen", "(", ")", ";", "s", "!=", "nil", "{", "return", "s", ",", "nil", "\n", "}", "else", "{", "return", "nil", ",", "e", "\n", "}", "\n", "}" ]
// NewScreen returns a default Screen suitable for the user's terminal // environment.
[ "NewScreen", "returns", "a", "default", "Screen", "suitable", "for", "the", "user", "s", "terminal", "environment", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/screen.go#L200-L209
22,286
gdamore/tcell
views/app.go
initialize
func (app *Application) initialize() error { if app.screen == nil { if app.screen, app.err = tcell.NewScreen(); app.err != nil { return app.err } app.screen.SetStyle(app.style) } return nil }
go
func (app *Application) initialize() error { if app.screen == nil { if app.screen, app.err = tcell.NewScreen(); app.err != nil { return app.err } app.screen.SetStyle(app.style) } return nil }
[ "func", "(", "app", "*", "Application", ")", "initialize", "(", ")", "error", "{", "if", "app", ".", "screen", "==", "nil", "{", "if", "app", ".", "screen", ",", "app", ".", "err", "=", "tcell", ".", "NewScreen", "(", ")", ";", "app", ".", "err", "!=", "nil", "{", "return", "app", ".", "err", "\n", "}", "\n", "app", ".", "screen", ".", "SetStyle", "(", "app", ".", "style", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// initialize initializes the application. It will normally attempt to // allocate a default screen if one is not already established.
[ "initialize", "initializes", "the", "application", ".", "It", "will", "normally", "attempt", "to", "allocate", "a", "default", "screen", "if", "one", "is", "not", "already", "established", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/app.go#L39-L47
22,287
gdamore/tcell
views/app.go
Quit
func (app *Application) Quit() { ev := &eventAppQuit{} ev.SetEventNow() if scr := app.screen; scr != nil { go func() { scr.PostEventWait(ev) }() } }
go
func (app *Application) Quit() { ev := &eventAppQuit{} ev.SetEventNow() if scr := app.screen; scr != nil { go func() { scr.PostEventWait(ev) }() } }
[ "func", "(", "app", "*", "Application", ")", "Quit", "(", ")", "{", "ev", ":=", "&", "eventAppQuit", "{", "}", "\n", "ev", ".", "SetEventNow", "(", ")", "\n", "if", "scr", ":=", "app", ".", "screen", ";", "scr", "!=", "nil", "{", "go", "func", "(", ")", "{", "scr", ".", "PostEventWait", "(", "ev", ")", "}", "(", ")", "\n", "}", "\n", "}" ]
// Quit causes the application to shutdown gracefully. It does not wait // for the application to exit, but returns immediately.
[ "Quit", "causes", "the", "application", "to", "shutdown", "gracefully", ".", "It", "does", "not", "wait", "for", "the", "application", "to", "exit", "but", "returns", "immediately", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/app.go#L51-L57
22,288
gdamore/tcell
views/app.go
Refresh
func (app *Application) Refresh() { ev := &eventAppRefresh{} ev.SetEventNow() if scr := app.screen; scr != nil { go func() { scr.PostEventWait(ev) }() } }
go
func (app *Application) Refresh() { ev := &eventAppRefresh{} ev.SetEventNow() if scr := app.screen; scr != nil { go func() { scr.PostEventWait(ev) }() } }
[ "func", "(", "app", "*", "Application", ")", "Refresh", "(", ")", "{", "ev", ":=", "&", "eventAppRefresh", "{", "}", "\n", "ev", ".", "SetEventNow", "(", ")", "\n", "if", "scr", ":=", "app", ".", "screen", ";", "scr", "!=", "nil", "{", "go", "func", "(", ")", "{", "scr", ".", "PostEventWait", "(", "ev", ")", "}", "(", ")", "\n", "}", "\n", "}" ]
// Refresh causes the application forcibly redraw everything. Use this // to clear up screen corruption, etc.
[ "Refresh", "causes", "the", "application", "forcibly", "redraw", "everything", ".", "Use", "this", "to", "clear", "up", "screen", "corruption", "etc", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/app.go#L61-L67
22,289
gdamore/tcell
views/app.go
Update
func (app *Application) Update() { ev := &eventAppUpdate{} ev.SetEventNow() if scr := app.screen; scr != nil { go func() { scr.PostEventWait(ev) }() } }
go
func (app *Application) Update() { ev := &eventAppUpdate{} ev.SetEventNow() if scr := app.screen; scr != nil { go func() { scr.PostEventWait(ev) }() } }
[ "func", "(", "app", "*", "Application", ")", "Update", "(", ")", "{", "ev", ":=", "&", "eventAppUpdate", "{", "}", "\n", "ev", ".", "SetEventNow", "(", ")", "\n", "if", "scr", ":=", "app", ".", "screen", ";", "scr", "!=", "nil", "{", "go", "func", "(", ")", "{", "scr", ".", "PostEventWait", "(", "ev", ")", "}", "(", ")", "\n", "}", "\n", "}" ]
// Update asks the application to draw any screen updates that have not // been drawn yet.
[ "Update", "asks", "the", "application", "to", "draw", "any", "screen", "updates", "that", "have", "not", "been", "drawn", "yet", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/app.go#L71-L77
22,290
gdamore/tcell
views/app.go
PostFunc
func (app *Application) PostFunc(fn func()) { ev := &eventAppFunc{fn: fn} ev.SetEventNow() if scr := app.screen; scr != nil { go func() { scr.PostEventWait(ev) }() } }
go
func (app *Application) PostFunc(fn func()) { ev := &eventAppFunc{fn: fn} ev.SetEventNow() if scr := app.screen; scr != nil { go func() { scr.PostEventWait(ev) }() } }
[ "func", "(", "app", "*", "Application", ")", "PostFunc", "(", "fn", "func", "(", ")", ")", "{", "ev", ":=", "&", "eventAppFunc", "{", "fn", ":", "fn", "}", "\n", "ev", ".", "SetEventNow", "(", ")", "\n", "if", "scr", ":=", "app", ".", "screen", ";", "scr", "!=", "nil", "{", "go", "func", "(", ")", "{", "scr", ".", "PostEventWait", "(", "ev", ")", "}", "(", ")", "\n", "}", "\n", "}" ]
// PostFunc posts a function to be executed in the context of the // application's event loop. Functions that need to update displayed // state, etc. can do this to avoid holding locks.
[ "PostFunc", "posts", "a", "function", "to", "be", "executed", "in", "the", "context", "of", "the", "application", "s", "event", "loop", ".", "Functions", "that", "need", "to", "update", "displayed", "state", "etc", ".", "can", "do", "this", "to", "avoid", "holding", "locks", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/app.go#L82-L88
22,291
gdamore/tcell
views/app.go
SetScreen
func (app *Application) SetScreen(scr tcell.Screen) { if app.screen == nil { app.screen = scr app.err = nil } }
go
func (app *Application) SetScreen(scr tcell.Screen) { if app.screen == nil { app.screen = scr app.err = nil } }
[ "func", "(", "app", "*", "Application", ")", "SetScreen", "(", "scr", "tcell", ".", "Screen", ")", "{", "if", "app", ".", "screen", "==", "nil", "{", "app", ".", "screen", "=", "scr", "\n", "app", ".", "err", "=", "nil", "\n", "}", "\n", "}" ]
// SetScreen sets the screen to use for the application. This must be // done before the application starts to run or is initialized.
[ "SetScreen", "sets", "the", "screen", "to", "use", "for", "the", "application", ".", "This", "must", "be", "done", "before", "the", "application", "starts", "to", "run", "or", "is", "initialized", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/app.go#L92-L97
22,292
gdamore/tcell
mouse.go
NewEventMouse
func NewEventMouse(x, y int, btn ButtonMask, mod ModMask) *EventMouse { return &EventMouse{t: time.Now(), x: x, y: y, btn: btn, mod: mod} }
go
func NewEventMouse(x, y int, btn ButtonMask, mod ModMask) *EventMouse { return &EventMouse{t: time.Now(), x: x, y: y, btn: btn, mod: mod} }
[ "func", "NewEventMouse", "(", "x", ",", "y", "int", ",", "btn", "ButtonMask", ",", "mod", "ModMask", ")", "*", "EventMouse", "{", "return", "&", "EventMouse", "{", "t", ":", "time", ".", "Now", "(", ")", ",", "x", ":", "x", ",", "y", ":", "y", ",", "btn", ":", "btn", ",", "mod", ":", "mod", "}", "\n", "}" ]
// NewEventMouse is used to create a new mouse event. Applications // shouldn't need to use this; its mostly for screen implementors.
[ "NewEventMouse", "is", "used", "to", "create", "a", "new", "mouse", "event", ".", "Applications", "shouldn", "t", "need", "to", "use", "this", ";", "its", "mostly", "for", "screen", "implementors", "." ]
dcf1bb30770eb1158b67005e1e472de6d74f055d
https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/mouse.go#L69-L71
22,293
onsi/ginkgo
ginkgo/run_command.go
moveCoverprofiles
func (r *SpecRunner) moveCoverprofiles(runners []*testrunner.TestRunner) { for _, runner := range runners { _, filename := filepath.Split(runner.CoverageFile) err := os.Rename(runner.CoverageFile, filepath.Join(r.getOutputDir(), filename)) if err != nil { fmt.Printf("Unable to move coverprofile %s, %v\n", runner.CoverageFile, err) return } } }
go
func (r *SpecRunner) moveCoverprofiles(runners []*testrunner.TestRunner) { for _, runner := range runners { _, filename := filepath.Split(runner.CoverageFile) err := os.Rename(runner.CoverageFile, filepath.Join(r.getOutputDir(), filename)) if err != nil { fmt.Printf("Unable to move coverprofile %s, %v\n", runner.CoverageFile, err) return } } }
[ "func", "(", "r", "*", "SpecRunner", ")", "moveCoverprofiles", "(", "runners", "[", "]", "*", "testrunner", ".", "TestRunner", ")", "{", "for", "_", ",", "runner", ":=", "range", "runners", "{", "_", ",", "filename", ":=", "filepath", ".", "Split", "(", "runner", ".", "CoverageFile", ")", "\n", "err", ":=", "os", ".", "Rename", "(", "runner", ".", "CoverageFile", ",", "filepath", ".", "Join", "(", "r", ".", "getOutputDir", "(", ")", ",", "filename", ")", ")", "\n\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "runner", ".", "CoverageFile", ",", "err", ")", "\n", "return", "\n", "}", "\n", "}", "\n", "}" ]
// Moves all generated profiles to specified directory
[ "Moves", "all", "generated", "profiles", "to", "specified", "directory" ]
eea6ad008b96acdaa524f5b409513bf062b500ad
https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo/run_command.go#L144-L154
22,294
onsi/ginkgo
ginkgo/run_command.go
combineCoverprofiles
func (r *SpecRunner) combineCoverprofiles(runners []*testrunner.TestRunner) error { path, _ := filepath.Abs(r.getOutputDir()) if !fileExists(path) { return fmt.Errorf("Unable to create combined profile, outputdir does not exist: %s", r.getOutputDir()) } fmt.Println("path is " + path) combined, err := os.OpenFile(filepath.Join(path, r.getCoverprofile()), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0666) if err != nil { fmt.Printf("Unable to create combined profile, %v\n", err) return nil // non-fatal error } for _, runner := range runners { contents, err := ioutil.ReadFile(runner.CoverageFile) if err != nil { fmt.Printf("Unable to read coverage file %s to combine, %v\n", runner.CoverageFile, err) return nil // non-fatal error } _, err = combined.Write(contents) if err != nil { fmt.Printf("Unable to append to coverprofile, %v\n", err) return nil // non-fatal error } } fmt.Println("All profiles combined") return nil }
go
func (r *SpecRunner) combineCoverprofiles(runners []*testrunner.TestRunner) error { path, _ := filepath.Abs(r.getOutputDir()) if !fileExists(path) { return fmt.Errorf("Unable to create combined profile, outputdir does not exist: %s", r.getOutputDir()) } fmt.Println("path is " + path) combined, err := os.OpenFile(filepath.Join(path, r.getCoverprofile()), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0666) if err != nil { fmt.Printf("Unable to create combined profile, %v\n", err) return nil // non-fatal error } for _, runner := range runners { contents, err := ioutil.ReadFile(runner.CoverageFile) if err != nil { fmt.Printf("Unable to read coverage file %s to combine, %v\n", runner.CoverageFile, err) return nil // non-fatal error } _, err = combined.Write(contents) if err != nil { fmt.Printf("Unable to append to coverprofile, %v\n", err) return nil // non-fatal error } } fmt.Println("All profiles combined") return nil }
[ "func", "(", "r", "*", "SpecRunner", ")", "combineCoverprofiles", "(", "runners", "[", "]", "*", "testrunner", ".", "TestRunner", ")", "error", "{", "path", ",", "_", ":=", "filepath", ".", "Abs", "(", "r", ".", "getOutputDir", "(", ")", ")", "\n", "if", "!", "fileExists", "(", "path", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "r", ".", "getOutputDir", "(", ")", ")", "\n", "}", "\n\n", "fmt", ".", "Println", "(", "\"", "\"", "+", "path", ")", "\n\n", "combined", ",", "err", ":=", "os", ".", "OpenFile", "(", "filepath", ".", "Join", "(", "path", ",", "r", ".", "getCoverprofile", "(", ")", ")", ",", "os", ".", "O_APPEND", "|", "os", ".", "O_WRONLY", "|", "os", ".", "O_CREATE", ",", "0666", ")", "\n\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "err", ")", "\n", "return", "nil", "// non-fatal error", "\n", "}", "\n\n", "for", "_", ",", "runner", ":=", "range", "runners", "{", "contents", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "runner", ".", "CoverageFile", ")", "\n\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "runner", ".", "CoverageFile", ",", "err", ")", "\n", "return", "nil", "// non-fatal error", "\n", "}", "\n\n", "_", ",", "err", "=", "combined", ".", "Write", "(", "contents", ")", "\n\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "err", ")", "\n", "return", "nil", "// non-fatal error", "\n", "}", "\n", "}", "\n\n", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}" ]
// Combines all generated profiles in the specified directory
[ "Combines", "all", "generated", "profiles", "in", "the", "specified", "directory" ]
eea6ad008b96acdaa524f5b409513bf062b500ad
https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo/run_command.go#L157-L192
22,295
onsi/ginkgo
internal/remote/server.go
NewServer
func NewServer(parallelTotal int) (*Server, error) { listener, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { return nil, err } return &Server{ listener: listener, lock: &sync.Mutex{}, alives: make([]func() bool, parallelTotal), beforeSuiteData: types.RemoteBeforeSuiteData{Data: nil, State: types.RemoteBeforeSuiteStatePending}, parallelTotal: parallelTotal, }, nil }
go
func NewServer(parallelTotal int) (*Server, error) { listener, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { return nil, err } return &Server{ listener: listener, lock: &sync.Mutex{}, alives: make([]func() bool, parallelTotal), beforeSuiteData: types.RemoteBeforeSuiteData{Data: nil, State: types.RemoteBeforeSuiteStatePending}, parallelTotal: parallelTotal, }, nil }
[ "func", "NewServer", "(", "parallelTotal", "int", ")", "(", "*", "Server", ",", "error", ")", "{", "listener", ",", "err", ":=", "net", ".", "Listen", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "Server", "{", "listener", ":", "listener", ",", "lock", ":", "&", "sync", ".", "Mutex", "{", "}", ",", "alives", ":", "make", "(", "[", "]", "func", "(", ")", "bool", ",", "parallelTotal", ")", ",", "beforeSuiteData", ":", "types", ".", "RemoteBeforeSuiteData", "{", "Data", ":", "nil", ",", "State", ":", "types", ".", "RemoteBeforeSuiteStatePending", "}", ",", "parallelTotal", ":", "parallelTotal", ",", "}", ",", "nil", "\n", "}" ]
//Create a new server, automatically selecting a port
[ "Create", "a", "new", "server", "automatically", "selecting", "a", "port" ]
eea6ad008b96acdaa524f5b409513bf062b500ad
https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/internal/remote/server.go#L39-L51
22,296
onsi/ginkgo
internal/remote/server.go
readAll
func (server *Server) readAll(request *http.Request) []byte { defer request.Body.Close() body, _ := ioutil.ReadAll(request.Body) return body }
go
func (server *Server) readAll(request *http.Request) []byte { defer request.Body.Close() body, _ := ioutil.ReadAll(request.Body) return body }
[ "func", "(", "server", "*", "Server", ")", "readAll", "(", "request", "*", "http", ".", "Request", ")", "[", "]", "byte", "{", "defer", "request", ".", "Body", ".", "Close", "(", ")", "\n", "body", ",", "_", ":=", "ioutil", ".", "ReadAll", "(", "request", ".", "Body", ")", "\n", "return", "body", "\n", "}" ]
// // Streaming Endpoints // //The server will forward all received messages to Ginkgo reporters registered with `RegisterReporters`
[ "Streaming", "Endpoints", "The", "server", "will", "forward", "all", "received", "messages", "to", "Ginkgo", "reporters", "registered", "with", "RegisterReporters" ]
eea6ad008b96acdaa524f5b409513bf062b500ad
https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/internal/remote/server.go#L91-L95
22,297
onsi/ginkgo
ginkgo_dsl.go
Skip
func Skip(message string, callerSkip ...int) { skip := 0 if len(callerSkip) > 0 { skip = callerSkip[0] } globalFailer.Skip(message, codelocation.New(skip+1)) panic(GINKGO_PANIC) }
go
func Skip(message string, callerSkip ...int) { skip := 0 if len(callerSkip) > 0 { skip = callerSkip[0] } globalFailer.Skip(message, codelocation.New(skip+1)) panic(GINKGO_PANIC) }
[ "func", "Skip", "(", "message", "string", ",", "callerSkip", "...", "int", ")", "{", "skip", ":=", "0", "\n", "if", "len", "(", "callerSkip", ")", ">", "0", "{", "skip", "=", "callerSkip", "[", "0", "]", "\n", "}", "\n\n", "globalFailer", ".", "Skip", "(", "message", ",", "codelocation", ".", "New", "(", "skip", "+", "1", ")", ")", "\n", "panic", "(", "GINKGO_PANIC", ")", "\n", "}" ]
//Skip notifies Ginkgo that the current spec was skipped.
[ "Skip", "notifies", "Ginkgo", "that", "the", "current", "spec", "was", "skipped", "." ]
eea6ad008b96acdaa524f5b409513bf062b500ad
https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo_dsl.go#L244-L252
22,298
onsi/ginkgo
ginkgo_dsl.go
PDescribe
func PDescribe(text string, body func()) bool { globalSuite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1)) return true }
go
func PDescribe(text string, body func()) bool { globalSuite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1)) return true }
[ "func", "PDescribe", "(", "text", "string", ",", "body", "func", "(", ")", ")", "bool", "{", "globalSuite", ".", "PushContainerNode", "(", "text", ",", "body", ",", "types", ".", "FlagTypePending", ",", "codelocation", ".", "New", "(", "1", ")", ")", "\n", "return", "true", "\n", "}" ]
//You can mark the tests within a describe block as pending using PDescribe
[ "You", "can", "mark", "the", "tests", "within", "a", "describe", "block", "as", "pending", "using", "PDescribe" ]
eea6ad008b96acdaa524f5b409513bf062b500ad
https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo_dsl.go#L300-L303
22,299
onsi/ginkgo
ginkgo_dsl.go
FWhen
func FWhen(text string, body func()) bool { globalSuite.PushContainerNode("when "+text, body, types.FlagTypeFocused, codelocation.New(1)) return true }
go
func FWhen(text string, body func()) bool { globalSuite.PushContainerNode("when "+text, body, types.FlagTypeFocused, codelocation.New(1)) return true }
[ "func", "FWhen", "(", "text", "string", ",", "body", "func", "(", ")", ")", "bool", "{", "globalSuite", ".", "PushContainerNode", "(", "\"", "\"", "+", "text", ",", "body", ",", "types", ".", "FlagTypeFocused", ",", "codelocation", ".", "New", "(", "1", ")", ")", "\n", "return", "true", "\n", "}" ]
//You can focus the tests within a describe block using FWhen
[ "You", "can", "focus", "the", "tests", "within", "a", "describe", "block", "using", "FWhen" ]
eea6ad008b96acdaa524f5b409513bf062b500ad
https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo_dsl.go#L352-L355