repo stringlengths 5 67 | sha stringlengths 40 40 | path stringlengths 4 234 | url stringlengths 85 339 | language stringclasses 6
values | split stringclasses 3
values | doc stringlengths 3 51.2k | sign stringlengths 5 8.01k | problem stringlengths 13 51.2k | output stringlengths 0 3.87M |
|---|---|---|---|---|---|---|---|---|---|
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | style.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/style.go#L99-L101 | go | train | // Bold returns a new style based on s, with the bold attribute set
// as requested. | func (s Style) Bold(on bool) Style | // Bold returns a new style based on s, with the bold attribute set
// as requested.
func (s Style) Bold(on bool) Style | {
return s.setAttrs(Style(AttrBold), on)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | style.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/style.go#L105-L107 | go | train | // Blink returns a new style based on s, with the blink attribute set
// as requested. | func (s Style) Blink(on bool) Style | // Blink returns a new style based on s, with the blink attribute set
// as requested.
func (s Style) Blink(on bool) Style | {
return s.setAttrs(Style(AttrBlink), on)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | style.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/style.go#L111-L113 | go | train | // Dim returns a new style based on s, with the dim attribute set
// as requested. | func (s Style) Dim(on bool) Style | // Dim returns a new style based on s, with the dim attribute set
// as requested.
func (s Style) Dim(on bool) Style | {
return s.setAttrs(Style(AttrDim), on)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | style.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/style.go#L118-L120 | go | train | // Reverse returns a new style based on s, with the reverse attribute set
// as requested. (Reverse usually changes the foreground and background
// colors.) | func (s Style) Reverse(on bool) Style | // Reverse returns a new style based on s, with the reverse attribute set
// as requested. (Reverse usually changes the foreground and background
// colors.)
func (s Style) Reverse(on bool) Style | {
return s.setAttrs(Style(AttrReverse), on)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | style.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/style.go#L124-L126 | go | train | // Underline returns a new style based on s, with the underline attribute set
// as requested. | func (s Style) Underline(on bool) Style | // Underline returns a new style based on s, with the underline attribute set
// as requested.
func (s Style) Underline(on bool) Style | {
return s.setAttrs(Style(AttrUnderline), on)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | key.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/key.go#L206-L237 | go | train | // Name returns a printable value or the key stroke. This can be used
// when printing the event, for example. | func (ev *EventKey) Name() string | // Name returns a printable value or the key stroke. This can be used
// when printing the event, for example.
func (ev *EventKey) Name() string | {
s := ""
m := []string{}
if ev.mod&ModShift != 0 {
m = append(m, "Shift")
}
if ev.mod&ModAlt != 0 {
m = append(m, "Alt")
}
if ev.mod&ModMeta != 0 {
m = append(m, "Meta")
}
if ev.mod&ModCtrl != 0 {
m = append(m, "Ctrl")
}
ok := false
if s, ok = KeyNames[ev.key]; !ok {
if ev.key == KeyRune {
s... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | key.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/key.go#L243-L259 | go | train | // NewEventKey attempts to create a suitable event. It parses the various
// ASCII control sequences if KeyRune is passed for Key, but if the caller
// has more precise information it should set that specifically. Callers
// that aren't sure about modifier state (most) should just pass ModNone. | func NewEventKey(k Key, ch rune, mod ModMask) *EventKey | // NewEventKey attempts to create a suitable event. It parses the various
// ASCII control sequences if KeyRune is passed for Key, but if the caller
// has more precise information it should set that specifically. Callers
// that aren't sure about modifier state (most) should just pass ModNone.
func NewEventKey(k Key... | {
if k == KeyRune && (ch < ' ' || ch == 0x7f) {
// Turn specials into proper key codes. This is for
// control characters and the DEL.
k = Key(ch)
if mod == ModNone && ch < ' ' {
switch Key(ch) {
case KeyBackspace, KeyTab, KeyEsc, KeyEnter:
// these keys are directly typeable without CTRL
defaul... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | colorfit.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/colorfit.go#L25-L52 | go | train | // 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. | func FindColor(c Color, palette []Color) Color | // 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.
func FindColor(c Color, palette []Color) Color | {
match := ColorDefault
dist := float64(0)
r, g, b := c.RGB()
c1 := colorful.Color{
R: float64(r) / 255.0,
G: float64(g) / 255.0,
B: float64(b) / 255.0,
}
for _, d := range palette {
r, g, b = d.RGB()
c2 := colorful.Color{
R: float64(r) / 255.0,
G: float64(g) / 255.0,
B: float64(b) / 255.0,
... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | tscreen.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/tscreen.go#L39-L60 | go | train | // NewTerminfoScreen returns a Screen that uses the stock TTY interface
// and POSIX termios, combined with a terminfo description taken from
// the $TERM environment variable. It returns an error if the terminal
// is not supported for any reason.
//
// For terminals that do not support dynamic resize events, the $LI... | func NewTerminfoScreen() (Screen, error) | // NewTerminfoScreen returns a Screen that uses the stock TTY interface
// and POSIX termios, combined with a terminfo description taken from
// the $TERM environment variable. It returns an error if the terminal
// is not supported for any reason.
//
// For terminals that do not support dynamic resize events, the $LI... | {
ti, e := terminfo.LookupTerminfo(os.Getenv("TERM"))
if e != nil {
return nil, e
}
t := &tScreen{ti: ti}
t.keyexist = make(map[Key]bool)
t.keycodes = make(map[string]*tKeyCode)
if len(ti.Mouse) > 0 {
t.mouse = []byte(ti.Mouse)
}
t.prepareKeys()
t.buildAcsMap()
t.sigwinch = make(chan os.Signal, 10)
t.... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | tscreen.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/tscreen.go#L660-L666 | go | train | // writeString sends a string to the terminal. The string is sent as-is and
// this function does not expand inline padding indications (of the form
// $<[delay]> where [delay] is msec). In order to have these expanded, use
// TPuts. If the screen is "buffering", the string is collected in a buffer,
// with the intenti... | func (t *tScreen) writeString(s string) | // writeString sends a string to the terminal. The string is sent as-is and
// this function does not expand inline padding indications (of the form
// $<[delay]> where [delay] is msec). In order to have these expanded, use
// TPuts. If the screen is "buffering", the string is collected in a buffer,
// with the intenti... | {
if t.buffering {
io.WriteString(&t.buf, s)
} else {
io.WriteString(t.out, s)
}
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | tscreen.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/tscreen.go#L846-L857 | go | train | // 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. | func (t *tScreen) buildAcsMap() | // 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.
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:]
}
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | tscreen.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/tscreen.go#L954-L1069 | go | train | // parseSgrMouse attempts to locate an SGR mouse record at the start of the
// buffer. It returns true, true if it found one, and the associated bytes
// be removed from the buffer. It returns true, false if the buffer might
// contain such an event, but more bytes are necessary (partial match), and
// false, false i... | func (t *tScreen) parseSgrMouse(buf *bytes.Buffer) (bool, bool) | // parseSgrMouse attempts to locate an SGR mouse record at the start of the
// buffer. It returns true, true if it found one, and the associated bytes
// be removed from the buffer. It returns true, false if the buffer might
// contain such an event, but more bytes are necessary (partial match), and
// false, false i... | {
b := buf.Bytes()
var x, y, btn, state int
dig := false
neg := false
motion := false
i := 0
val := 0
for i = range b {
switch b[i] {
case '\x1b':
if state != 0 {
return false, false
}
state = 1
case '\x9b':
if state != 0 {
return false, false
}
state = 2
case '[':
if ... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | tscreen.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/tscreen.go#L1073-L1120 | go | train | // parseXtermMouse is like parseSgrMouse, but it parses a legacy
// X11 mouse record. | func (t *tScreen) parseXtermMouse(buf *bytes.Buffer) (bool, bool) | // parseXtermMouse is like parseSgrMouse, but it parses a legacy
// X11 mouse record.
func (t *tScreen) parseXtermMouse(buf *bytes.Buffer) (bool, bool) | {
b := buf.Bytes()
state := 0
btn := 0
x := 0
y := 0
for i := range b {
switch state {
case 0:
switch b[i] {
case '\x1b':
state = 1
case '\x9b':
state = 2
default:
return false, false
}
case 1:
if b[i] != '[' {
return false, false
}
state = 2
case 2:
if b[i] ... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/boxlayout.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L188-L196 | go | train | // Resize adjusts the layout when the underlying View changes size. | func (b *BoxLayout) Resize() | // Resize adjusts the layout when the underlying View changes size.
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)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/boxlayout.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L199-L211 | go | train | // Draw is called to update the displayed content. | func (b *BoxLayout) Draw() | // Draw is called to update the displayed content.
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()
}
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/boxlayout.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L219-L225 | go | train | // SetView sets the View object used for the text bar. | func (b *BoxLayout) SetView(view View) | // SetView sets the View object used for the text bar.
func (b *BoxLayout) SetView(view View) | {
b.changed = true
b.view = view
for _, c := range b.cells {
c.view.SetView(view)
}
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/boxlayout.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L231-L245 | go | train | // 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. | func (b *BoxLayout) HandleEvent(ev tcell.Event) bool | // 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.
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
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/boxlayout.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L248-L260 | go | train | // AddWidget adds a widget to the end of the BoxLayout. | func (b *BoxLayout) AddWidget(widget Widget, fill float64) | // AddWidget adds a widget to the end of the BoxLayout.
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)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/boxlayout.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L265-L284 | go | train | // 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. | func (b *BoxLayout) InsertWidget(index int, widget Widget, fill float64) | // 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.
func (b *BoxLayout) InsertWidget(index int, widget Widget, fill float64) | {
c := &boxLayoutCell{
widget: widget,
fill: fill,
view: NewViewPort(b.view, 0, 0, 0, 0),
}
c.widget.SetView(c.view)
if index < 0 {
index = 0
}
if index > len(b.cells) {
index = len(b.cells)
}
b.cells = append(b.cells, c)
copy(b.cells[index+1:], b.cells[index:])
b.cells[index] = c
widget.Watch... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/boxlayout.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L287-L302 | go | train | // RemoveWidget removes a Widget from the layout. | func (b *BoxLayout) RemoveWidget(widget Widget) | // RemoveWidget removes a Widget from the layout.
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)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/boxlayout.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L305-L311 | go | train | // Widgets returns the list of Widgets for this BoxLayout. | func (b *BoxLayout) Widgets() []Widget | // Widgets returns the list of Widgets for this BoxLayout.
func (b *BoxLayout) Widgets() []Widget | {
w := make([]Widget, 0, len(b.cells))
for _, c := range b.cells {
w = append(w, c.widget)
}
return w
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/boxlayout.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L314-L320 | go | train | // SetOrientation sets the orientation as either Horizontal or Vertical. | func (b *BoxLayout) SetOrientation(orient Orientation) | // SetOrientation sets the orientation as either Horizontal or Vertical.
func (b *BoxLayout) SetOrientation(orient Orientation) | {
if b.orient != orient {
b.orient = orient
b.changed = true
b.PostEventWidgetContent(b)
}
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/boxlayout.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/boxlayout.go#L323-L326 | go | train | // SetStyle sets the style used. | func (b *BoxLayout) SetStyle(style tcell.Style) | // SetStyle sets the style used.
func (b *BoxLayout) SetStyle(style tcell.Style) | {
b.style = style
b.PostEventWidgetContent(b)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | console_win.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/console_win.go#L445-L447 | go | train | // NB: All Windows platforms are little endian. We assume this
// never, ever change. The following code is endian safe. and does
// not use unsafe pointers. | func getu32(v []byte) uint32 | // NB: All Windows platforms are little endian. We assume this
// never, ever change. The following code is endian safe. and does
// not use unsafe pointers.
func getu32(v []byte) uint32 | {
return uint32(v[0]) + (uint32(v[1]) << 8) + (uint32(v[2]) << 16) + (uint32(v[3]) << 24)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | console_win.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/console_win.go#L459-L474 | go | train | // Convert windows dwControlKeyState to modifier mask | func mod2mask(cks uint32) ModMask | // Convert windows dwControlKeyState to modifier mask
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
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | console_win.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/console_win.go#L652-L667 | go | train | // Windows uses RGB signals | func mapColor2RGB(c Color) uint16 | // Windows uses RGB signals
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
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | console_win.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/console_win.go#L670-L703 | go | train | // Map a tcell style to Windows attributes | func (s *cScreen) mapStyle(style Style) uint16 | // Map a tcell style to Windows attributes
func (s *cScreen) mapStyle(style Style) uint16 | {
f, b, a := style.Decompose()
fa := s.oscreen.attrs & 0xf
ba := (s.oscreen.attrs) >> 4 & 0xf
if f != ColorDefault {
fa = mapColor2RGB(f)
}
if b != ColorDefault {
ba = mapColor2RGB(b)
}
var attr uint16
// We simulate reverse by doing the color swap ourselves.
// Apparently windows cannot really do this e... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/sstext.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/sstext.go#L52-L88 | go | train | // SetMarkup sets the text used for the string. It applies markup as follows
// (modeled on tcsh style prompt markup):
//
// * %% - emit a single % in current style
// * %N - normal style
// * %A - alternate style
// * %S - start standout (reverse) style
// * %B - start bold style
// * %U - start underline style
//
//... | func (t *SimpleStyledText) SetMarkup(s string) | // SetMarkup sets the text used for the string. It applies markup as follows
// (modeled on tcsh style prompt markup):
//
// * %% - emit a single % in current style
// * %N - normal style
// * %A - alternate style
// * %S - start standout (reverse) style
// * %B - start bold style
// * %U - start underline style
//
//... | {
markup := []rune(s)
styl := make([]tcell.Style, 0, len(markup))
text := make([]rune, 0, len(markup))
style := t.styles['N']
esc := false
for _, r := range markup {
if esc {
esc = false
switch r {
case '%':
text = append(text, '%')
styl = append(styl, style)
default:
style = t.style... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/sstext.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/sstext.go#L95-L102 | go | train | // Registers a style for the given rune. This style will be used for
// text marked with %<r>. See SetMarkup() for more detail. Note that
// this must be done before using any of the styles with SetMarkup().
// Only letters may be used when registering styles, and be advised that
// the system may have predefined use... | func (t *SimpleStyledText) RegisterStyle(r rune, style tcell.Style) | // Registers a style for the given rune. This style will be used for
// text marked with %<r>. See SetMarkup() for more detail. Note that
// this must be done before using any of the styles with SetMarkup().
// Only letters may be used when registering styles, and be advised that
// the system may have predefined use... | {
if r == 'N' {
t.Text.SetStyle(style)
}
if unicode.IsLetter(r) {
t.styles[r] = style
}
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/sstext.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/sstext.go#L107-L109 | go | train | // LookupStyle returns the style registered for the given rune.
// Returns tcell.StyleDefault if no style was previously registered
// for the rune. | func (t *SimpleStyledText) LookupStyle(r rune) tcell.Style | // LookupStyle returns the style registered for the given rune.
// Returns tcell.StyleDefault if no style was previously registered
// for the rune.
func (t *SimpleStyledText) LookupStyle(r rune) tcell.Style | {
return t.styles[r]
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/sstext.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/sstext.go#L117-L126 | go | train | // NewSimpleStyledText creates an empty Text. | func NewSimpleStyledText() *SimpleStyledText | // NewSimpleStyledText creates an empty Text.
func NewSimpleStyledText() *SimpleStyledText | {
ss := &SimpleStyledText{}
// Create map and establish default styles.
ss.styles = make(map[rune]tcell.Style)
ss.styles['N'] = tcell.StyleDefault
ss.styles['S'] = tcell.StyleDefault.Reverse(true)
ss.styles['U'] = tcell.StyleDefault.Underline(true)
ss.styles['B'] = tcell.StyleDefault.Bold(true)
return ss
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/panel.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/panel.go#L44-L47 | go | train | // Draw draws the Panel. | func (p *Panel) Draw() | // Draw draws the Panel.
func (p *Panel) Draw() | {
p.BoxLayout.SetOrientation(Vertical)
p.BoxLayout.Draw()
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/panel.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/panel.go#L50-L56 | go | train | // SetTitle sets the Widget to display in the title area. | func (p *Panel) SetTitle(w Widget) | // SetTitle sets the Widget to display in the title area.
func (p *Panel) SetTitle(w Widget) | {
if p.title != nil {
p.RemoveWidget(p.title)
}
p.InsertWidget(0, w, 0.0)
p.title = w
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/panel.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/panel.go#L60-L70 | go | train | // SetMenu sets the Widget to display in the menu area, which is
// just below the title. | func (p *Panel) SetMenu(w Widget) | // SetMenu sets the Widget to display in the menu area, which is
// just below the title.
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
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/panel.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/panel.go#L73-L86 | go | train | // SetContent sets the Widget to display in the content area. | func (p *Panel) SetContent(w Widget) | // SetContent sets the Widget to display in the content area.
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
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/panel.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/panel.go#L90-L106 | go | train | // SetStatus sets the Widget to display in the status area, which is at
// the bottom of the panel. | func (p *Panel) SetStatus(w Widget) | // SetStatus sets the Widget to display in the status area, which is at
// the bottom of the panel.
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
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/cellarea.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L51-L94 | go | train | // Draw draws the content. | func (a *CellView) Draw() | // Draw draws the content.
func (a *CellView) Draw() | {
port := a.port
model := a.model
port.Fill(' ', a.style)
if a.view == nil {
return
}
if model == nil {
return
}
vw, vh := a.view.Size()
for y := 0; y < vh; y++ {
for x := 0; x < vw; x++ {
a.view.SetContent(x, y, ' ', nil, a.style)
}
}
ex, ey := model.GetBounds()
vx, vy := port.Size()
if ex ... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/cellarea.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L176-L184 | go | train | // MakeCursorVisible ensures that the cursor is visible, panning the ViewPort
// as necessary, if the cursor is enabled. | func (a *CellView) MakeCursorVisible() | // MakeCursorVisible ensures that the cursor is visible, panning the ViewPort
// as necessary, if the cursor is enabled.
func (a *CellView) MakeCursorVisible() | {
if a.model == nil {
return
}
x, y, enabled, _ := a.model.GetCursor()
if enabled {
a.MakeVisible(x, y)
}
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/cellarea.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L188-L222 | go | train | // HandleEvent handles events. In particular, it handles certain key events
// to move the cursor or pan the view. | func (a *CellView) HandleEvent(e tcell.Event) bool | // HandleEvent handles events. In particular, it handles certain key events
// to move the cursor or pan the view.
func (a *CellView) HandleEvent(e tcell.Event) bool | {
if a.model == nil {
return false
}
switch e := e.(type) {
case *tcell.EventKey:
switch e.Key() {
case tcell.KeyUp, tcell.KeyCtrlP:
a.keyUp()
return true
case tcell.KeyDown, tcell.KeyCtrlN:
a.keyDown()
return true
case tcell.KeyRight, tcell.KeyCtrlF:
a.keyRight()
return true
case tce... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/cellarea.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L225-L236 | go | train | // Size returns the content size, based on the model. | func (a *CellView) Size() (int, int) | // Size returns the content size, based on the model.
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
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/cellarea.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L239-L246 | go | train | // SetModel sets the model for this CellView. | func (a *CellView) SetModel(model CellModel) | // SetModel sets the model for this CellView.
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)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/cellarea.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L249-L263 | go | train | // SetView sets the View context. | func (a *CellView) SetView(view View) | // SetView sets the View context.
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()
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/cellarea.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L267-L273 | go | train | // Resize is called when the View is resized. It will ensure that the
// cursor is visible, if present. | func (a *CellView) Resize() | // Resize is called when the View is resized. It will ensure that the
// cursor is visible, if present.
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()
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/cellarea.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L276-L280 | go | train | // SetCursor sets the the cursor position. | func (a *CellView) SetCursor(x, y int) | // SetCursor sets the the cursor position.
func (a *CellView) SetCursor(x, y int) | {
a.cursorX = x
a.cursorY = y
a.model.SetCursor(x, y)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/cellarea.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L283-L285 | go | train | // SetCursorX sets the the cursor column. | func (a *CellView) SetCursorX(x int) | // SetCursorX sets the the cursor column.
func (a *CellView) SetCursorX(x int) | {
a.SetCursor(x, a.cursorY)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/cellarea.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L288-L290 | go | train | // SetCursorY sets the the cursor row. | func (a *CellView) SetCursorY(y int) | // SetCursorY sets the the cursor row.
func (a *CellView) SetCursorY(y int) | {
a.SetCursor(a.cursorX, y)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/cellarea.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L294-L296 | go | train | // MakeVisible makes the given coordinates visible, if they are not already.
// It does this by moving the ViewPort for the CellView. | func (a *CellView) MakeVisible(x, y int) | // MakeVisible makes the given coordinates visible, if they are not already.
// It does this by moving the ViewPort for the CellView.
func (a *CellView) MakeVisible(x, y int) | {
a.port.MakeVisible(x, y)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/cellarea.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/cellarea.go#L304-L309 | go | train | // Init initializes a new CellView for use. | func (a *CellView) Init() | // Init initializes a new CellView for use.
func (a *CellView) Init() | {
a.once.Do(func() {
a.port = NewViewPort(nil, 0, 0, 0, 0)
a.style = tcell.StyleDefault
})
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | encoding/all.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/encoding/all.go#L32-L115 | go | train | // Register registers all known encodings. This is a short-cut to
// add full character set support to your program. Note that this can
// add several megabytes to your program's size, because some of the encodings
// are rather large (particularly those from East Asia.) | func Register() | // Register registers all known encodings. This is a short-cut to
// add full character set support to your program. Note that this can
// add several megabytes to your program's size, because some of the encodings
// are rather large (particularly those from East Asia.)
func Register() | {
// We supply latin1 and latin5, because Go doesn't
tcell.RegisterEncoding("ISO8859-1", encoding.ISO8859_1)
tcell.RegisterEncoding("ISO8859-9", encoding.ISO8859_9)
tcell.RegisterEncoding("ISO8859-10", charmap.ISO8859_10)
tcell.RegisterEncoding("ISO8859-13", charmap.ISO8859_13)
tcell.RegisterEncoding("ISO8859-1... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | simulation.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/simulation.go#L26-L32 | go | train | // NewSimulationScreen returns a SimulationScreen. Note that
// SimulationScreen is also a Screen. | func NewSimulationScreen(charset string) SimulationScreen | // NewSimulationScreen returns a SimulationScreen. Note that
// SimulationScreen is also a Screen.
func NewSimulationScreen(charset string) SimulationScreen | {
if charset == "" {
charset = "UTF-8"
}
s := &simscreen{charset: charset}
return s
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | resize.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/resize.go#L30-L32 | go | train | // NewEventResize creates an EventResize with the new updated window size,
// which is given in character cells. | func NewEventResize(width, height int) *EventResize | // NewEventResize creates an EventResize with the new updated window size,
// which is given in character cells.
func NewEventResize(width, height int) *EventResize | {
return &EventResize{t: time.Now(), w: width, h: height}
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | terminfo/terminfo.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/terminfo/terminfo.go#L317-L322 | go | train | // Start initializes the params buffer with the initial string data.
// It also locks the paramsBuffer. The caller must call End() when
// finished. | func (pb *paramsBuffer) Start(s string) | // Start initializes the params buffer with the initial string data.
// It also locks the paramsBuffer. The caller must call End() when
// finished.
func (pb *paramsBuffer) Start(s string) | {
pb.lk.Lock()
pb.out.Reset()
pb.buf.Reset()
pb.buf.WriteString(s)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | terminfo/terminfo.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/terminfo/terminfo.go#L325-L329 | go | train | // End returns the final output from TParam, but it also releases the lock. | func (pb *paramsBuffer) End() string | // End returns the final output from TParam, but it also releases the lock.
func (pb *paramsBuffer) End() string | {
s := pb.out.String()
pb.lk.Unlock()
return s
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | terminfo/terminfo.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/terminfo/terminfo.go#L351-L617 | go | train | // TParm takes a terminfo parameterized string, such as setaf or cup, and
// evaluates the string, and returns the result with the parameter
// applied. | func (t *Terminfo) TParm(s string, p ...int) string | // TParm takes a terminfo parameterized string, such as setaf or cup, and
// evaluates the string, and returns the result with the parameter
// applied.
func (t *Terminfo) TParm(s string, p ...int) string | {
var stk stack
var a, b string
var ai, bi int
var ab bool
var dvars [26]string
var params [9]int
pb.Start(s)
// make sure we always have 9 parameters -- makes it easier
// later to skip checks
for i := 0; i < len(params) && i < len(p); i++ {
params[i] = p[i]
}
nest := 0
for {
ch, err := pb.NextC... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | terminfo/terminfo.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/terminfo/terminfo.go#L625-L671 | go | train | // TPuts emits the string to the writer, but expands inline padding
// indications (of the form $<[delay]> where [delay] is msec) to
// a suitable number of padding characters (usually null bytes) based
// upon the supplied baud. At high baud rates, more padding characters
// will be inserted. All Terminfo based stri... | func (t *Terminfo) TPuts(w io.Writer, s string, baud int) | // TPuts emits the string to the writer, but expands inline padding
// indications (of the form $<[delay]> where [delay] is msec) to
// a suitable number of padding characters (usually null bytes) based
// upon the supplied baud. At high baud rates, more padding characters
// will be inserted. All Terminfo based stri... | {
for {
beg := strings.Index(s, "$<")
if beg < 0 {
// Most strings don't need padding, which is good news!
io.WriteString(w, s)
return
}
io.WriteString(w, s[:beg])
s = s[beg+2:]
end := strings.Index(s, ">")
if end < 0 {
// unterminated.. just emit bytes unadulterated
io.WriteString(w, "$<... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | terminfo/terminfo.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/terminfo/terminfo.go#L675-L677 | go | train | // TGoto returns a string suitable for addressing the cursor at the given
// row and column. The origin 0, 0 is in the upper left corner of the screen. | func (t *Terminfo) TGoto(col, row int) string | // TGoto returns a string suitable for addressing the cursor at the given
// row and column. The origin 0, 0 is in the upper left corner of the screen.
func (t *Terminfo) TGoto(col, row int) string | {
return t.TParm(t.SetCursor, row, col)
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | terminfo/terminfo.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/terminfo/terminfo.go#L681-L702 | go | train | // TColor returns a string corresponding to the given foreground and background
// colors. Either fg or bg can be set to -1 to elide. | func (t *Terminfo) TColor(fi, bi int) string | // TColor returns a string corresponding to the given foreground and background
// colors. Either fg or bg can be set to -1 to elide.
func (t *Terminfo) TColor(fi, bi int) string | {
rv := ""
// As a special case, we map bright colors to lower versions if the
// color table only holds 8. For the remaining 240 colors, the user
// is out of luck. Someday we could create a mapping table, but its
// not worth it.
if t.Colors == 8 {
if fi > 7 && fi < 16 {
fi -= 8
}
if bi > 7 && bi < ... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | terminfo/terminfo.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/terminfo/terminfo.go#L711-L718 | go | train | // AddTerminfo can be called to register a new Terminfo entry. | func AddTerminfo(t *Terminfo) | // AddTerminfo can be called to register a new Terminfo entry.
func AddTerminfo(t *Terminfo) | {
dblock.Lock()
terminfos[t.Name] = t
for _, x := range t.Aliases {
terminfos[x] = t
}
dblock.Unlock()
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | terminfo/terminfo.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/terminfo/terminfo.go#L768-L923 | go | train | // LookupTerminfo attempts to find a definition for the named $TERM.
// It first looks in the builtin database, which should cover just about
// everyone. If it can't find one there, then it will attempt to read
// one from the JSON file located in either $TCELLDB, $HOME/.tcelldb,
// or as a database file.
//
// The d... | func LookupTerminfo(name string) (*Terminfo, error) | // LookupTerminfo attempts to find a definition for the named $TERM.
// It first looks in the builtin database, which should cover just about
// everyone. If it can't find one there, then it will attempt to read
// one from the JSON file located in either $TCELLDB, $HOME/.tcelldb,
// or as a database file.
//
// The d... | {
if name == "" {
// else on windows: index out of bounds
// on the name[0] reference below
return nil, ErrTermNotFound
}
addtruecolor := false
switch os.Getenv("COLORTERM") {
case "truecolor", "24bit", "24-bit":
addtruecolor = true
}
dblock.Lock()
t := terminfos[name]
dblock.Unlock()
if t == nil {... |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | screen.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/screen.go#L200-L209 | go | train | // NewScreen returns a default Screen suitable for the user's terminal
// environment. | func NewScreen() (Screen, error) | // NewScreen returns a default Screen suitable for the user's terminal
// environment.
func NewScreen() (Screen, error) | {
// Windows is happier if we try for a console screen first.
if s, _ := NewConsoleScreen(); s != nil {
return s, nil
} else if s, e := NewTerminfoScreen(); s != nil {
return s, nil
} else {
return nil, e
}
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/app.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/app.go#L39-L47 | go | train | // initialize initializes the application. It will normally attempt to
// allocate a default screen if one is not already established. | func (app *Application) initialize() error | // initialize initializes the application. It will normally attempt to
// allocate a default screen if one is not already established.
func (app *Application) initialize() error | {
if app.screen == nil {
if app.screen, app.err = tcell.NewScreen(); app.err != nil {
return app.err
}
app.screen.SetStyle(app.style)
}
return nil
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/app.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/app.go#L51-L57 | go | train | // Quit causes the application to shutdown gracefully. It does not wait
// for the application to exit, but returns immediately. | func (app *Application) Quit() | // Quit causes the application to shutdown gracefully. It does not wait
// for the application to exit, but returns immediately.
func (app *Application) Quit() | {
ev := &eventAppQuit{}
ev.SetEventNow()
if scr := app.screen; scr != nil {
go func() { scr.PostEventWait(ev) }()
}
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/app.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/app.go#L61-L67 | go | train | // Refresh causes the application forcibly redraw everything. Use this
// to clear up screen corruption, etc. | func (app *Application) Refresh() | // Refresh causes the application forcibly redraw everything. Use this
// to clear up screen corruption, etc.
func (app *Application) Refresh() | {
ev := &eventAppRefresh{}
ev.SetEventNow()
if scr := app.screen; scr != nil {
go func() { scr.PostEventWait(ev) }()
}
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/app.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/app.go#L71-L77 | go | train | // Update asks the application to draw any screen updates that have not
// been drawn yet. | func (app *Application) Update() | // Update asks the application to draw any screen updates that have not
// been drawn yet.
func (app *Application) Update() | {
ev := &eventAppUpdate{}
ev.SetEventNow()
if scr := app.screen; scr != nil {
go func() { scr.PostEventWait(ev) }()
}
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/app.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/app.go#L82-L88 | go | train | // PostFunc posts a function to be executed in the context of the
// application's event loop. Functions that need to update displayed
// state, etc. can do this to avoid holding locks. | func (app *Application) PostFunc(fn func()) | // PostFunc posts a function to be executed in the context of the
// application's event loop. Functions that need to update displayed
// state, etc. can do this to avoid holding locks.
func (app *Application) PostFunc(fn func()) | {
ev := &eventAppFunc{fn: fn}
ev.SetEventNow()
if scr := app.screen; scr != nil {
go func() { scr.PostEventWait(ev) }()
}
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/app.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/app.go#L92-L97 | go | train | // SetScreen sets the screen to use for the application. This must be
// done before the application starts to run or is initialized. | func (app *Application) SetScreen(scr tcell.Screen) | // SetScreen sets the screen to use for the application. This must be
// done before the application starts to run or is initialized.
func (app *Application) SetScreen(scr tcell.Screen) | {
if app.screen == nil {
app.screen = scr
app.err = nil
}
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | views/app.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/views/app.go#L101-L106 | go | train | // SetStyle sets the default style (background) to be used for Widgets
// that have not specified any other style. | func (app *Application) SetStyle(style tcell.Style) | // SetStyle sets the default style (background) to be used for Widgets
// that have not specified any other style.
func (app *Application) SetStyle(style tcell.Style) | {
app.style = style
if app.screen != nil {
app.screen.SetStyle(style)
}
} |
gdamore/tcell | dcf1bb30770eb1158b67005e1e472de6d74f055d | mouse.go | https://github.com/gdamore/tcell/blob/dcf1bb30770eb1158b67005e1e472de6d74f055d/mouse.go#L69-L71 | go | train | // NewEventMouse is used to create a new mouse event. Applications
// shouldn't need to use this; its mostly for screen implementors. | func NewEventMouse(x, y int, btn ButtonMask, mod ModMask) *EventMouse | // NewEventMouse is used to create a new mouse event. Applications
// shouldn't need to use this; its mostly for screen implementors.
func NewEventMouse(x, y int, btn ButtonMask, mod ModMask) *EventMouse | {
return &EventMouse{t: time.Now(), x: x, y: y, btn: btn, mod: mod}
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo/convert/package_rewriter.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo/convert/package_rewriter.go#L18-L28 | go | train | /*
* RewritePackage takes a name (eg: my-package/tools), finds its test files using
* Go's build package, and then rewrites them. A ginkgo test suite file will
* also be added for this package, and all of its child packages.
*/ | func RewritePackage(packageName string) | /*
* RewritePackage takes a name (eg: my-package/tools), finds its test files using
* Go's build package, and then rewrites them. A ginkgo test suite file will
* also be added for this package, and all of its child packages.
*/
func RewritePackage(packageName string) | {
pkg, err := packageWithName(packageName)
if err != nil {
panic(fmt.Sprintf("unexpected error reading package: '%s'\n%s\n", packageName, err.Error()))
}
for _, filename := range findTestsInPackage(pkg) {
rewriteTestsInFile(filename)
}
return
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo/convert/package_rewriter.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo/convert/package_rewriter.go#L73-L101 | go | train | /*
* Shells out to `ginkgo bootstrap` to create a test suite file
*/ | func addGinkgoSuiteForPackage(pkg *build.Package) | /*
* Shells out to `ginkgo bootstrap` to create a test suite file
*/
func addGinkgoSuiteForPackage(pkg *build.Package) | {
originalDir, err := os.Getwd()
if err != nil {
panic(err)
}
suite_test_file := filepath.Join(pkg.Dir, pkg.Name+"_suite_test.go")
_, err = os.Stat(suite_test_file)
if err == nil {
return // test file already exists, this should be a no-op
}
err = os.Chdir(pkg.Dir)
if err != nil {
panic(err)
}
out... |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo/convert/package_rewriter.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo/convert/package_rewriter.go#L106-L112 | go | train | /*
* Shells out to `go fmt` to format the package
*/ | func goFmtPackage(pkg *build.Package) | /*
* Shells out to `go fmt` to format the package
*/
func goFmtPackage(pkg *build.Package) | {
output, err := exec.Command("go", "fmt", pkg.ImportPath).Output()
if err != nil {
fmt.Printf("Warning: Error running 'go fmt %s'.\nstdout: %s\n%s\n", pkg.ImportPath, output, err.Error())
}
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo/convert/package_rewriter.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo/convert/package_rewriter.go#L119-L127 | go | train | /*
* Attempts to return a package with its test files already read.
* The ImportMode arg to build.Import lets you specify if you want go to read the
* buildable go files inside the package, but it fails if the package has no go files
*/ | func packageWithName(name string) (pkg *build.Package, err error) | /*
* Attempts to return a package with its test files already read.
* The ImportMode arg to build.Import lets you specify if you want go to read the
* buildable go files inside the package, but it fails if the package has no go files
*/
func packageWithName(name string) (pkg *build.Package, err error) | {
pkg, err = build.Default.Import(name, ".", build.ImportMode(0))
if err == nil {
return
}
pkg, err = build.Default.Import(name, ".", build.ImportMode(1))
return
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | extensions/table/table.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/extensions/table/table.go#L44-L47 | go | train | /*
DescribeTable describes a table-driven test.
For example:
DescribeTable("a simple table",
func(x int, y int, expected bool) {
Ω(x > y).Should(Equal(expected))
},
Entry("x > y", 1, 0, true),
Entry("x == y", 0, 0, false),
Entry("x < y", 0, 1, false),
)
The... | func DescribeTable(description string, itBody interface{}, entries ...TableEntry) bool | /*
DescribeTable describes a table-driven test.
For example:
DescribeTable("a simple table",
func(x int, y int, expected bool) {
Ω(x > y).Should(Equal(expected))
},
Entry("x > y", 1, 0, true),
Entry("x == y", 0, 0, false),
Entry("x < y", 0, 1, false),
)
The... | {
describeTable(description, itBody, entries, false, false)
return true
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo/run_command.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo/run_command.go#L144-L154 | go | train | // Moves all generated profiles to specified directory | func (r *SpecRunner) moveCoverprofiles(runners []*testrunner.TestRunner) | // Moves all generated profiles to specified directory
func (r *SpecRunner) moveCoverprofiles(runners []*testrunner.TestRunner) | {
for _, runner := range runners {
_, filename := filepath.Split(runner.CoverageFile)
err := os.Rename(runner.CoverageFile, filepath.Join(r.getOutputDir(), filename))
if err != nil {
fmt.Printf("Unable to move coverprofile %s, %v\n", runner.CoverageFile, err)
return
}
}
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo/run_command.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo/run_command.go#L157-L192 | go | train | // Combines all generated profiles in the specified directory | func (r *SpecRunner) combineCoverprofiles(runners []*testrunner.TestRunner) error | // Combines all generated profiles in the specified directory
func (r *SpecRunner) combineCoverprofiles(runners []*testrunner.TestRunner) error | {
path, _ := filepath.Abs(r.getOutputDir())
if !fileExists(path) {
return fmt.Errorf("Unable to create combined profile, outputdir does not exist: %s", r.getOutputDir())
}
fmt.Println("path is " + path)
combined, err := os.OpenFile(filepath.Join(path, r.getCoverprofile()),
os.O_APPEND|os.O_WRONLY|os.O_CREA... |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | extensions/table/table_entry.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/extensions/table/table_entry.go#L58-L60 | go | train | /*
Entry constructs a TableEntry.
The first argument is a required description (this becomes the content of the generated Ginkgo `It`).
Subsequent parameters are saved off and sent to the callback passed in to `DescribeTable`.
Each Entry ends up generating an individual Ginkgo It.
*/ | func Entry(description string, parameters ...interface{}) TableEntry | /*
Entry constructs a TableEntry.
The first argument is a required description (this becomes the content of the generated Ginkgo `It`).
Subsequent parameters are saved off and sent to the callback passed in to `DescribeTable`.
Each Entry ends up generating an individual Ginkgo It.
*/
func Entry(description string, pa... | {
return TableEntry{description, parameters, false, false}
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | extensions/table/table_entry.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/extensions/table/table_entry.go#L65-L67 | go | train | /*
You can focus a particular entry with FEntry. This is equivalent to FIt.
*/ | func FEntry(description string, parameters ...interface{}) TableEntry | /*
You can focus a particular entry with FEntry. This is equivalent to FIt.
*/
func FEntry(description string, parameters ...interface{}) TableEntry | {
return TableEntry{description, parameters, false, true}
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | extensions/table/table_entry.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/extensions/table/table_entry.go#L72-L74 | go | train | /*
You can mark a particular entry as pending with PEntry. This is equivalent to PIt.
*/ | func PEntry(description string, parameters ...interface{}) TableEntry | /*
You can mark a particular entry as pending with PEntry. This is equivalent to PIt.
*/
func PEntry(description string, parameters ...interface{}) TableEntry | {
return TableEntry{description, parameters, true, false}
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | extensions/table/table_entry.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/extensions/table/table_entry.go#L79-L81 | go | train | /*
You can mark a particular entry as pending with XEntry. This is equivalent to XIt.
*/ | func XEntry(description string, parameters ...interface{}) TableEntry | /*
You can mark a particular entry as pending with XEntry. This is equivalent to XIt.
*/
func XEntry(description string, parameters ...interface{}) TableEntry | {
return TableEntry{description, parameters, true, false}
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo/convert/import.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo/convert/import.go#L13-L29 | go | train | /*
* Given the root node of an AST, returns the node containing the
* import statements for the file.
*/ | func importsForRootNode(rootNode *ast.File) (imports *ast.GenDecl, err error) | /*
* Given the root node of an AST, returns the node containing the
* import statements for the file.
*/
func importsForRootNode(rootNode *ast.File) (imports *ast.GenDecl, err error) | {
for _, declaration := range rootNode.Decls {
decl, ok := declaration.(*ast.GenDecl)
if !ok || len(decl.Specs) == 0 {
continue
}
_, ok = decl.Specs[0].(*ast.ImportSpec)
if ok {
imports = decl
return
}
}
err = errors.New(fmt.Sprintf("Could not find imports for root node:\n\t%#v\n", rootNode))... |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo/convert/import.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo/convert/import.go#L55-L81 | go | train | /*
* Adds import statements for onsi/ginkgo, if missing
*/ | func addGinkgoImports(rootNode *ast.File) | /*
* Adds import statements for onsi/ginkgo, if missing
*/
func addGinkgoImports(rootNode *ast.File) | {
importDecl, err := importsForRootNode(rootNode)
if err != nil {
panic(err.Error())
}
if len(importDecl.Specs) == 0 {
// TODO: might need to create a import decl here
panic("unimplemented : expected to find an imports block")
}
needsGinkgo := true
for _, importSpec := range importDecl.Specs {
importS... |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo/convert/import.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo/convert/import.go#L86-L91 | go | train | /*
* convenience function to create an import statement
*/ | func createImport(name, path string) *ast.ImportSpec | /*
* convenience function to create an import statement
*/
func createImport(name, path string) *ast.ImportSpec | {
return &ast.ImportSpec{
Name: &ast.Ident{Name: name},
Path: &ast.BasicLit{Kind: 9, Value: path},
}
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | internal/spec/specs.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/internal/spec/specs.go#L77-L91 | go | train | // toMatch returns a byte[] to be used by regex matchers. When adding new behaviours to the matching function,
// this is the place which we append to. | func (e *Specs) toMatch(description string, i int) []byte | // toMatch returns a byte[] to be used by regex matchers. When adding new behaviours to the matching function,
// this is the place which we append to.
func (e *Specs) toMatch(description string, i int) []byte | {
if i > len(e.names) {
return nil
}
if e.RegexScansFilePath {
return []byte(
description + " " +
e.names[i] + " " +
e.specs[i].subject.CodeLocation().FileName)
} else {
return []byte(
description + " " +
e.names[i])
}
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | internal/remote/server.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/internal/remote/server.go#L39-L51 | go | train | //Create a new server, automatically selecting a port | func NewServer(parallelTotal int) (*Server, error) | //Create a new server, automatically selecting a port
func NewServer(parallelTotal int) (*Server, error) | {
listener, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
return nil, err
}
return &Server{
listener: listener,
lock: &sync.Mutex{},
alives: make([]func() bool, parallelTotal),
beforeSuiteData: types.RemoteBeforeSuiteData{Data: nil, State: types.RemoteBeforeSuiteState... |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | internal/remote/server.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/internal/remote/server.go#L54-L74 | go | train | //Start the server. You don't need to `go s.Start()`, just `s.Start()` | func (server *Server) Start() | //Start the server. You don't need to `go s.Start()`, just `s.Start()`
func (server *Server) Start() | {
httpServer := &http.Server{}
mux := http.NewServeMux()
httpServer.Handler = mux
//streaming endpoints
mux.HandleFunc("/SpecSuiteWillBegin", server.specSuiteWillBegin)
mux.HandleFunc("/BeforeSuiteDidRun", server.beforeSuiteDidRun)
mux.HandleFunc("/AfterSuiteDidRun", server.afterSuiteDidRun)
mux.HandleFunc("/... |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | internal/remote/server.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/internal/remote/server.go#L91-L95 | go | train | //
// Streaming Endpoints
//
//The server will forward all received messages to Ginkgo reporters registered with `RegisterReporters` | func (server *Server) readAll(request *http.Request) []byte | //
// Streaming Endpoints
//
//The server will forward all received messages to Ginkgo reporters registered with `RegisterReporters`
func (server *Server) readAll(request *http.Request) []byte | {
defer request.Body.Close()
body, _ := ioutil.ReadAll(request.Body)
return body
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | internal/remote/server.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/internal/remote/server.go#L170-L174 | go | train | //
// Synchronization Endpoints
// | func (server *Server) RegisterAlive(node int, alive func() bool) | //
// Synchronization Endpoints
//
func (server *Server) RegisterAlive(node int, alive func() bool) | {
server.lock.Lock()
defer server.lock.Unlock()
server.alives[node-1] = alive
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo/convert/ginkgo_ast_nodes.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo/convert/ginkgo_ast_nodes.go#L13-L19 | go | train | /*
* Creates a func init() node
*/ | func createVarUnderscoreBlock() *ast.ValueSpec | /*
* Creates a func init() node
*/
func createVarUnderscoreBlock() *ast.ValueSpec | {
valueSpec := &ast.ValueSpec{}
object := &ast.Object{Kind: 4, Name: "_", Decl: valueSpec, Data: 0}
ident := &ast.Ident{Name: "_", Obj: object}
valueSpec.Names = append(valueSpec.Names, ident)
return valueSpec
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo/convert/ginkgo_ast_nodes.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo/convert/ginkgo_ast_nodes.go#L24-L33 | go | train | /*
* Creates a Describe("Testing with ginkgo", func() { }) node
*/ | func createDescribeBlock() *ast.CallExpr | /*
* Creates a Describe("Testing with ginkgo", func() { }) node
*/
func createDescribeBlock() *ast.CallExpr | {
blockStatement := &ast.BlockStmt{List: []ast.Stmt{}}
fieldList := &ast.FieldList{}
funcType := &ast.FuncType{Params: fieldList}
funcLit := &ast.FuncLit{Type: funcType, Body: blockStatement}
basicLit := &ast.BasicLit{Kind: 9, Value: "\"Testing with Ginkgo\""}
describeIdent := &ast.Ident{Name: "Describe"}
retu... |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo/convert/ginkgo_ast_nodes.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo/convert/ginkgo_ast_nodes.go#L48-L66 | go | train | /*
* Convenience function to return the block statement node for a Describe statement
*/ | func blockStatementFromDescribe(desc *ast.CallExpr) *ast.BlockStmt | /*
* Convenience function to return the block statement node for a Describe statement
*/
func blockStatementFromDescribe(desc *ast.CallExpr) *ast.BlockStmt | {
var funcLit *ast.FuncLit
var found = false
for _, node := range desc.Args {
switch node := node.(type) {
case *ast.FuncLit:
found = true
funcLit = node
break
}
}
if !found {
panic("Error finding ast.FuncLit inside describe statement. Somebody done goofed.")
}
return funcLit.Body
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo_dsl.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo_dsl.go#L98-L104 | go | train | //Some matcher libraries or legacy codebases require a *testing.T
//GinkgoT implements an interface analogous to *testing.T and can be used if
//the library in question accepts *testing.T through an interface
//
// For example, with testify:
// assert.Equal(GinkgoT(), 123, 123, "they should be equal")
//
// Or with gom... | func GinkgoT(optionalOffset ...int) GinkgoTInterface | //Some matcher libraries or legacy codebases require a *testing.T
//GinkgoT implements an interface analogous to *testing.T and can be used if
//the library in question accepts *testing.T through an interface
//
// For example, with testify:
// assert.Equal(GinkgoT(), 123, 123, "they should be equal")
//
// Or with gom... | {
offset := 3
if len(optionalOffset) > 0 {
offset = optionalOffset[0]
}
return testingtproxy.New(GinkgoWriter, Fail, offset)
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo_dsl.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo_dsl.go#L200-L203 | go | train | //RunSpecs is the entry point for the Ginkgo test runner.
//You must call this within a Golang testing TestX(t *testing.T) function.
//
//To bootstrap a test suite you can use the Ginkgo CLI:
//
// ginkgo bootstrap | func RunSpecs(t GinkgoTestingT, description string) bool | //RunSpecs is the entry point for the Ginkgo test runner.
//You must call this within a Golang testing TestX(t *testing.T) function.
//
//To bootstrap a test suite you can use the Ginkgo CLI:
//
// ginkgo bootstrap
func RunSpecs(t GinkgoTestingT, description string) bool | {
specReporters := []Reporter{buildDefaultReporter()}
return RunSpecsWithCustomReporters(t, description, specReporters)
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo_dsl.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo_dsl.go#L207-L210 | go | train | //To run your tests with Ginkgo's default reporter and your custom reporter(s), replace
//RunSpecs() with this method. | func RunSpecsWithDefaultAndCustomReporters(t GinkgoTestingT, description string, specReporters []Reporter) bool | //To run your tests with Ginkgo's default reporter and your custom reporter(s), replace
//RunSpecs() with this method.
func RunSpecsWithDefaultAndCustomReporters(t GinkgoTestingT, description string, specReporters []Reporter) bool | {
specReporters = append(specReporters, buildDefaultReporter())
return RunSpecsWithCustomReporters(t, description, specReporters)
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo_dsl.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo_dsl.go#L214-L227 | go | train | //To run your tests with your custom reporter(s) (and *not* Ginkgo's default reporter), replace
//RunSpecs() with this method. Note that parallel tests will not work correctly without the default reporter | func RunSpecsWithCustomReporters(t GinkgoTestingT, description string, specReporters []Reporter) bool | //To run your tests with your custom reporter(s) (and *not* Ginkgo's default reporter), replace
//RunSpecs() with this method. Note that parallel tests will not work correctly without the default reporter
func RunSpecsWithCustomReporters(t GinkgoTestingT, description string, specReporters []Reporter) bool | {
writer := GinkgoWriter.(*writer.Writer)
writer.SetStream(config.DefaultReporterConfig.Verbose)
reporters := make([]reporters.Reporter, len(specReporters))
for i, reporter := range specReporters {
reporters[i] = reporter
}
passed, hasFocusedTests := globalSuite.Run(t, description, reporters, writer, config.Gi... |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo_dsl.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo_dsl.go#L244-L252 | go | train | //Skip notifies Ginkgo that the current spec was skipped. | func Skip(message string, callerSkip ...int) | //Skip notifies Ginkgo that the current spec was skipped.
func Skip(message string, callerSkip ...int) | {
skip := 0
if len(callerSkip) > 0 {
skip = callerSkip[0]
}
globalFailer.Skip(message, codelocation.New(skip+1))
panic(GINKGO_PANIC)
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo_dsl.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo_dsl.go#L275-L280 | go | train | //GinkgoRecover should be deferred at the top of any spawned goroutine that (may) call `Fail`
//Since Gomega assertions call fail, you should throw a `defer GinkgoRecover()` at the top of any goroutine that
//calls out to Gomega
//
//Here's why: Ginkgo's `Fail` method records the failure and then panics to prevent
//fu... | func GinkgoRecover() | //GinkgoRecover should be deferred at the top of any spawned goroutine that (may) call `Fail`
//Since Gomega assertions call fail, you should throw a `defer GinkgoRecover()` at the top of any goroutine that
//calls out to Gomega
//
//Here's why: Ginkgo's `Fail` method records the failure and then panics to prevent
//fu... | {
e := recover()
if e != nil {
globalFailer.Panic(codelocation.New(1), e)
}
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo_dsl.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo_dsl.go#L300-L303 | go | train | //You can mark the tests within a describe block as pending using PDescribe | func PDescribe(text string, body func()) bool | //You can mark the tests within a describe block as pending using PDescribe
func PDescribe(text string, body func()) bool | {
globalSuite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1))
return true
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo_dsl.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo_dsl.go#L317-L320 | go | train | //Context blocks allow you to organize your specs. A Context block can contain any number of
//BeforeEach, AfterEach, JustBeforeEach, It, and Measurement blocks.
//
//In addition you can nest Describe, Context and When blocks. Describe, Context and When blocks are functionally
//equivalent. The difference is purely ... | func Context(text string, body func()) bool | //Context blocks allow you to organize your specs. A Context block can contain any number of
//BeforeEach, AfterEach, JustBeforeEach, It, and Measurement blocks.
//
//In addition you can nest Describe, Context and When blocks. Describe, Context and When blocks are functionally
//equivalent. The difference is purely ... | {
globalSuite.PushContainerNode(text, body, types.FlagTypeNone, codelocation.New(1))
return true
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo_dsl.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo_dsl.go#L352-L355 | go | train | //You can focus the tests within a describe block using FWhen | func FWhen(text string, body func()) bool | //You can focus the tests within a describe block using FWhen
func FWhen(text string, body func()) bool | {
globalSuite.PushContainerNode("when "+text, body, types.FlagTypeFocused, codelocation.New(1))
return true
} |
onsi/ginkgo | eea6ad008b96acdaa524f5b409513bf062b500ad | ginkgo_dsl.go | https://github.com/onsi/ginkgo/blob/eea6ad008b96acdaa524f5b409513bf062b500ad/ginkgo_dsl.go#L374-L377 | go | train | //It blocks contain your test code and assertions. You cannot nest any other Ginkgo blocks
//within an It block.
//
//Ginkgo will normally run It blocks synchronously. To perform asynchronous tests, pass a
//function that accepts a Done channel. When you do this, you can also provide an optional timeout. | func It(text string, body interface{}, timeout ...float64) bool | //It blocks contain your test code and assertions. You cannot nest any other Ginkgo blocks
//within an It block.
//
//Ginkgo will normally run It blocks synchronously. To perform asynchronous tests, pass a
//function that accepts a Done channel. When you do this, you can also provide an optional timeout.
func It(tex... | {
globalSuite.PushItNode(text, body, types.FlagTypeNone, codelocation.New(1), parseTimeout(timeout...))
return true
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.