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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
kubernetes-retired/heapster | metrics/sinks/hawkular/client.go | checkCache | func (h *hawkularSink) checkCache(key string, hash uint64) bool {
h.regLock.Lock()
defer h.regLock.Unlock()
_, found := h.expReg[key]
if !found || h.expReg[key].hash != hash {
return false
}
// Update the TTL
h.expReg[key].ttl = h.runId
return true
} | go | func (h *hawkularSink) checkCache(key string, hash uint64) bool {
h.regLock.Lock()
defer h.regLock.Unlock()
_, found := h.expReg[key]
if !found || h.expReg[key].hash != hash {
return false
}
// Update the TTL
h.expReg[key].ttl = h.runId
return true
} | [
"func",
"(",
"h",
"*",
"hawkularSink",
")",
"checkCache",
"(",
"key",
"string",
",",
"hash",
"uint64",
")",
"bool",
"{",
"h",
".",
"regLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"regLock",
".",
"Unlock",
"(",
")",
"\n",
"_",
",",
"fou... | // checkCache returns false if the cached instance is not current. Updates the TTL in the cache | [
"checkCache",
"returns",
"false",
"if",
"the",
"cached",
"instance",
"is",
"not",
"current",
".",
"Updates",
"the",
"TTL",
"in",
"the",
"cache"
] | e1e83412787b60d8a70088f09a2cb12339b305c3 | https://github.com/kubernetes-retired/heapster/blob/e1e83412787b60d8a70088f09a2cb12339b305c3/metrics/sinks/hawkular/client.go#L65-L75 | train |
kubernetes-retired/heapster | metrics/sinks/hawkular/client.go | expireCache | func (h *hawkularSink) expireCache(runId uint64) {
h.regLock.Lock()
defer h.regLock.Unlock()
for k, v := range h.expReg {
if (v.ttl + h.cacheAge) <= runId {
delete(h.expReg, k)
}
}
} | go | func (h *hawkularSink) expireCache(runId uint64) {
h.regLock.Lock()
defer h.regLock.Unlock()
for k, v := range h.expReg {
if (v.ttl + h.cacheAge) <= runId {
delete(h.expReg, k)
}
}
} | [
"func",
"(",
"h",
"*",
"hawkularSink",
")",
"expireCache",
"(",
"runId",
"uint64",
")",
"{",
"h",
".",
"regLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"regLock",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"k",
",",
"v",
":=",
"range",
"h"... | // expireCache will process the map and check for any item that has been expired and release it | [
"expireCache",
"will",
"process",
"the",
"map",
"and",
"check",
"for",
"any",
"item",
"that",
"has",
"been",
"expired",
"and",
"release",
"it"
] | e1e83412787b60d8a70088f09a2cb12339b305c3 | https://github.com/kubernetes-retired/heapster/blob/e1e83412787b60d8a70088f09a2cb12339b305c3/metrics/sinks/hawkular/client.go#L78-L87 | train |
kubernetes-retired/heapster | metrics/sinks/hawkular/client.go | updateDefinitions | func (h *hawkularSink) updateDefinitions(mds []*metrics.MetricDefinition) error {
for _, p := range mds {
if model, f := h.models[p.Tags[descriptorTag]]; f && !h.recent(p, model) {
if err := h.client.UpdateTags(p.Type, p.ID, p.Tags, h.modifiers...); err != nil {
return err
}
}
h.cache(p)
}
return ni... | go | func (h *hawkularSink) updateDefinitions(mds []*metrics.MetricDefinition) error {
for _, p := range mds {
if model, f := h.models[p.Tags[descriptorTag]]; f && !h.recent(p, model) {
if err := h.client.UpdateTags(p.Type, p.ID, p.Tags, h.modifiers...); err != nil {
return err
}
}
h.cache(p)
}
return ni... | [
"func",
"(",
"h",
"*",
"hawkularSink",
")",
"updateDefinitions",
"(",
"mds",
"[",
"]",
"*",
"metrics",
".",
"MetricDefinition",
")",
"error",
"{",
"for",
"_",
",",
"p",
":=",
"range",
"mds",
"{",
"if",
"model",
",",
"f",
":=",
"h",
".",
"models",
"... | // Fetches definitions from the server and checks that they're matching the descriptors | [
"Fetches",
"definitions",
"from",
"the",
"server",
"and",
"checks",
"that",
"they",
"re",
"matching",
"the",
"descriptors"
] | e1e83412787b60d8a70088f09a2cb12339b305c3 | https://github.com/kubernetes-retired/heapster/blob/e1e83412787b60d8a70088f09a2cb12339b305c3/metrics/sinks/hawkular/client.go#L90-L101 | train |
kubernetes-retired/heapster | metrics/sinks/hawkular/client.go | recent | func (h *hawkularSink) recent(live *metrics.MetricDefinition, model *metrics.MetricDefinition) bool {
recent := true
for k := range model.Tags {
if v, found := live.Tags[k]; !found {
// There's a label that wasn't in our stored definition
live.Tags[k] = v
recent = false
}
}
return recent
} | go | func (h *hawkularSink) recent(live *metrics.MetricDefinition, model *metrics.MetricDefinition) bool {
recent := true
for k := range model.Tags {
if v, found := live.Tags[k]; !found {
// There's a label that wasn't in our stored definition
live.Tags[k] = v
recent = false
}
}
return recent
} | [
"func",
"(",
"h",
"*",
"hawkularSink",
")",
"recent",
"(",
"live",
"*",
"metrics",
".",
"MetricDefinition",
",",
"model",
"*",
"metrics",
".",
"MetricDefinition",
")",
"bool",
"{",
"recent",
":=",
"true",
"\n",
"for",
"k",
":=",
"range",
"model",
".",
... | // Checks that stored definition is up to date with the model | [
"Checks",
"that",
"stored",
"definition",
"is",
"up",
"to",
"date",
"with",
"the",
"model"
] | e1e83412787b60d8a70088f09a2cb12339b305c3 | https://github.com/kubernetes-retired/heapster/blob/e1e83412787b60d8a70088f09a2cb12339b305c3/metrics/sinks/hawkular/client.go#L125-L136 | train |
kubernetes-retired/heapster | metrics/sinks/hawkular/client.go | descriptorToDefinition | func (h *hawkularSink) descriptorToDefinition(md *core.MetricDescriptor) metrics.MetricDefinition {
tags := make(map[string]string)
// Postfix description tags with _description
for _, l := range md.Labels {
if len(l.Description) > 0 {
tags[l.Key+descriptionTag] = l.Description
}
}
if len(md.Units.String()... | go | func (h *hawkularSink) descriptorToDefinition(md *core.MetricDescriptor) metrics.MetricDefinition {
tags := make(map[string]string)
// Postfix description tags with _description
for _, l := range md.Labels {
if len(l.Description) > 0 {
tags[l.Key+descriptionTag] = l.Description
}
}
if len(md.Units.String()... | [
"func",
"(",
"h",
"*",
"hawkularSink",
")",
"descriptorToDefinition",
"(",
"md",
"*",
"core",
".",
"MetricDescriptor",
")",
"metrics",
".",
"MetricDefinition",
"{",
"tags",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"// Postfix descri... | // Transform the MetricDescriptor to a format used by Hawkular-Metrics | [
"Transform",
"the",
"MetricDescriptor",
"to",
"a",
"format",
"used",
"by",
"Hawkular",
"-",
"Metrics"
] | e1e83412787b60d8a70088f09a2cb12339b305c3 | https://github.com/kubernetes-retired/heapster/blob/e1e83412787b60d8a70088f09a2cb12339b305c3/metrics/sinks/hawkular/client.go#L139-L161 | train |
kubernetes-retired/heapster | metrics/sinks/hawkular/client.go | pointToLabeledMetricHeader | func (h *hawkularSink) pointToLabeledMetricHeader(ms *core.MetricSet, metric core.LabeledMetric, timestamp time.Time) (*metrics.MetricHeader, error) {
name := h.idName(ms, metric.Name)
if resourceID, found := metric.Labels[core.LabelResourceID.Key]; found {
name = h.idName(ms, metric.Name+separator+resourceID)
}
... | go | func (h *hawkularSink) pointToLabeledMetricHeader(ms *core.MetricSet, metric core.LabeledMetric, timestamp time.Time) (*metrics.MetricHeader, error) {
name := h.idName(ms, metric.Name)
if resourceID, found := metric.Labels[core.LabelResourceID.Key]; found {
name = h.idName(ms, metric.Name+separator+resourceID)
}
... | [
"func",
"(",
"h",
"*",
"hawkularSink",
")",
"pointToLabeledMetricHeader",
"(",
"ms",
"*",
"core",
".",
"MetricSet",
",",
"metric",
"core",
".",
"LabeledMetric",
",",
"timestamp",
"time",
".",
"Time",
")",
"(",
"*",
"metrics",
".",
"MetricHeader",
",",
"err... | // Converts Timeseries to metric structure used by the Hawkular | [
"Converts",
"Timeseries",
"to",
"metric",
"structure",
"used",
"by",
"the",
"Hawkular"
] | e1e83412787b60d8a70088f09a2cb12339b305c3 | https://github.com/kubernetes-retired/heapster/blob/e1e83412787b60d8a70088f09a2cb12339b305c3/metrics/sinks/hawkular/client.go#L356-L382 | train |
kubernetes-retired/heapster | metrics/sinks/hawkular/client.go | parseFilters | func parseFilters(v []string) ([]Filter, error) {
fs := make([]Filter, 0, len(v))
for _, s := range v {
p := strings.Index(s, "(")
if p < 0 {
return nil, fmt.Errorf("Incorrect syntax in filter parameters, missing (")
}
if strings.Index(s, ")") != len(s)-1 {
return nil, fmt.Errorf("Incorrect syntax in f... | go | func parseFilters(v []string) ([]Filter, error) {
fs := make([]Filter, 0, len(v))
for _, s := range v {
p := strings.Index(s, "(")
if p < 0 {
return nil, fmt.Errorf("Incorrect syntax in filter parameters, missing (")
}
if strings.Index(s, ")") != len(s)-1 {
return nil, fmt.Errorf("Incorrect syntax in f... | [
"func",
"parseFilters",
"(",
"v",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"Filter",
",",
"error",
")",
"{",
"fs",
":=",
"make",
"(",
"[",
"]",
"Filter",
",",
"0",
",",
"len",
"(",
"v",
")",
")",
"\n",
"for",
"_",
",",
"s",
":=",
"range",
"v... | // If Heapster gets filters, remove these.. | [
"If",
"Heapster",
"gets",
"filters",
"remove",
"these",
".."
] | e1e83412787b60d8a70088f09a2cb12339b305c3 | https://github.com/kubernetes-retired/heapster/blob/e1e83412787b60d8a70088f09a2cb12339b305c3/metrics/sinks/hawkular/client.go#L385-L426 | train |
gdamore/tcell | _demos/mouse.go | main | func main() {
encoding.Register()
s, e := tcell.NewScreen()
if e != nil {
fmt.Fprintf(os.Stderr, "%v\n", e)
os.Exit(1)
}
if e := s.Init(); e != nil {
fmt.Fprintf(os.Stderr, "%v\n", e)
os.Exit(1)
}
defStyle = tcell.StyleDefault.
Background(tcell.ColorBlack).
Foreground(tcell.ColorWhite)
s.SetStyle(... | go | func main() {
encoding.Register()
s, e := tcell.NewScreen()
if e != nil {
fmt.Fprintf(os.Stderr, "%v\n", e)
os.Exit(1)
}
if e := s.Init(); e != nil {
fmt.Fprintf(os.Stderr, "%v\n", e)
os.Exit(1)
}
defStyle = tcell.StyleDefault.
Background(tcell.ColorBlack).
Foreground(tcell.ColorWhite)
s.SetStyle(... | [
"func",
"main",
"(",
")",
"{",
"encoding",
".",
"Register",
"(",
")",
"\n\n",
"s",
",",
"e",
":=",
"tcell",
".",
"NewScreen",
"(",
")",
"\n",
"if",
"e",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"os",
".",
"Stderr",
",",
"\"",
"\\n",
"\"",
... | // This program just shows simple mouse and keyboard events. Press ESC twice to
// exit. | [
"This",
"program",
"just",
"shows",
"simple",
"mouse",
"and",
"keyboard",
"events",
".",
"Press",
"ESC",
"twice",
"to",
"exit",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/_demos/mouse.go#L101-L250 | train |
gdamore/tcell | views/view.go | Fill | func (v *ViewPort) Fill(ch rune, style tcell.Style) {
if v.v != nil {
for y := 0; y < v.height; y++ {
for x := 0; x < v.width; x++ {
v.v.SetContent(x+v.physx, y+v.physy, ch, nil, style)
}
}
}
} | go | func (v *ViewPort) Fill(ch rune, style tcell.Style) {
if v.v != nil {
for y := 0; y < v.height; y++ {
for x := 0; x < v.width; x++ {
v.v.SetContent(x+v.physx, y+v.physy, ch, nil, style)
}
}
}
} | [
"func",
"(",
"v",
"*",
"ViewPort",
")",
"Fill",
"(",
"ch",
"rune",
",",
"style",
"tcell",
".",
"Style",
")",
"{",
"if",
"v",
".",
"v",
"!=",
"nil",
"{",
"for",
"y",
":=",
"0",
";",
"y",
"<",
"v",
".",
"height",
";",
"y",
"++",
"{",
"for",
... | // Fill fills the displayed view port with the given character and style. | [
"Fill",
"fills",
"the",
"displayed",
"view",
"port",
"with",
"the",
"given",
"character",
"and",
"style",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/view.go#L73-L81 | train |
gdamore/tcell | views/view.go | Reset | func (v *ViewPort) Reset() {
v.limx = 0
v.limy = 0
v.viewx = 0
v.viewy = 0
} | go | func (v *ViewPort) Reset() {
v.limx = 0
v.limy = 0
v.viewx = 0
v.viewy = 0
} | [
"func",
"(",
"v",
"*",
"ViewPort",
")",
"Reset",
"(",
")",
"{",
"v",
".",
"limx",
"=",
"0",
"\n",
"v",
".",
"limy",
"=",
"0",
"\n",
"v",
".",
"viewx",
"=",
"0",
"\n",
"v",
".",
"viewy",
"=",
"0",
"\n",
"}"
] | // Reset resets the record of content, and also resets the offset back
// to the origin. It doesn't alter the dimensions of the view port, nor
// the physical location relative to its parent. | [
"Reset",
"resets",
"the",
"record",
"of",
"content",
"and",
"also",
"resets",
"the",
"offset",
"back",
"to",
"the",
"origin",
".",
"It",
"doesn",
"t",
"alter",
"the",
"dimensions",
"of",
"the",
"view",
"port",
"nor",
"the",
"physical",
"location",
"relativ... | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/view.go#L91-L96 | train |
gdamore/tcell | views/view.go | MakeVisible | func (v *ViewPort) MakeVisible(x, y int) {
if x < v.limx && x >= v.viewx+v.width {
v.viewx = x - (v.width - 1)
}
if x >= 0 && x < v.viewx {
v.viewx = x
}
if y < v.limy && y >= v.viewy+v.height {
v.viewy = y - (v.height - 1)
}
if y >= 0 && y < v.viewy {
v.viewy = y
}
v.ValidateView()
} | go | func (v *ViewPort) MakeVisible(x, y int) {
if x < v.limx && x >= v.viewx+v.width {
v.viewx = x - (v.width - 1)
}
if x >= 0 && x < v.viewx {
v.viewx = x
}
if y < v.limy && y >= v.viewy+v.height {
v.viewy = y - (v.height - 1)
}
if y >= 0 && y < v.viewy {
v.viewy = y
}
v.ValidateView()
} | [
"func",
"(",
"v",
"*",
"ViewPort",
")",
"MakeVisible",
"(",
"x",
",",
"y",
"int",
")",
"{",
"if",
"x",
"<",
"v",
".",
"limx",
"&&",
"x",
">=",
"v",
".",
"viewx",
"+",
"v",
".",
"width",
"{",
"v",
".",
"viewx",
"=",
"x",
"-",
"(",
"v",
"."... | // MakeVisible moves the ViewPort the minimum necessary to make the given
// point visible. This should be called before any content is changed with
// SetContent, since otherwise it may be possible to move the location onto
// a region whose contents have been discarded. | [
"MakeVisible",
"moves",
"the",
"ViewPort",
"the",
"minimum",
"necessary",
"to",
"make",
"the",
"given",
"point",
"visible",
".",
"This",
"should",
"be",
"called",
"before",
"any",
"content",
"is",
"changed",
"with",
"SetContent",
"since",
"otherwise",
"it",
"m... | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/view.go#L130-L144 | train |
gdamore/tcell | views/view.go | ValidateViewY | func (v *ViewPort) ValidateViewY() {
if v.viewy >= v.limy-v.height {
v.viewy = (v.limy - v.height)
}
if v.viewy < 0 {
v.viewy = 0
}
} | go | func (v *ViewPort) ValidateViewY() {
if v.viewy >= v.limy-v.height {
v.viewy = (v.limy - v.height)
}
if v.viewy < 0 {
v.viewy = 0
}
} | [
"func",
"(",
"v",
"*",
"ViewPort",
")",
"ValidateViewY",
"(",
")",
"{",
"if",
"v",
".",
"viewy",
">=",
"v",
".",
"limy",
"-",
"v",
".",
"height",
"{",
"v",
".",
"viewy",
"=",
"(",
"v",
".",
"limy",
"-",
"v",
".",
"height",
")",
"\n",
"}",
"... | // ValidateViewY ensures that the Y offset of the view port is limited so that
// it cannot scroll away from the content. | [
"ValidateViewY",
"ensures",
"that",
"the",
"Y",
"offset",
"of",
"the",
"view",
"port",
"is",
"limited",
"so",
"that",
"it",
"cannot",
"scroll",
"away",
"from",
"the",
"content",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/view.go#L148-L155 | train |
gdamore/tcell | views/view.go | ValidateViewX | func (v *ViewPort) ValidateViewX() {
if v.viewx >= v.limx-v.width {
v.viewx = (v.limx - v.width)
}
if v.viewx < 0 {
v.viewx = 0
}
} | go | func (v *ViewPort) ValidateViewX() {
if v.viewx >= v.limx-v.width {
v.viewx = (v.limx - v.width)
}
if v.viewx < 0 {
v.viewx = 0
}
} | [
"func",
"(",
"v",
"*",
"ViewPort",
")",
"ValidateViewX",
"(",
")",
"{",
"if",
"v",
".",
"viewx",
">=",
"v",
".",
"limx",
"-",
"v",
".",
"width",
"{",
"v",
".",
"viewx",
"=",
"(",
"v",
".",
"limx",
"-",
"v",
".",
"width",
")",
"\n",
"}",
"\n... | // ValidateViewX ensures that the X offset of the view port is limited so that
// it cannot scroll away from the content. | [
"ValidateViewX",
"ensures",
"that",
"the",
"X",
"offset",
"of",
"the",
"view",
"port",
"is",
"limited",
"so",
"that",
"it",
"cannot",
"scroll",
"away",
"from",
"the",
"content",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/view.go#L159-L166 | train |
gdamore/tcell | views/view.go | Center | func (v *ViewPort) Center(x, y int) {
if x < 0 || y < 0 || x >= v.limx || y >= v.limy || v.v == nil {
return
}
v.viewx = x - (v.width / 2)
v.viewy = y - (v.height / 2)
v.ValidateView()
} | go | func (v *ViewPort) Center(x, y int) {
if x < 0 || y < 0 || x >= v.limx || y >= v.limy || v.v == nil {
return
}
v.viewx = x - (v.width / 2)
v.viewy = y - (v.height / 2)
v.ValidateView()
} | [
"func",
"(",
"v",
"*",
"ViewPort",
")",
"Center",
"(",
"x",
",",
"y",
"int",
")",
"{",
"if",
"x",
"<",
"0",
"||",
"y",
"<",
"0",
"||",
"x",
">=",
"v",
".",
"limx",
"||",
"y",
">=",
"v",
".",
"limy",
"||",
"v",
".",
"v",
"==",
"nil",
"{"... | // Center centers the point, if possible, in the View. | [
"Center",
"centers",
"the",
"point",
"if",
"possible",
"in",
"the",
"View",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/view.go#L176-L183 | train |
gdamore/tcell | views/view.go | ScrollUp | func (v *ViewPort) ScrollUp(rows int) {
v.viewy -= rows
v.ValidateViewY()
} | go | func (v *ViewPort) ScrollUp(rows int) {
v.viewy -= rows
v.ValidateViewY()
} | [
"func",
"(",
"v",
"*",
"ViewPort",
")",
"ScrollUp",
"(",
"rows",
"int",
")",
"{",
"v",
".",
"viewy",
"-=",
"rows",
"\n",
"v",
".",
"ValidateViewY",
"(",
")",
"\n",
"}"
] | // ScrollUp moves the view up, showing lower numbered rows of content. | [
"ScrollUp",
"moves",
"the",
"view",
"up",
"showing",
"lower",
"numbered",
"rows",
"of",
"content",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/view.go#L186-L189 | train |
gdamore/tcell | views/view.go | ScrollDown | func (v *ViewPort) ScrollDown(rows int) {
v.viewy += rows
v.ValidateViewY()
} | go | func (v *ViewPort) ScrollDown(rows int) {
v.viewy += rows
v.ValidateViewY()
} | [
"func",
"(",
"v",
"*",
"ViewPort",
")",
"ScrollDown",
"(",
"rows",
"int",
")",
"{",
"v",
".",
"viewy",
"+=",
"rows",
"\n",
"v",
".",
"ValidateViewY",
"(",
")",
"\n",
"}"
] | // ScrollDown moves the view down, showingh higher numbered rows of content. | [
"ScrollDown",
"moves",
"the",
"view",
"down",
"showingh",
"higher",
"numbered",
"rows",
"of",
"content",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/view.go#L192-L195 | train |
gdamore/tcell | views/view.go | ScrollLeft | func (v *ViewPort) ScrollLeft(cols int) {
v.viewx -= cols
v.ValidateViewX()
} | go | func (v *ViewPort) ScrollLeft(cols int) {
v.viewx -= cols
v.ValidateViewX()
} | [
"func",
"(",
"v",
"*",
"ViewPort",
")",
"ScrollLeft",
"(",
"cols",
"int",
")",
"{",
"v",
".",
"viewx",
"-=",
"cols",
"\n",
"v",
".",
"ValidateViewX",
"(",
")",
"\n",
"}"
] | // ScrollLeft moves the view to the left. | [
"ScrollLeft",
"moves",
"the",
"view",
"to",
"the",
"left",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/view.go#L198-L201 | train |
gdamore/tcell | views/view.go | ScrollRight | func (v *ViewPort) ScrollRight(cols int) {
v.viewx += cols
v.ValidateViewX()
} | go | func (v *ViewPort) ScrollRight(cols int) {
v.viewx += cols
v.ValidateViewX()
} | [
"func",
"(",
"v",
"*",
"ViewPort",
")",
"ScrollRight",
"(",
"cols",
"int",
")",
"{",
"v",
".",
"viewx",
"+=",
"cols",
"\n",
"v",
".",
"ValidateViewX",
"(",
")",
"\n",
"}"
] | // ScrollRight moves the view to the left. | [
"ScrollRight",
"moves",
"the",
"view",
"to",
"the",
"left",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/view.go#L204-L207 | train |
gdamore/tcell | views/view.go | SetSize | func (v *ViewPort) SetSize(width, height int) {
v.height = height
v.width = width
v.ValidateView()
} | go | func (v *ViewPort) SetSize(width, height int) {
v.height = height
v.width = width
v.ValidateView()
} | [
"func",
"(",
"v",
"*",
"ViewPort",
")",
"SetSize",
"(",
"width",
",",
"height",
"int",
")",
"{",
"v",
".",
"height",
"=",
"height",
"\n",
"v",
".",
"width",
"=",
"width",
"\n",
"v",
".",
"ValidateView",
"(",
")",
"\n",
"}"
] | // SetSize is used to set the visible size of the view. Enclosing views or
// layout managers can use this to inform the View of its correct visible size. | [
"SetSize",
"is",
"used",
"to",
"set",
"the",
"visible",
"size",
"of",
"the",
"view",
".",
"Enclosing",
"views",
"or",
"layout",
"managers",
"can",
"use",
"this",
"to",
"inform",
"the",
"View",
"of",
"its",
"correct",
"visible",
"size",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/view.go#L211-L215 | train |
gdamore/tcell | views/view.go | GetVisible | func (v *ViewPort) GetVisible() (int, int, int, int) {
return v.viewx, v.viewy, v.viewx + v.width - 1, v.viewy + v.height - 1
} | go | func (v *ViewPort) GetVisible() (int, int, int, int) {
return v.viewx, v.viewy, v.viewx + v.width - 1, v.viewy + v.height - 1
} | [
"func",
"(",
"v",
"*",
"ViewPort",
")",
"GetVisible",
"(",
")",
"(",
"int",
",",
"int",
",",
"int",
",",
"int",
")",
"{",
"return",
"v",
".",
"viewx",
",",
"v",
".",
"viewy",
",",
"v",
".",
"viewx",
"+",
"v",
".",
"width",
"-",
"1",
",",
"v... | // GetVisible returns the upper left and lower right coordinates of the visible
// content. That is, it will return x1, y1, x2, y2 where the upper left cell
// is position x1, y1, and the lower right is x2, y2. These coordinates are
// in the space of the content, that is the content area uses coordinate 0,0
// as it... | [
"GetVisible",
"returns",
"the",
"upper",
"left",
"and",
"lower",
"right",
"coordinates",
"of",
"the",
"visible",
"content",
".",
"That",
"is",
"it",
"will",
"return",
"x1",
"y1",
"x2",
"y2",
"where",
"the",
"upper",
"left",
"cell",
"is",
"position",
"x1",
... | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/view.go#L222-L224 | train |
gdamore/tcell | views/view.go | GetPhysical | func (v *ViewPort) GetPhysical() (int, int, int, int) {
return v.physx, v.physy, v.physx + v.width - 1, v.physy + v.height - 1
} | go | func (v *ViewPort) GetPhysical() (int, int, int, int) {
return v.physx, v.physy, v.physx + v.width - 1, v.physy + v.height - 1
} | [
"func",
"(",
"v",
"*",
"ViewPort",
")",
"GetPhysical",
"(",
")",
"(",
"int",
",",
"int",
",",
"int",
",",
"int",
")",
"{",
"return",
"v",
".",
"physx",
",",
"v",
".",
"physy",
",",
"v",
".",
"physx",
"+",
"v",
".",
"width",
"-",
"1",
",",
"... | // GetPhysical returns the upper left and lower right coordinates of the visible
// content in the coordinate space of the parent. This is may be the physical
// coordinates of the screen, if the screen is the view's parent. | [
"GetPhysical",
"returns",
"the",
"upper",
"left",
"and",
"lower",
"right",
"coordinates",
"of",
"the",
"visible",
"content",
"in",
"the",
"coordinate",
"space",
"of",
"the",
"parent",
".",
"This",
"is",
"may",
"be",
"the",
"physical",
"coordinates",
"of",
"t... | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/view.go#L229-L231 | train |
gdamore/tcell | views/view.go | Resize | func (v *ViewPort) Resize(x, y, width, height int) {
if v.v == nil {
return
}
px, py := v.v.Size()
if x >= 0 && x < px {
v.physx = x
}
if y >= 0 && y < py {
v.physy = y
}
if width < 0 {
width = px - x
}
if height < 0 {
height = py - y
}
if width <= x+px {
v.width = width
}
if height <= y+py {
... | go | func (v *ViewPort) Resize(x, y, width, height int) {
if v.v == nil {
return
}
px, py := v.v.Size()
if x >= 0 && x < px {
v.physx = x
}
if y >= 0 && y < py {
v.physy = y
}
if width < 0 {
width = px - x
}
if height < 0 {
height = py - y
}
if width <= x+px {
v.width = width
}
if height <= y+py {
... | [
"func",
"(",
"v",
"*",
"ViewPort",
")",
"Resize",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
"int",
")",
"{",
"if",
"v",
".",
"v",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"px",
",",
"py",
":=",
"v",
".",
"v",
".",
"Size",
"(",
... | // Resize is called by the enclosing view to change the size of the ViewPort,
// usually in response to a window resize event. The x, y refer are the
// ViewPort's location relative to the parent View. A negative value for either
// width or height will cause the ViewPort to expand to fill to the end of parent
// Vie... | [
"Resize",
"is",
"called",
"by",
"the",
"enclosing",
"view",
"to",
"change",
"the",
"size",
"of",
"the",
"ViewPort",
"usually",
"in",
"response",
"to",
"a",
"window",
"resize",
"event",
".",
"The",
"x",
"y",
"refer",
"are",
"the",
"ViewPort",
"s",
"locati... | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/view.go#L257-L280 | train |
gdamore/tcell | views/textbar.go | SetCenter | func (t *TextBar) SetCenter(s string, style tcell.Style) {
t.initialize()
if style == tcell.StyleDefault {
style = t.style
}
t.center.SetText(s)
t.center.SetStyle(style)
} | go | func (t *TextBar) SetCenter(s string, style tcell.Style) {
t.initialize()
if style == tcell.StyleDefault {
style = t.style
}
t.center.SetText(s)
t.center.SetStyle(style)
} | [
"func",
"(",
"t",
"*",
"TextBar",
")",
"SetCenter",
"(",
"s",
"string",
",",
"style",
"tcell",
".",
"Style",
")",
"{",
"t",
".",
"initialize",
"(",
")",
"\n",
"if",
"style",
"==",
"tcell",
".",
"StyleDefault",
"{",
"style",
"=",
"t",
".",
"style",
... | // SetCenter sets the center text for the textbar. The text is
// always center aligned. | [
"SetCenter",
"sets",
"the",
"center",
"text",
"for",
"the",
"textbar",
".",
"The",
"text",
"is",
"always",
"center",
"aligned",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/textbar.go#L44-L51 | train |
gdamore/tcell | views/textbar.go | SetStyle | func (t *TextBar) SetStyle(style tcell.Style) {
t.initialize()
t.style = style
} | go | func (t *TextBar) SetStyle(style tcell.Style) {
t.initialize()
t.style = style
} | [
"func",
"(",
"t",
"*",
"TextBar",
")",
"SetStyle",
"(",
"style",
"tcell",
".",
"Style",
")",
"{",
"t",
".",
"initialize",
"(",
")",
"\n",
"t",
".",
"style",
"=",
"style",
"\n",
"}"
] | // SetStyle is used to set a default style to use for the textbar, including
// areas where no text is present. Note that this will not change the text
// already displayed, so call this before changing or setting text. | [
"SetStyle",
"is",
"used",
"to",
"set",
"a",
"default",
"style",
"to",
"use",
"for",
"the",
"textbar",
"including",
"areas",
"where",
"no",
"text",
"is",
"present",
".",
"Note",
"that",
"this",
"will",
"not",
"change",
"the",
"text",
"already",
"displayed",... | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/textbar.go#L76-L79 | train |
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 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 | train |
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.l... | 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.l... | [
"func",
"(",
"t",
"*",
"TextBar",
")",
"Draw",
"(",
")",
"{",
"t",
".",
"initialize",
"(",
")",
"\n",
"if",
"t",
".",
"changed",
"{",
"t",
".",
"layout",
"(",
")",
"\n",
"}",
"\n",
"w",
",",
"h",
":=",
"t",
".",
"view",
".",
"Size",
"(",
... | // 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 | train |
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",
... | // 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 | train |
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",
"w... | // 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 | train |
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",
... | // 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 | train |
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",
"]... | // 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",
... | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/color.go#L975-L983 | train |
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... | // 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 | train |
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 | train |
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) {
re... | 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) {
re... | [
"func",
"(",
"cb",
"*",
"CellBuffer",
")",
"Dirty",
"(",
"x",
",",
"y",
"int",
")",
"bool",
"{",
"if",
"x",
">=",
"0",
"&&",
"y",
">=",
"0",
"&&",
"x",
"<",
"cb",
".",
"w",
"&&",
"y",
"<",
"cb",
".",
"h",
"{",
"c",
":=",
"&",
"cb",
".",... | // 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",
"las... | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/cell.go#L97-L119 | train |
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 = o... | 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 = o... | [
"func",
"(",
"cb",
"*",
"CellBuffer",
")",
"Resize",
"(",
"w",
",",
"h",
"int",
")",
"{",
"if",
"cb",
".",
"h",
"==",
"h",
"&&",
"cb",
".",
"w",
"==",
"w",
"{",
"return",
"\n",
"}",
"\n\n",
"newc",
":=",
"make",
"(",
"[",
"]",
"cell",
",",
... | // 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 | train |
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",... | // 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",
"ch... | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/cell.go#L169-L177 | train |
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",
"]",
"st... | // 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 | train |
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 | train |
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",
"... | // 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 | train |
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",
... | // 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 | train |
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",
"... | // 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 | train |
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",
".",
... | // 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 | train |
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",
"(",
... | // 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 | train |
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 | train |
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 | train |
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",
"\"",
")",
",",
"\"",
... | // 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 | train |
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... | // Init initializes the TextArea. | [
"Init",
"initializes",
"the",
"TextArea",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/textarea.go#L133-L140 | train |
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",
"}",
"\... | // 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 | train |
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",
"... | // 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 | train |
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.... | 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.... | [
"func",
"(",
"t",
"*",
"Text",
")",
"Draw",
"(",
")",
"{",
"v",
":=",
"t",
".",
"view",
"\n",
"if",
"v",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"width",
",",
"height",
":=",
"v",
".",
"Size",
"(",
")",
"\n",
"if",
"width",
"==",
"0"... | // Draw draws the Text. | [
"Draw",
"draws",
"the",
"Text",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/text.go#L74-L133 | train |
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... | // 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 | train |
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 | train |
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)]
}
... | 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)]
}
... | [
"func",
"(",
"t",
"*",
"Text",
")",
"SetText",
"(",
"s",
"string",
")",
"{",
"t",
".",
"width",
"=",
"0",
"\n",
"t",
".",
"text",
"=",
"[",
"]",
"rune",
"(",
"s",
")",
"\n",
"if",
"len",
"(",
"t",
".",
"widths",
")",
"<",
"len",
"(",
"t",... | // 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 | train |
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",
... | // 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 | train |
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",
"{",
"retur... | // 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 | train |
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 | train |
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",
"(",
... | // 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 | train |
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",
"++... | // 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 | train |
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",
... | // 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 | train |
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 | train |
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 | train |
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",
"&^",
"S... | // 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 | train |
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",
"&^",
"(",
"0x... | // 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 | train |
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... | // 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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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]; !o... | 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]; !o... | [
"func",
"(",
"ev",
"*",
"EventKey",
")",
"Name",
"(",
")",
"string",
"{",
"s",
":=",
"\"",
"\"",
"\n",
"m",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"if",
"ev",
".",
"mod",
"&",
"ModShift",
"!=",
"0",
"{",
"m",
"=",
"append",
"(",
"m",
","... | // 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 | train |
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: fl... | 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: fl... | [
"func",
"FindColor",
"(",
"c",
"Color",
",",
"palette",
"[",
"]",
"Color",
")",
"Color",
"{",
"match",
":=",
"ColorDefault",
"\n",
"dist",
":=",
"float64",
"(",
"0",
")",
"\n",
"r",
",",
"g",
",",
"b",
":=",
"c",
".",
"RGB",
"(",
")",
"\n",
"c1... | // 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... | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/colorfit.go#L25-L52 | train |
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",
")",
">",
... | // 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",
... | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/tscreen.go#L846-L857 | train |
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] != '[' ... | 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] != '[' ... | [
"func",
"(",
"t",
"*",
"tScreen",
")",
"parseXtermMouse",
"(",
"buf",
"*",
"bytes",
".",
"Buffer",
")",
"(",
"bool",
",",
"bool",
")",
"{",
"b",
":=",
"buf",
".",
"Bytes",
"(",
")",
"\n\n",
"state",
":=",
"0",
"\n",
"btn",
":=",
"0",
"\n",
"x",... | // 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 | train |
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 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 | train |
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... | // 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 | train |
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 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 | train |
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",
".",
... | // 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",
"ch... | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L231-L245 | train |
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",
".",
... | // 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 | train |
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)
co... | 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)
co... | [
"func",
"(",
"b",
"*",
"BoxLayout",
")",
"InsertWidget",
"(",
"index",
"int",
",",
"widget",
"Widget",
",",
"fill",
"float64",
")",
"{",
"c",
":=",
"&",
"boxLayoutCell",
"{",
"widget",
":",
"widget",
",",
"fill",
":",
"fill",
",",
"view",
":",
"NewVi... | // 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"... | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L265-L284 | train |
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",
... | // 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 | train |
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",
".",
... | // 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 | train |
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",
".",
"PostEventWid... | // 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 | train |
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 | train |
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 r... | // 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 | train |
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",
"(",
... | // Windows uses RGB signals | [
"Windows",
"uses",
"RGB",
"signals"
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/console_win.go#L652-L667 | train |
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.
... | 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.
... | [
"func",
"(",
"s",
"*",
"cScreen",
")",
"mapStyle",
"(",
"style",
"Style",
")",
"uint16",
"{",
"f",
",",
"b",
",",
"a",
":=",
"style",
".",
"Decompose",
"(",
")",
"\n",
"fa",
":=",
"s",
".",
"oscreen",
".",
"attrs",
"&",
"0xf",
"\n",
"ba",
":=",... | // 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 | train |
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 | train |
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'] = tc... | 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'] = tc... | [
"func",
"NewSimpleStyledText",
"(",
")",
"*",
"SimpleStyledText",
"{",
"ss",
":=",
"&",
"SimpleStyledText",
"{",
"}",
"\n",
"// Create map and establish default styles.",
"ss",
".",
"styles",
"=",
"make",
"(",
"map",
"[",
"rune",
"]",
"tcell",
".",
"Style",
")... | // NewSimpleStyledText creates an empty Text. | [
"NewSimpleStyledText",
"creates",
"an",
"empty",
"Text",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/sstext.go#L117-L126 | train |
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 | train |
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",
",... | // 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 | train |
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",
".",
"RemoveWidg... | // 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 | train |
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... | // 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 | train |
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"... | // 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 | train |
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, ... | 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, ... | [
"func",
"(",
"a",
"*",
"CellView",
")",
"Draw",
"(",
")",
"{",
"port",
":=",
"a",
".",
"port",
"\n",
"model",
":=",
"a",
".",
"model",
"\n",
"port",
".",
"Fill",
"(",
"' '",
",",
"a",
".",
"style",
")",
"\n\n",
"if",
"a",
".",
"view",
"==",
... | // Draw draws the content. | [
"Draw",
"draws",
"the",
"content",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L51-L94 | train |
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"... | // 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 | train |
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.K... | 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.K... | [
"func",
"(",
"a",
"*",
"CellView",
")",
"HandleEvent",
"(",
"e",
"tcell",
".",
"Event",
")",
"bool",
"{",
"if",
"a",
".",
"model",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"switch",
"e",
":=",
"e",
".",
"(",
"type",
")",
"{",
"case... | // 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 | train |
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 squar... | // 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 | train |
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",
... | // 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 | train |
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... | // SetView sets the View context. | [
"SetView",
"sets",
"the",
"View",
"context",
"."
] | dcf1bb30770eb1158b67005e1e472de6d74f055d | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L249-L263 | train |
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",
",",... | // 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 | train |
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 | train |
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 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.