_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q171300 | Mutate | validation | func (c *Client) Mutate(ctx context.Context, m interface{}, input Input, variables map[string]interface{}) error {
if variables == nil {
variables = map[string]interface{}{"input": input}
} else {
variables["input"] = input
}
return c.client.Mutate(ctx, m, variables)
} | go | {
"resource": ""
} |
q171301 | populateFiles | validation | func (d *FileSelectDialog) populateFiles() error {
d.listBox.Clear()
isRoot := filepath.Dir(d.currPath) == d.currPath
if !isRoot {
d.listBox.AddItem("..")
}
f, err := os.Open(d.currPath)
if err != nil {
return err
}
finfos, err := f.Readdir(0)
f.Close()
if err != nil {
return err
}
fnLess := func(... | go | {
"resource": ""
} |
q171302 | detectPath | validation | func (d *FileSelectDialog) detectPath() {
p := d.currPath
if p == "" {
d.currPath, _ = os.Getwd()
return
}
p = filepath.Clean(p)
for {
_, err := os.Stat(p)
if err == nil {
break
}
dirUp := filepath.Dir(p)
if dirUp == p {
p, _ = os.Getwd()
break
}
p = dirUp
}
d.currPath = p
} | go | {
"resource": ""
} |
q171303 | pathUp | validation | func (d *FileSelectDialog) pathUp() {
dirUp := filepath.Dir(d.currPath)
if dirUp == d.currPath {
return
}
d.currPath = dirUp
d.populateFiles()
d.selectFirst()
} | go | {
"resource": ""
} |
q171304 | pathDown | validation | func (d *FileSelectDialog) pathDown(dir string) {
d.currPath = filepath.Join(d.currPath, dir)
d.populateFiles()
d.selectFirst()
} | go | {
"resource": ""
} |
q171305 | Destroy | validation | func (c *BaseControl) Destroy() {
c.parent.removeChild(c)
c.parent.SetConstraints(0, 0)
} | go | {
"resource": ""
} |
q171306 | preload | validation | func (d *dbCache) preload(firstRow, rowCount int) {
if firstRow == d.firstRow && rowCount == d.rowCount {
// fast path: view area is the same, return immediately
return
}
// slow path: refill cache
fNames := []string{"Jack", "Alisa", "Richard", "Paul", "Nicole", "Steven", "Jane"}
lNames := []string{"Smith", "... | go | {
"resource": ""
} |
q171307 | value | validation | func (d *dbCache) value(row, col int) string {
rowId := row - d.firstRow
if rowId >= len(d.data) {
return ""
}
rowValues := d.data[rowId]
if col >= len(rowValues) {
return ""
}
return rowValues[col]
} | go | {
"resource": ""
} |
q171308 | RefreshScreen | validation | func RefreshScreen() {
comp.BeginUpdate()
term.Clear(ColorWhite, ColorBlack)
comp.EndUpdate()
windows := comp.getWindowList()
for _, wnd := range windows {
v := wnd.(*Window)
if v.Visible() {
wnd.Draw()
WindowManager().BeginUpdate()
PushAttributes()
term.Flush()
PopAttributes()
WindowManage... | go | {
"resource": ""
} |
q171309 | AddWindow | validation | func AddWindow(posX, posY, width, height int, title string) *Window {
window := CreateWindow(posX, posY, width, height, title)
window.SetBorder(comp.windowBorder)
comp.BeginUpdate()
comp.windows = append(comp.windows, window)
comp.EndUpdate()
window.Draw()
term.Flush()
comp.activateWindow(window)
RefreshScr... | go | {
"resource": ""
} |
q171310 | DestroyWindow | validation | func (c *Composer) DestroyWindow(view Control) {
ev := Event{Type: EventClose}
c.sendEventToActiveWindow(ev)
windows := c.getWindowList()
var newOrder []Control
for i := 0; i < len(windows); i++ {
if windows[i] != view {
newOrder = append(newOrder, windows[i])
}
}
if len(newOrder) == 0 {
go Stop()
r... | go | {
"resource": ""
} |
q171311 | IsDeadKey | validation | func IsDeadKey(key term.Key) bool {
if key == term.KeyCtrlS || key == term.KeyCtrlP ||
key == term.KeyCtrlW || key == term.KeyCtrlQ {
return true
}
return false
} | go | {
"resource": ""
} |
q171312 | SetTextDisplay | validation | func (l *Label) SetTextDisplay(align Align) {
if align != AlignLeft && align != AlignRight {
return
}
l.textDisplay = align
} | go | {
"resource": ""
} |
q171313 | CreateRadioGroup | validation | func CreateRadioGroup() *RadioGroup {
c := new(RadioGroup)
c.items = make([]*Radio, 0)
return c
} | go | {
"resource": ""
} |
q171314 | Selected | validation | func (c *RadioGroup) Selected() int {
selected := -1
for id, item := range c.items {
if item.Selected() {
selected = id
break
}
}
return selected
} | go | {
"resource": ""
} |
q171315 | SelectItem | validation | func (c *RadioGroup) SelectItem(r *Radio) bool {
found := false
for _, item := range c.items {
if item == r {
found = true
item.SetSelected(true)
} else {
item.SetSelected(false)
}
}
return found
} | go | {
"resource": ""
} |
q171316 | SetSelected | validation | func (c *RadioGroup) SetSelected(id int) bool {
found := false
if id < 0 || id >= len(c.items) {
return false
}
for idx, item := range c.items {
if idx == id {
found = true
item.SetSelected(true)
} else {
item.SetSelected(false)
}
}
return found
} | go | {
"resource": ""
} |
q171317 | AddItem | validation | func (c *RadioGroup) AddItem(r *Radio) {
c.items = append(c.items, r)
r.SetGroup(c)
} | go | {
"resource": ""
} |
q171318 | NewColorParser | validation | func NewColorParser(str string, defText, defBack term.Attribute) *ColorParser {
p := new(ColorParser)
p.text = []rune(str)
p.defBack, p.defText = defBack, defText
p.currBack, p.currText = defBack, defText
return p
} | go | {
"resource": ""
} |
q171319 | NextElement | validation | func (p *ColorParser) NextElement() TextElement {
if p.index >= len(p.text) {
return TextElement{Type: ElemEndOfText}
}
if p.text[p.index] == '\n' {
p.index++
return TextElement{Type: ElemLineBreak}
}
if p.text[p.index] != '<' {
p.index++
return TextElement{Type: ElemPrintable, Ch: p.text[p.index-1], F... | go | {
"resource": ""
} |
q171320 | SetTitle | validation | func (e *EditField) SetTitle(title string) {
e.setTitleInternal(title)
e.offset = 0
e.end()
} | go | {
"resource": ""
} |
q171321 | SetMaxWidth | validation | func (e *EditField) SetMaxWidth(w int) {
e.maxWidth = w
if w > 0 && xs.Len(e.title) > w {
e.title = xs.Slice(e.title, 0, w)
e.end()
}
} | go | {
"resource": ""
} |
q171322 | SetSize | validation | func (e *EditField) SetSize(width, height int) {
if width != KeepValue && (width > 1000 || width < e.minW) {
return
}
if height != KeepValue && (height > 200 || height < e.minH) {
return
}
if width != KeepValue {
e.width = width
}
e.height = 1
} | go | {
"resource": ""
} |
q171323 | PopAttributes | validation | func PopAttributes() {
if len(canvas.attrStack) == 0 {
return
}
a := canvas.attrStack[len(canvas.attrStack)-1]
canvas.attrStack = canvas.attrStack[:len(canvas.attrStack)-1]
SetTextColor(a.text)
SetBackColor(a.back)
} | go | {
"resource": ""
} |
q171324 | PushClip | validation | func PushClip() {
c := rect{x: canvas.clipX, y: canvas.clipY, w: canvas.clipW, h: canvas.clipH}
canvas.clipStack = append(canvas.clipStack, c)
} | go | {
"resource": ""
} |
q171325 | PopClip | validation | func PopClip() {
if len(canvas.clipStack) == 0 {
return
}
c := canvas.clipStack[len(canvas.clipStack)-1]
canvas.clipStack = canvas.clipStack[:len(canvas.clipStack)-1]
SetClipRect(c.x, c.y, c.w, c.h)
} | go | {
"resource": ""
} |
q171326 | InClipRect | validation | func InClipRect(x, y int) bool {
return x >= canvas.clipX && y >= canvas.clipY &&
x < canvas.clipX+canvas.clipW &&
y < canvas.clipY+canvas.clipH
} | go | {
"resource": ""
} |
q171327 | SetScreenSize | validation | func SetScreenSize(width int, height int) {
if canvas.width == width && canvas.height == height {
return
}
canvas.width = width
canvas.height = height
canvas.clipStack = make([]rect, 0)
SetClipRect(0, 0, width, height)
} | go | {
"resource": ""
} |
q171328 | Symbol | validation | func Symbol(x, y int) (term.Cell, bool) {
if x >= 0 && x < canvas.width && y >= 0 && y < canvas.height {
cells := term.CellBuffer()
return cells[y*canvas.width+x], true
}
return term.Cell{Ch: ' '}, false
} | go | {
"resource": ""
} |
q171329 | SetClipRect | validation | func SetClipRect(x, y, w, h int) {
if x < 0 {
x = 0
}
if y < 0 {
y = 0
}
if x+w > canvas.width {
w = canvas.width - x
}
if y+h > canvas.height {
h = canvas.height - h
}
canvas.clipX = x
canvas.clipY = y
canvas.clipW = w
canvas.clipH = h
} | go | {
"resource": ""
} |
q171330 | ClipRect | validation | func ClipRect() (x int, y int, w int, h int) {
return canvas.clipX, canvas.clipY, canvas.clipW, canvas.clipH
} | go | {
"resource": ""
} |
q171331 | DrawHorizontalLine | validation | func DrawHorizontalLine(x, y, w int, r rune) {
x, y, w, _ = clip(x, y, w, 1)
if w == 0 {
return
}
for i := x; i < x+w; i++ {
putCharUnsafe(i, y, r)
}
} | go | {
"resource": ""
} |
q171332 | DrawVerticalLine | validation | func DrawVerticalLine(x, y, h int, r rune) {
x, y, _, h = clip(x, y, 1, h)
if h == 0 {
return
}
for i := y; i < y+h; i++ {
putCharUnsafe(x, i, r)
}
} | go | {
"resource": ""
} |
q171333 | DrawRawText | validation | func DrawRawText(x, y int, text string) {
cx, cy, cw, ch := ClipRect()
if x >= cx+cw || y < cy || y >= cy+ch {
return
}
length := xs.Len(text)
if x+length < cx {
return
}
if x < cx {
text = xs.Slice(text, cx-x, -1)
length = length - (cx - x)
x = cx
}
text = CutText(text, cw)
dx := 0
for _, ch :=... | go | {
"resource": ""
} |
q171334 | DrawTextVertical | validation | func DrawTextVertical(x, y int, text string) {
PushAttributes()
defer PopAttributes()
defText, defBack := TextColor(), BackColor()
firstdrawn := InClipRect(x, y)
parser := NewColorParser(text, defText, defBack)
elem := parser.NextElement()
for elem.Type != ElemEndOfText {
if elem.Type == ElemPrintable {
S... | go | {
"resource": ""
} |
q171335 | DrawRawTextVertical | validation | func DrawRawTextVertical(x, y int, text string) {
cx, cy, cw, ch := ClipRect()
if y >= cy+ch || x < cx || x >= cx+cw {
return
}
length := xs.Len(text)
if y+length < cy {
return
}
if y < cy {
text = xs.Slice(text, cy-y, -1)
length = length - (cy - y)
y = cy
}
text = CutText(text, ch)
dy := 0
for ... | go | {
"resource": ""
} |
q171336 | DrawFrame | validation | func DrawFrame(x, y, w, h int, border BorderStyle) {
var chars string
if border == BorderThick {
chars = SysObject(ObjDoubleBorder)
} else if border == BorderThin {
chars = SysObject(ObjSingleBorder)
} else if border == BorderNone {
chars = " "
} else {
chars = " "
}
parts := []rune(chars)
H,... | go | {
"resource": ""
} |
q171337 | FillRect | validation | func FillRect(x, y, w, h int, r rune) {
x, y, w, h = clip(x, y, w, h)
if w < 1 || y < -1 {
return
}
for yy := y; yy < y+h; yy++ {
for xx := x; xx < x+w; xx++ {
putCharUnsafe(xx, yy, r)
}
}
} | go | {
"resource": ""
} |
q171338 | TextExtent | validation | func TextExtent(text string) (int, int) {
if text == "" {
return 0, 0
}
parts := strings.Split(text, "\n")
h := len(parts)
w := 0
for _, p := range parts {
s := UnColorizeText(p)
l := len(s)
if l > w {
w = l
}
}
return h, w
} | go | {
"resource": ""
} |
q171339 | EnsureVisible | validation | func (l *ListBox) EnsureVisible() {
length := len(l.items)
if length <= l.height || l.currSelection == -1 {
return
}
diff := l.currSelection - l.topLine
if diff >= 0 && diff < l.height {
return
}
if diff < 0 {
l.topLine = l.currSelection
} else {
top := l.currSelection - l.height + 1
if length-top ... | go | {
"resource": ""
} |
q171340 | Clear | validation | func (l *ListBox) Clear() {
l.items = make([]string, 0)
l.currSelection = -1
l.topLine = 0
} | go | {
"resource": ""
} |
q171341 | AddItem | validation | func (l *ListBox) AddItem(item string) bool {
l.items = append(l.items, item)
return true
} | go | {
"resource": ""
} |
q171342 | SelectItem | validation | func (l *ListBox) SelectItem(id int) bool {
if len(l.items) <= id || id < 0 {
return false
}
l.currSelection = id
l.EnsureVisible()
return true
} | go | {
"resource": ""
} |
q171343 | Item | validation | func (l *ListBox) Item(id int) (string, bool) {
if len(l.items) <= id || id < 0 {
return "", false
}
return l.items[id], true
} | go | {
"resource": ""
} |
q171344 | FindItem | validation | func (l *ListBox) FindItem(text string, caseSensitive bool) int {
for idx, itm := range l.items {
if itm == text || (caseSensitive && strings.EqualFold(itm, text)) {
return idx
}
}
return -1
} | go | {
"resource": ""
} |
q171345 | PartialFindItem | validation | func (l *ListBox) PartialFindItem(text string, caseSensitive bool) int {
if !caseSensitive {
text = strings.ToLower(text)
}
for idx, itm := range l.items {
if caseSensitive {
if strings.HasPrefix(itm, text) {
return idx
}
} else {
low := strings.ToLower(itm)
if strings.HasPrefix(low, text) {
... | go | {
"resource": ""
} |
q171346 | SelectedItemText | validation | func (l *ListBox) SelectedItemText() string {
if l.currSelection == -1 {
return ""
}
return l.items[l.currSelection]
} | go | {
"resource": ""
} |
q171347 | RemoveItem | validation | func (l *ListBox) RemoveItem(id int) bool {
if id < 0 || id >= len(l.items) {
return false
}
l.items = append(l.items[:id], l.items[id+1:]...)
return true
} | go | {
"resource": ""
} |
q171348 | SysColor | validation | func SysColor(color string) term.Attribute {
thememtx.RLock()
sch, ok := themeManager.themes[themeManager.current]
if !ok {
sch = themeManager.themes[defaultTheme]
}
thememtx.RUnlock()
clr, okclr := sch.colors[color]
if !okclr {
visited := make(map[string]int, 0)
visited[themeManager.current] = 1
if !ok... | go | {
"resource": ""
} |
q171349 | SysObject | validation | func SysObject(object string) string {
thememtx.RLock()
sch, ok := themeManager.themes[themeManager.current]
if !ok {
sch = themeManager.themes[defaultTheme]
}
thememtx.RUnlock()
obj, okobj := sch.objects[object]
if !okobj {
visited := make(map[string]int, 0)
visited[themeManager.current] = 1
if !ok {
... | go | {
"resource": ""
} |
q171350 | SetThemePath | validation | func SetThemePath(path string) {
if path == themeManager.themePath {
return
}
themeManager.themePath = path
ThemeReset()
} | go | {
"resource": ""
} |
q171351 | loadTheme | validation | func (s *ThemeManager) loadTheme(name string) {
thememtx.Lock()
defer thememtx.Unlock()
if _, ok := s.themes[name]; ok {
return
}
theme := theme{parent: defaultTheme, title: "", author: ""}
theme.colors = make(map[string]term.Attribute, 0)
theme.objects = make(map[string]string, 0)
file, err := os.Open(s.t... | go | {
"resource": ""
} |
q171352 | ReloadTheme | validation | func ReloadTheme(name string) {
if name == defaultTheme {
// default theme cannot be reloaded
return
}
thememtx.Lock()
if _, ok := themeManager.themes[name]; ok {
delete(themeManager.themes, name)
}
thememtx.Unlock()
themeManager.loadTheme(name)
} | go | {
"resource": ""
} |
q171353 | ThemeInfo | validation | func ThemeInfo(name string) ThemeDesc {
themeManager.loadTheme(name)
thememtx.RLock()
defer thememtx.RUnlock()
var theme ThemeDesc
if t, ok := themeManager.themes[name]; !ok {
theme.parent = t.parent
theme.title = t.title
theme.version = t.version
}
return theme
} | go | {
"resource": ""
} |
q171354 | Ellipsize | validation | func Ellipsize(str string, maxWidth int) string {
ln := xs.Len(str)
if ln <= maxWidth {
return str
}
if maxWidth < 5 {
return xs.Slice(str, 0, maxWidth)
}
left := int((maxWidth - 3) / 2)
right := maxWidth - left - 3
return xs.Slice(str, 0, left) + "..." + xs.Slice(str, ln-right, -1)
} | go | {
"resource": ""
} |
q171355 | CutText | validation | func CutText(str string, maxWidth int) string {
ln := xs.Len(str)
if ln <= maxWidth {
return str
}
return xs.Slice(str, 0, maxWidth)
} | go | {
"resource": ""
} |
q171356 | AlignText | validation | func AlignText(str string, width int, align Align) (shift int, out string) {
length := xs.Len(str)
if length >= width {
return 0, CutText(str, width)
}
if align == AlignRight {
return width - length, str
} else if align == AlignCenter {
return (width - length) / 2, str
}
return 0, str
} | go | {
"resource": ""
} |
q171357 | SliceColorized | validation | func SliceColorized(str string, start, end int) string {
if str == "" {
return str
}
if start < 0 {
start = 0
}
fgChanged, bgChanged := false, false
curr := 0
parser := NewColorParser(str, term.ColorBlack, term.ColorBlack)
var out string
for {
if end != -1 && curr >= end {
break
}
elem := parser.... | go | {
"resource": ""
} |
q171358 | ColorToString | validation | func ColorToString(attr term.Attribute) string {
var out string
rawClr := attr & 15
if rawClr < 8 {
for k, v := range colorMap {
if v == rawClr {
out += k + " "
break
}
}
}
if attr&term.AttrBold != 0 {
out += "bold "
}
if attr&term.AttrUnderline != 0 {
out += "underline "
}
if attr&term... | go | {
"resource": ""
} |
q171359 | MainLoop | validation | func MainLoop() {
RefreshScreen()
eventQueue := make(chan term.Event)
go func() {
for {
eventQueue <- term.PollEvent()
}
}()
for {
RefreshScreen()
select {
case ev := <-eventQueue:
switch ev.Type {
case term.EventError:
panic(ev.Err)
default:
ProcessEvent(termboxEventToLocal(ev))
... | go | {
"resource": ""
} |
q171360 | CreateEditField | validation | func CreateEditField(parent Control, width int, text string, scale int) *EditField {
e := new(EditField)
e.BaseControl = NewBaseControl()
e.onChange = nil
e.SetTitle(text)
e.SetEnabled(true)
if width == AutoSize {
width = xs.Len(text) + 1
}
e.SetSize(width, 1)
e.cursorPos = xs.Len(text)
e.offset = 0
e.pa... | go | {
"resource": ""
} |
q171361 | ChildAt | validation | func ChildAt(parent Control, x, y int) Control {
px, py := parent.Pos()
pw, ph := parent.Size()
if px > x || py > y || px+pw <= x || py+ph <= y {
return nil
}
if len(parent.Children()) == 0 {
return parent
}
var ctrl Control
ctrl = parent
for _, child := range parent.Children() {
if !child.Visible() {
... | go | {
"resource": ""
} |
q171362 | DeactivateControls | validation | func DeactivateControls(parent Control) {
for _, ctrl := range parent.Children() {
if ctrl.Active() {
ctrl.SetActive(false)
ctrl.ProcessEvent(Event{Type: EventActivate, X: 0})
}
DeactivateControls(ctrl)
}
} | go | {
"resource": ""
} |
q171363 | ActivateControl | validation | func ActivateControl(parent, control Control) bool {
DeactivateControls(parent)
res := false
ctrl := FindChild(parent, control)
if ctrl != nil {
res = true
if !ctrl.Active() {
ctrl.ProcessEvent(Event{Type: EventActivate, X: 1})
ctrl.SetActive(true)
}
}
return res
} | go | {
"resource": ""
} |
q171364 | FindChild | validation | func FindChild(parent, control Control) Control {
var res Control
if parent == control {
return parent
}
for _, ctrl := range parent.Children() {
if ctrl == control {
res = ctrl
break
}
res = FindChild(ctrl, control)
if res != nil {
break
}
}
return res
} | go | {
"resource": ""
} |
q171365 | IsMouseClickEvent | validation | func IsMouseClickEvent(ev Event) bool {
if ev.Type == EventClick {
return true
}
if ev.Type == EventMouse && ev.Key == term.MouseLeft {
return true
}
return false
} | go | {
"resource": ""
} |
q171366 | FindFirstControl | validation | func FindFirstControl(parent Control, fn func(Control) bool) Control {
linear := getLinearControlList(parent, fn)
if len(linear) == 0 {
return nil
}
return linear[0]
} | go | {
"resource": ""
} |
q171367 | ActiveControl | validation | func ActiveControl(parent Control) Control {
fnActive := func(c Control) bool {
return c.Active()
}
return FindFirstControl(parent, fnActive)
} | go | {
"resource": ""
} |
q171368 | FindFirstActiveControl | validation | func FindFirstActiveControl(parent Control) Control {
for _, curr := range getLinearControlList(parent, nil) {
if curr.Active() {
return curr
}
}
return nil
} | go | {
"resource": ""
} |
q171369 | SendEventToChild | validation | func SendEventToChild(parent Control, ev Event) bool {
var child Control
if IsMouseClickEvent(ev) {
child = ChildAt(parent, ev.X, ev.Y)
if child != nil && !child.Active() {
ActivateControl(parent, child)
}
} else {
child = ActiveControl(parent)
}
if child != nil && child != parent {
ev.Target = child... | go | {
"resource": ""
} |
q171370 | CalcClipper | validation | func CalcClipper(c Control) (int, int, int, int) {
w, h := c.Size()
x, y := c.Pos()
px, py := c.Paddings()
x = x + px
y = y + py
w = w - 2*px
h = h - 2*py
return x, y, w, h
} | go | {
"resource": ""
} |
q171371 | ClippedParent | validation | func ClippedParent(c Control) Control {
var clipped Control
ctrl := c.Parent()
clipped = c
for ctrl != nil {
if ctrl.Clipped() {
clipped = ctrl
break
}
ctrl = ctrl.Parent()
}
return clipped
} | go | {
"resource": ""
} |
q171372 | ControlInRect | validation | func ControlInRect(c Control, x int, y int, w int, h int) bool {
xx, yy := c.Pos()
ww, hh := c.Size()
return xx >= x && ww <= x+w && yy <= y+h &&
yy+hh <= y+h && yy >= y && yy+h >= y
} | go | {
"resource": ""
} |
q171373 | CreateAlertDialog | validation | func CreateAlertDialog(title, message string, button string) *ConfirmationDialog {
return CreateConfirmationDialog(title, message, []string{button}, 0)
} | go | {
"resource": ""
} |
q171374 | ProcessEvent | validation | func (c *CheckBox) ProcessEvent(event Event) bool {
if (!c.Active() && event.Type == EventKey) || !c.Enabled() {
return false
}
if (event.Type == EventKey && event.Key == term.KeySpace) || (event.Type == EventClick) {
if c.state == 0 {
c.SetState(1)
} else if c.state == 2 {
c.SetState(0)
} else {
i... | go | {
"resource": ""
} |
q171375 | SetState | validation | func (c *CheckBox) SetState(val int) {
c.mtx.Lock()
defer c.mtx.Unlock()
if val == c.state {
return
}
if val < 0 {
val = 0
}
if val > 1 && !c.allow3state {
val = 1
}
if val > 2 {
val = 2
}
c.state = val
if c.onChange != nil {
go c.onChange(val)
}
} | go | {
"resource": ""
} |
q171376 | State | validation | func (c *CheckBox) State() int {
c.mtx.RLock()
defer c.mtx.RUnlock()
return c.state
} | go | {
"resource": ""
} |
q171377 | SetAllow3State | validation | func (c *CheckBox) SetAllow3State(enable bool) {
if !enable && c.state == 2 {
c.state = 0
}
c.allow3state = enable
} | go | {
"resource": ""
} |
q171378 | SetSize | validation | func (c *CheckBox) SetSize(width, height int) {
if width != KeepValue && (width > 1000 || width < c.minW) {
return
}
if height != KeepValue && (height > 200 || height < c.minH) {
return
}
if width != KeepValue {
c.width = width
}
c.height = 1
} | go | {
"resource": ""
} |
q171379 | ScrollTo | validation | func (f *Frame) ScrollTo(x int, y int) {
if !f.scrollable {
return
}
f.x = x
f.y = y
f.ResizeChildren()
f.PlaceChildren()
} | go | {
"resource": ""
} |
q171380 | EnsureColVisible | validation | func (l *TableView) EnsureColVisible() {
if l.isColVisible(l.selectedCol) {
return
}
if l.selectedCol < l.topCol {
l.topCol = l.selectedCol
return
}
width := l.width - 1 - l.counterWidth()
if l.showRowNo && l.showVLines {
width--
}
toShow := l.selectedCol
for width > 0 {
if l.columns[toShow].Width... | go | {
"resource": ""
} |
q171381 | EnsureRowVisible | validation | func (l *TableView) EnsureRowVisible() {
length := l.rowCount
hgt := l.height - 3
if length <= hgt || l.selectedRow == -1 {
return
}
diff := l.selectedRow - l.topRow
if diff >= 0 && diff < hgt {
return
}
if diff < 0 {
l.topRow = l.selectedRow
} else {
top := l.selectedRow - hgt + 1
if length-top ... | go | {
"resource": ""
} |
q171382 | Columns | validation | func (l *TableView) Columns() []Column {
c := make([]Column, len(l.columns))
copy(c, l.columns)
return c
} | go | {
"resource": ""
} |
q171383 | SetColumnInfo | validation | func (l *TableView) SetColumnInfo(id int, col Column) {
if id < len(l.columns) {
l.columns[id] = col
}
} | go | {
"resource": ""
} |
q171384 | OnKeyPress | validation | func (l *TableView) OnKeyPress(fn func(term.Key) bool) {
l.onKeyPress = fn
} | go | {
"resource": ""
} |
q171385 | OnDrawCell | validation | func (l *TableView) OnDrawCell(fn func(*ColumnDrawInfo)) {
l.mtx.Lock()
l.onDrawCell = fn
l.mtx.Unlock()
} | go | {
"resource": ""
} |
q171386 | SetSelectedRow | validation | func (l *TableView) SetSelectedRow(row int) {
oldSelection := l.selectedRow
if row >= l.rowCount {
l.selectedRow = l.rowCount - 1
} else if row < -1 {
l.selectedRow = -1
}
if l.selectedRow != oldSelection {
l.EnsureRowVisible()
l.emitSelectionChange()
}
} | go | {
"resource": ""
} |
q171387 | SetSelectedCol | validation | func (l *TableView) SetSelectedCol(col int) {
oldSelection := l.selectedCol
if col >= len(l.columns) {
l.selectedCol = len(l.columns) - 1
} else if col < -1 {
l.selectedCol = -1
}
if l.selectedCol != oldSelection {
l.EnsureColVisible()
l.emitSelectionChange()
}
} | go | {
"resource": ""
} |
q171388 | SetSelected | validation | func (c *Radio) SetSelected(val bool) {
c.selected = val
if c.onChange != nil {
go c.onChange(val)
}
} | go | {
"resource": ""
} |
q171389 | OnChange | validation | func (c *Radio) OnChange(fn func(bool)) {
c.mtx.Lock()
defer c.mtx.Unlock()
c.onChange = fn
} | go | {
"resource": ""
} |
q171390 | SetText | validation | func (l *TextView) SetText(text []string) {
l.lines = make([]string, len(text))
copy(l.lines, text)
l.applyLimit()
l.calculateVirtualSize()
if l.autoscroll {
l.end()
}
} | go | {
"resource": ""
} |
q171391 | SetWordWrap | validation | func (l *TextView) SetWordWrap(wrap bool) {
if wrap != l.wordWrap {
l.wordWrap = wrap
l.calculateVirtualSize()
l.recalculateTopLine()
l.Draw()
}
} | go | {
"resource": ""
} |
q171392 | LoadFile | validation | func (l *TextView) LoadFile(filename string) bool {
l.lines = make([]string, 0)
file, err := os.Open(filename)
if err != nil {
return false
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
line = strings.TrimSpace(line)
l.lines = append(l.lines, line)
... | go | {
"resource": ""
} |
q171393 | AddText | validation | func (l *TextView) AddText(text []string) {
l.lines = append(l.lines, text...)
l.applyLimit()
l.calculateVirtualSize()
if l.autoscroll {
l.end()
}
} | go | {
"resource": ""
} |
q171394 | Value | validation | func (b *ProgressBar) Value() int {
b.mtx.RLock()
defer b.mtx.RUnlock()
return b.value
} | go | {
"resource": ""
} |
q171395 | SetLimits | validation | func (b *ProgressBar) SetLimits(min, max int) {
b.min = min
b.max = max
if b.value < b.min {
b.value = min
}
if b.value > b.max {
b.value = max
}
} | go | {
"resource": ""
} |
q171396 | Step | validation | func (b *ProgressBar) Step() int {
b.mtx.Lock()
defer b.mtx.Unlock()
b.value++
if b.value > b.max {
b.value = b.max
}
return b.value
} | go | {
"resource": ""
} |
q171397 | SecondaryColors | validation | func (b *ProgressBar) SecondaryColors() (term.Attribute, term.Attribute) {
return b.emptyFg, b.emptyBg
} | go | {
"resource": ""
} |
q171398 | SetSecondaryColors | validation | func (b *ProgressBar) SetSecondaryColors(fg, bg term.Attribute) {
b.emptyFg, b.emptyBg = fg, bg
} | go | {
"resource": ""
} |
q171399 | SetAutoSize | validation | func (b *BarChart) SetAutoSize(auto bool) {
b.mtx.Lock()
defer b.mtx.Unlock()
b.autosize = auto
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.