id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
124,600
BurntSushi/xgbutil
xevent/xevent.go
SendRootEvent
func SendRootEvent(xu *xgbutil.XUtil, ev xgb.Event, evMask uint32) error { return xproto.SendEventChecked(xu.Conn(), false, xu.RootWin(), evMask, string(ev.Bytes())).Check() }
go
func SendRootEvent(xu *xgbutil.XUtil, ev xgb.Event, evMask uint32) error { return xproto.SendEventChecked(xu.Conn(), false, xu.RootWin(), evMask, string(ev.Bytes())).Check() }
[ "func", "SendRootEvent", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "ev", "xgb", ".", "Event", ",", "evMask", "uint32", ")", "error", "{", "return", "xproto", ".", "SendEventChecked", "(", "xu", ".", "Conn", "(", ")", ",", "false", ",", "xu", ".",...
// SendRootEvent takes a type implementing the xgb.Event interface, converts it // to raw X bytes, and sends it to the root window using the SendEvent request.
[ "SendRootEvent", "takes", "a", "type", "implementing", "the", "xgb", ".", "Event", "interface", "converts", "it", "to", "raw", "X", "bytes", "and", "sends", "it", "to", "the", "root", "window", "using", "the", "SendEvent", "request", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xevent/xevent.go#L229-L232
124,601
BurntSushi/xgbutil
xevent/xevent.go
ReplayPointer
func ReplayPointer(xu *xgbutil.XUtil) { xproto.AllowEvents(xu.Conn(), xproto.AllowReplayPointer, 0) }
go
func ReplayPointer(xu *xgbutil.XUtil) { xproto.AllowEvents(xu.Conn(), xproto.AllowReplayPointer, 0) }
[ "func", "ReplayPointer", "(", "xu", "*", "xgbutil", ".", "XUtil", ")", "{", "xproto", ".", "AllowEvents", "(", "xu", ".", "Conn", "(", ")", ",", "xproto", ".", "AllowReplayPointer", ",", "0", ")", "\n", "}" ]
// ReplayPointer is a quick alias to AllowEvents with 'ReplayPointer' mode.
[ "ReplayPointer", "is", "a", "quick", "alias", "to", "AllowEvents", "with", "ReplayPointer", "mode", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xevent/xevent.go#L235-L237
124,602
BurntSushi/xgbutil
mousebind/drag.go
dragGrab
func dragGrab(xu *xgbutil.XUtil, grabwin xproto.Window, win xproto.Window, cursor xproto.Cursor) bool { status, err := GrabPointer(xu, grabwin, xu.RootWin(), cursor) if err != nil { xgbutil.Logger.Printf("Mouse dragging was unsuccessful because: %v", err) return false } if !status { xgbutil.Logger.Printl...
go
func dragGrab(xu *xgbutil.XUtil, grabwin xproto.Window, win xproto.Window, cursor xproto.Cursor) bool { status, err := GrabPointer(xu, grabwin, xu.RootWin(), cursor) if err != nil { xgbutil.Logger.Printf("Mouse dragging was unsuccessful because: %v", err) return false } if !status { xgbutil.Logger.Printl...
[ "func", "dragGrab", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "grabwin", "xproto", ".", "Window", ",", "win", "xproto", ".", "Window", ",", "cursor", "xproto", ".", "Cursor", ")", "bool", "{", "status", ",", "err", ":=", "GrabPointer", "(", "xu", ...
// dragGrab is a shortcut for grabbing the pointer for a drag.
[ "dragGrab", "is", "a", "shortcut", "for", "grabbing", "the", "pointer", "for", "a", "drag", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/mousebind/drag.go#L37-L54
124,603
BurntSushi/xgbutil
mousebind/drag.go
dragStep
func dragStep(xu *xgbutil.XUtil, ev xevent.MotionNotifyEvent) { // If for whatever reason we don't have any *piece* of a grab, // we've gotta back out. if !mouseDrag(xu) || mouseDragStep(xu) == nil || mouseDragEnd(xu) == nil { dragUngrab(xu) mouseDragStepSet(xu, nil) mouseDragEndSet(xu, nil) return } // T...
go
func dragStep(xu *xgbutil.XUtil, ev xevent.MotionNotifyEvent) { // If for whatever reason we don't have any *piece* of a grab, // we've gotta back out. if !mouseDrag(xu) || mouseDragStep(xu) == nil || mouseDragEnd(xu) == nil { dragUngrab(xu) mouseDragStepSet(xu, nil) mouseDragEndSet(xu, nil) return } // T...
[ "func", "dragStep", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "ev", "xevent", ".", "MotionNotifyEvent", ")", "{", "// If for whatever reason we don't have any *piece* of a grab,", "// we've gotta back out.", "if", "!", "mouseDrag", "(", "xu", ")", "||", "mouseDrag...
// dragStep executes the "step" function registered for the current drag. // It also compresses the MotionNotify events.
[ "dragStep", "executes", "the", "step", "function", "registered", "for", "the", "current", "drag", ".", "It", "also", "compresses", "the", "MotionNotify", "events", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/mousebind/drag.go#L98-L146
124,604
BurntSushi/xgbutil
mousebind/drag.go
DragEnd
func DragEnd(xu *xgbutil.XUtil, ev xevent.ButtonReleaseEvent) { if mouseDragEnd(xu) != nil { mouseDragEnd(xu)(xu, int(ev.RootX), int(ev.RootY), int(ev.EventX), int(ev.EventY)) } dragUngrab(xu) mouseDragStepSet(xu, nil) mouseDragEndSet(xu, nil) }
go
func DragEnd(xu *xgbutil.XUtil, ev xevent.ButtonReleaseEvent) { if mouseDragEnd(xu) != nil { mouseDragEnd(xu)(xu, int(ev.RootX), int(ev.RootY), int(ev.EventX), int(ev.EventY)) } dragUngrab(xu) mouseDragStepSet(xu, nil) mouseDragEndSet(xu, nil) }
[ "func", "DragEnd", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "ev", "xevent", ".", "ButtonReleaseEvent", ")", "{", "if", "mouseDragEnd", "(", "xu", ")", "!=", "nil", "{", "mouseDragEnd", "(", "xu", ")", "(", "xu", ",", "int", "(", "ev", ".", "Ro...
// DragEnd executes the "end" function registered for the current drag. // This must be called at some point if DragStart has been called.
[ "DragEnd", "executes", "the", "end", "function", "registered", "for", "the", "current", "drag", ".", "This", "must", "be", "called", "at", "some", "point", "if", "DragStart", "has", "been", "called", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/mousebind/drag.go#L150-L159
124,605
BurntSushi/xgbutil
xevent/eventloop.go
Read
func Read(xu *xgbutil.XUtil, block bool) { if block { ev, err := xu.Conn().WaitForEvent() if ev == nil && err == nil { xgbutil.Logger.Fatal("BUG: Could not read an event or an error.") } Enqueue(xu, ev, err) } // Clean up anything that's in the queue for { ev, err := xu.Conn().PollForEvent() // No ...
go
func Read(xu *xgbutil.XUtil, block bool) { if block { ev, err := xu.Conn().WaitForEvent() if ev == nil && err == nil { xgbutil.Logger.Fatal("BUG: Could not read an event or an error.") } Enqueue(xu, ev, err) } // Clean up anything that's in the queue for { ev, err := xu.Conn().PollForEvent() // No ...
[ "func", "Read", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "block", "bool", ")", "{", "if", "block", "{", "ev", ",", "err", ":=", "xu", ".", "Conn", "(", ")", ".", "WaitForEvent", "(", ")", "\n", "if", "ev", "==", "nil", "&&", "err", "==", ...
// Read reads one or more events and queues them in XUtil. // If 'block' is True, then call 'WaitForEvent' before sucking up // all events that have been queued by XGB.
[ "Read", "reads", "one", "or", "more", "events", "and", "queues", "them", "in", "XUtil", ".", "If", "block", "is", "True", "then", "call", "WaitForEvent", "before", "sucking", "up", "all", "events", "that", "have", "been", "queued", "by", "XGB", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xevent/eventloop.go#L23-L44
124,606
BurntSushi/xgbutil
xevent/eventloop.go
mainEventLoop
func mainEventLoop(xu *xgbutil.XUtil, pingBefore, pingAfter, pingQuit chan struct{}) { for { if Quitting(xu) { if pingQuit != nil { pingQuit <- struct{}{} } break } // Gobble up as many events as possible (into the queue). // If there are no events, we block. Read(xu, true) // Now process e...
go
func mainEventLoop(xu *xgbutil.XUtil, pingBefore, pingAfter, pingQuit chan struct{}) { for { if Quitting(xu) { if pingQuit != nil { pingQuit <- struct{}{} } break } // Gobble up as many events as possible (into the queue). // If there are no events, we block. Read(xu, true) // Now process e...
[ "func", "mainEventLoop", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "pingBefore", ",", "pingAfter", ",", "pingQuit", "chan", "struct", "{", "}", ")", "{", "for", "{", "if", "Quitting", "(", "xu", ")", "{", "if", "pingQuit", "!=", "nil", "{", "ping...
// mainEventLoop runs the main event loop with an optional ping channel.
[ "mainEventLoop", "runs", "the", "main", "event", "loop", "with", "an", "optional", "ping", "channel", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xevent/eventloop.go#L93-L110
124,607
BurntSushi/xgbutil
mousebind/callback.go
connect
func connect(xu *xgbutil.XUtil, callback xgbutil.CallbackMouse, evtype int, win xproto.Window, buttonStr string, sync bool, grab bool) error { // Get the mods/button first mods, button, err := ParseString(xu, buttonStr) if err != nil { return err } // Only do the grab if we haven't yet on this window. // And...
go
func connect(xu *xgbutil.XUtil, callback xgbutil.CallbackMouse, evtype int, win xproto.Window, buttonStr string, sync bool, grab bool) error { // Get the mods/button first mods, button, err := ParseString(xu, buttonStr) if err != nil { return err } // Only do the grab if we haven't yet on this window. // And...
[ "func", "connect", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "callback", "xgbutil", ".", "CallbackMouse", ",", "evtype", "int", ",", "win", "xproto", ".", "Window", ",", "buttonStr", "string", ",", "sync", "bool", ",", "grab", "bool", ")", "error", ...
// connect is essentially 'Connect' for either ButtonPress or // ButtonRelease events.
[ "connect", "is", "essentially", "Connect", "for", "either", "ButtonPress", "or", "ButtonRelease", "events", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/mousebind/callback.go#L14-L60
124,608
BurntSushi/xgbutil
mousebind/callback.go
runButtonPressCallbacks
func runButtonPressCallbacks(xu *xgbutil.XUtil, ev xevent.ButtonPressEvent) { mods, button := DeduceButtonInfo(ev.State, ev.Detail) runMouseBindCallbacks(xu, ev, xevent.ButtonPress, ev.Event, mods, button) }
go
func runButtonPressCallbacks(xu *xgbutil.XUtil, ev xevent.ButtonPressEvent) { mods, button := DeduceButtonInfo(ev.State, ev.Detail) runMouseBindCallbacks(xu, ev, xevent.ButtonPress, ev.Event, mods, button) }
[ "func", "runButtonPressCallbacks", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "ev", "xevent", ".", "ButtonPressEvent", ")", "{", "mods", ",", "button", ":=", "DeduceButtonInfo", "(", "ev", ".", "State", ",", "ev", ".", "Detail", ")", "\n\n", "runMouseBi...
// runButtonPressCallbacks infers the window, button and modifiers from a // ButtonPressEvent and runs the corresponding callbacks.
[ "runButtonPressCallbacks", "infers", "the", "window", "button", "and", "modifiers", "from", "a", "ButtonPressEvent", "and", "runs", "the", "corresponding", "callbacks", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/mousebind/callback.go#L131-L135
124,609
BurntSushi/xgbutil
mousebind/callback.go
runButtonReleaseCallbacks
func runButtonReleaseCallbacks(xu *xgbutil.XUtil, ev xevent.ButtonReleaseEvent) { mods, button := DeduceButtonInfo(ev.State, ev.Detail) runMouseBindCallbacks(xu, ev, xevent.ButtonRelease, ev.Event, mods, button) }
go
func runButtonReleaseCallbacks(xu *xgbutil.XUtil, ev xevent.ButtonReleaseEvent) { mods, button := DeduceButtonInfo(ev.State, ev.Detail) runMouseBindCallbacks(xu, ev, xevent.ButtonRelease, ev.Event, mods, button) }
[ "func", "runButtonReleaseCallbacks", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "ev", "xevent", ".", "ButtonReleaseEvent", ")", "{", "mods", ",", "button", ":=", "DeduceButtonInfo", "(", "ev", ".", "State", ",", "ev", ".", "Detail", ")", "\n\n", "runMou...
// runButtonReleaseCallbacks infers the window, keycode and modifiers from a // ButtonPressEvent and runs the corresponding callbacks.
[ "runButtonReleaseCallbacks", "infers", "the", "window", "keycode", "and", "modifiers", "from", "a", "ButtonPressEvent", "and", "runs", "the", "corresponding", "callbacks", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/mousebind/callback.go#L139-L145
124,610
BurntSushi/xgbutil
mousebind/callback.go
Detach
func Detach(xu *xgbutil.XUtil, win xproto.Window) { detach(xu, xevent.ButtonPress, win) detach(xu, xevent.ButtonRelease, win) }
go
func Detach(xu *xgbutil.XUtil, win xproto.Window) { detach(xu, xevent.ButtonPress, win) detach(xu, xevent.ButtonRelease, win) }
[ "func", "Detach", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "win", "xproto", ".", "Window", ")", "{", "detach", "(", "xu", ",", "xevent", ".", "ButtonPress", ",", "win", ")", "\n", "detach", "(", "xu", ",", "xevent", ".", "ButtonRelease", ",", ...
// Detach removes all handlers for all mouse events for the provided window id. // This should be called whenever a window is no longer receiving events to make // sure the garbage collector can release memory used to store the handler info.
[ "Detach", "removes", "all", "handlers", "for", "all", "mouse", "events", "for", "the", "provided", "window", "id", ".", "This", "should", "be", "called", "whenever", "a", "window", "is", "no", "longer", "receiving", "events", "to", "make", "sure", "the", "...
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/mousebind/callback.go#L150-L153
124,611
BurntSushi/xgbutil
xwindow/ewmh.go
WMMove
func (w *Window) WMMove(x, y int) error { return ewmh.MoveWindow(w.X, w.Id, x, y) }
go
func (w *Window) WMMove(x, y int) error { return ewmh.MoveWindow(w.X, w.Id, x, y) }
[ "func", "(", "w", "*", "Window", ")", "WMMove", "(", "x", ",", "y", "int", ")", "error", "{", "return", "ewmh", ".", "MoveWindow", "(", "w", ".", "X", ",", "w", ".", "Id", ",", "x", ",", "y", ")", "\n", "}" ]
// WMMove changes the position of a window without touching the size. // This should be used when moving a top-level client window with // reparenting winow managers that support EWMH.
[ "WMMove", "changes", "the", "position", "of", "a", "window", "without", "touching", "the", "size", ".", "This", "should", "be", "used", "when", "moving", "a", "top", "-", "level", "client", "window", "with", "reparenting", "winow", "managers", "that", "suppo...
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xwindow/ewmh.go#L54-L56
124,612
BurntSushi/xgbutil
xwindow/ewmh.go
WMResize
func (w *Window) WMResize(width, height int) error { neww, newh, err := adjustSize(w.X, w.Id, width, height) if err != nil { return err } return ewmh.ResizeWindow(w.X, w.Id, neww, newh) }
go
func (w *Window) WMResize(width, height int) error { neww, newh, err := adjustSize(w.X, w.Id, width, height) if err != nil { return err } return ewmh.ResizeWindow(w.X, w.Id, neww, newh) }
[ "func", "(", "w", "*", "Window", ")", "WMResize", "(", "width", ",", "height", "int", ")", "error", "{", "neww", ",", "newh", ",", "err", ":=", "adjustSize", "(", "w", ".", "X", ",", "w", ".", "Id", ",", "width", ",", "height", ")", "\n", "if",...
// WMResize changes the size of a window without touching the position. // This should be used when resizing a top-level client window with // reparenting window managers that support EWMH.
[ "WMResize", "changes", "the", "size", "of", "a", "window", "without", "touching", "the", "position", ".", "This", "should", "be", "used", "when", "resizing", "a", "top", "-", "level", "client", "window", "with", "reparenting", "window", "managers", "that", "...
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xwindow/ewmh.go#L61-L67
124,613
BurntSushi/xgbutil
icccm/icccm.go
WmNormalHintsSet
func WmNormalHintsSet(xu *xgbutil.XUtil, win xproto.Window, nh *NormalHints) error { raw := []uint{ nh.Flags, uint(nh.X), uint(nh.Y), nh.Width, nh.Height, nh.MinWidth, nh.MinHeight, nh.MaxWidth, nh.MaxHeight, nh.WidthInc, nh.HeightInc, nh.MinAspectNum, nh.MinAspectDen, nh.MaxAspectNum, nh.MaxAspectDen,...
go
func WmNormalHintsSet(xu *xgbutil.XUtil, win xproto.Window, nh *NormalHints) error { raw := []uint{ nh.Flags, uint(nh.X), uint(nh.Y), nh.Width, nh.Height, nh.MinWidth, nh.MinHeight, nh.MaxWidth, nh.MaxHeight, nh.WidthInc, nh.HeightInc, nh.MinAspectNum, nh.MinAspectDen, nh.MaxAspectNum, nh.MaxAspectDen,...
[ "func", "WmNormalHintsSet", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "win", "xproto", ".", "Window", ",", "nh", "*", "NormalHints", ")", "error", "{", "raw", ":=", "[", "]", "uint", "{", "nh", ".", "Flags", ",", "uint", "(", "nh", ".", "X", ...
// WM_NORMAL_HINTS set // Make sure to set the flags in the NormalHints struct correctly!
[ "WM_NORMAL_HINTS", "set", "Make", "sure", "to", "set", "the", "flags", "in", "the", "NormalHints", "struct", "correctly!" ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/icccm/icccm.go#L122-L138
124,614
BurntSushi/xgbutil
icccm/icccm.go
WmHintsSet
func WmHintsSet(xu *xgbutil.XUtil, win xproto.Window, hints *Hints) error { raw := []uint{ hints.Flags, hints.Input, hints.InitialState, uint(hints.IconPixmap), uint(hints.IconWindow), uint(hints.IconX), uint(hints.IconY), uint(hints.IconMask), uint(hints.WindowGroup), } return xprop.ChangeProp32(xu, win, ...
go
func WmHintsSet(xu *xgbutil.XUtil, win xproto.Window, hints *Hints) error { raw := []uint{ hints.Flags, hints.Input, hints.InitialState, uint(hints.IconPixmap), uint(hints.IconWindow), uint(hints.IconX), uint(hints.IconY), uint(hints.IconMask), uint(hints.WindowGroup), } return xprop.ChangeProp32(xu, win, ...
[ "func", "WmHintsSet", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "win", "xproto", ".", "Window", ",", "hints", "*", "Hints", ")", "error", "{", "raw", ":=", "[", "]", "uint", "{", "hints", ".", "Flags", ",", "hints", ".", "Input", ",", "hints", ...
// WM_HINTS set // Make sure to set the flags in the Hints struct correctly!
[ "WM_HINTS", "set", "Make", "sure", "to", "set", "the", "flags", "in", "the", "Hints", "struct", "correctly!" ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/icccm/icccm.go#L181-L190
124,615
BurntSushi/xgbutil
xprop/xprop.go
GetProperty
func GetProperty(xu *xgbutil.XUtil, win xproto.Window, atom string) ( *xproto.GetPropertyReply, error) { atomId, err := Atm(xu, atom) if err != nil { return nil, err } reply, err := xproto.GetProperty(xu.Conn(), false, win, atomId, xproto.GetPropertyTypeAny, 0, (1<<32)-1).Reply() if err != nil { return n...
go
func GetProperty(xu *xgbutil.XUtil, win xproto.Window, atom string) ( *xproto.GetPropertyReply, error) { atomId, err := Atm(xu, atom) if err != nil { return nil, err } reply, err := xproto.GetProperty(xu.Conn(), false, win, atomId, xproto.GetPropertyTypeAny, 0, (1<<32)-1).Reply() if err != nil { return n...
[ "func", "GetProperty", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "win", "xproto", ".", "Window", ",", "atom", "string", ")", "(", "*", "xproto", ".", "GetPropertyReply", ",", "error", ")", "{", "atomId", ",", "err", ":=", "Atm", "(", "xu", ",", ...
// GetProperty abstracts the messiness of calling xgb.GetProperty.
[ "GetProperty", "abstracts", "the", "messiness", "of", "calling", "xgb", ".", "GetProperty", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xprop/xprop.go#L13-L35
124,616
BurntSushi/xgbutil
xprop/xprop.go
ChangeProp
func ChangeProp(xu *xgbutil.XUtil, win xproto.Window, format byte, prop string, typ string, data []byte) error { propAtom, err := Atm(xu, prop) if err != nil { return err } typAtom, err := Atm(xu, typ) if err != nil { return err } return xproto.ChangePropertyChecked(xu.Conn(), xproto.PropModeReplace, win...
go
func ChangeProp(xu *xgbutil.XUtil, win xproto.Window, format byte, prop string, typ string, data []byte) error { propAtom, err := Atm(xu, prop) if err != nil { return err } typAtom, err := Atm(xu, typ) if err != nil { return err } return xproto.ChangePropertyChecked(xu.Conn(), xproto.PropModeReplace, win...
[ "func", "ChangeProp", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "win", "xproto", ".", "Window", ",", "format", "byte", ",", "prop", "string", ",", "typ", "string", ",", "data", "[", "]", "byte", ")", "error", "{", "propAtom", ",", "err", ":=", ...
// ChangeProperty abstracts the semi-nastiness of xgb.ChangeProperty.
[ "ChangeProperty", "abstracts", "the", "semi", "-", "nastiness", "of", "xgb", ".", "ChangeProperty", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xprop/xprop.go#L38-L54
124,617
BurntSushi/xgbutil
xprop/xprop.go
ChangeProp32
func ChangeProp32(xu *xgbutil.XUtil, win xproto.Window, prop string, typ string, data ...uint) error { buf := make([]byte, len(data)*4) for i, datum := range data { xgb.Put32(buf[(i*4):], uint32(datum)) } return ChangeProp(xu, win, 32, prop, typ, buf) }
go
func ChangeProp32(xu *xgbutil.XUtil, win xproto.Window, prop string, typ string, data ...uint) error { buf := make([]byte, len(data)*4) for i, datum := range data { xgb.Put32(buf[(i*4):], uint32(datum)) } return ChangeProp(xu, win, 32, prop, typ, buf) }
[ "func", "ChangeProp32", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "win", "xproto", ".", "Window", ",", "prop", "string", ",", "typ", "string", ",", "data", "...", "uint", ")", "error", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "len"...
// ChangeProperty32 makes changing 32 bit formatted properties easier // by constructing the raw X data for you.
[ "ChangeProperty32", "makes", "changing", "32", "bit", "formatted", "properties", "easier", "by", "constructing", "the", "raw", "X", "data", "for", "you", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xprop/xprop.go#L58-L67
124,618
BurntSushi/xgbutil
xprop/xprop.go
PropValAtom
func PropValAtom(xu *xgbutil.XUtil, reply *xproto.GetPropertyReply, err error) (string, error) { if err != nil { return "", err } if reply.Format != 32 { return "", fmt.Errorf("PropValAtom: Expected format 32 but got %d", reply.Format) } return AtomName(xu, xproto.Atom(xgb.Get32(reply.Value))) }
go
func PropValAtom(xu *xgbutil.XUtil, reply *xproto.GetPropertyReply, err error) (string, error) { if err != nil { return "", err } if reply.Format != 32 { return "", fmt.Errorf("PropValAtom: Expected format 32 but got %d", reply.Format) } return AtomName(xu, xproto.Atom(xgb.Get32(reply.Value))) }
[ "func", "PropValAtom", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "reply", "*", "xproto", ".", "GetPropertyReply", ",", "err", "error", ")", "(", "string", ",", "error", ")", "{", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", ...
// PropValAtom transforms a GetPropertyReply struct into an ATOM name. // The property reply must be in 32 bit format.
[ "PropValAtom", "transforms", "a", "GetPropertyReply", "struct", "into", "an", "ATOM", "name", ".", "The", "property", "reply", "must", "be", "in", "32", "bit", "format", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xprop/xprop.go#L107-L119
124,619
BurntSushi/xgbutil
xprop/xprop.go
PropValAtoms
func PropValAtoms(xu *xgbutil.XUtil, reply *xproto.GetPropertyReply, err error) ([]string, error) { if err != nil { return nil, err } if reply.Format != 32 { return nil, fmt.Errorf("PropValAtoms: Expected format 32 but got %d", reply.Format) } ids := make([]string, reply.ValueLen) vals := reply.Value f...
go
func PropValAtoms(xu *xgbutil.XUtil, reply *xproto.GetPropertyReply, err error) ([]string, error) { if err != nil { return nil, err } if reply.Format != 32 { return nil, fmt.Errorf("PropValAtoms: Expected format 32 but got %d", reply.Format) } ids := make([]string, reply.ValueLen) vals := reply.Value f...
[ "func", "PropValAtoms", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "reply", "*", "xproto", ".", "GetPropertyReply", ",", "err", "error", ")", "(", "[", "]", "string", ",", "error", ")", "{", "if", "err", "!=", "nil", "{", "return", "nil", ",", "...
// PropValAtoms is the same as PropValAtom, except that it returns a slice // of atom names. Also must be 32 bit format. // This is a method of an XUtil struct, unlike the other 'PropVal...' functions.
[ "PropValAtoms", "is", "the", "same", "as", "PropValAtom", "except", "that", "it", "returns", "a", "slice", "of", "atom", "names", ".", "Also", "must", "be", "32", "bit", "format", ".", "This", "is", "a", "method", "of", "an", "XUtil", "struct", "unlike",...
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xprop/xprop.go#L124-L146
124,620
BurntSushi/xgbutil
xprop/xprop.go
PropValWindow
func PropValWindow(reply *xproto.GetPropertyReply, err error) (xproto.Window, error) { if err != nil { return 0, err } if reply.Format != 32 { return 0, fmt.Errorf("PropValId: Expected format 32 but got %d", reply.Format) } return xproto.Window(xgb.Get32(reply.Value)), nil }
go
func PropValWindow(reply *xproto.GetPropertyReply, err error) (xproto.Window, error) { if err != nil { return 0, err } if reply.Format != 32 { return 0, fmt.Errorf("PropValId: Expected format 32 but got %d", reply.Format) } return xproto.Window(xgb.Get32(reply.Value)), nil }
[ "func", "PropValWindow", "(", "reply", "*", "xproto", ".", "GetPropertyReply", ",", "err", "error", ")", "(", "xproto", ".", "Window", ",", "error", ")", "{", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "if", "reply", ...
// PropValWindow transforms a GetPropertyReply struct into an X resource // window identifier. // The property reply must be in 32 bit format.
[ "PropValWindow", "transforms", "a", "GetPropertyReply", "struct", "into", "an", "X", "resource", "window", "identifier", ".", "The", "property", "reply", "must", "be", "in", "32", "bit", "format", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xprop/xprop.go#L151-L162
124,621
BurntSushi/xgbutil
xprop/xprop.go
PropValWindows
func PropValWindows(reply *xproto.GetPropertyReply, err error) ([]xproto.Window, error) { if err != nil { return nil, err } if reply.Format != 32 { return nil, fmt.Errorf("PropValIds: Expected format 32 but got %d", reply.Format) } ids := make([]xproto.Window, reply.ValueLen) vals := reply.Value for i ...
go
func PropValWindows(reply *xproto.GetPropertyReply, err error) ([]xproto.Window, error) { if err != nil { return nil, err } if reply.Format != 32 { return nil, fmt.Errorf("PropValIds: Expected format 32 but got %d", reply.Format) } ids := make([]xproto.Window, reply.ValueLen) vals := reply.Value for i ...
[ "func", "PropValWindows", "(", "reply", "*", "xproto", ".", "GetPropertyReply", ",", "err", "error", ")", "(", "[", "]", "xproto", ".", "Window", ",", "error", ")", "{", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "...
// PropValWindows is the same as PropValWindow, except that it returns a slice // of identifiers. Also must be 32 bit format.
[ "PropValWindows", "is", "the", "same", "as", "PropValWindow", "except", "that", "it", "returns", "a", "slice", "of", "identifiers", ".", "Also", "must", "be", "32", "bit", "format", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xprop/xprop.go#L166-L184
124,622
BurntSushi/xgbutil
xprop/xprop.go
PropValNum
func PropValNum(reply *xproto.GetPropertyReply, err error) (uint, error) { if err != nil { return 0, err } if reply.Format != 32 { return 0, fmt.Errorf("PropValNum: Expected format 32 but got %d", reply.Format) } return uint(xgb.Get32(reply.Value)), nil }
go
func PropValNum(reply *xproto.GetPropertyReply, err error) (uint, error) { if err != nil { return 0, err } if reply.Format != 32 { return 0, fmt.Errorf("PropValNum: Expected format 32 but got %d", reply.Format) } return uint(xgb.Get32(reply.Value)), nil }
[ "func", "PropValNum", "(", "reply", "*", "xproto", ".", "GetPropertyReply", ",", "err", "error", ")", "(", "uint", ",", "error", ")", "{", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "if", "reply", ".", "Format", "!="...
// PropValNum transforms a GetPropertyReply struct into an unsigned // integer. Useful when the property value is a single integer.
[ "PropValNum", "transforms", "a", "GetPropertyReply", "struct", "into", "an", "unsigned", "integer", ".", "Useful", "when", "the", "property", "value", "is", "a", "single", "integer", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xprop/xprop.go#L188-L197
124,623
BurntSushi/xgbutil
xprop/xprop.go
PropValNums
func PropValNums(reply *xproto.GetPropertyReply, err error) ([]uint, error) { if err != nil { return nil, err } if reply.Format != 32 { return nil, fmt.Errorf("PropValIds: Expected format 32 but got %d", reply.Format) } nums := make([]uint, reply.ValueLen) vals := reply.Value for i := 0; len(vals) >= 4; ...
go
func PropValNums(reply *xproto.GetPropertyReply, err error) ([]uint, error) { if err != nil { return nil, err } if reply.Format != 32 { return nil, fmt.Errorf("PropValIds: Expected format 32 but got %d", reply.Format) } nums := make([]uint, reply.ValueLen) vals := reply.Value for i := 0; len(vals) >= 4; ...
[ "func", "PropValNums", "(", "reply", "*", "xproto", ".", "GetPropertyReply", ",", "err", "error", ")", "(", "[", "]", "uint", ",", "error", ")", "{", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "reply", ".", ...
// PropValNums is the same as PropValNum, except that it returns a slice // of integers. Also must be 32 bit format.
[ "PropValNums", "is", "the", "same", "as", "PropValNum", "except", "that", "it", "returns", "a", "slice", "of", "integers", ".", "Also", "must", "be", "32", "bit", "format", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xprop/xprop.go#L201-L217
124,624
BurntSushi/xgbutil
xprop/xprop.go
PropValNum64
func PropValNum64(reply *xproto.GetPropertyReply, err error) (int64, error) { if err != nil { return 0, err } if reply.Format != 32 { return 0, fmt.Errorf("PropValNum: Expected format 32 but got %d", reply.Format) } return int64(xgb.Get32(reply.Value)), nil }
go
func PropValNum64(reply *xproto.GetPropertyReply, err error) (int64, error) { if err != nil { return 0, err } if reply.Format != 32 { return 0, fmt.Errorf("PropValNum: Expected format 32 but got %d", reply.Format) } return int64(xgb.Get32(reply.Value)), nil }
[ "func", "PropValNum64", "(", "reply", "*", "xproto", ".", "GetPropertyReply", ",", "err", "error", ")", "(", "int64", ",", "error", ")", "{", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "if", "reply", ".", "Format", "...
// PropValNum64 transforms a GetPropertyReply struct into a 64 bit // integer. Useful when the property value is a single integer.
[ "PropValNum64", "transforms", "a", "GetPropertyReply", "struct", "into", "a", "64", "bit", "integer", ".", "Useful", "when", "the", "property", "value", "is", "a", "single", "integer", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xprop/xprop.go#L221-L230
124,625
BurntSushi/xgbutil
xprop/xprop.go
PropValStr
func PropValStr(reply *xproto.GetPropertyReply, err error) (string, error) { if err != nil { return "", err } if reply.Format != 8 { return "", fmt.Errorf("PropValStr: Expected format 8 but got %d", reply.Format) } return string(reply.Value), nil }
go
func PropValStr(reply *xproto.GetPropertyReply, err error) (string, error) { if err != nil { return "", err } if reply.Format != 8 { return "", fmt.Errorf("PropValStr: Expected format 8 but got %d", reply.Format) } return string(reply.Value), nil }
[ "func", "PropValStr", "(", "reply", "*", "xproto", ".", "GetPropertyReply", ",", "err", "error", ")", "(", "string", ",", "error", ")", "{", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "if", "reply", ".", "Form...
// PropValStr transforms a GetPropertyReply struct into a string. // Useful when the property value is a null terminated string represented // by integers. Also must be 8 bit format.
[ "PropValStr", "transforms", "a", "GetPropertyReply", "struct", "into", "a", "string", ".", "Useful", "when", "the", "property", "value", "is", "a", "null", "terminated", "string", "represented", "by", "integers", ".", "Also", "must", "be", "8", "bit", "format"...
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xprop/xprop.go#L235-L244
124,626
BurntSushi/xgbutil
xprop/xprop.go
PropValStrs
func PropValStrs(reply *xproto.GetPropertyReply, err error) ([]string, error) { if err != nil { return nil, err } if reply.Format != 8 { return nil, fmt.Errorf("PropValStrs: Expected format 8 but got %d", reply.Format) } var strs []string sstart := 0 for i, c := range reply.Value { if c == 0 { strs ...
go
func PropValStrs(reply *xproto.GetPropertyReply, err error) ([]string, error) { if err != nil { return nil, err } if reply.Format != 8 { return nil, fmt.Errorf("PropValStrs: Expected format 8 but got %d", reply.Format) } var strs []string sstart := 0 for i, c := range reply.Value { if c == 0 { strs ...
[ "func", "PropValStrs", "(", "reply", "*", "xproto", ".", "GetPropertyReply", ",", "err", "error", ")", "(", "[", "]", "string", ",", "error", ")", "{", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "reply", ".",...
// PropValStrs is the same as PropValStr, except that it returns a slice // of strings. The raw byte string is a sequence of null terminated strings, // which is translated into a slice of strings.
[ "PropValStrs", "is", "the", "same", "as", "PropValStr", "except", "that", "it", "returns", "a", "slice", "of", "strings", ".", "The", "raw", "byte", "string", "is", "a", "sequence", "of", "null", "terminated", "strings", "which", "is", "translated", "into", ...
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xprop/xprop.go#L249-L270
124,627
BurntSushi/xgbutil
xrect/xrect.go
RectPieces
func RectPieces(xr Rect) (int, int, int, int) { return xr.X(), xr.Y(), xr.Width(), xr.Height() }
go
func RectPieces(xr Rect) (int, int, int, int) { return xr.X(), xr.Y(), xr.Width(), xr.Height() }
[ "func", "RectPieces", "(", "xr", "Rect", ")", "(", "int", ",", "int", ",", "int", ",", "int", ")", "{", "return", "xr", ".", "X", "(", ")", ",", "xr", ".", "Y", "(", ")", ",", "xr", ".", "Width", "(", ")", ",", "xr", ".", "Height", "(", "...
// RectPieces just returns a four-tuple of x, y, width and height
[ "RectPieces", "just", "returns", "a", "four", "-", "tuple", "of", "x", "y", "width", "and", "height" ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xrect/xrect.go#L19-L21
124,628
BurntSushi/xgbutil
xrect/xrect.go
New
func New(x, y, w, h int) *XRect { return &XRect{x, y, w, h} }
go
func New(x, y, w, h int) *XRect { return &XRect{x, y, w, h} }
[ "func", "New", "(", "x", ",", "y", ",", "w", ",", "h", "int", ")", "*", "XRect", "{", "return", "&", "XRect", "{", "x", ",", "y", ",", "w", ",", "h", "}", "\n", "}" ]
// Provide the ability to construct an XRect.
[ "Provide", "the", "ability", "to", "construct", "an", "XRect", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xrect/xrect.go#L34-L36
124,629
BurntSushi/xgbutil
xrect/xrect.go
Pieces
func (r *XRect) Pieces() (int, int, int, int) { return r.X(), r.Y(), r.Width(), r.Height() }
go
func (r *XRect) Pieces() (int, int, int, int) { return r.X(), r.Y(), r.Width(), r.Height() }
[ "func", "(", "r", "*", "XRect", ")", "Pieces", "(", ")", "(", "int", ",", "int", ",", "int", ",", "int", ")", "{", "return", "r", ".", "X", "(", ")", ",", "r", ".", "Y", "(", ")", ",", "r", ".", "Width", "(", ")", ",", "r", ".", "Height...
// Pieces just returns a four-tuple of x, y, width and height
[ "Pieces", "just", "returns", "a", "four", "-", "tuple", "of", "x", "y", "width", "and", "height" ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xrect/xrect.go#L76-L78
124,630
BurntSushi/xgbutil
xrect/xrect.go
Subtract
func Subtract(r1 Rect, r2 Rect) []Rect { r1x1, r1y1, r1w, r1h := r1.Pieces() r2x1, r2y1, r2w, r2h := r2.Pieces() r1x2, r1y2 := r1x1+r1w, r1y1+r1h r2x2, r2y2 := r2x1+r2w, r2y1+r2h // No intersection; return r1. if r2x1 >= r1x2 || r1x1 >= r2x2 || r2y1 >= r1y2 || r1y1 >= r2y2 { return []Rect{New(r1x1, r1y1, r1w,...
go
func Subtract(r1 Rect, r2 Rect) []Rect { r1x1, r1y1, r1w, r1h := r1.Pieces() r2x1, r2y1, r2w, r2h := r2.Pieces() r1x2, r1y2 := r1x1+r1w, r1y1+r1h r2x2, r2y2 := r2x1+r2w, r2y1+r2h // No intersection; return r1. if r2x1 >= r1x2 || r1x1 >= r2x2 || r2y1 >= r1y2 || r1y1 >= r2y2 { return []Rect{New(r1x1, r1y1, r1w,...
[ "func", "Subtract", "(", "r1", "Rect", ",", "r2", "Rect", ")", "[", "]", "Rect", "{", "r1x1", ",", "r1y1", ",", "r1w", ",", "r1h", ":=", "r1", ".", "Pieces", "(", ")", "\n", "r2x1", ",", "r2y1", ",", "r2w", ",", "r2h", ":=", "r2", ".", "Piece...
// Subtract subtracts r2 from r1 and returns the result as a // new slice of Rects. // Basically, rectangle subtraction works by cutting r2 out of r1, and returning // the resulting rectangles. // If r1 does not overlap r2, then only one rectangle is returned and is // equivalent to r1. // If r2 covers r1, then no rect...
[ "Subtract", "subtracts", "r2", "from", "r1", "and", "returns", "the", "result", "as", "a", "new", "slice", "of", "Rects", ".", "Basically", "rectangle", "subtraction", "works", "by", "cutting", "r2", "out", "of", "r1", "and", "returning", "the", "resulting",...
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xrect/xrect.go#L95-L135
124,631
BurntSushi/xgbutil
xrect/xrect.go
IntersectArea
func IntersectArea(r1 Rect, r2 Rect) int { x1, y1, w1, h1 := RectPieces(r1) x2, y2, w2, h2 := RectPieces(r2) if x2 < x1+w1 && x2+w2 > x1 && y2 < y1+h1 && y2+h2 > y1 { iw := min(x1+w1-1, x2+w2-1) - max(x1, x2) + 1 ih := min(y1+h1-1, y2+h2-1) - max(y1, y2) + 1 return iw * ih } return 0 }
go
func IntersectArea(r1 Rect, r2 Rect) int { x1, y1, w1, h1 := RectPieces(r1) x2, y2, w2, h2 := RectPieces(r2) if x2 < x1+w1 && x2+w2 > x1 && y2 < y1+h1 && y2+h2 > y1 { iw := min(x1+w1-1, x2+w2-1) - max(x1, x2) + 1 ih := min(y1+h1-1, y2+h2-1) - max(y1, y2) + 1 return iw * ih } return 0 }
[ "func", "IntersectArea", "(", "r1", "Rect", ",", "r2", "Rect", ")", "int", "{", "x1", ",", "y1", ",", "w1", ",", "h1", ":=", "RectPieces", "(", "r1", ")", "\n", "x2", ",", "y2", ",", "w2", ",", "h2", ":=", "RectPieces", "(", "r2", ")", "\n", ...
// IntersectArea takes two rectangles satisfying the Rect interface and // returns the area of their intersection. If there is no intersection, return // 0 area.
[ "IntersectArea", "takes", "two", "rectangles", "satisfying", "the", "Rect", "interface", "and", "returns", "the", "area", "of", "their", "intersection", ".", "If", "there", "is", "no", "intersection", "return", "0", "area", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xrect/xrect.go#L140-L150
124,632
BurntSushi/xgbutil
xrect/xrect.go
xInRect
func xInRect(xtest uint, rect Rect) bool { x, _, w, _ := RectPieces(rect) return int(xtest) >= x && int(xtest) < (x+w) }
go
func xInRect(xtest uint, rect Rect) bool { x, _, w, _ := RectPieces(rect) return int(xtest) >= x && int(xtest) < (x+w) }
[ "func", "xInRect", "(", "xtest", "uint", ",", "rect", "Rect", ")", "bool", "{", "x", ",", "_", ",", "w", ",", "_", ":=", "RectPieces", "(", "rect", ")", "\n", "return", "int", "(", "xtest", ")", ">=", "x", "&&", "int", "(", "xtest", ")", "<", ...
// xInRect is whether a particular x-coordinate is vertically constrained by // a rectangle.
[ "xInRect", "is", "whether", "a", "particular", "x", "-", "coordinate", "is", "vertically", "constrained", "by", "a", "rectangle", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xrect/xrect.go#L258-L261
124,633
BurntSushi/xgbutil
xrect/xrect.go
yInRect
func yInRect(ytest uint, rect Rect) bool { _, y, _, h := RectPieces(rect) return int(ytest) >= y && int(ytest) < (y+h) }
go
func yInRect(ytest uint, rect Rect) bool { _, y, _, h := RectPieces(rect) return int(ytest) >= y && int(ytest) < (y+h) }
[ "func", "yInRect", "(", "ytest", "uint", ",", "rect", "Rect", ")", "bool", "{", "_", ",", "y", ",", "_", ",", "h", ":=", "RectPieces", "(", "rect", ")", "\n", "return", "int", "(", "ytest", ")", ">=", "y", "&&", "int", "(", "ytest", ")", "<", ...
// yInRect is whether a particular y-coordinate is horizontally constrained by // a rectangle.
[ "yInRect", "is", "whether", "a", "particular", "y", "-", "coordinate", "is", "horizontally", "constrained", "by", "a", "rectangle", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xrect/xrect.go#L265-L268
124,634
BurntSushi/xgbutil
_examples/multiple-source-event-loop/main.go
otherSource
func otherSource() chan int { c := make(chan int, 0) go func() { defer close(c) i := 1 for { c <- i i++ time.Sleep(time.Second) } }() return c }
go
func otherSource() chan int { c := make(chan int, 0) go func() { defer close(c) i := 1 for { c <- i i++ time.Sleep(time.Second) } }() return c }
[ "func", "otherSource", "(", ")", "chan", "int", "{", "c", ":=", "make", "(", "chan", "int", ",", "0", ")", "\n", "go", "func", "(", ")", "{", "defer", "close", "(", "c", ")", "\n\n", "i", ":=", "1", "\n", "for", "{", "c", "<-", "i", "\n", "...
// otherSource serves as a placeholder from some other source of user input.
[ "otherSource", "serves", "as", "a", "placeholder", "from", "some", "other", "source", "of", "user", "input", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/_examples/multiple-source-event-loop/main.go#L21-L34
124,635
BurntSushi/xgbutil
_examples/pointer-painting/main.go
drawGopher
func drawGopher(canvas *xgraphics.Image, gopher image.Image, win *xwindow.Window, x, y int) { // Find the rectangle of the canvas where we're going to draw the gopher. gopherRect := midRect(x, y, gopherWidth, gopherHeight, width, height) // If the rectangle contains no pixels, don't draw anything. if gopherRect....
go
func drawGopher(canvas *xgraphics.Image, gopher image.Image, win *xwindow.Window, x, y int) { // Find the rectangle of the canvas where we're going to draw the gopher. gopherRect := midRect(x, y, gopherWidth, gopherHeight, width, height) // If the rectangle contains no pixels, don't draw anything. if gopherRect....
[ "func", "drawGopher", "(", "canvas", "*", "xgraphics", ".", "Image", ",", "gopher", "image", ".", "Image", ",", "win", "*", "xwindow", ".", "Window", ",", "x", ",", "y", "int", ")", "{", "// Find the rectangle of the canvas where we're going to draw the gopher.", ...
// drawGopher draws the gopher image to the canvas.
[ "drawGopher", "draws", "the", "gopher", "image", "to", "the", "canvas", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/_examples/pointer-painting/main.go#L93-L128
124,636
BurntSushi/xgbutil
_examples/pointer-painting/main.go
clearCanvas
func clearCanvas(canvas *xgraphics.Image, win *xwindow.Window) { log.Println("Clearing canvas...") canvas.For(func(x, y int) xgraphics.BGRA { return bg }) canvas.XDraw() canvas.XPaint(win.Id) }
go
func clearCanvas(canvas *xgraphics.Image, win *xwindow.Window) { log.Println("Clearing canvas...") canvas.For(func(x, y int) xgraphics.BGRA { return bg }) canvas.XDraw() canvas.XPaint(win.Id) }
[ "func", "clearCanvas", "(", "canvas", "*", "xgraphics", ".", "Image", ",", "win", "*", "xwindow", ".", "Window", ")", "{", "log", ".", "Println", "(", "\"", "\"", ")", "\n", "canvas", ".", "For", "(", "func", "(", "x", ",", "y", "int", ")", "xgra...
// clearCanvas erases all your pencil marks.
[ "clearCanvas", "erases", "all", "your", "pencil", "marks", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/_examples/pointer-painting/main.go#L131-L139
124,637
BurntSushi/xgbutil
keybind/encoding.go
ModifierString
func ModifierString(mods uint16) string { modStrs := make([]string, 0, 3) for i, mod := range Modifiers { if mod&mods > 0 && len(NiceModifiers[i]) > 0 { modStrs = append(modStrs, NiceModifiers[i]) } } return strings.Join(modStrs, "-") }
go
func ModifierString(mods uint16) string { modStrs := make([]string, 0, 3) for i, mod := range Modifiers { if mod&mods > 0 && len(NiceModifiers[i]) > 0 { modStrs = append(modStrs, NiceModifiers[i]) } } return strings.Join(modStrs, "-") }
[ "func", "ModifierString", "(", "mods", "uint16", ")", "string", "{", "modStrs", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "3", ")", "\n", "for", "i", ",", "mod", ":=", "range", "Modifiers", "{", "if", "mod", "&", "mods", ">", "0", "&&...
// ModifierString takes in a keyboard state and returns a string of all // modifiers in the state.
[ "ModifierString", "takes", "in", "a", "keyboard", "state", "and", "returns", "a", "string", "of", "all", "modifiers", "in", "the", "state", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/keybind/encoding.go#L62-L70
124,638
BurntSushi/xgbutil
_examples/xgraphics-compat/main.go
checkCompatibility
func checkCompatibility(X *xgbutil.XUtil) { s := X.Setup() scrn := X.Screen() failed := false if s.ImageByteOrder != xproto.ImageOrderLSBFirst { log.Printf("Your X server uses MSB image byte order. Unfortunately, " + "xgraphics currently requires LSB image byte order. You may see " + "weird things. Please ...
go
func checkCompatibility(X *xgbutil.XUtil) { s := X.Setup() scrn := X.Screen() failed := false if s.ImageByteOrder != xproto.ImageOrderLSBFirst { log.Printf("Your X server uses MSB image byte order. Unfortunately, " + "xgraphics currently requires LSB image byte order. You may see " + "weird things. Please ...
[ "func", "checkCompatibility", "(", "X", "*", "xgbutil", ".", "XUtil", ")", "{", "s", ":=", "X", ".", "Setup", "(", ")", "\n", "scrn", ":=", "X", ".", "Screen", "(", ")", "\n", "failed", ":=", "false", "\n\n", "if", "s", ".", "ImageByteOrder", "!=",...
// checkCompatibility reads info in the X setup info struct and emits // messages to stderr if they don't correspond to values that xgraphics // supports. // The idea is that in the future, we'll support more values. // The real reason for checkCompatibility is to make debugging easier. Without // it, if the values wer...
[ "checkCompatibility", "reads", "info", "in", "the", "X", "setup", "info", "struct", "and", "emits", "messages", "to", "stderr", "if", "they", "don", "t", "correspond", "to", "values", "that", "xgraphics", "supports", ".", "The", "idea", "is", "that", "in", ...
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/_examples/xgraphics-compat/main.go#L29-L84
124,639
BurntSushi/xgbutil
mousebind/xutil.go
mouseKeys
func mouseKeys(xu *xgbutil.XUtil) []xgbutil.MouseKey { xu.MousebindsLck.RLock() defer xu.MousebindsLck.RUnlock() keys := make([]xgbutil.MouseKey, len(xu.Mousebinds)) i := 0 for key, _ := range xu.Mousebinds { keys[i] = key i++ } return keys }
go
func mouseKeys(xu *xgbutil.XUtil) []xgbutil.MouseKey { xu.MousebindsLck.RLock() defer xu.MousebindsLck.RUnlock() keys := make([]xgbutil.MouseKey, len(xu.Mousebinds)) i := 0 for key, _ := range xu.Mousebinds { keys[i] = key i++ } return keys }
[ "func", "mouseKeys", "(", "xu", "*", "xgbutil", ".", "XUtil", ")", "[", "]", "xgbutil", ".", "MouseKey", "{", "xu", ".", "MousebindsLck", ".", "RLock", "(", ")", "\n", "defer", "xu", ".", "MousebindsLck", ".", "RUnlock", "(", ")", "\n\n", "keys", ":=...
// mouseKeys returns a copy of all the keys in the 'Mousebinds' map.
[ "mouseKeys", "returns", "a", "copy", "of", "all", "the", "keys", "in", "the", "Mousebinds", "map", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/mousebind/xutil.go#L39-L50
124,640
BurntSushi/xgbutil
mousebind/xutil.go
mouseCallbacks
func mouseCallbacks(xu *xgbutil.XUtil, key xgbutil.MouseKey) []xgbutil.CallbackMouse { xu.MousebindsLck.RLock() defer xu.MousebindsLck.RUnlock() cbs := make([]xgbutil.CallbackMouse, len(xu.Mousebinds[key])) copy(cbs, xu.Mousebinds[key]) return cbs }
go
func mouseCallbacks(xu *xgbutil.XUtil, key xgbutil.MouseKey) []xgbutil.CallbackMouse { xu.MousebindsLck.RLock() defer xu.MousebindsLck.RUnlock() cbs := make([]xgbutil.CallbackMouse, len(xu.Mousebinds[key])) copy(cbs, xu.Mousebinds[key]) return cbs }
[ "func", "mouseCallbacks", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "key", "xgbutil", ".", "MouseKey", ")", "[", "]", "xgbutil", ".", "CallbackMouse", "{", "xu", ".", "MousebindsLck", ".", "RLock", "(", ")", "\n", "defer", "xu", ".", "MousebindsLck",...
// mouseBindCallbacks returns a slice of callbacks for a particular key.
[ "mouseBindCallbacks", "returns", "a", "slice", "of", "callbacks", "for", "a", "particular", "key", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/mousebind/xutil.go#L53-L62
124,641
BurntSushi/xgbutil
mousebind/xutil.go
mouseDragStepSet
func mouseDragStepSet(xu *xgbutil.XUtil, f xgbutil.MouseDragFun) { xu.MouseDragStepFun = f }
go
func mouseDragStepSet(xu *xgbutil.XUtil, f xgbutil.MouseDragFun) { xu.MouseDragStepFun = f }
[ "func", "mouseDragStepSet", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "f", "xgbutil", ".", "MouseDragFun", ")", "{", "xu", ".", "MouseDragStepFun", "=", "f", "\n", "}" ]
// mouseDragStepSet sets the function associated with the step of a drag.
[ "mouseDragStepSet", "sets", "the", "function", "associated", "with", "the", "step", "of", "a", "drag", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/mousebind/xutil.go#L140-L142
124,642
BurntSushi/xgbutil
mousebind/xutil.go
mouseDragEndSet
func mouseDragEndSet(xu *xgbutil.XUtil, f xgbutil.MouseDragFun) { xu.MouseDragEndFun = f }
go
func mouseDragEndSet(xu *xgbutil.XUtil, f xgbutil.MouseDragFun) { xu.MouseDragEndFun = f }
[ "func", "mouseDragEndSet", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "f", "xgbutil", ".", "MouseDragFun", ")", "{", "xu", ".", "MouseDragEndFun", "=", "f", "\n", "}" ]
// mouseDragEndSet sets the function associated with the end of a drag.
[ "mouseDragEndSet", "sets", "the", "function", "associated", "with", "the", "end", "of", "a", "drag", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/mousebind/xutil.go#L151-L153
124,643
BurntSushi/xgbutil
_examples/compress-events/main.go
newWindow
func newWindow(X *xgbutil.XUtil, color uint32) *xwindow.Window { win, err := xwindow.Generate(X) if err != nil { log.Fatal(err) } err = win.CreateChecked(X.RootWin(), 0, 0, 400, 400, xproto.CwBackPixel|xproto.CwEventMask, color, xproto.EventMaskPointerMotion) if err != nil { log.Fatal(err) } win.Map() ...
go
func newWindow(X *xgbutil.XUtil, color uint32) *xwindow.Window { win, err := xwindow.Generate(X) if err != nil { log.Fatal(err) } err = win.CreateChecked(X.RootWin(), 0, 0, 400, 400, xproto.CwBackPixel|xproto.CwEventMask, color, xproto.EventMaskPointerMotion) if err != nil { log.Fatal(err) } win.Map() ...
[ "func", "newWindow", "(", "X", "*", "xgbutil", ".", "XUtil", ",", "color", "uint32", ")", "*", "xwindow", ".", "Window", "{", "win", ",", "err", ":=", "xwindow", ".", "Generate", "(", "X", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fa...
// newWindow creates a new window that listens to MotionNotify events with // the given backgroundcolor.
[ "newWindow", "creates", "a", "new", "window", "that", "listens", "to", "MotionNotify", "events", "with", "the", "given", "backgroundcolor", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/_examples/compress-events/main.go#L65-L80
124,644
BurntSushi/xgbutil
mousebind/mousebind.go
Initialize
func Initialize(xu *xgbutil.XUtil) { xevent.MotionNotifyFun(dragStep).Connect(xu, xu.Dummy()) xevent.ButtonReleaseFun(DragEnd).Connect(xu, xu.Dummy()) }
go
func Initialize(xu *xgbutil.XUtil) { xevent.MotionNotifyFun(dragStep).Connect(xu, xu.Dummy()) xevent.ButtonReleaseFun(DragEnd).Connect(xu, xu.Dummy()) }
[ "func", "Initialize", "(", "xu", "*", "xgbutil", ".", "XUtil", ")", "{", "xevent", ".", "MotionNotifyFun", "(", "dragStep", ")", ".", "Connect", "(", "xu", ",", "xu", ".", "Dummy", "(", ")", ")", "\n", "xevent", ".", "ButtonReleaseFun", "(", "DragEnd",...
// Initialize attaches the appropriate callbacks to make mouse bindings easier. // i.e., prep the dummy window to handle mouse dragging events
[ "Initialize", "attaches", "the", "appropriate", "callbacks", "to", "make", "mouse", "bindings", "easier", ".", "i", ".", "e", ".", "prep", "the", "dummy", "window", "to", "handle", "mouse", "dragging", "events" ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/mousebind/mousebind.go#L29-L32
124,645
BurntSushi/xgbutil
mousebind/mousebind.go
Ungrab
func Ungrab(xu *xgbutil.XUtil, win xproto.Window, mods uint16, button xproto.Button) { for _, m := range xevent.IgnoreMods { xproto.UngrabButtonChecked(xu.Conn(), byte(button), win, mods|m).Check() } }
go
func Ungrab(xu *xgbutil.XUtil, win xproto.Window, mods uint16, button xproto.Button) { for _, m := range xevent.IgnoreMods { xproto.UngrabButtonChecked(xu.Conn(), byte(button), win, mods|m).Check() } }
[ "func", "Ungrab", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "win", "xproto", ".", "Window", ",", "mods", "uint16", ",", "button", "xproto", ".", "Button", ")", "{", "for", "_", ",", "m", ":=", "range", "xevent", ".", "IgnoreMods", "{", "xproto", ...
// Ungrab undoes Grab. It will handle all combinations of modifiers found // in xevent.IgnoreMods.
[ "Ungrab", "undoes", "Grab", ".", "It", "will", "handle", "all", "combinations", "of", "modifiers", "found", "in", "xevent", ".", "IgnoreMods", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/mousebind/mousebind.go#L141-L147
124,646
BurntSushi/xgbutil
xgraphics/image.go
Destroy
func (im *Image) Destroy() { if im.Pixmap != 0 { xproto.FreePixmap(im.X.Conn(), im.Pixmap) im.Pixmap = 0 } }
go
func (im *Image) Destroy() { if im.Pixmap != 0 { xproto.FreePixmap(im.X.Conn(), im.Pixmap) im.Pixmap = 0 } }
[ "func", "(", "im", "*", "Image", ")", "Destroy", "(", ")", "{", "if", "im", ".", "Pixmap", "!=", "0", "{", "xproto", ".", "FreePixmap", "(", "im", ".", "X", ".", "Conn", "(", ")", ",", "im", ".", "Pixmap", ")", "\n", "im", ".", "Pixmap", "=",...
// Destroy frees the pixmap resource being used by this image. // It should be called whenever the image will no longer be drawn or painted.
[ "Destroy", "frees", "the", "pixmap", "resource", "being", "used", "by", "this", "image", ".", "It", "should", "be", "called", "whenever", "the", "image", "will", "no", "longer", "be", "drawn", "or", "painted", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xgraphics/image.go#L100-L105
124,647
BurntSushi/xgbutil
xgraphics/image.go
WritePng
func (im *Image) WritePng(w io.Writer) error { return png.Encode(w, im) }
go
func (im *Image) WritePng(w io.Writer) error { return png.Encode(w, im) }
[ "func", "(", "im", "*", "Image", ")", "WritePng", "(", "w", "io", ".", "Writer", ")", "error", "{", "return", "png", ".", "Encode", "(", "w", ",", "im", ")", "\n", "}" ]
// WritePng encodes the image to w as a png.
[ "WritePng", "encodes", "the", "image", "to", "w", "as", "a", "png", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xgraphics/image.go#L121-L123
124,648
BurntSushi/xgbutil
xgraphics/image.go
SavePng
func (im *Image) SavePng(name string) error { file, err := os.Create(name) if err != nil { return err } return im.WritePng(file) }
go
func (im *Image) SavePng(name string) error { file, err := os.Create(name) if err != nil { return err } return im.WritePng(file) }
[ "func", "(", "im", "*", "Image", ")", "SavePng", "(", "name", "string", ")", "error", "{", "file", ",", "err", ":=", "os", ".", "Create", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "im", "...
// SavePng writes the Image to a file with name as a png.
[ "SavePng", "writes", "the", "Image", "to", "a", "file", "with", "name", "as", "a", "png", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xgraphics/image.go#L126-L132
124,649
BurntSushi/xgbutil
xgraphics/image.go
At
func (im *Image) At(x, y int) color.Color { if !(image.Point{x, y}.In(im.Rect)) { return BGRA{} } i := im.PixOffset(x, y) return BGRA{ B: im.Pix[i], G: im.Pix[i+1], R: im.Pix[i+2], A: im.Pix[i+3], } }
go
func (im *Image) At(x, y int) color.Color { if !(image.Point{x, y}.In(im.Rect)) { return BGRA{} } i := im.PixOffset(x, y) return BGRA{ B: im.Pix[i], G: im.Pix[i+1], R: im.Pix[i+2], A: im.Pix[i+3], } }
[ "func", "(", "im", "*", "Image", ")", "At", "(", "x", ",", "y", "int", ")", "color", ".", "Color", "{", "if", "!", "(", "image", ".", "Point", "{", "x", ",", "y", "}", ".", "In", "(", "im", ".", "Rect", ")", ")", "{", "return", "BGRA", "{...
// At returns the color at the specified pixel.
[ "At", "returns", "the", "color", "at", "the", "specified", "pixel", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xgraphics/image.go#L145-L156
124,650
BurntSushi/xgbutil
xgraphics/image.go
SetBGRA
func (im *Image) SetBGRA(x, y int, c BGRA) { if !(image.Point{x, y}.In(im.Rect)) { return } i := im.PixOffset(x, y) im.Pix[i] = c.B im.Pix[i+1] = c.G im.Pix[i+2] = c.R im.Pix[i+3] = c.A }
go
func (im *Image) SetBGRA(x, y int, c BGRA) { if !(image.Point{x, y}.In(im.Rect)) { return } i := im.PixOffset(x, y) im.Pix[i] = c.B im.Pix[i+1] = c.G im.Pix[i+2] = c.R im.Pix[i+3] = c.A }
[ "func", "(", "im", "*", "Image", ")", "SetBGRA", "(", "x", ",", "y", "int", ",", "c", "BGRA", ")", "{", "if", "!", "(", "image", ".", "Point", "{", "x", ",", "y", "}", ".", "In", "(", "im", ".", "Rect", ")", ")", "{", "return", "\n", "}",...
// SetBGRA is like set, but without the type assertion.
[ "SetBGRA", "is", "like", "set", "but", "without", "the", "type", "assertion", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xgraphics/image.go#L174-L184
124,651
BurntSushi/xgbutil
xgraphics/image.go
SubImage
func (im *Image) SubImage(r image.Rectangle) image.Image { r = r.Intersect(im.Rect) if r.Empty() { return nil } i := im.PixOffset(r.Min.X, r.Min.Y) return &Image{ X: im.X, Pixmap: im.Pixmap, Pix: im.Pix[i:], Stride: im.Stride, Rect: r, Subimg: true, } }
go
func (im *Image) SubImage(r image.Rectangle) image.Image { r = r.Intersect(im.Rect) if r.Empty() { return nil } i := im.PixOffset(r.Min.X, r.Min.Y) return &Image{ X: im.X, Pixmap: im.Pixmap, Pix: im.Pix[i:], Stride: im.Stride, Rect: r, Subimg: true, } }
[ "func", "(", "im", "*", "Image", ")", "SubImage", "(", "r", "image", ".", "Rectangle", ")", "image", ".", "Image", "{", "r", "=", "r", ".", "Intersect", "(", "im", ".", "Rect", ")", "\n", "if", "r", ".", "Empty", "(", ")", "{", "return", "nil",...
// SubImage provides a sub image of Image without copying image data. // N.B. The standard library defines a similar function, but returns an // image.Image. Here, we return xgraphics.Image so that we can use the extra // methods defined by xgraphics on it. // // This method is cheap to call. It should be used to updat...
[ "SubImage", "provides", "a", "sub", "image", "of", "Image", "without", "copying", "image", "data", ".", "N", ".", "B", ".", "The", "standard", "library", "defines", "a", "similar", "function", "but", "returns", "an", "image", ".", "Image", ".", "Here", "...
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xgraphics/image.go#L224-L239
124,652
BurntSushi/xgbutil
xgraphics/image.go
Window
func (im *Image) Window(parent xproto.Window) *xwindow.Window { win := xwindow.Must(xwindow.Create(im.X, parent)) win.Resize(im.Bounds().Dx(), im.Bounds().Dy()) im.XSurfaceSet(win.Id) im.XDraw() im.XPaint(win.Id) im.Destroy() return win }
go
func (im *Image) Window(parent xproto.Window) *xwindow.Window { win := xwindow.Must(xwindow.Create(im.X, parent)) win.Resize(im.Bounds().Dx(), im.Bounds().Dy()) im.XSurfaceSet(win.Id) im.XDraw() im.XPaint(win.Id) im.Destroy() return win }
[ "func", "(", "im", "*", "Image", ")", "Window", "(", "parent", "xproto", ".", "Window", ")", "*", "xwindow", ".", "Window", "{", "win", ":=", "xwindow", ".", "Must", "(", "xwindow", ".", "Create", "(", "im", ".", "X", ",", "parent", ")", ")", "\n...
// Window is a convenience function for painting the provided // Image value to a new window, destroying the pixmap created by that image, // and returning the window value. // The window is sized to the dimensions of the image.
[ "Window", "is", "a", "convenience", "function", "for", "painting", "the", "provided", "Image", "value", "to", "a", "new", "window", "destroying", "the", "pixmap", "created", "by", "that", "image", "and", "returning", "the", "window", "value", ".", "The", "wi...
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xgraphics/image.go#L251-L261
124,653
BurntSushi/xgbutil
xgraphics/image.go
RGBA
func (c BGRA) RGBA() (r, g, b, a uint32) { r = uint32(c.R) r |= r << 8 g = uint32(c.G) g |= g << 8 b = uint32(c.B) b |= b << 8 a = uint32(c.A) a |= a << 8 return }
go
func (c BGRA) RGBA() (r, g, b, a uint32) { r = uint32(c.R) r |= r << 8 g = uint32(c.G) g |= g << 8 b = uint32(c.B) b |= b << 8 a = uint32(c.A) a |= a << 8 return }
[ "func", "(", "c", "BGRA", ")", "RGBA", "(", ")", "(", "r", ",", "g", ",", "b", ",", "a", "uint32", ")", "{", "r", "=", "uint32", "(", "c", ".", "R", ")", "\n", "r", "|=", "r", "<<", "8", "\n\n", "g", "=", "uint32", "(", "c", ".", "G", ...
// RGBA satisfies the color.Color interface.
[ "RGBA", "satisfies", "the", "color", ".", "Color", "interface", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xgraphics/image.go#L270-L284
124,654
BurntSushi/xgbutil
xgraphics/image.go
bgraModel
func bgraModel(c color.Color) color.Color { if _, ok := c.(BGRA); ok { return c } r, g, b, a := c.RGBA() return BGRA{ B: uint8(b >> 8), G: uint8(g >> 8), R: uint8(r >> 8), A: uint8(a >> 8), } }
go
func bgraModel(c color.Color) color.Color { if _, ok := c.(BGRA); ok { return c } r, g, b, a := c.RGBA() return BGRA{ B: uint8(b >> 8), G: uint8(g >> 8), R: uint8(r >> 8), A: uint8(a >> 8), } }
[ "func", "bgraModel", "(", "c", "color", ".", "Color", ")", "color", ".", "Color", "{", "if", "_", ",", "ok", ":=", "c", ".", "(", "BGRA", ")", ";", "ok", "{", "return", "c", "\n", "}", "\n\n", "r", ",", "g", ",", "b", ",", "a", ":=", "c", ...
// bgraModel converts from any color to a BGRA color type.
[ "bgraModel", "converts", "from", "any", "color", "to", "a", "BGRA", "color", "type", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xgraphics/image.go#L287-L299
124,655
BurntSushi/xgbutil
keybind/xutil.go
addKeyString
func addKeyString(xu *xgbutil.XUtil, callback xgbutil.CallbackKey, evtype int, win xproto.Window, keyStr string, grab bool) { xu.KeybindsLck.Lock() defer xu.KeybindsLck.Unlock() k := xgbutil.KeyString{ Str: keyStr, Callback: callback, Evtype: evtype, Win: win, Grab: grab, } xu.Keystrin...
go
func addKeyString(xu *xgbutil.XUtil, callback xgbutil.CallbackKey, evtype int, win xproto.Window, keyStr string, grab bool) { xu.KeybindsLck.Lock() defer xu.KeybindsLck.Unlock() k := xgbutil.KeyString{ Str: keyStr, Callback: callback, Evtype: evtype, Win: win, Grab: grab, } xu.Keystrin...
[ "func", "addKeyString", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "callback", "xgbutil", ".", "CallbackKey", ",", "evtype", "int", ",", "win", "xproto", ".", "Window", ",", "keyStr", "string", ",", "grab", "bool", ")", "{", "xu", ".", "KeybindsLck", ...
// addKeyString adds a new key binding string to XUtil.Keystrings. // The invariant is that each key string appears once and only once.
[ "addKeyString", "adds", "a", "new", "key", "binding", "string", "to", "XUtil", ".", "Keystrings", ".", "The", "invariant", "is", "that", "each", "key", "string", "appears", "once", "and", "only", "once", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/keybind/xutil.go#L41-L55
124,656
BurntSushi/xgbutil
keybind/xutil.go
keyKeys
func keyKeys(xu *xgbutil.XUtil) []xgbutil.KeyKey { xu.KeybindsLck.RLock() defer xu.KeybindsLck.RUnlock() keys := make([]xgbutil.KeyKey, len(xu.Keybinds)) i := 0 for key, _ := range xu.Keybinds { keys[i] = key i++ } return keys }
go
func keyKeys(xu *xgbutil.XUtil) []xgbutil.KeyKey { xu.KeybindsLck.RLock() defer xu.KeybindsLck.RUnlock() keys := make([]xgbutil.KeyKey, len(xu.Keybinds)) i := 0 for key, _ := range xu.Keybinds { keys[i] = key i++ } return keys }
[ "func", "keyKeys", "(", "xu", "*", "xgbutil", ".", "XUtil", ")", "[", "]", "xgbutil", ".", "KeyKey", "{", "xu", ".", "KeybindsLck", ".", "RLock", "(", ")", "\n", "defer", "xu", ".", "KeybindsLck", ".", "RUnlock", "(", ")", "\n\n", "keys", ":=", "ma...
// keyBindKeys returns a copy of all the keys in the 'keybinds' map.
[ "keyBindKeys", "returns", "a", "copy", "of", "all", "the", "keys", "in", "the", "keybinds", "map", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/keybind/xutil.go#L58-L69
124,657
BurntSushi/xgbutil
keybind/xutil.go
keyCallbacks
func keyCallbacks(xu *xgbutil.XUtil, key xgbutil.KeyKey) []xgbutil.CallbackKey { xu.KeybindsLck.RLock() defer xu.KeybindsLck.RUnlock() cbs := make([]xgbutil.CallbackKey, len(xu.Keybinds[key])) copy(cbs, xu.Keybinds[key]) return cbs }
go
func keyCallbacks(xu *xgbutil.XUtil, key xgbutil.KeyKey) []xgbutil.CallbackKey { xu.KeybindsLck.RLock() defer xu.KeybindsLck.RUnlock() cbs := make([]xgbutil.CallbackKey, len(xu.Keybinds[key])) copy(cbs, xu.Keybinds[key]) return cbs }
[ "func", "keyCallbacks", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "key", "xgbutil", ".", "KeyKey", ")", "[", "]", "xgbutil", ".", "CallbackKey", "{", "xu", ".", "KeybindsLck", ".", "RLock", "(", ")", "\n", "defer", "xu", ".", "KeybindsLck", ".", ...
// keyBindCallbacks returns a slice of callbacks for a particular key.
[ "keyBindCallbacks", "returns", "a", "slice", "of", "callbacks", "for", "a", "particular", "key", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/keybind/xutil.go#L84-L93
124,658
BurntSushi/xgbutil
keybind/xutil.go
connectedKeyBind
func connectedKeyBind(xu *xgbutil.XUtil, evtype int, win xproto.Window) bool { xu.KeybindsLck.RLock() defer xu.KeybindsLck.RUnlock() // Since we can't create a full key, loop through all key binds // and check if evtype and window match. for key, _ := range xu.Keybinds { if key.Evtype == evtype && key.Win == wi...
go
func connectedKeyBind(xu *xgbutil.XUtil, evtype int, win xproto.Window) bool { xu.KeybindsLck.RLock() defer xu.KeybindsLck.RUnlock() // Since we can't create a full key, loop through all key binds // and check if evtype and window match. for key, _ := range xu.Keybinds { if key.Evtype == evtype && key.Win == wi...
[ "func", "connectedKeyBind", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "evtype", "int", ",", "win", "xproto", ".", "Window", ")", "bool", "{", "xu", ".", "KeybindsLck", ".", "RLock", "(", ")", "\n", "defer", "xu", ".", "KeybindsLck", ".", "RUnlock",...
// ConnectedKeyBind checks to see if there are any key binds for a particular // event type already in play.
[ "ConnectedKeyBind", "checks", "to", "see", "if", "there", "are", "any", "key", "binds", "for", "a", "particular", "event", "type", "already", "in", "play", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/keybind/xutil.go#L97-L109
124,659
BurntSushi/xgbutil
keybind/keybind.go
Initialize
func Initialize(xu *xgbutil.XUtil) { // Listen to mapping notify events xevent.MappingNotifyFun(updateMaps).Connect(xu, xevent.NoWindow) // Give us an initial mapping state... keyMap, modMap := MapsGet(xu) KeyMapSet(xu, keyMap) ModMapSet(xu, modMap) }
go
func Initialize(xu *xgbutil.XUtil) { // Listen to mapping notify events xevent.MappingNotifyFun(updateMaps).Connect(xu, xevent.NoWindow) // Give us an initial mapping state... keyMap, modMap := MapsGet(xu) KeyMapSet(xu, keyMap) ModMapSet(xu, modMap) }
[ "func", "Initialize", "(", "xu", "*", "xgbutil", ".", "XUtil", ")", "{", "// Listen to mapping notify events", "xevent", ".", "MappingNotifyFun", "(", "updateMaps", ")", ".", "Connect", "(", "xu", ",", "xevent", ".", "NoWindow", ")", "\n\n", "// Give us an initi...
// Initialize attaches the appropriate callbacks to make key bindings easier. // i.e., update state of the world on a MappingNotify.
[ "Initialize", "attaches", "the", "appropriate", "callbacks", "to", "make", "key", "bindings", "easier", ".", "i", ".", "e", ".", "update", "state", "of", "the", "world", "on", "a", "MappingNotify", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/keybind/keybind.go#L28-L36
124,660
BurntSushi/xgbutil
keybind/keybind.go
minMaxKeycodeGet
func minMaxKeycodeGet(xu *xgbutil.XUtil) (xproto.Keycode, xproto.Keycode) { return xu.Setup().MinKeycode, xu.Setup().MaxKeycode }
go
func minMaxKeycodeGet(xu *xgbutil.XUtil) (xproto.Keycode, xproto.Keycode) { return xu.Setup().MinKeycode, xu.Setup().MaxKeycode }
[ "func", "minMaxKeycodeGet", "(", "xu", "*", "xgbutil", ".", "XUtil", ")", "(", "xproto", ".", "Keycode", ",", "xproto", ".", "Keycode", ")", "{", "return", "xu", ".", "Setup", "(", ")", ".", "MinKeycode", ",", "xu", ".", "Setup", "(", ")", ".", "Ma...
// minMaxKeycodeGet a simple accessor to the X setup info to return the // minimum and maximum keycodes. They are typically 8 and 255, respectively.
[ "minMaxKeycodeGet", "a", "simple", "accessor", "to", "the", "X", "setup", "info", "to", "return", "the", "minimum", "and", "maximum", "keycodes", ".", "They", "are", "typically", "8", "and", "255", "respectively", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/keybind/keybind.go#L94-L96
124,661
BurntSushi/xgbutil
keybind/keybind.go
keycodesGet
func keycodesGet(xu *xgbutil.XUtil, keysym xproto.Keysym) []xproto.Keycode { min, max := minMaxKeycodeGet(xu) keyMap := KeyMapGet(xu) if keyMap == nil { panic("keybind.Initialize must be called before using the keybind " + "package.") } var c byte var keycode xproto.Keycode keycodes := make([]xproto.Keycod...
go
func keycodesGet(xu *xgbutil.XUtil, keysym xproto.Keysym) []xproto.Keycode { min, max := minMaxKeycodeGet(xu) keyMap := KeyMapGet(xu) if keyMap == nil { panic("keybind.Initialize must be called before using the keybind " + "package.") } var c byte var keycode xproto.Keycode keycodes := make([]xproto.Keycod...
[ "func", "keycodesGet", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "keysym", "xproto", ".", "Keysym", ")", "[", "]", "xproto", ".", "Keycode", "{", "min", ",", "max", ":=", "minMaxKeycodeGet", "(", "xu", ")", "\n", "keyMap", ":=", "KeyMapGet", "(", ...
// Given a keysym, find all keycodes mapped to it in the current X environment. // keybind.Initialize MUST have been called before using this function.
[ "Given", "a", "keysym", "find", "all", "keycodes", "mapped", "to", "it", "in", "the", "current", "X", "environment", ".", "keybind", ".", "Initialize", "MUST", "have", "been", "called", "before", "using", "this", "function", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/keybind/keybind.go#L201-L224
124,662
BurntSushi/xgbutil
keybind/keybind.go
KeysymGet
func KeysymGet(xu *xgbutil.XUtil, keycode xproto.Keycode, column byte) xproto.Keysym { return KeysymGetWithMap(xu, KeyMapGet(xu), keycode, column) }
go
func KeysymGet(xu *xgbutil.XUtil, keycode xproto.Keycode, column byte) xproto.Keysym { return KeysymGetWithMap(xu, KeyMapGet(xu), keycode, column) }
[ "func", "KeysymGet", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "keycode", "xproto", ".", "Keycode", ",", "column", "byte", ")", "xproto", ".", "Keysym", "{", "return", "KeysymGetWithMap", "(", "xu", ",", "KeyMapGet", "(", "xu", ")", ",", "keycode", ...
// KeysymGet is a shortcut alias for 'KeysymGetWithMap' using the current // keymap stored in XUtil. // keybind.Initialize MUST have been called before using this function.
[ "KeysymGet", "is", "a", "shortcut", "alias", "for", "KeysymGetWithMap", "using", "the", "current", "keymap", "stored", "in", "XUtil", ".", "keybind", ".", "Initialize", "MUST", "have", "been", "called", "before", "using", "this", "function", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/keybind/keybind.go#L248-L252
124,663
BurntSushi/xgbutil
keybind/keybind.go
KeysymGetWithMap
func KeysymGetWithMap(xu *xgbutil.XUtil, keyMap *xgbutil.KeyboardMapping, keycode xproto.Keycode, column byte) xproto.Keysym { min, _ := minMaxKeycodeGet(xu) i := (int(keycode)-int(min))*int(keyMap.KeysymsPerKeycode) + int(column) return keyMap.Keysyms[i] }
go
func KeysymGetWithMap(xu *xgbutil.XUtil, keyMap *xgbutil.KeyboardMapping, keycode xproto.Keycode, column byte) xproto.Keysym { min, _ := minMaxKeycodeGet(xu) i := (int(keycode)-int(min))*int(keyMap.KeysymsPerKeycode) + int(column) return keyMap.Keysyms[i] }
[ "func", "KeysymGetWithMap", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "keyMap", "*", "xgbutil", ".", "KeyboardMapping", ",", "keycode", "xproto", ".", "Keycode", ",", "column", "byte", ")", "xproto", ".", "Keysym", "{", "min", ",", "_", ":=", "minMax...
// KeysymGetWithMap uses the given key map and finds a keysym associated // with the given keycode in the current X environment.
[ "KeysymGetWithMap", "uses", "the", "given", "key", "map", "and", "finds", "a", "keysym", "associated", "with", "the", "given", "keycode", "in", "the", "current", "X", "environment", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/keybind/keybind.go#L256-L263
124,664
BurntSushi/xgbutil
keybind/keybind.go
ModGet
func ModGet(xu *xgbutil.XUtil, keycode xproto.Keycode) uint16 { modMap := ModMapGet(xu) var i byte for i = 0; int(i) < len(modMap.Keycodes); i++ { if modMap.Keycodes[i] == keycode { return Modifiers[i/modMap.KeycodesPerModifier] } } return 0 }
go
func ModGet(xu *xgbutil.XUtil, keycode xproto.Keycode) uint16 { modMap := ModMapGet(xu) var i byte for i = 0; int(i) < len(modMap.Keycodes); i++ { if modMap.Keycodes[i] == keycode { return Modifiers[i/modMap.KeycodesPerModifier] } } return 0 }
[ "func", "ModGet", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "keycode", "xproto", ".", "Keycode", ")", "uint16", "{", "modMap", ":=", "ModMapGet", "(", "xu", ")", "\n\n", "var", "i", "byte", "\n", "for", "i", "=", "0", ";", "int", "(", "i", ")...
// ModGet finds the modifier currently associated with a given keycode. // If a modifier doesn't exist for this keycode, then 0 is returned.
[ "ModGet", "finds", "the", "modifier", "currently", "associated", "with", "a", "given", "keycode", ".", "If", "a", "modifier", "doesn", "t", "exist", "for", "this", "keycode", "then", "0", "is", "returned", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/keybind/keybind.go#L267-L277
124,665
BurntSushi/xgbutil
keybind/keybind.go
Grab
func Grab(xu *xgbutil.XUtil, win xproto.Window, mods uint16, key xproto.Keycode) { for _, m := range xevent.IgnoreMods { xproto.GrabKey(xu.Conn(), true, win, mods|m, key, xproto.GrabModeAsync, xproto.GrabModeAsync) } }
go
func Grab(xu *xgbutil.XUtil, win xproto.Window, mods uint16, key xproto.Keycode) { for _, m := range xevent.IgnoreMods { xproto.GrabKey(xu.Conn(), true, win, mods|m, key, xproto.GrabModeAsync, xproto.GrabModeAsync) } }
[ "func", "Grab", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "win", "xproto", ".", "Window", ",", "mods", "uint16", ",", "key", "xproto", ".", "Keycode", ")", "{", "for", "_", ",", "m", ":=", "range", "xevent", ".", "IgnoreMods", "{", "xproto", "....
// Grab grabs a key with mods on a particular window. // This will also grab all combinations of modifiers found in xevent.IgnoreMods.
[ "Grab", "grabs", "a", "key", "with", "mods", "on", "a", "particular", "window", ".", "This", "will", "also", "grab", "all", "combinations", "of", "modifiers", "found", "in", "xevent", ".", "IgnoreMods", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/keybind/keybind.go#L281-L288
124,666
BurntSushi/xgbutil
keybind/keybind.go
Ungrab
func Ungrab(xu *xgbutil.XUtil, win xproto.Window, mods uint16, key xproto.Keycode) { for _, m := range xevent.IgnoreMods { xproto.UngrabKeyChecked(xu.Conn(), key, win, mods|m).Check() } }
go
func Ungrab(xu *xgbutil.XUtil, win xproto.Window, mods uint16, key xproto.Keycode) { for _, m := range xevent.IgnoreMods { xproto.UngrabKeyChecked(xu.Conn(), key, win, mods|m).Check() } }
[ "func", "Ungrab", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "win", "xproto", ".", "Window", ",", "mods", "uint16", ",", "key", "xproto", ".", "Keycode", ")", "{", "for", "_", ",", "m", ":=", "range", "xevent", ".", "IgnoreMods", "{", "xproto", ...
// Ungrab undoes Grab. It will handle all combinations od modifiers found // in xevent.IgnoreMods.
[ "Ungrab", "undoes", "Grab", ".", "It", "will", "handle", "all", "combinations", "od", "modifiers", "found", "in", "xevent", ".", "IgnoreMods", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/keybind/keybind.go#L311-L317
124,667
BurntSushi/xgbutil
keybind/keybind.go
SmartGrab
func SmartGrab(xu *xgbutil.XUtil, win xproto.Window) error { err := GrabKeyboard(xu, win) if err != nil { return fmt.Errorf("SmartGrab: %s", err) } // Now redirect all key events to the dummy window to prevent races xevent.RedirectKeyEvents(xu, win) return nil }
go
func SmartGrab(xu *xgbutil.XUtil, win xproto.Window) error { err := GrabKeyboard(xu, win) if err != nil { return fmt.Errorf("SmartGrab: %s", err) } // Now redirect all key events to the dummy window to prevent races xevent.RedirectKeyEvents(xu, win) return nil }
[ "func", "SmartGrab", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "win", "xproto", ".", "Window", ")", "error", "{", "err", ":=", "GrabKeyboard", "(", "xu", ",", "win", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(",...
// SmartGrab grabs the keyboard for the given window, and redirects all // key events in the xevent main event loop to avoid races.
[ "SmartGrab", "grabs", "the", "keyboard", "for", "the", "given", "window", "and", "redirects", "all", "key", "events", "in", "the", "xevent", "main", "event", "loop", "to", "avoid", "races", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/keybind/keybind.go#L358-L368
124,668
BurntSushi/xgbutil
xinerama/xinerama.go
Less
func (hds Heads) Less(i int, j int) bool { return hds[i].X() < hds[j].X() || (hds[i].X() == hds[j].X() && hds[i].Y() < hds[j].Y()) }
go
func (hds Heads) Less(i int, j int) bool { return hds[i].X() < hds[j].X() || (hds[i].X() == hds[j].X() && hds[i].Y() < hds[j].Y()) }
[ "func", "(", "hds", "Heads", ")", "Less", "(", "i", "int", ",", "j", "int", ")", "bool", "{", "return", "hds", "[", "i", "]", ".", "X", "(", ")", "<", "hds", "[", "j", "]", ".", "X", "(", ")", "||", "(", "hds", "[", "i", "]", ".", "X", ...
// Less satisfies 'Less' in sort.Interface.
[ "Less", "satisfies", "Less", "in", "sort", ".", "Interface", "." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xinerama/xinerama.go#L21-L24
124,669
BurntSushi/xgbutil
xinerama/xinerama.go
Swap
func (hds Heads) Swap(i int, j int) { hds[i], hds[j] = hds[j], hds[i] }
go
func (hds Heads) Swap(i int, j int) { hds[i], hds[j] = hds[j], hds[i] }
[ "func", "(", "hds", "Heads", ")", "Swap", "(", "i", "int", ",", "j", "int", ")", "{", "hds", "[", "i", "]", ",", "hds", "[", "j", "]", "=", "hds", "[", "j", "]", ",", "hds", "[", "i", "]", "\n", "}" ]
// Swap does just that. Nothing to see here...
[ "Swap", "does", "just", "that", ".", "Nothing", "to", "see", "here", "..." ]
f7c97cef3b4e6c88280a5a7091c3314e815ca243
https://github.com/BurntSushi/xgbutil/blob/f7c97cef3b4e6c88280a5a7091c3314e815ca243/xinerama/xinerama.go#L27-L29
124,670
goph/emperror
context.go
With
func With(err error, keyvals ...interface{}) error { if err == nil { return nil } if len(keyvals) == 0 { return err } var kvs []interface{} // extract context from previous error if c, ok := err.(*withContext); ok { err = c.err kvs = append(kvs, c.keyvals...) if len(kvs)%2 != 0 { kvs = append(k...
go
func With(err error, keyvals ...interface{}) error { if err == nil { return nil } if len(keyvals) == 0 { return err } var kvs []interface{} // extract context from previous error if c, ok := err.(*withContext); ok { err = c.err kvs = append(kvs, c.keyvals...) if len(kvs)%2 != 0 { kvs = append(k...
[ "func", "With", "(", "err", "error", ",", "keyvals", "...", "interface", "{", "}", ")", "error", "{", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "len", "(", "keyvals", ")", "==", "0", "{", "return", "err", "\n", "}",...
// The implementation bellow is heavily influenced by go-kit's log context. // With returns a new error with keyvals context appended to it. // If the wrapped error is already a contextual error created by With // keyvals is appended to the existing context, but a new error is returned.
[ "The", "implementation", "bellow", "is", "heavily", "influenced", "by", "go", "-", "kit", "s", "log", "context", ".", "With", "returns", "a", "new", "error", "with", "keyvals", "context", "appended", "to", "it", ".", "If", "the", "wrapped", "error", "is", ...
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/context.go#L13-L48
124,671
goph/emperror
handler_composite.go
Handle
func (h *compositeHandler) Handle(err error) { for _, handler := range h.handlers { handler.Handle(err) } }
go
func (h *compositeHandler) Handle(err error) { for _, handler := range h.handlers { handler.Handle(err) } }
[ "func", "(", "h", "*", "compositeHandler", ")", "Handle", "(", "err", "error", ")", "{", "for", "_", ",", "handler", ":=", "range", "h", ".", "handlers", "{", "handler", ".", "Handle", "(", "err", ")", "\n", "}", "\n", "}" ]
// Handle goes through the handlers and call each of them for the error.
[ "Handle", "goes", "through", "the", "handlers", "and", "call", "each", "of", "them", "for", "the", "error", "." ]
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/handler_composite.go#L14-L18
124,672
goph/emperror
utils.go
Handle
func Handle(handler Handler, err error) { if err != nil { handler.Handle(err) } }
go
func Handle(handler Handler, err error) { if err != nil { handler.Handle(err) } }
[ "func", "Handle", "(", "handler", "Handler", ",", "err", "error", ")", "{", "if", "err", "!=", "nil", "{", "handler", ".", "Handle", "(", "err", ")", "\n", "}", "\n", "}" ]
// Handle handles an error whenever it occurs.
[ "Handle", "handles", "an", "error", "whenever", "it", "occurs", "." ]
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/utils.go#L14-L18
124,673
goph/emperror
multierr.go
Add
func (b *MultiErrorBuilder) Add(err error) { // Do not add nil values. if err == nil { return } b.errors = append(b.errors, err) }
go
func (b *MultiErrorBuilder) Add(err error) { // Do not add nil values. if err == nil { return } b.errors = append(b.errors, err) }
[ "func", "(", "b", "*", "MultiErrorBuilder", ")", "Add", "(", "err", "error", ")", "{", "// Do not add nil values.", "if", "err", "==", "nil", "{", "return", "\n", "}", "\n\n", "b", ".", "errors", "=", "append", "(", "b", ".", "errors", ",", "err", ")...
// Add adds an error to the list. // // Calling this method concurrently is not safe.
[ "Add", "adds", "an", "error", "to", "the", "list", ".", "Calling", "this", "method", "concurrently", "is", "not", "safe", "." ]
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/multierr.go#L53-L60
124,674
goph/emperror
multierr.go
ErrOrNil
func (b *MultiErrorBuilder) ErrOrNil() error { // No errors added, return nil. if len(b.errors) == 0 { return nil } // Return a single error when there is only one and the builder is told to do so. if len(b.errors) == 1 && b.SingleWrapMode == ReturnSingle { return b.errors[0] } return &multiError{b.errors,...
go
func (b *MultiErrorBuilder) ErrOrNil() error { // No errors added, return nil. if len(b.errors) == 0 { return nil } // Return a single error when there is only one and the builder is told to do so. if len(b.errors) == 1 && b.SingleWrapMode == ReturnSingle { return b.errors[0] } return &multiError{b.errors,...
[ "func", "(", "b", "*", "MultiErrorBuilder", ")", "ErrOrNil", "(", ")", "error", "{", "// No errors added, return nil.", "if", "len", "(", "b", ".", "errors", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "// Return a single error when there is only on...
// ErrOrNil returns a MultiError the builder aggregates a list of errors, // or returns nil if the list of errors is empty. // // It is useful to avoid checking if there are any errors added to the list.
[ "ErrOrNil", "returns", "a", "MultiError", "the", "builder", "aggregates", "a", "list", "of", "errors", "or", "returns", "nil", "if", "the", "list", "of", "errors", "is", "empty", ".", "It", "is", "useful", "to", "avoid", "checking", "if", "there", "are", ...
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/multierr.go#L66-L78
124,675
goph/emperror
stack.go
Format
func (w *withStack) Format(s fmt.State, verb rune) { switch verb { case 'v': if s.Flag('+') { _, _ = fmt.Fprintf(s, "%+v", w.Cause()) return } fallthrough case 's': _, _ = io.WriteString(s, w.Error()) case 'q': _, _ = fmt.Fprintf(s, "%q", w.Error()) } }
go
func (w *withStack) Format(s fmt.State, verb rune) { switch verb { case 'v': if s.Flag('+') { _, _ = fmt.Fprintf(s, "%+v", w.Cause()) return } fallthrough case 's': _, _ = io.WriteString(s, w.Error()) case 'q': _, _ = fmt.Fprintf(s, "%q", w.Error()) } }
[ "func", "(", "w", "*", "withStack", ")", "Format", "(", "s", "fmt", ".", "State", ",", "verb", "rune", ")", "{", "switch", "verb", "{", "case", "'v'", ":", "if", "s", ".", "Flag", "(", "'+'", ")", "{", "_", ",", "_", "=", "fmt", ".", "Fprintf...
// Format implements the fmt.Formatter interface.
[ "Format", "implements", "the", "fmt", ".", "Formatter", "interface", "." ]
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/stack.go#L59-L74
124,676
goph/emperror
handler/logrushandler/handler.go
Handle
func (h *Handler) Handle(err error) { logger := h.logger // Extract context from the error and attach it to the log if kvs := emperror.Context(err); len(kvs) > 0 { logger = h.logger.WithFields(logrus.Fields(keyvals.ToMap(kvs))) } type errorCollection interface { Errors() []error } if errs, ok := err.(erro...
go
func (h *Handler) Handle(err error) { logger := h.logger // Extract context from the error and attach it to the log if kvs := emperror.Context(err); len(kvs) > 0 { logger = h.logger.WithFields(logrus.Fields(keyvals.ToMap(kvs))) } type errorCollection interface { Errors() []error } if errs, ok := err.(erro...
[ "func", "(", "h", "*", "Handler", ")", "Handle", "(", "err", "error", ")", "{", "logger", ":=", "h", ".", "logger", "\n\n", "// Extract context from the error and attach it to the log", "if", "kvs", ":=", "emperror", ".", "Context", "(", "err", ")", ";", "le...
// Handle logs an error.
[ "Handle", "logs", "an", "error", "." ]
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/handler/logrushandler/handler.go#L24-L43
124,677
goph/emperror
handler/airbrakehandler/handler.go
NewFromNotifier
func NewFromNotifier(notifier *gobrake.Notifier) *Handler { handler := &Handler{ notifier: notifier, } return handler }
go
func NewFromNotifier(notifier *gobrake.Notifier) *Handler { handler := &Handler{ notifier: notifier, } return handler }
[ "func", "NewFromNotifier", "(", "notifier", "*", "gobrake", ".", "Notifier", ")", "*", "Handler", "{", "handler", ":=", "&", "Handler", "{", "notifier", ":", "notifier", ",", "}", "\n\n", "return", "handler", "\n", "}" ]
// NewFromNotifier creates a new handler from a notifier instance.
[ "NewFromNotifier", "creates", "a", "new", "handler", "from", "a", "notifier", "instance", "." ]
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/handler/airbrakehandler/handler.go#L34-L40
124,678
goph/emperror
handler/airbrakehandler/handler.go
NewSyncFromNotifier
func NewSyncFromNotifier(notifier *gobrake.Notifier) *Handler { handler := NewFromNotifier(notifier) handler.sendSynchronously = true return handler }
go
func NewSyncFromNotifier(notifier *gobrake.Notifier) *Handler { handler := NewFromNotifier(notifier) handler.sendSynchronously = true return handler }
[ "func", "NewSyncFromNotifier", "(", "notifier", "*", "gobrake", ".", "Notifier", ")", "*", "Handler", "{", "handler", ":=", "NewFromNotifier", "(", "notifier", ")", "\n\n", "handler", ".", "sendSynchronously", "=", "true", "\n\n", "return", "handler", "\n", "}...
// NewSyncFromNotifier creates a new handler from a notifier instance that sends errors synchronously.
[ "NewSyncFromNotifier", "creates", "a", "new", "handler", "from", "a", "notifier", "instance", "that", "sends", "errors", "synchronously", "." ]
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/handler/airbrakehandler/handler.go#L43-L49
124,679
goph/emperror
handler/sentryhandler/handler.go
NewSyncFromClient
func NewSyncFromClient(client *raven.Client) *Handler { handler := NewFromClient(client) handler.sendSynchronously = true return handler }
go
func NewSyncFromClient(client *raven.Client) *Handler { handler := NewFromClient(client) handler.sendSynchronously = true return handler }
[ "func", "NewSyncFromClient", "(", "client", "*", "raven", ".", "Client", ")", "*", "Handler", "{", "handler", ":=", "NewFromClient", "(", "client", ")", "\n\n", "handler", ".", "sendSynchronously", "=", "true", "\n\n", "return", "handler", "\n", "}" ]
// NewSyncFromClient creates a new handler from a client instance that sends errors synchronously.
[ "NewSyncFromClient", "creates", "a", "new", "handler", "from", "a", "client", "instance", "that", "sends", "errors", "synchronously", "." ]
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/handler/sentryhandler/handler.go#L49-L55
124,680
goph/emperror
handler/sentryhandler/handler.go
Close
func (h *Handler) Close() error { h.client.Close() h.client.Wait() return nil }
go
func (h *Handler) Close() error { h.client.Close() h.client.Wait() return nil }
[ "func", "(", "h", "*", "Handler", ")", "Close", "(", ")", "error", "{", "h", ".", "client", ".", "Close", "(", ")", "\n", "h", ".", "client", ".", "Wait", "(", ")", "\n\n", "return", "nil", "\n", "}" ]
// Close closes the underlying notifier and waits for asynchronous reports to finish.
[ "Close", "closes", "the", "underlying", "notifier", "and", "waits", "for", "asynchronous", "reports", "to", "finish", "." ]
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/handler/sentryhandler/handler.go#L86-L91
124,681
goph/emperror
handler/bugsnaghandler/handler.go
Handle
func (h *Handler) Handle(err error) { // Expose the stackTracer interface on the outer error (if there is stack trace in the error) // Convert error with stack trace to an internal error type if e, ok := emperror.ExposeStackTrace(err).(stackTracer); ok { err = newErrorWithStackFrames(e) } var rawData []interfac...
go
func (h *Handler) Handle(err error) { // Expose the stackTracer interface on the outer error (if there is stack trace in the error) // Convert error with stack trace to an internal error type if e, ok := emperror.ExposeStackTrace(err).(stackTracer); ok { err = newErrorWithStackFrames(e) } var rawData []interfac...
[ "func", "(", "h", "*", "Handler", ")", "Handle", "(", "err", "error", ")", "{", "// Expose the stackTracer interface on the outer error (if there is stack trace in the error)", "// Convert error with stack trace to an internal error type", "if", "e", ",", "ok", ":=", "emperror"...
// Handle sends the error to Bugsnag.
[ "Handle", "sends", "the", "error", "to", "Bugsnag", "." ]
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/handler/bugsnaghandler/handler.go#L34-L58
124,682
goph/emperror
internal/keyvals/to_map.go
ToMap
func ToMap(kvs []interface{}) map[string]interface{} { m := map[string]interface{}{} if len(kvs) == 0 { return m } if len(kvs)%2 == 1 { kvs = append(kvs, nil) } for i := 0; i < len(kvs); i += 2 { merge(m, kvs[i], kvs[i+1]) } return m }
go
func ToMap(kvs []interface{}) map[string]interface{} { m := map[string]interface{}{} if len(kvs) == 0 { return m } if len(kvs)%2 == 1 { kvs = append(kvs, nil) } for i := 0; i < len(kvs); i += 2 { merge(m, kvs[i], kvs[i+1]) } return m }
[ "func", "ToMap", "(", "kvs", "[", "]", "interface", "{", "}", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "m", ":=", "map", "[", "string", "]", "interface", "{", "}", "{", "}", "\n\n", "if", "len", "(", "kvs", ")", "==", "0", ...
// ToMap creates a map of key-value pairs from a variadic key-value pair slice. // // The implementation bellow is from go-kit's JSON logger.
[ "ToMap", "creates", "a", "map", "of", "key", "-", "value", "pairs", "from", "a", "variadic", "key", "-", "value", "pair", "slice", ".", "The", "implementation", "bellow", "is", "from", "go", "-", "kit", "s", "JSON", "logger", "." ]
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/internal/keyvals/to_map.go#L11-L27
124,683
goph/emperror
httperr/http.go
WithHTTPRequest
func WithHTTPRequest(err error, r *http.Request) error { return &withHTTPRequest{ req: r, err: err, } }
go
func WithHTTPRequest(err error, r *http.Request) error { return &withHTTPRequest{ req: r, err: err, } }
[ "func", "WithHTTPRequest", "(", "err", "error", ",", "r", "*", "http", ".", "Request", ")", "error", "{", "return", "&", "withHTTPRequest", "{", "req", ":", "r", ",", "err", ":", "err", ",", "}", "\n", "}" ]
// WithHTTPRequest attaches an HTTP request to the error.
[ "WithHTTPRequest", "attaches", "an", "HTTP", "request", "to", "the", "error", "." ]
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/httperr/http.go#L12-L17
124,684
goph/emperror
handler_context.go
HandlerWith
func HandlerWith(handler Handler, keyvals ...interface{}) Handler { if len(keyvals) == 0 { return handler } kvs, handler := extractHandlerContext(handler) kvs = append(kvs, keyvals...) if len(kvs)%2 != 0 { kvs = append(kvs, nil) } // Limiting the capacity of the stored keyvals ensures that a new // back...
go
func HandlerWith(handler Handler, keyvals ...interface{}) Handler { if len(keyvals) == 0 { return handler } kvs, handler := extractHandlerContext(handler) kvs = append(kvs, keyvals...) if len(kvs)%2 != 0 { kvs = append(kvs, nil) } // Limiting the capacity of the stored keyvals ensures that a new // back...
[ "func", "HandlerWith", "(", "handler", "Handler", ",", "keyvals", "...", "interface", "{", "}", ")", "Handler", "{", "if", "len", "(", "keyvals", ")", "==", "0", "{", "return", "handler", "\n", "}", "\n\n", "kvs", ",", "handler", ":=", "extractHandlerCon...
// The implementation bellow is heavily influenced by go-kit's log context. // HandlerWith returns a new error handler with keyvals context appended to it. // If the wrapped error handler is already a contextual error handler created by HandlerWith or HandlerWithPrefix // keyvals is appended to the existing context, bu...
[ "The", "implementation", "bellow", "is", "heavily", "influenced", "by", "go", "-", "kit", "s", "log", "context", ".", "HandlerWith", "returns", "a", "new", "error", "handler", "with", "keyvals", "context", "appended", "to", "it", ".", "If", "the", "wrapped",...
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/handler_context.go#L10-L27
124,685
goph/emperror
handler_context.go
HandlerWithPrefix
func HandlerWithPrefix(handler Handler, keyvals ...interface{}) Handler { if len(keyvals) == 0 { return handler } prevkvs, handler := extractHandlerContext(handler) n := len(prevkvs) + len(keyvals) if len(keyvals)%2 != 0 { n++ } kvs := make([]interface{}, 0, n) kvs = append(kvs, keyvals...) if len(kvs)...
go
func HandlerWithPrefix(handler Handler, keyvals ...interface{}) Handler { if len(keyvals) == 0 { return handler } prevkvs, handler := extractHandlerContext(handler) n := len(prevkvs) + len(keyvals) if len(keyvals)%2 != 0 { n++ } kvs := make([]interface{}, 0, n) kvs = append(kvs, keyvals...) if len(kvs)...
[ "func", "HandlerWithPrefix", "(", "handler", "Handler", ",", "keyvals", "...", "interface", "{", "}", ")", "Handler", "{", "if", "len", "(", "keyvals", ")", "==", "0", "{", "return", "handler", "\n", "}", "\n\n", "prevkvs", ",", "handler", ":=", "extract...
// HandlerWithPrefix returns a new error handler with keyvals context prepended to it. // If the wrapped error handler is already a contextual error handler created by HandlerWith or HandlerWithPrefix // keyvals is prepended to the existing context, but a new error handler is returned. // // The created handler will pr...
[ "HandlerWithPrefix", "returns", "a", "new", "error", "handler", "with", "keyvals", "context", "prepended", "to", "it", ".", "If", "the", "wrapped", "error", "handler", "is", "already", "a", "contextual", "error", "handler", "created", "by", "HandlerWith", "or", ...
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/handler_context.go#L34-L56
124,686
goph/emperror
handler_context.go
extractHandlerContext
func extractHandlerContext(handler Handler) ([]interface{}, Handler) { var kvs []interface{} if c, ok := handler.(*contextualHandler); ok { handler = c.handler kvs = c.keyvals } return kvs, handler }
go
func extractHandlerContext(handler Handler) ([]interface{}, Handler) { var kvs []interface{} if c, ok := handler.(*contextualHandler); ok { handler = c.handler kvs = c.keyvals } return kvs, handler }
[ "func", "extractHandlerContext", "(", "handler", "Handler", ")", "(", "[", "]", "interface", "{", "}", ",", "Handler", ")", "{", "var", "kvs", "[", "]", "interface", "{", "}", "\n\n", "if", "c", ",", "ok", ":=", "handler", ".", "(", "*", "contextualH...
// extractHandlerContext extracts the context and optionally the wrapped handler when it's the same container.
[ "extractHandlerContext", "extracts", "the", "context", "and", "optionally", "the", "wrapped", "handler", "when", "it", "s", "the", "same", "container", "." ]
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/handler_context.go#L59-L68
124,687
goph/emperror
cause.go
ForEachCause
func ForEachCause(err error, fn func(err error) bool) { // causer is the interface defined in github.com/pkg/errors for specifying a parent error. type causer interface { Cause() error } for err != nil { continueLoop := fn(err) if !continueLoop { break } cause, ok := err.(causer) if !ok { break ...
go
func ForEachCause(err error, fn func(err error) bool) { // causer is the interface defined in github.com/pkg/errors for specifying a parent error. type causer interface { Cause() error } for err != nil { continueLoop := fn(err) if !continueLoop { break } cause, ok := err.(causer) if !ok { break ...
[ "func", "ForEachCause", "(", "err", "error", ",", "fn", "func", "(", "err", "error", ")", "bool", ")", "{", "// causer is the interface defined in github.com/pkg/errors for specifying a parent error.", "type", "causer", "interface", "{", "Cause", "(", ")", "error", "\...
// ForEachCause loops through an error chain and calls a function for each of them, // starting with the topmost one. // // The function can return false to break the loop before it ends.
[ "ForEachCause", "loops", "through", "an", "error", "chain", "and", "calls", "a", "function", "for", "each", "of", "them", "starting", "with", "the", "topmost", "one", ".", "The", "function", "can", "return", "false", "to", "break", "the", "loop", "before", ...
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/cause.go#L7-L26
124,688
goph/emperror
panic.go
Panic
func Panic(err error) { if err != nil { if _, ok := StackTrace(err); !ok { err = &wrappedError{ err: err, stack: callers(), } } panic(err) } }
go
func Panic(err error) { if err != nil { if _, ok := StackTrace(err); !ok { err = &wrappedError{ err: err, stack: callers(), } } panic(err) } }
[ "func", "Panic", "(", "err", "error", ")", "{", "if", "err", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "StackTrace", "(", "err", ")", ";", "!", "ok", "{", "err", "=", "&", "wrappedError", "{", "err", ":", "err", ",", "stack", ":", "callers"...
// Panic panics if the passed error is not nil. // If the error does not contain any stack trace, the function attaches one, starting from the frame of the // "Panic" function call. // // This function is useful with HandleRecover when panic is used as a flow control tool to stop the application.
[ "Panic", "panics", "if", "the", "passed", "error", "is", "not", "nil", ".", "If", "the", "error", "does", "not", "contain", "any", "stack", "trace", "the", "function", "attaches", "one", "starting", "from", "the", "frame", "of", "the", "Panic", "function",...
ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17
https://github.com/goph/emperror/blob/ae59d9fdc3f0c4814bc5fac2d4a68441dcff5a17/panic.go#L8-L19
124,689
cloudfoundry/route-emitter
routingtable/routingtable.go
mergeUnfreshRoutes
func mergeUnfreshRoutes(before, after RoutableEndpoints, domains models.DomainSet) RoutableEndpoints { merged := after.copy() merged.Domain = before.Domain if !domains.Contains(before.Domain) { // non-fresh domain, append routes from older endpoint for _, oldRoute := range before.Routes { routeExistInNewLRP ...
go
func mergeUnfreshRoutes(before, after RoutableEndpoints, domains models.DomainSet) RoutableEndpoints { merged := after.copy() merged.Domain = before.Domain if !domains.Contains(before.Domain) { // non-fresh domain, append routes from older endpoint for _, oldRoute := range before.Routes { routeExistInNewLRP ...
[ "func", "mergeUnfreshRoutes", "(", "before", ",", "after", "RoutableEndpoints", ",", "domains", "models", ".", "DomainSet", ")", "RoutableEndpoints", "{", "merged", ":=", "after", ".", "copy", "(", ")", "\n", "merged", ".", "Domain", "=", "before", ".", "Dom...
// merge the routes from both endpoints, ensuring that non-fresh routes aren't removed
[ "merge", "the", "routes", "from", "both", "endpoints", "ensuring", "that", "non", "-", "fresh", "routes", "aren", "t", "removed" ]
1a971a54af97eea7a94c6f0978bda9dafe008e40
https://github.com/cloudfoundry/route-emitter/blob/1a971a54af97eea7a94c6f0978bda9dafe008e40/routingtable/routingtable.go#L386-L408
124,690
cloudfoundry/route-emitter
routingtable/registry_message.go
InternalEndpointRegistryMessageFor
func InternalEndpointRegistryMessageFor(endpoint Endpoint, route InternalRoute, emitEndpointUpdatedAt bool) RegistryMessage { var index string if endpoint.InstanceGUID != "" { index = fmt.Sprintf("%d", endpoint.Index) } since := endpoint.Since if !emitEndpointUpdatedAt { since = 0 } return RegistryMessage{ ...
go
func InternalEndpointRegistryMessageFor(endpoint Endpoint, route InternalRoute, emitEndpointUpdatedAt bool) RegistryMessage { var index string if endpoint.InstanceGUID != "" { index = fmt.Sprintf("%d", endpoint.Index) } since := endpoint.Since if !emitEndpointUpdatedAt { since = 0 } return RegistryMessage{ ...
[ "func", "InternalEndpointRegistryMessageFor", "(", "endpoint", "Endpoint", ",", "route", "InternalRoute", ",", "emitEndpointUpdatedAt", "bool", ")", "RegistryMessage", "{", "var", "index", "string", "\n", "if", "endpoint", ".", "InstanceGUID", "!=", "\"", "\"", "{",...
// This is used to generate registry messages for Internal routes
[ "This", "is", "used", "to", "generate", "registry", "messages", "for", "Internal", "routes" ]
1a971a54af97eea7a94c6f0978bda9dafe008e40
https://github.com/cloudfoundry/route-emitter/blob/1a971a54af97eea7a94c6f0978bda9dafe008e40/routingtable/registry_message.go#L76-L94
124,691
codahale/metrics
metrics.go
AddN
func (c Counter) AddN(delta uint64) { cm.Lock() counters[string(c)] += delta cm.Unlock() }
go
func (c Counter) AddN(delta uint64) { cm.Lock() counters[string(c)] += delta cm.Unlock() }
[ "func", "(", "c", "Counter", ")", "AddN", "(", "delta", "uint64", ")", "{", "cm", ".", "Lock", "(", ")", "\n", "counters", "[", "string", "(", "c", ")", "]", "+=", "delta", "\n", "cm", ".", "Unlock", "(", ")", "\n", "}" ]
// AddN increments the counter by N.
[ "AddN", "increments", "the", "counter", "by", "N", "." ]
bc2005d86c7922adc3dd228f42f16015d8132ac8
https://github.com/codahale/metrics/blob/bc2005d86c7922adc3dd228f42f16015d8132ac8/metrics.go#L52-L56
124,692
codahale/metrics
metrics.go
SetFunc
func (c Counter) SetFunc(f func() uint64) { cm.Lock() defer cm.Unlock() counterFuncs[string(c)] = f }
go
func (c Counter) SetFunc(f func() uint64) { cm.Lock() defer cm.Unlock() counterFuncs[string(c)] = f }
[ "func", "(", "c", "Counter", ")", "SetFunc", "(", "f", "func", "(", ")", "uint64", ")", "{", "cm", ".", "Lock", "(", ")", "\n", "defer", "cm", ".", "Unlock", "(", ")", "\n\n", "counterFuncs", "[", "string", "(", "c", ")", "]", "=", "f", "\n", ...
// SetFunc sets the counter's value to the lazily-called return value of the // given function.
[ "SetFunc", "sets", "the", "counter", "s", "value", "to", "the", "lazily", "-", "called", "return", "value", "of", "the", "given", "function", "." ]
bc2005d86c7922adc3dd228f42f16015d8132ac8
https://github.com/codahale/metrics/blob/bc2005d86c7922adc3dd228f42f16015d8132ac8/metrics.go#L60-L65
124,693
codahale/metrics
metrics.go
SetBatchFunc
func (c Counter) SetBatchFunc(key interface{}, init func(), f func() uint64) { gm.Lock() defer gm.Unlock() cm.Lock() defer cm.Unlock() counterFuncs[string(c)] = f if _, ok := inits[key]; !ok { inits[key] = init } }
go
func (c Counter) SetBatchFunc(key interface{}, init func(), f func() uint64) { gm.Lock() defer gm.Unlock() cm.Lock() defer cm.Unlock() counterFuncs[string(c)] = f if _, ok := inits[key]; !ok { inits[key] = init } }
[ "func", "(", "c", "Counter", ")", "SetBatchFunc", "(", "key", "interface", "{", "}", ",", "init", "func", "(", ")", ",", "f", "func", "(", ")", "uint64", ")", "{", "gm", ".", "Lock", "(", ")", "\n", "defer", "gm", ".", "Unlock", "(", ")", "\n\n...
// SetBatchFunc sets the counter's value to the lazily-called return value of // the given function, with an additional initializer function for a related // batch of counters, all of which are keyed by an arbitrary value.
[ "SetBatchFunc", "sets", "the", "counter", "s", "value", "to", "the", "lazily", "-", "called", "return", "value", "of", "the", "given", "function", "with", "an", "additional", "initializer", "function", "for", "a", "related", "batch", "of", "counters", "all", ...
bc2005d86c7922adc3dd228f42f16015d8132ac8
https://github.com/codahale/metrics/blob/bc2005d86c7922adc3dd228f42f16015d8132ac8/metrics.go#L70-L81
124,694
codahale/metrics
metrics.go
Remove
func (c Counter) Remove() { gm.Lock() defer gm.Unlock() cm.Lock() defer cm.Unlock() delete(counters, string(c)) delete(counterFuncs, string(c)) delete(inits, string(c)) }
go
func (c Counter) Remove() { gm.Lock() defer gm.Unlock() cm.Lock() defer cm.Unlock() delete(counters, string(c)) delete(counterFuncs, string(c)) delete(inits, string(c)) }
[ "func", "(", "c", "Counter", ")", "Remove", "(", ")", "{", "gm", ".", "Lock", "(", ")", "\n", "defer", "gm", ".", "Unlock", "(", ")", "\n\n", "cm", ".", "Lock", "(", ")", "\n", "defer", "cm", ".", "Unlock", "(", ")", "\n\n", "delete", "(", "c...
// Remove removes the given counter.
[ "Remove", "removes", "the", "given", "counter", "." ]
bc2005d86c7922adc3dd228f42f16015d8132ac8
https://github.com/codahale/metrics/blob/bc2005d86c7922adc3dd228f42f16015d8132ac8/metrics.go#L84-L94
124,695
codahale/metrics
metrics.go
Set
func (g Gauge) Set(value int64) { gm.Lock() defer gm.Unlock() gauges[string(g)] = func() int64 { return value } }
go
func (g Gauge) Set(value int64) { gm.Lock() defer gm.Unlock() gauges[string(g)] = func() int64 { return value } }
[ "func", "(", "g", "Gauge", ")", "Set", "(", "value", "int64", ")", "{", "gm", ".", "Lock", "(", ")", "\n", "defer", "gm", ".", "Unlock", "(", ")", "\n\n", "gauges", "[", "string", "(", "g", ")", "]", "=", "func", "(", ")", "int64", "{", "retu...
// Set the gauge's value to the given value.
[ "Set", "the", "gauge", "s", "value", "to", "the", "given", "value", "." ]
bc2005d86c7922adc3dd228f42f16015d8132ac8
https://github.com/codahale/metrics/blob/bc2005d86c7922adc3dd228f42f16015d8132ac8/metrics.go#L103-L110
124,696
codahale/metrics
metrics.go
SetFunc
func (g Gauge) SetFunc(f func() int64) { gm.Lock() defer gm.Unlock() gauges[string(g)] = f }
go
func (g Gauge) SetFunc(f func() int64) { gm.Lock() defer gm.Unlock() gauges[string(g)] = f }
[ "func", "(", "g", "Gauge", ")", "SetFunc", "(", "f", "func", "(", ")", "int64", ")", "{", "gm", ".", "Lock", "(", ")", "\n", "defer", "gm", ".", "Unlock", "(", ")", "\n\n", "gauges", "[", "string", "(", "g", ")", "]", "=", "f", "\n", "}" ]
// SetFunc sets the gauge's value to the lazily-called return value of the given // function.
[ "SetFunc", "sets", "the", "gauge", "s", "value", "to", "the", "lazily", "-", "called", "return", "value", "of", "the", "given", "function", "." ]
bc2005d86c7922adc3dd228f42f16015d8132ac8
https://github.com/codahale/metrics/blob/bc2005d86c7922adc3dd228f42f16015d8132ac8/metrics.go#L114-L119
124,697
codahale/metrics
metrics.go
SetBatchFunc
func (g Gauge) SetBatchFunc(key interface{}, init func(), f func() int64) { gm.Lock() defer gm.Unlock() gauges[string(g)] = f if _, ok := inits[key]; !ok { inits[key] = init } }
go
func (g Gauge) SetBatchFunc(key interface{}, init func(), f func() int64) { gm.Lock() defer gm.Unlock() gauges[string(g)] = f if _, ok := inits[key]; !ok { inits[key] = init } }
[ "func", "(", "g", "Gauge", ")", "SetBatchFunc", "(", "key", "interface", "{", "}", ",", "init", "func", "(", ")", ",", "f", "func", "(", ")", "int64", ")", "{", "gm", ".", "Lock", "(", ")", "\n", "defer", "gm", ".", "Unlock", "(", ")", "\n\n", ...
// SetBatchFunc sets the gauge's value to the lazily-called return value of the // given function, with an additional initializer function for a related batch // of gauges, all of which are keyed by an arbitrary value.
[ "SetBatchFunc", "sets", "the", "gauge", "s", "value", "to", "the", "lazily", "-", "called", "return", "value", "of", "the", "given", "function", "with", "an", "additional", "initializer", "function", "for", "a", "related", "batch", "of", "gauges", "all", "of...
bc2005d86c7922adc3dd228f42f16015d8132ac8
https://github.com/codahale/metrics/blob/bc2005d86c7922adc3dd228f42f16015d8132ac8/metrics.go#L124-L132
124,698
codahale/metrics
metrics.go
Remove
func (g Gauge) Remove() { gm.Lock() defer gm.Unlock() delete(gauges, string(g)) delete(inits, string(g)) }
go
func (g Gauge) Remove() { gm.Lock() defer gm.Unlock() delete(gauges, string(g)) delete(inits, string(g)) }
[ "func", "(", "g", "Gauge", ")", "Remove", "(", ")", "{", "gm", ".", "Lock", "(", ")", "\n", "defer", "gm", ".", "Unlock", "(", ")", "\n\n", "delete", "(", "gauges", ",", "string", "(", "g", ")", ")", "\n", "delete", "(", "inits", ",", "string",...
// Remove removes the given gauge.
[ "Remove", "removes", "the", "given", "gauge", "." ]
bc2005d86c7922adc3dd228f42f16015d8132ac8
https://github.com/codahale/metrics/blob/bc2005d86c7922adc3dd228f42f16015d8132ac8/metrics.go#L135-L141
124,699
codahale/metrics
metrics.go
Reset
func Reset() { hm.Lock() defer hm.Unlock() gm.Lock() defer gm.Unlock() cm.Lock() defer cm.Unlock() counters = make(map[string]uint64) counterFuncs = make(map[string]func() uint64) gauges = make(map[string]func() int64) histograms = make(map[string]*Histogram) inits = make(map[interface{}]func()) }
go
func Reset() { hm.Lock() defer hm.Unlock() gm.Lock() defer gm.Unlock() cm.Lock() defer cm.Unlock() counters = make(map[string]uint64) counterFuncs = make(map[string]func() uint64) gauges = make(map[string]func() int64) histograms = make(map[string]*Histogram) inits = make(map[interface{}]func()) }
[ "func", "Reset", "(", ")", "{", "hm", ".", "Lock", "(", ")", "\n", "defer", "hm", ".", "Unlock", "(", ")", "\n\n", "gm", ".", "Lock", "(", ")", "\n", "defer", "gm", ".", "Unlock", "(", ")", "\n\n", "cm", ".", "Lock", "(", ")", "\n", "defer", ...
// Reset removes all existing counters and gauges.
[ "Reset", "removes", "all", "existing", "counters", "and", "gauges", "." ]
bc2005d86c7922adc3dd228f42f16015d8132ac8
https://github.com/codahale/metrics/blob/bc2005d86c7922adc3dd228f42f16015d8132ac8/metrics.go#L144-L159