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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
151,200 | degdb/degdb | network/conn.go | Send | func (c *Conn) Send(m *protocol.Message) error {
msg, err := m.Marshal()
if err != nil {
return err
}
packet := make([]byte, len(msg)+4)
binary.BigEndian.PutUint32(packet, uint32(len(msg)))
copy(packet[4:], msg)
_, err = c.Conn.Write(packet)
return err
} | go | func (c *Conn) Send(m *protocol.Message) error {
msg, err := m.Marshal()
if err != nil {
return err
}
packet := make([]byte, len(msg)+4)
binary.BigEndian.PutUint32(packet, uint32(len(msg)))
copy(packet[4:], msg)
_, err = c.Conn.Write(packet)
return err
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Send",
"(",
"m",
"*",
"protocol",
".",
"Message",
")",
"error",
"{",
"msg",
",",
"err",
":=",
"m",
".",
"Marshal",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"packet",
... | // Send a message on the specified connection. Consider Request. | [
"Send",
"a",
"message",
"on",
"the",
"specified",
"connection",
".",
"Consider",
"Request",
"."
] | a69b0804daddf97dcacc876daa199078a293a9d0 | https://github.com/degdb/degdb/blob/a69b0804daddf97dcacc876daa199078a293a9d0/network/conn.go#L41-L51 |
151,201 | degdb/degdb | network/conn.go | Request | func (c *Conn) Request(m *protocol.Message) (*protocol.Message, error) {
m.Id = uint64(rand.Int63())
m.ResponseRequired = true
if err := c.Send(m); err != nil {
return nil, err
}
timeout := make(chan bool, 1)
go func() {
time.Sleep(10 * time.Second)
timeout <- true
}()
resp := make(chan *protocol.Message, 1)
c.expectedMessages[m.Id] = resp
var msg *protocol.Message
var err error
select {
case msg = <-resp:
case <-timeout:
err = Timeout
}
delete(c.expectedMessages, m.Id)
return msg, err
} | go | func (c *Conn) Request(m *protocol.Message) (*protocol.Message, error) {
m.Id = uint64(rand.Int63())
m.ResponseRequired = true
if err := c.Send(m); err != nil {
return nil, err
}
timeout := make(chan bool, 1)
go func() {
time.Sleep(10 * time.Second)
timeout <- true
}()
resp := make(chan *protocol.Message, 1)
c.expectedMessages[m.Id] = resp
var msg *protocol.Message
var err error
select {
case msg = <-resp:
case <-timeout:
err = Timeout
}
delete(c.expectedMessages, m.Id)
return msg, err
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Request",
"(",
"m",
"*",
"protocol",
".",
"Message",
")",
"(",
"*",
"protocol",
".",
"Message",
",",
"error",
")",
"{",
"m",
".",
"Id",
"=",
"uint64",
"(",
"rand",
".",
"Int63",
"(",
")",
")",
"\n",
"m",
"... | // Request sends a message on a connection and waits for a response.
// Returns error network.Timeout if no response in 10 seconds. | [
"Request",
"sends",
"a",
"message",
"on",
"a",
"connection",
"and",
"waits",
"for",
"a",
"response",
".",
"Returns",
"error",
"network",
".",
"Timeout",
"if",
"no",
"response",
"in",
"10",
"seconds",
"."
] | a69b0804daddf97dcacc876daa199078a293a9d0 | https://github.com/degdb/degdb/blob/a69b0804daddf97dcacc876daa199078a293a9d0/network/conn.go#L55-L79 |
151,202 | degdb/degdb | network/conn.go | RespondTo | func (c *Conn) RespondTo(to *protocol.Message, resp *protocol.Message) error {
resp.ResponseTo = to.Id
return c.Send(resp)
} | go | func (c *Conn) RespondTo(to *protocol.Message, resp *protocol.Message) error {
resp.ResponseTo = to.Id
return c.Send(resp)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"RespondTo",
"(",
"to",
"*",
"protocol",
".",
"Message",
",",
"resp",
"*",
"protocol",
".",
"Message",
")",
"error",
"{",
"resp",
".",
"ResponseTo",
"=",
"to",
".",
"Id",
"\n",
"return",
"c",
".",
"Send",
"(",
... | // RespondTo sends `resp` as a response to the request `to`. | [
"RespondTo",
"sends",
"resp",
"as",
"a",
"response",
"to",
"the",
"request",
"to",
"."
] | a69b0804daddf97dcacc876daa199078a293a9d0 | https://github.com/degdb/degdb/blob/a69b0804daddf97dcacc876daa199078a293a9d0/network/conn.go#L82-L85 |
151,203 | degdb/degdb | network/conn.go | Close | func (c *Conn) Close() error {
if c == nil {
return nil
}
c.Closed = true
if c.Conn != nil {
return c.Conn.Close()
}
return nil
} | go | func (c *Conn) Close() error {
if c == nil {
return nil
}
c.Closed = true
if c.Conn != nil {
return c.Conn.Close()
}
return nil
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"c",
".",
"Closed",
"=",
"true",
"\n",
"if",
"c",
".",
"Conn",
"!=",
"nil",
"{",
"return",
"c",
".",
"Conn",
... | // Close closes the connection and sets Closed to true. | [
"Close",
"closes",
"the",
"connection",
"and",
"sets",
"Closed",
"to",
"true",
"."
] | a69b0804daddf97dcacc876daa199078a293a9d0 | https://github.com/degdb/degdb/blob/a69b0804daddf97dcacc876daa199078a293a9d0/network/conn.go#L88-L97 |
151,204 | degdb/degdb | network/conn.go | PrettyID | func (c *Conn) PrettyID() string {
var remote string
if c.Peer != nil {
remote = c.Peer.Id
} else {
remote = c.RemoteAddr().String()
}
return color.CyanString(remote)
} | go | func (c *Conn) PrettyID() string {
var remote string
if c.Peer != nil {
remote = c.Peer.Id
} else {
remote = c.RemoteAddr().String()
}
return color.CyanString(remote)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"PrettyID",
"(",
")",
"string",
"{",
"var",
"remote",
"string",
"\n",
"if",
"c",
".",
"Peer",
"!=",
"nil",
"{",
"remote",
"=",
"c",
".",
"Peer",
".",
"Id",
"\n",
"}",
"else",
"{",
"remote",
"=",
"c",
".",
"... | // PrettyID returns a terminal colored format of the connection ID. | [
"PrettyID",
"returns",
"a",
"terminal",
"colored",
"format",
"of",
"the",
"connection",
"ID",
"."
] | a69b0804daddf97dcacc876daa199078a293a9d0 | https://github.com/degdb/degdb/blob/a69b0804daddf97dcacc876daa199078a293a9d0/network/conn.go#L100-L108 |
151,205 | degdb/degdb | core/http.go | handleInsertTriple | func (s *server) handleInsertTriple(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
http.Error(w, "endpoint needs POST", 400)
return
}
body, _ := ioutil.ReadAll(r.Body)
var triples []*protocol.Triple
if err := json.Unmarshal(body, &triples); err != nil {
http.Error(w, err.Error(), 500)
return
}
// TODO(d4l3k): This should ideally be refactored and force the client to presign the triple.
if err := s.signAndInsertTriples(triples, s.crypto); err != nil {
http.Error(w, err.Error(), 500)
}
w.Write([]byte(fmt.Sprintf("Inserted %d triples.", len(triples))))
} | go | func (s *server) handleInsertTriple(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
http.Error(w, "endpoint needs POST", 400)
return
}
body, _ := ioutil.ReadAll(r.Body)
var triples []*protocol.Triple
if err := json.Unmarshal(body, &triples); err != nil {
http.Error(w, err.Error(), 500)
return
}
// TODO(d4l3k): This should ideally be refactored and force the client to presign the triple.
if err := s.signAndInsertTriples(triples, s.crypto); err != nil {
http.Error(w, err.Error(), 500)
}
w.Write([]byte(fmt.Sprintf("Inserted %d triples.", len(triples))))
} | [
"func",
"(",
"s",
"*",
"server",
")",
"handleInsertTriple",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"r",
".",
"Method",
"!=",
"\"",
"\"",
"{",
"http",
".",
"Error",
"(",
"w",
",",
"\"",
"\""... | // handleInsertTriple inserts set of triples into the graph. | [
"handleInsertTriple",
"inserts",
"set",
"of",
"triples",
"into",
"the",
"graph",
"."
] | a69b0804daddf97dcacc876daa199078a293a9d0 | https://github.com/degdb/degdb/blob/a69b0804daddf97dcacc876daa199078a293a9d0/core/http.go#L41-L59 |
151,206 | degdb/degdb | core/http.go | signAndInsertTriples | func (s *server) signAndInsertTriples(triples []*protocol.Triple, key *crypto.PrivateKey) error {
hashes := make(map[uint64][]*protocol.Triple)
unix := time.Now().Unix()
for _, triple := range triples {
if err := key.SignTriple(triple); err != nil {
return err
}
triple.Created = unix
hash := murmur3.Sum64([]byte(triple.Subj))
hashes[hash] = append(hashes[hash], triple)
}
for hash, triples := range hashes {
msg := &protocol.Message{
Message: &protocol.Message_InsertTriples{
InsertTriples: &protocol.InsertTriples{
Triples: triples,
}},
Gossip: true,
}
currentKeyspace := s.network.LocalPeer().Keyspace.Includes(hash)
if err := s.network.Broadcast(&hash, msg); currentKeyspace && err == network.ErrNoRecipients {
} else if err != nil {
return err
}
if currentKeyspace {
s.ts.Insert(triples)
}
}
return nil
} | go | func (s *server) signAndInsertTriples(triples []*protocol.Triple, key *crypto.PrivateKey) error {
hashes := make(map[uint64][]*protocol.Triple)
unix := time.Now().Unix()
for _, triple := range triples {
if err := key.SignTriple(triple); err != nil {
return err
}
triple.Created = unix
hash := murmur3.Sum64([]byte(triple.Subj))
hashes[hash] = append(hashes[hash], triple)
}
for hash, triples := range hashes {
msg := &protocol.Message{
Message: &protocol.Message_InsertTriples{
InsertTriples: &protocol.InsertTriples{
Triples: triples,
}},
Gossip: true,
}
currentKeyspace := s.network.LocalPeer().Keyspace.Includes(hash)
if err := s.network.Broadcast(&hash, msg); currentKeyspace && err == network.ErrNoRecipients {
} else if err != nil {
return err
}
if currentKeyspace {
s.ts.Insert(triples)
}
}
return nil
} | [
"func",
"(",
"s",
"*",
"server",
")",
"signAndInsertTriples",
"(",
"triples",
"[",
"]",
"*",
"protocol",
".",
"Triple",
",",
"key",
"*",
"crypto",
".",
"PrivateKey",
")",
"error",
"{",
"hashes",
":=",
"make",
"(",
"map",
"[",
"uint64",
"]",
"[",
"]",... | // signAndInsertTriples signs a set of triples with the server's key and then inserts them into the graph. | [
"signAndInsertTriples",
"signs",
"a",
"set",
"of",
"triples",
"with",
"the",
"server",
"s",
"key",
"and",
"then",
"inserts",
"them",
"into",
"the",
"graph",
"."
] | a69b0804daddf97dcacc876daa199078a293a9d0 | https://github.com/degdb/degdb/blob/a69b0804daddf97dcacc876daa199078a293a9d0/core/http.go#L62-L92 |
151,207 | degdb/degdb | core/http.go | handleQuery | func (s *server) handleQuery(w http.ResponseWriter, r *http.Request) {
err := r.ParseForm()
if err != nil {
http.Error(w, err.Error(), 400)
return
}
q := r.FormValue("q")
s.Printf("Query: %s", q)
triple, err := query.Parse(q)
if err != nil {
http.Error(w, err.Error(), 400)
return
}
query := &protocol.QueryRequest{
Type: protocol.BASIC,
Steps: []*protocol.ArrayOp{{
Triples: triple,
}},
}
triples, err := s.ExecuteQuery(query)
if err != nil {
http.Error(w, err.Error(), 400)
return
}
json.NewEncoder(w).Encode(triples)
} | go | func (s *server) handleQuery(w http.ResponseWriter, r *http.Request) {
err := r.ParseForm()
if err != nil {
http.Error(w, err.Error(), 400)
return
}
q := r.FormValue("q")
s.Printf("Query: %s", q)
triple, err := query.Parse(q)
if err != nil {
http.Error(w, err.Error(), 400)
return
}
query := &protocol.QueryRequest{
Type: protocol.BASIC,
Steps: []*protocol.ArrayOp{{
Triples: triple,
}},
}
triples, err := s.ExecuteQuery(query)
if err != nil {
http.Error(w, err.Error(), 400)
return
}
json.NewEncoder(w).Encode(triples)
} | [
"func",
"(",
"s",
"*",
"server",
")",
"handleQuery",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"err",
":=",
"r",
".",
"ParseForm",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"http",
".",
"Error"... | // handleQuery executes a query against the graph. | [
"handleQuery",
"executes",
"a",
"query",
"against",
"the",
"graph",
"."
] | a69b0804daddf97dcacc876daa199078a293a9d0 | https://github.com/degdb/degdb/blob/a69b0804daddf97dcacc876daa199078a293a9d0/core/http.go#L95-L120 |
151,208 | degdb/degdb | core/http.go | handleTriples | func (s *server) handleTriples(w http.ResponseWriter, r *http.Request) {
triples, err := s.ts.Query(&protocol.Triple{}, -1)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
json.NewEncoder(w).Encode(triples)
} | go | func (s *server) handleTriples(w http.ResponseWriter, r *http.Request) {
triples, err := s.ts.Query(&protocol.Triple{}, -1)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
json.NewEncoder(w).Encode(triples)
} | [
"func",
"(",
"s",
"*",
"server",
")",
"handleTriples",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"triples",
",",
"err",
":=",
"s",
".",
"ts",
".",
"Query",
"(",
"&",
"protocol",
".",
"Triple",
"{",
... | // handleTriples is a debug method to dump the triple DB into a JSON blob. | [
"handleTriples",
"is",
"a",
"debug",
"method",
"to",
"dump",
"the",
"triple",
"DB",
"into",
"a",
"JSON",
"blob",
"."
] | a69b0804daddf97dcacc876daa199078a293a9d0 | https://github.com/degdb/degdb/blob/a69b0804daddf97dcacc876daa199078a293a9d0/core/http.go#L123-L130 |
151,209 | degdb/degdb | core/http.go | handlePeers | func (s *server) handlePeers(w http.ResponseWriter, r *http.Request) {
peers := make([]*protocol.Peer, 0, len(s.network.Peers))
for _, peer := range s.network.Peers {
peers = append(peers, peer.Peer)
}
json.NewEncoder(w).Encode(peers)
} | go | func (s *server) handlePeers(w http.ResponseWriter, r *http.Request) {
peers := make([]*protocol.Peer, 0, len(s.network.Peers))
for _, peer := range s.network.Peers {
peers = append(peers, peer.Peer)
}
json.NewEncoder(w).Encode(peers)
} | [
"func",
"(",
"s",
"*",
"server",
")",
"handlePeers",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"peers",
":=",
"make",
"(",
"[",
"]",
"*",
"protocol",
".",
"Peer",
",",
"0",
",",
"len",
"(",
"s",
"... | // handlePeers is a debug method to dump the current known peers. | [
"handlePeers",
"is",
"a",
"debug",
"method",
"to",
"dump",
"the",
"current",
"known",
"peers",
"."
] | a69b0804daddf97dcacc876daa199078a293a9d0 | https://github.com/degdb/degdb/blob/a69b0804daddf97dcacc876daa199078a293a9d0/core/http.go#L133-L139 |
151,210 | degdb/degdb | core/http.go | handleInfo | func (s *server) handleInfo(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(s.network.LocalPeer())
} | go | func (s *server) handleInfo(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(s.network.LocalPeer())
} | [
"func",
"(",
"s",
"*",
"server",
")",
"handleInfo",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"json",
".",
"NewEncoder",
"(",
"w",
")",
".",
"Encode",
"(",
"s",
".",
"network",
".",
"LocalPeer",
"(",
... | // handleInfo return information about the local node. | [
"handleInfo",
"return",
"information",
"about",
"the",
"local",
"node",
"."
] | a69b0804daddf97dcacc876daa199078a293a9d0 | https://github.com/degdb/degdb/blob/a69b0804daddf97dcacc876daa199078a293a9d0/core/http.go#L142-L144 |
151,211 | degdb/degdb | core/http.go | handleMyIP | func (s *server) handleMyIP(w http.ResponseWriter, r *http.Request) {
addr, err := net.ResolveTCPAddr("tcp", r.RemoteAddr)
if err != nil {
http.Error(w, err.Error(), 500)
}
w.Write([]byte(addr.IP.String()))
} | go | func (s *server) handleMyIP(w http.ResponseWriter, r *http.Request) {
addr, err := net.ResolveTCPAddr("tcp", r.RemoteAddr)
if err != nil {
http.Error(w, err.Error(), 500)
}
w.Write([]byte(addr.IP.String()))
} | [
"func",
"(",
"s",
"*",
"server",
")",
"handleMyIP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"addr",
",",
"err",
":=",
"net",
".",
"ResolveTCPAddr",
"(",
"\"",
"\"",
",",
"r",
".",
"RemoteAddr",
")",... | // handleMyIP returns the requesters IP address. | [
"handleMyIP",
"returns",
"the",
"requesters",
"IP",
"address",
"."
] | a69b0804daddf97dcacc876daa199078a293a9d0 | https://github.com/degdb/degdb/blob/a69b0804daddf97dcacc876daa199078a293a9d0/core/http.go#L147-L153 |
151,212 | degdb/degdb | core/core.go | Main | func Main(port int, peers []string, diskAllocated int) {
s, err := newServer(port, peers, diskAllocated)
if err != nil {
log.Fatal(err)
}
bitcoin.NewClient()
s.Fatal(s.network.Listen())
} | go | func Main(port int, peers []string, diskAllocated int) {
s, err := newServer(port, peers, diskAllocated)
if err != nil {
log.Fatal(err)
}
bitcoin.NewClient()
s.Fatal(s.network.Listen())
} | [
"func",
"Main",
"(",
"port",
"int",
",",
"peers",
"[",
"]",
"string",
",",
"diskAllocated",
"int",
")",
"{",
"s",
",",
"err",
":=",
"newServer",
"(",
"port",
",",
"peers",
",",
"diskAllocated",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
... | // Main launches a node with the specified parameters. | [
"Main",
"launches",
"a",
"node",
"with",
"the",
"specified",
"parameters",
"."
] | a69b0804daddf97dcacc876daa199078a293a9d0 | https://github.com/degdb/degdb/blob/a69b0804daddf97dcacc876daa199078a293a9d0/core/core.go#L34-L43 |
151,213 | bit4bit/gami | event/event.go | New | func New(event *gami.AMIEvent) interface{} {
if intf, ok := eventTrap[event.ID]; ok {
return build(event, &intf)
}
return *event
} | go | func New(event *gami.AMIEvent) interface{} {
if intf, ok := eventTrap[event.ID]; ok {
return build(event, &intf)
}
return *event
} | [
"func",
"New",
"(",
"event",
"*",
"gami",
".",
"AMIEvent",
")",
"interface",
"{",
"}",
"{",
"if",
"intf",
",",
"ok",
":=",
"eventTrap",
"[",
"event",
".",
"ID",
"]",
";",
"ok",
"{",
"return",
"build",
"(",
"event",
",",
"&",
"intf",
")",
"\n",
... | //New build a new event Type if not return the AMIEvent | [
"New",
"build",
"a",
"new",
"event",
"Type",
"if",
"not",
"return",
"the",
"AMIEvent"
] | a57db6fa69cb46cd857d897b60c988923c7f708c | https://github.com/bit4bit/gami/blob/a57db6fa69cb46cd857d897b60c988923c7f708c/event/event.go#L17-L22 |
151,214 | bit4bit/gami | gami.go | Login | func (client *AMIClient) Login(username, password string) error {
response, err := client.Action("Login", Params{"Username": username, "Secret": password})
if err != nil {
return err
}
if (*response).Status == "Error" {
return errors.New((*response).Params["Message"])
}
client.amiUser = username
client.amiPass = password
return nil
} | go | func (client *AMIClient) Login(username, password string) error {
response, err := client.Action("Login", Params{"Username": username, "Secret": password})
if err != nil {
return err
}
if (*response).Status == "Error" {
return errors.New((*response).Params["Message"])
}
client.amiUser = username
client.amiPass = password
return nil
} | [
"func",
"(",
"client",
"*",
"AMIClient",
")",
"Login",
"(",
"username",
",",
"password",
"string",
")",
"error",
"{",
"response",
",",
"err",
":=",
"client",
".",
"Action",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
":",
"username",
",",
"\"",
... | // Login authenticate to AMI | [
"Login",
"authenticate",
"to",
"AMI"
] | a57db6fa69cb46cd857d897b60c988923c7f708c | https://github.com/bit4bit/gami/blob/a57db6fa69cb46cd857d897b60c988923c7f708c/gami.go#L155-L168 |
151,215 | bit4bit/gami | gami.go | Reconnect | func (client *AMIClient) Reconnect() error {
client.conn.Close()
err := client.NewConn()
if err != nil {
client.NetError <- err
return err
}
client.waitNewConnection <- struct{}{}
if err := client.Login(client.amiUser, client.amiPass); err != nil {
return err
}
return nil
} | go | func (client *AMIClient) Reconnect() error {
client.conn.Close()
err := client.NewConn()
if err != nil {
client.NetError <- err
return err
}
client.waitNewConnection <- struct{}{}
if err := client.Login(client.amiUser, client.amiPass); err != nil {
return err
}
return nil
} | [
"func",
"(",
"client",
"*",
"AMIClient",
")",
"Reconnect",
"(",
")",
"error",
"{",
"client",
".",
"conn",
".",
"Close",
"(",
")",
"\n",
"err",
":=",
"client",
".",
"NewConn",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"client",
".",
"NetError... | // Reconnect the session, autologin if a new network error it put on client.NetError | [
"Reconnect",
"the",
"session",
"autologin",
"if",
"a",
"new",
"network",
"error",
"it",
"put",
"on",
"client",
".",
"NetError"
] | a57db6fa69cb46cd857d897b60c988923c7f708c | https://github.com/bit4bit/gami/blob/a57db6fa69cb46cd857d897b60c988923c7f708c/gami.go#L171-L187 |
151,216 | bit4bit/gami | gami.go | Action | func (client *AMIClient) Action(action string, params Params) (*AMIResponse, error) {
resp, err := client.AsyncAction(action, params)
if err != nil {
return nil, err
}
response := <-resp
return response, nil
} | go | func (client *AMIClient) Action(action string, params Params) (*AMIResponse, error) {
resp, err := client.AsyncAction(action, params)
if err != nil {
return nil, err
}
response := <-resp
return response, nil
} | [
"func",
"(",
"client",
"*",
"AMIClient",
")",
"Action",
"(",
"action",
"string",
",",
"params",
"Params",
")",
"(",
"*",
"AMIResponse",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"client",
".",
"AsyncAction",
"(",
"action",
",",
"params",
")",
... | // Action send with params | [
"Action",
"send",
"with",
"params"
] | a57db6fa69cb46cd857d897b60c988923c7f708c | https://github.com/bit4bit/gami/blob/a57db6fa69cb46cd857d897b60c988923c7f708c/gami.go#L218-L226 |
151,217 | bit4bit/gami | gami.go | Run | func (client *AMIClient) Run() {
go func() {
for {
data, err := client.conn.ReadMIMEHeader()
if err != nil {
switch err {
case syscall.ECONNABORTED:
fallthrough
case syscall.ECONNRESET:
fallthrough
case syscall.ECONNREFUSED:
fallthrough
case io.EOF:
client.NetError <- err
<-client.waitNewConnection
default:
client.Error <- err
}
continue
}
if ev, err := newEvent(&data); err != nil {
if err != errNotEvent {
client.Error <- err
}
} else {
client.Events <- ev
}
//only handle valid responses
//@todo handle longs response
// see https://marcelog.github.io/articles/php_asterisk_manager_interface_protocol_tutorial_introduction.html
if response, err := newResponse(&data); err == nil {
client.notifyResponse(response)
}
}
}()
} | go | func (client *AMIClient) Run() {
go func() {
for {
data, err := client.conn.ReadMIMEHeader()
if err != nil {
switch err {
case syscall.ECONNABORTED:
fallthrough
case syscall.ECONNRESET:
fallthrough
case syscall.ECONNREFUSED:
fallthrough
case io.EOF:
client.NetError <- err
<-client.waitNewConnection
default:
client.Error <- err
}
continue
}
if ev, err := newEvent(&data); err != nil {
if err != errNotEvent {
client.Error <- err
}
} else {
client.Events <- ev
}
//only handle valid responses
//@todo handle longs response
// see https://marcelog.github.io/articles/php_asterisk_manager_interface_protocol_tutorial_introduction.html
if response, err := newResponse(&data); err == nil {
client.notifyResponse(response)
}
}
}()
} | [
"func",
"(",
"client",
"*",
"AMIClient",
")",
"Run",
"(",
")",
"{",
"go",
"func",
"(",
")",
"{",
"for",
"{",
"data",
",",
"err",
":=",
"client",
".",
"conn",
".",
"ReadMIMEHeader",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"switch",
"err",
... | // Run process socket waiting events and responses | [
"Run",
"process",
"socket",
"waiting",
"events",
"and",
"responses"
] | a57db6fa69cb46cd857d897b60c988923c7f708c | https://github.com/bit4bit/gami/blob/a57db6fa69cb46cd857d897b60c988923c7f708c/gami.go#L229-L267 |
151,218 | bit4bit/gami | gami.go | newResponse | func newResponse(data *textproto.MIMEHeader) (*AMIResponse, error) {
if data.Get("Response") == "" {
return nil, errors.New("Not Response")
}
response := &AMIResponse{data.Get("Actionid"),
data.Get("Response"),
make(map[string]string)}
for k, v := range *data {
if k == "Response" {
continue
}
response.Params[k] = v[0]
}
return response, nil
} | go | func newResponse(data *textproto.MIMEHeader) (*AMIResponse, error) {
if data.Get("Response") == "" {
return nil, errors.New("Not Response")
}
response := &AMIResponse{data.Get("Actionid"),
data.Get("Response"),
make(map[string]string)}
for k, v := range *data {
if k == "Response" {
continue
}
response.Params[k] = v[0]
}
return response, nil
} | [
"func",
"newResponse",
"(",
"data",
"*",
"textproto",
".",
"MIMEHeader",
")",
"(",
"*",
"AMIResponse",
",",
"error",
")",
"{",
"if",
"data",
".",
"Get",
"(",
"\"",
"\"",
")",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
... | //newResponse build a response for action | [
"newResponse",
"build",
"a",
"response",
"for",
"action"
] | a57db6fa69cb46cd857d897b60c988923c7f708c | https://github.com/bit4bit/gami/blob/a57db6fa69cb46cd857d897b60c988923c7f708c/gami.go#L289-L305 |
151,219 | bit4bit/gami | gami.go | newEvent | func newEvent(data *textproto.MIMEHeader) (*AMIEvent, error) {
if data.Get("Event") == "" {
return nil, errNotEvent
}
ev := &AMIEvent{data.Get("Event"),
strings.Split(data.Get("Privilege"), ","),
make(map[string]string)}
for k, v := range *data {
if k == "Event" || k == "Privilege" {
continue
}
ev.Params[k] = v[0]
}
return ev, nil
} | go | func newEvent(data *textproto.MIMEHeader) (*AMIEvent, error) {
if data.Get("Event") == "" {
return nil, errNotEvent
}
ev := &AMIEvent{data.Get("Event"),
strings.Split(data.Get("Privilege"), ","),
make(map[string]string)}
for k, v := range *data {
if k == "Event" || k == "Privilege" {
continue
}
ev.Params[k] = v[0]
}
return ev, nil
} | [
"func",
"newEvent",
"(",
"data",
"*",
"textproto",
".",
"MIMEHeader",
")",
"(",
"*",
"AMIEvent",
",",
"error",
")",
"{",
"if",
"data",
".",
"Get",
"(",
"\"",
"\"",
")",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errNotEvent",
"\n",
"}",
"\n",
... | //newEvent build event | [
"newEvent",
"build",
"event"
] | a57db6fa69cb46cd857d897b60c988923c7f708c | https://github.com/bit4bit/gami/blob/a57db6fa69cb46cd857d897b60c988923c7f708c/gami.go#L308-L323 |
151,220 | bit4bit/gami | gami.go | Dial | func Dial(address string, options ...func(*AMIClient)) (*AMIClient, error) {
client := &AMIClient{
address: address,
amiUser: "",
amiPass: "",
mutexAsyncAction: new(sync.RWMutex),
waitNewConnection: make(chan struct{}),
response: make(map[string]chan *AMIResponse),
Events: make(chan *AMIEvent, 100),
Error: make(chan error, 1),
NetError: make(chan error, 1),
useTLS: false,
unsecureTLS: false,
tlsConfig: new(tls.Config),
}
for _, op := range options {
op(client)
}
err := client.NewConn()
if err != nil {
return nil, err
}
return client, nil
} | go | func Dial(address string, options ...func(*AMIClient)) (*AMIClient, error) {
client := &AMIClient{
address: address,
amiUser: "",
amiPass: "",
mutexAsyncAction: new(sync.RWMutex),
waitNewConnection: make(chan struct{}),
response: make(map[string]chan *AMIResponse),
Events: make(chan *AMIEvent, 100),
Error: make(chan error, 1),
NetError: make(chan error, 1),
useTLS: false,
unsecureTLS: false,
tlsConfig: new(tls.Config),
}
for _, op := range options {
op(client)
}
err := client.NewConn()
if err != nil {
return nil, err
}
return client, nil
} | [
"func",
"Dial",
"(",
"address",
"string",
",",
"options",
"...",
"func",
"(",
"*",
"AMIClient",
")",
")",
"(",
"*",
"AMIClient",
",",
"error",
")",
"{",
"client",
":=",
"&",
"AMIClient",
"{",
"address",
":",
"address",
",",
"amiUser",
":",
"\"",
"\""... | // Dial create a new connection to AMI | [
"Dial",
"create",
"a",
"new",
"connection",
"to",
"AMI"
] | a57db6fa69cb46cd857d897b60c988923c7f708c | https://github.com/bit4bit/gami/blob/a57db6fa69cb46cd857d897b60c988923c7f708c/gami.go#L326-L349 |
151,221 | bit4bit/gami | gami.go | NewConn | func (client *AMIClient) NewConn() (err error) {
if client.useTLS {
client.tlsConfig.InsecureSkipVerify = client.unsecureTLS
client.connRaw, err = tls.Dial("tcp", client.address, client.tlsConfig)
} else {
client.connRaw, err = net.Dial("tcp", client.address)
}
if err != nil {
return err
}
client.conn = textproto.NewConn(client.connRaw)
label, err := client.conn.ReadLine()
if err != nil {
return err
}
if strings.Contains(label, "Asterisk Call Manager") != true {
return ErrNotAMI
}
return nil
} | go | func (client *AMIClient) NewConn() (err error) {
if client.useTLS {
client.tlsConfig.InsecureSkipVerify = client.unsecureTLS
client.connRaw, err = tls.Dial("tcp", client.address, client.tlsConfig)
} else {
client.connRaw, err = net.Dial("tcp", client.address)
}
if err != nil {
return err
}
client.conn = textproto.NewConn(client.connRaw)
label, err := client.conn.ReadLine()
if err != nil {
return err
}
if strings.Contains(label, "Asterisk Call Manager") != true {
return ErrNotAMI
}
return nil
} | [
"func",
"(",
"client",
"*",
"AMIClient",
")",
"NewConn",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"client",
".",
"useTLS",
"{",
"client",
".",
"tlsConfig",
".",
"InsecureSkipVerify",
"=",
"client",
".",
"unsecureTLS",
"\n",
"client",
".",
"connRaw"... | // NewConn create a new connection to AMI | [
"NewConn",
"create",
"a",
"new",
"connection",
"to",
"AMI"
] | a57db6fa69cb46cd857d897b60c988923c7f708c | https://github.com/bit4bit/gami/blob/a57db6fa69cb46cd857d897b60c988923c7f708c/gami.go#L352-L375 |
151,222 | br0xen/termbox-util | termbox_progressbar.go | CreateProgressBar | func CreateProgressBar(tot, x, y int, fg, bg termbox.Attribute) *ProgressBar {
c := ProgressBar{total: tot,
fullChar: '#', emptyChar: ' ',
x: x, y: y, height: 1, width: 10,
bordered: true, fg: fg, bg: bg,
activeFg: fg, activeBg: bg,
alignment: AlignLeft,
}
return &c
} | go | func CreateProgressBar(tot, x, y int, fg, bg termbox.Attribute) *ProgressBar {
c := ProgressBar{total: tot,
fullChar: '#', emptyChar: ' ',
x: x, y: y, height: 1, width: 10,
bordered: true, fg: fg, bg: bg,
activeFg: fg, activeBg: bg,
alignment: AlignLeft,
}
return &c
} | [
"func",
"CreateProgressBar",
"(",
"tot",
",",
"x",
",",
"y",
"int",
",",
"fg",
",",
"bg",
"termbox",
".",
"Attribute",
")",
"*",
"ProgressBar",
"{",
"c",
":=",
"ProgressBar",
"{",
"total",
":",
"tot",
",",
"fullChar",
":",
"'#'",
",",
"emptyChar",
":... | // CreateProgressBar Create a progress bar object | [
"CreateProgressBar",
"Create",
"a",
"progress",
"bar",
"object"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_progressbar.go#L26-L35 |
151,223 | br0xen/termbox-util | termbox_progressbar.go | SetProgress | func (c *ProgressBar) SetProgress(p int) {
if (p <= c.total || c.allowOverflow) || (p >= 0 || c.allowUnderflow) {
c.progress = p
}
} | go | func (c *ProgressBar) SetProgress(p int) {
if (p <= c.total || c.allowOverflow) || (p >= 0 || c.allowUnderflow) {
c.progress = p
}
} | [
"func",
"(",
"c",
"*",
"ProgressBar",
")",
"SetProgress",
"(",
"p",
"int",
")",
"{",
"if",
"(",
"p",
"<=",
"c",
".",
"total",
"||",
"c",
".",
"allowOverflow",
")",
"||",
"(",
"p",
">=",
"0",
"||",
"c",
".",
"allowUnderflow",
")",
"{",
"c",
".",... | // SetProgress sets the current progress of the bar | [
"SetProgress",
"sets",
"the",
"current",
"progress",
"of",
"the",
"bar"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_progressbar.go#L56-L60 |
151,224 | br0xen/termbox-util | termbox_progressbar.go | IncrProgress | func (c *ProgressBar) IncrProgress() {
if c.progress < c.total || c.allowOverflow {
c.progress++
}
} | go | func (c *ProgressBar) IncrProgress() {
if c.progress < c.total || c.allowOverflow {
c.progress++
}
} | [
"func",
"(",
"c",
"*",
"ProgressBar",
")",
"IncrProgress",
"(",
")",
"{",
"if",
"c",
".",
"progress",
"<",
"c",
".",
"total",
"||",
"c",
".",
"allowOverflow",
"{",
"c",
".",
"progress",
"++",
"\n",
"}",
"\n",
"}"
] | // IncrProgress increments the current progress of the bar | [
"IncrProgress",
"increments",
"the",
"current",
"progress",
"of",
"the",
"bar"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_progressbar.go#L63-L67 |
151,225 | br0xen/termbox-util | termbox_progressbar.go | GetPercent | func (c *ProgressBar) GetPercent() int {
return int(float64(c.progress) / float64(c.total) * 100)
} | go | func (c *ProgressBar) GetPercent() int {
return int(float64(c.progress) / float64(c.total) * 100)
} | [
"func",
"(",
"c",
"*",
"ProgressBar",
")",
"GetPercent",
"(",
")",
"int",
"{",
"return",
"int",
"(",
"float64",
"(",
"c",
".",
"progress",
")",
"/",
"float64",
"(",
"c",
".",
"total",
")",
"*",
"100",
")",
"\n",
"}"
] | // GetPercent returns the percent full of the bar | [
"GetPercent",
"returns",
"the",
"percent",
"full",
"of",
"the",
"bar"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_progressbar.go#L77-L79 |
151,226 | br0xen/termbox-util | termbox_confirmmodal.go | CreateConfirmModal | func CreateConfirmModal(title string, x, y, width, height int, fg, bg termbox.Attribute) *ConfirmModal {
i := ConfirmModal{title: title, x: x, y: y, width: width, height: height, fg: fg, bg: bg, activeFg: fg, activeBg: bg}
if i.title == "" && i.text == "" {
i.title = "Confirm?"
}
i.showHelp = true
return &i
} | go | func CreateConfirmModal(title string, x, y, width, height int, fg, bg termbox.Attribute) *ConfirmModal {
i := ConfirmModal{title: title, x: x, y: y, width: width, height: height, fg: fg, bg: bg, activeFg: fg, activeBg: bg}
if i.title == "" && i.text == "" {
i.title = "Confirm?"
}
i.showHelp = true
return &i
} | [
"func",
"CreateConfirmModal",
"(",
"title",
"string",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
"int",
",",
"fg",
",",
"bg",
"termbox",
".",
"Attribute",
")",
"*",
"ConfirmModal",
"{",
"i",
":=",
"ConfirmModal",
"{",
"title",
":",
"title",
",",
... | // CreateConfirmModal Creates a confirmation modal with the specified attributes | [
"CreateConfirmModal",
"Creates",
"a",
"confirmation",
"modal",
"with",
"the",
"specified",
"attributes"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_confirmmodal.go#L26-L33 |
151,227 | br0xen/termbox-util | termbox_asciiart.go | CreateASCIIArt | func CreateASCIIArt(c []string, x, y int, fg, bg termbox.Attribute) *ASCIIArt {
i := ASCIIArt{contents: c, x: x, y: y, fg: fg, bg: bg, bordered: false, tabSkip: true}
i.activeFg, i.activeBg = fg, bg
return &i
} | go | func CreateASCIIArt(c []string, x, y int, fg, bg termbox.Attribute) *ASCIIArt {
i := ASCIIArt{contents: c, x: x, y: y, fg: fg, bg: bg, bordered: false, tabSkip: true}
i.activeFg, i.activeBg = fg, bg
return &i
} | [
"func",
"CreateASCIIArt",
"(",
"c",
"[",
"]",
"string",
",",
"x",
",",
"y",
"int",
",",
"fg",
",",
"bg",
"termbox",
".",
"Attribute",
")",
"*",
"ASCIIArt",
"{",
"i",
":=",
"ASCIIArt",
"{",
"contents",
":",
"c",
",",
"x",
":",
"x",
",",
"y",
":"... | // CreateASCIIArt Create an ASCII art object from a string slice | [
"CreateASCIIArt",
"Create",
"an",
"ASCII",
"art",
"object",
"from",
"a",
"string",
"slice"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_asciiart.go#L22-L26 |
151,228 | br0xen/termbox-util | termbox_asciiart.go | SetHeight | func (i *ASCIIArt) SetHeight(h int) {
if len(i.contents) > h {
i.contents = i.contents[:h]
} else {
for j := len(i.contents); j < h; j++ {
i.contents = append(i.contents, "")
}
}
} | go | func (i *ASCIIArt) SetHeight(h int) {
if len(i.contents) > h {
i.contents = i.contents[:h]
} else {
for j := len(i.contents); j < h; j++ {
i.contents = append(i.contents, "")
}
}
} | [
"func",
"(",
"i",
"*",
"ASCIIArt",
")",
"SetHeight",
"(",
"h",
"int",
")",
"{",
"if",
"len",
"(",
"i",
".",
"contents",
")",
">",
"h",
"{",
"i",
".",
"contents",
"=",
"i",
".",
"contents",
"[",
":",
"h",
"]",
"\n",
"}",
"else",
"{",
"for",
... | // SetHeight truncates lines from the bottom of the ascii art | [
"SetHeight",
"truncates",
"lines",
"from",
"the",
"bottom",
"of",
"the",
"ascii",
"art"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_asciiart.go#L58-L66 |
151,229 | br0xen/termbox-util | termbox_asciiart.go | GetWidth | func (i *ASCIIArt) GetWidth() int {
// Find the longest line
var ret int
for j := range i.contents {
if len(i.contents[j]) > ret {
ret = len(i.contents[j])
}
}
return ret
} | go | func (i *ASCIIArt) GetWidth() int {
// Find the longest line
var ret int
for j := range i.contents {
if len(i.contents[j]) > ret {
ret = len(i.contents[j])
}
}
return ret
} | [
"func",
"(",
"i",
"*",
"ASCIIArt",
")",
"GetWidth",
"(",
")",
"int",
"{",
"// Find the longest line",
"var",
"ret",
"int",
"\n",
"for",
"j",
":=",
"range",
"i",
".",
"contents",
"{",
"if",
"len",
"(",
"i",
".",
"contents",
"[",
"j",
"]",
")",
">",
... | // GetWidth Returns the number of strings in the contents slice | [
"GetWidth",
"Returns",
"the",
"number",
"of",
"strings",
"in",
"the",
"contents",
"slice"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_asciiart.go#L69-L78 |
151,230 | br0xen/termbox-util | termbox_asciiart.go | SetWidth | func (i *ASCIIArt) SetWidth(w int) {
// Find the longest line
for j := range i.contents {
mkUp := w - len(i.contents[j])
if mkUp > 0 {
i.contents[j] = i.contents[j] + strings.Repeat(" ", mkUp)
} else {
i.contents[j] = i.contents[j][:w]
}
}
} | go | func (i *ASCIIArt) SetWidth(w int) {
// Find the longest line
for j := range i.contents {
mkUp := w - len(i.contents[j])
if mkUp > 0 {
i.contents[j] = i.contents[j] + strings.Repeat(" ", mkUp)
} else {
i.contents[j] = i.contents[j][:w]
}
}
} | [
"func",
"(",
"i",
"*",
"ASCIIArt",
")",
"SetWidth",
"(",
"w",
"int",
")",
"{",
"// Find the longest line",
"for",
"j",
":=",
"range",
"i",
".",
"contents",
"{",
"mkUp",
":=",
"w",
"-",
"len",
"(",
"i",
".",
"contents",
"[",
"j",
"]",
")",
"\n",
"... | // SetWidth Sets all lines in the contents to width w | [
"SetWidth",
"Sets",
"all",
"lines",
"in",
"the",
"contents",
"to",
"width",
"w"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_asciiart.go#L81-L91 |
151,231 | br0xen/termbox-util | termbox_asciiart.go | SetContentLine | func (i *ASCIIArt) SetContentLine(s string, idx int) {
if idx >= 0 && idx < len(i.contents) {
i.contents[idx] = s
}
} | go | func (i *ASCIIArt) SetContentLine(s string, idx int) {
if idx >= 0 && idx < len(i.contents) {
i.contents[idx] = s
}
} | [
"func",
"(",
"i",
"*",
"ASCIIArt",
")",
"SetContentLine",
"(",
"s",
"string",
",",
"idx",
"int",
")",
"{",
"if",
"idx",
">=",
"0",
"&&",
"idx",
"<",
"len",
"(",
"i",
".",
"contents",
")",
"{",
"i",
".",
"contents",
"[",
"idx",
"]",
"=",
"s",
... | // SetContentLine Sets a specific line of the contents to s | [
"SetContentLine",
"Sets",
"a",
"specific",
"line",
"of",
"the",
"contents",
"to",
"s"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_asciiart.go#L109-L113 |
151,232 | br0xen/termbox-util | termbox_asciiart.go | Align | func (i *ASCIIArt) Align(a TextAlignment, width int) {
// First get the width of the longest string in the slice
var newContents []string
incomingLength := 0
for _, line := range i.contents {
if len(line) > incomingLength {
incomingLength = len(line)
}
}
for _, line := range i.contents {
newContents = append(newContents, AlignText(AlignText(line, incomingLength, AlignLeft), width, a))
}
i.contents = newContents
} | go | func (i *ASCIIArt) Align(a TextAlignment, width int) {
// First get the width of the longest string in the slice
var newContents []string
incomingLength := 0
for _, line := range i.contents {
if len(line) > incomingLength {
incomingLength = len(line)
}
}
for _, line := range i.contents {
newContents = append(newContents, AlignText(AlignText(line, incomingLength, AlignLeft), width, a))
}
i.contents = newContents
} | [
"func",
"(",
"i",
"*",
"ASCIIArt",
")",
"Align",
"(",
"a",
"TextAlignment",
",",
"width",
"int",
")",
"{",
"// First get the width of the longest string in the slice",
"var",
"newContents",
"[",
"]",
"string",
"\n",
"incomingLength",
":=",
"0",
"\n",
"for",
"_",... | // Align Align the Ascii art over width width with alignment a | [
"Align",
"Align",
"the",
"Ascii",
"art",
"over",
"width",
"width",
"with",
"alignment",
"a"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_asciiart.go#L132-L145 |
151,233 | br0xen/termbox-util | termbox_dropmenu.go | CreateDropMenu | func CreateDropMenu(title string, options []string, x, y, width, height int, fg, bg, cursorFg, cursorBg termbox.Attribute) *DropMenu {
c := DropMenu{
title: title,
x: x, y: y, width: width, height: height,
fg: fg, bg: bg, activeFg: fg, activeBg: bg,
cursorFg: fg, cursorBg: bg,
}
c.menu = CreateMenu("", options, x, y+2, width, height, fg, bg)
return &c
} | go | func CreateDropMenu(title string, options []string, x, y, width, height int, fg, bg, cursorFg, cursorBg termbox.Attribute) *DropMenu {
c := DropMenu{
title: title,
x: x, y: y, width: width, height: height,
fg: fg, bg: bg, activeFg: fg, activeBg: bg,
cursorFg: fg, cursorBg: bg,
}
c.menu = CreateMenu("", options, x, y+2, width, height, fg, bg)
return &c
} | [
"func",
"CreateDropMenu",
"(",
"title",
"string",
",",
"options",
"[",
"]",
"string",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
"int",
",",
"fg",
",",
"bg",
",",
"cursorFg",
",",
"cursorBg",
"termbox",
".",
"Attribute",
")",
"*",
"DropMenu",
"... | // CreateDropMenu Creates a menu with the specified attributes | [
"CreateDropMenu",
"Creates",
"a",
"menu",
"with",
"the",
"specified",
"attributes"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_dropmenu.go#L22-L31 |
151,234 | br0xen/termbox-util | termbox_dropmenu.go | SetBordered | func (c *DropMenu) SetBordered(b bool) {
c.bordered = b
c.menu.SetBordered(b)
} | go | func (c *DropMenu) SetBordered(b bool) {
c.bordered = b
c.menu.SetBordered(b)
} | [
"func",
"(",
"c",
"*",
"DropMenu",
")",
"SetBordered",
"(",
"b",
"bool",
")",
"{",
"c",
".",
"bordered",
"=",
"b",
"\n",
"c",
".",
"menu",
".",
"SetBordered",
"(",
"b",
")",
"\n",
"}"
] | // SetBordered sets the bordered flag | [
"SetBordered",
"sets",
"the",
"bordered",
"flag"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_dropmenu.go#L111-L114 |
151,235 | br0xen/termbox-util | termbox_dropmenu.go | Draw | func (c *DropMenu) Draw() {
// The title
ttlFg, ttlBg := c.fg, c.bg
if !c.menuSelected {
ttlFg, ttlBg = c.cursorFg, c.cursorBg
}
ttlTxt := c.title
if c.showMenu {
ttlTxt = ttlTxt + "-Showing Menu"
}
DrawStringAtPoint(AlignText(c.title, c.width, AlignLeft), c.x, c.y, ttlFg, ttlBg)
if c.showMenu {
c.menu.Draw()
}
} | go | func (c *DropMenu) Draw() {
// The title
ttlFg, ttlBg := c.fg, c.bg
if !c.menuSelected {
ttlFg, ttlBg = c.cursorFg, c.cursorBg
}
ttlTxt := c.title
if c.showMenu {
ttlTxt = ttlTxt + "-Showing Menu"
}
DrawStringAtPoint(AlignText(c.title, c.width, AlignLeft), c.x, c.y, ttlFg, ttlBg)
if c.showMenu {
c.menu.Draw()
}
} | [
"func",
"(",
"c",
"*",
"DropMenu",
")",
"Draw",
"(",
")",
"{",
"// The title",
"ttlFg",
",",
"ttlBg",
":=",
"c",
".",
"fg",
",",
"c",
".",
"bg",
"\n",
"if",
"!",
"c",
".",
"menuSelected",
"{",
"ttlFg",
",",
"ttlBg",
"=",
"c",
".",
"cursorFg",
"... | // Draw draws the menu | [
"Draw",
"draws",
"the",
"menu"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_dropmenu.go#L170-L184 |
151,236 | br0xen/termbox-util | termbox_inputfield.go | CreateInputField | func CreateInputField(x, y, w, h int, fg, bg termbox.Attribute) *InputField {
c := InputField{x: x, y: y, width: w, height: h,
fg: fg, bg: bg, cursorFg: bg, cursorBg: fg, activeFg: fg, activeBg: bg,
}
return &c
} | go | func CreateInputField(x, y, w, h int, fg, bg termbox.Attribute) *InputField {
c := InputField{x: x, y: y, width: w, height: h,
fg: fg, bg: bg, cursorFg: bg, cursorBg: fg, activeFg: fg, activeBg: bg,
}
return &c
} | [
"func",
"CreateInputField",
"(",
"x",
",",
"y",
",",
"w",
",",
"h",
"int",
",",
"fg",
",",
"bg",
"termbox",
".",
"Attribute",
")",
"*",
"InputField",
"{",
"c",
":=",
"InputField",
"{",
"x",
":",
"x",
",",
"y",
":",
"y",
",",
"width",
":",
"w",
... | // CreateInputField creates an input field at x, y that is w by h | [
"CreateInputField",
"creates",
"an",
"input",
"field",
"at",
"x",
"y",
"that",
"is",
"w",
"by",
"h"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_inputfield.go#L23-L28 |
151,237 | br0xen/termbox-util | termbox_label.go | CreateLabel | func CreateLabel(lbl string, x, y, w, h int, fg, bg termbox.Attribute) *Label {
c := Label{
value: lbl, x: x, y: y, width: w, height: h,
fg: fg, bg: bg, activeFg: fg, activeBg: bg,
}
return &c
} | go | func CreateLabel(lbl string, x, y, w, h int, fg, bg termbox.Attribute) *Label {
c := Label{
value: lbl, x: x, y: y, width: w, height: h,
fg: fg, bg: bg, activeFg: fg, activeBg: bg,
}
return &c
} | [
"func",
"CreateLabel",
"(",
"lbl",
"string",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
"int",
",",
"fg",
",",
"bg",
"termbox",
".",
"Attribute",
")",
"*",
"Label",
"{",
"c",
":=",
"Label",
"{",
"value",
":",
"lbl",
",",
"x",
":",
"x",
",",
"y",... | // CreateLabel creates an input field at x, y that is w by h | [
"CreateLabel",
"creates",
"an",
"input",
"field",
"at",
"x",
"y",
"that",
"is",
"w",
"by",
"h"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_label.go#L20-L26 |
151,238 | br0xen/termbox-util | termbox_label.go | GetWidth | func (c *Label) GetWidth() int {
if c.width == -1 {
if c.bordered {
return len(c.value) + 2
}
return len(c.value)
}
return c.width
} | go | func (c *Label) GetWidth() int {
if c.width == -1 {
if c.bordered {
return len(c.value) + 2
}
return len(c.value)
}
return c.width
} | [
"func",
"(",
"c",
"*",
"Label",
")",
"GetWidth",
"(",
")",
"int",
"{",
"if",
"c",
".",
"width",
"==",
"-",
"1",
"{",
"if",
"c",
".",
"bordered",
"{",
"return",
"len",
"(",
"c",
".",
"value",
")",
"+",
"2",
"\n",
"}",
"\n",
"return",
"len",
... | // GetWidth returns the current width of the input field | [
"GetWidth",
"returns",
"the",
"current",
"width",
"of",
"the",
"input",
"field"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_label.go#L64-L72 |
151,239 | br0xen/termbox-util | termbox_util.go | KeyIsAlpha | func KeyIsAlpha(event termbox.Event) bool {
k := event.Ch
if (k >= 'a' && k <= 'z') || (k >= 'A' && k <= 'Z') {
return true
}
return false
} | go | func KeyIsAlpha(event termbox.Event) bool {
k := event.Ch
if (k >= 'a' && k <= 'z') || (k >= 'A' && k <= 'Z') {
return true
}
return false
} | [
"func",
"KeyIsAlpha",
"(",
"event",
"termbox",
".",
"Event",
")",
"bool",
"{",
"k",
":=",
"event",
".",
"Ch",
"\n",
"if",
"(",
"k",
">=",
"'a'",
"&&",
"k",
"<=",
"'z'",
")",
"||",
"(",
"k",
">=",
"'A'",
"&&",
"k",
"<=",
"'Z'",
")",
"{",
"retu... | // KeyIsAlpha Returns whether the termbox event is a
// alphabetic Key press | [
"KeyIsAlpha",
"Returns",
"whether",
"the",
"termbox",
"event",
"is",
"a",
"alphabetic",
"Key",
"press"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_util.go#L59-L65 |
151,240 | br0xen/termbox-util | termbox_util.go | KeyIsSymbol | func KeyIsSymbol(event termbox.Event) bool {
symbols := []rune{'!', '@', '#', '$', '%', '^', '&', '*',
'(', ')', '-', '_', '=', '+', '[', ']', '{', '}', '|',
';', ':', '"', '\'', ',', '<', '.', '>', '/', '?', '`', '~'}
k := event.Ch
for i := range symbols {
if k == symbols[i] {
return true
}
}
return false
} | go | func KeyIsSymbol(event termbox.Event) bool {
symbols := []rune{'!', '@', '#', '$', '%', '^', '&', '*',
'(', ')', '-', '_', '=', '+', '[', ']', '{', '}', '|',
';', ':', '"', '\'', ',', '<', '.', '>', '/', '?', '`', '~'}
k := event.Ch
for i := range symbols {
if k == symbols[i] {
return true
}
}
return false
} | [
"func",
"KeyIsSymbol",
"(",
"event",
"termbox",
".",
"Event",
")",
"bool",
"{",
"symbols",
":=",
"[",
"]",
"rune",
"{",
"'!'",
",",
"'@'",
",",
"'#'",
",",
"'$'",
",",
"'%'",
",",
"'^'",
",",
"'&'",
",",
"'*'",
",",
"'('",
",",
"')'",
",",
"'-'... | // KeyIsSymbol Returns whether the termbox event is a
// symbol Key press | [
"KeyIsSymbol",
"Returns",
"whether",
"the",
"termbox",
"event",
"is",
"a",
"symbol",
"Key",
"press"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_util.go#L79-L90 |
151,241 | br0xen/termbox-util | termbox_util.go | FillWithChar | func FillWithChar(r rune, x1, y1, x2, y2 int, fg termbox.Attribute, bg termbox.Attribute) {
for xx := x1; xx <= x2; xx++ {
for yx := y1; yx <= y2; yx++ {
termbox.SetCell(xx, yx, r, fg, bg)
}
}
} | go | func FillWithChar(r rune, x1, y1, x2, y2 int, fg termbox.Attribute, bg termbox.Attribute) {
for xx := x1; xx <= x2; xx++ {
for yx := y1; yx <= y2; yx++ {
termbox.SetCell(xx, yx, r, fg, bg)
}
}
} | [
"func",
"FillWithChar",
"(",
"r",
"rune",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
"int",
",",
"fg",
"termbox",
".",
"Attribute",
",",
"bg",
"termbox",
".",
"Attribute",
")",
"{",
"for",
"xx",
":=",
"x1",
";",
"xx",
"<=",
"x2",
";",
"xx",
"+... | // FillWithChar Fills from x1,y1 through x2,y2 with the rune r, foreground color fg, background bg | [
"FillWithChar",
"Fills",
"from",
"x1",
"y1",
"through",
"x2",
"y2",
"with",
"the",
"rune",
"r",
"foreground",
"color",
"fg",
"background",
"bg"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_util.go#L105-L111 |
151,242 | br0xen/termbox-util | termbox_util.go | DrawBorder | func DrawBorder(x1, y1, x2, y2 int, fg, bg termbox.Attribute) {
termbox.SetCell(x1, y1, '╔', fg, bg)
FillWithChar('═', x1+1, y1, x2-1, y1, fg, bg)
termbox.SetCell(x2, y1, '╗', fg, bg)
FillWithChar('║', x1, y1+1, x1, y2-1, fg, bg)
FillWithChar('║', x2, y1+1, x2, y2-1, fg, bg)
termbox.SetCell(x1, y2, '╚', fg, bg)
FillWithChar('═', x1+1, y2, x2-1, y2, fg, bg)
termbox.SetCell(x2, y2, '╝', fg, bg)
} | go | func DrawBorder(x1, y1, x2, y2 int, fg, bg termbox.Attribute) {
termbox.SetCell(x1, y1, '╔', fg, bg)
FillWithChar('═', x1+1, y1, x2-1, y1, fg, bg)
termbox.SetCell(x2, y1, '╗', fg, bg)
FillWithChar('║', x1, y1+1, x1, y2-1, fg, bg)
FillWithChar('║', x2, y1+1, x2, y2-1, fg, bg)
termbox.SetCell(x1, y2, '╚', fg, bg)
FillWithChar('═', x1+1, y2, x2-1, y2, fg, bg)
termbox.SetCell(x2, y2, '╝', fg, bg)
} | [
"func",
"DrawBorder",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
"int",
",",
"fg",
",",
"bg",
"termbox",
".",
"Attribute",
")",
"{",
"termbox",
".",
"SetCell",
"(",
"x1",
",",
"y1",
",",
"'╔', ",
"f",
", ",
"b",
")",
"",
"\n",
"FillWithChar",
... | // DrawBorder Draw a border around the area inside x1,y1 -> x2, y2 | [
"DrawBorder",
"Draw",
"a",
"border",
"around",
"the",
"area",
"inside",
"x1",
"y1",
"-",
">",
"x2",
"y2"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_util.go#L114-L125 |
151,243 | br0xen/termbox-util | termbox_util.go | AlignText | func AlignText(txt string, width int, align TextAlignment) string {
return AlignTextWithFill(txt, width, align, ' ')
} | go | func AlignText(txt string, width int, align TextAlignment) string {
return AlignTextWithFill(txt, width, align, ' ')
} | [
"func",
"AlignText",
"(",
"txt",
"string",
",",
"width",
"int",
",",
"align",
"TextAlignment",
")",
"string",
"{",
"return",
"AlignTextWithFill",
"(",
"txt",
",",
"width",
",",
"align",
",",
"' '",
")",
"\n",
"}"
] | // AlignText Aligns the text txt within width characters using the specified alignment | [
"AlignText",
"Aligns",
"the",
"text",
"txt",
"within",
"width",
"characters",
"using",
"the",
"specified",
"alignment"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_util.go#L178-L180 |
151,244 | br0xen/termbox-util | termbox_util.go | AlignTextWithFill | func AlignTextWithFill(txt string, width int, align TextAlignment, fill rune) string {
fillChar := string(fill)
numSpaces := width - len(txt)
switch align {
case AlignCenter:
if numSpaces/2 > 0 {
return fmt.Sprintf("%s%s%s",
strings.Repeat(fillChar, numSpaces/2),
txt, strings.Repeat(fillChar, numSpaces/2),
)
}
return txt
case AlignRight:
return fmt.Sprintf("%s%s", strings.Repeat(fillChar, numSpaces), txt)
default:
if numSpaces >= 0 {
return fmt.Sprintf("%s%s", txt, strings.Repeat(fillChar, numSpaces))
}
return txt
}
} | go | func AlignTextWithFill(txt string, width int, align TextAlignment, fill rune) string {
fillChar := string(fill)
numSpaces := width - len(txt)
switch align {
case AlignCenter:
if numSpaces/2 > 0 {
return fmt.Sprintf("%s%s%s",
strings.Repeat(fillChar, numSpaces/2),
txt, strings.Repeat(fillChar, numSpaces/2),
)
}
return txt
case AlignRight:
return fmt.Sprintf("%s%s", strings.Repeat(fillChar, numSpaces), txt)
default:
if numSpaces >= 0 {
return fmt.Sprintf("%s%s", txt, strings.Repeat(fillChar, numSpaces))
}
return txt
}
} | [
"func",
"AlignTextWithFill",
"(",
"txt",
"string",
",",
"width",
"int",
",",
"align",
"TextAlignment",
",",
"fill",
"rune",
")",
"string",
"{",
"fillChar",
":=",
"string",
"(",
"fill",
")",
"\n",
"numSpaces",
":=",
"width",
"-",
"len",
"(",
"txt",
")",
... | // AlignTextWithFill Aligns the text txt within width characters using the specified alignment
// filling any spaces with the 'fill' character | [
"AlignTextWithFill",
"Aligns",
"the",
"text",
"txt",
"within",
"width",
"characters",
"using",
"the",
"specified",
"alignment",
"filling",
"any",
"spaces",
"with",
"the",
"fill",
"character"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_util.go#L184-L204 |
151,245 | br0xen/termbox-util | termbox_scrollframe.go | CreateScrollFrame | func CreateScrollFrame(x, y, w, h int, fg, bg termbox.Attribute) *ScrollFrame {
c := ScrollFrame{
x: x, y: y, width: w, height: h,
fg: fg, bg: bg, activeFg: fg, activeBg: bg,
}
return &c
} | go | func CreateScrollFrame(x, y, w, h int, fg, bg termbox.Attribute) *ScrollFrame {
c := ScrollFrame{
x: x, y: y, width: w, height: h,
fg: fg, bg: bg, activeFg: fg, activeBg: bg,
}
return &c
} | [
"func",
"CreateScrollFrame",
"(",
"x",
",",
"y",
",",
"w",
",",
"h",
"int",
",",
"fg",
",",
"bg",
"termbox",
".",
"Attribute",
")",
"*",
"ScrollFrame",
"{",
"c",
":=",
"ScrollFrame",
"{",
"x",
":",
"x",
",",
"y",
":",
"y",
",",
"width",
":",
"w... | // CreateScrollFrame creates Scrolling Frame at x, y that is w by h | [
"CreateScrollFrame",
"creates",
"Scrolling",
"Frame",
"at",
"x",
"y",
"that",
"is",
"w",
"by",
"h"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_scrollframe.go#L20-L26 |
151,246 | br0xen/termbox-util | termbox_scrollframe.go | IsVisible | func (c *ScrollFrame) IsVisible(t termboxControl) bool {
// Check if any part of t should be visible
cX, cY := t.GetX(), t.GetY()
if cX+t.GetWidth() >= c.scrollX && cX <= c.scrollX+c.width {
return cY+t.GetHeight() >= c.scrollY && cY <= c.scrollY+c.height
}
return false
} | go | func (c *ScrollFrame) IsVisible(t termboxControl) bool {
// Check if any part of t should be visible
cX, cY := t.GetX(), t.GetY()
if cX+t.GetWidth() >= c.scrollX && cX <= c.scrollX+c.width {
return cY+t.GetHeight() >= c.scrollY && cY <= c.scrollY+c.height
}
return false
} | [
"func",
"(",
"c",
"*",
"ScrollFrame",
")",
"IsVisible",
"(",
"t",
"termboxControl",
")",
"bool",
"{",
"// Check if any part of t should be visible",
"cX",
",",
"cY",
":=",
"t",
".",
"GetX",
"(",
")",
",",
"t",
".",
"GetY",
"(",
")",
"\n",
"if",
"cX",
"... | // IsVisible takes a Termbox Control and returns whether
// that control would be visible in the frame | [
"IsVisible",
"takes",
"a",
"Termbox",
"Control",
"and",
"returns",
"whether",
"that",
"control",
"would",
"be",
"visible",
"in",
"the",
"frame"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_scrollframe.go#L146-L153 |
151,247 | br0xen/termbox-util | termbox_inputmodal.go | CreateInputModal | func CreateInputModal(title string, x, y, width, height int, fg, bg termbox.Attribute) *InputModal {
c := InputModal{title: title, x: x, y: y, width: width, height: height, fg: fg, bg: bg, bordered: true}
c.input = CreateInputField(c.x+2, c.y+3, c.width-2, 2, c.fg, c.bg)
c.showHelp = true
c.input.bordered = true
c.isVisible = true
c.inputSelected = true
return &c
} | go | func CreateInputModal(title string, x, y, width, height int, fg, bg termbox.Attribute) *InputModal {
c := InputModal{title: title, x: x, y: y, width: width, height: height, fg: fg, bg: bg, bordered: true}
c.input = CreateInputField(c.x+2, c.y+3, c.width-2, 2, c.fg, c.bg)
c.showHelp = true
c.input.bordered = true
c.isVisible = true
c.inputSelected = true
return &c
} | [
"func",
"CreateInputModal",
"(",
"title",
"string",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
"int",
",",
"fg",
",",
"bg",
"termbox",
".",
"Attribute",
")",
"*",
"InputModal",
"{",
"c",
":=",
"InputModal",
"{",
"title",
":",
"title",
",",
"x",... | // CreateInputModal Create an input modal with the given attributes | [
"CreateInputModal",
"Create",
"an",
"input",
"modal",
"with",
"the",
"given",
"attributes"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_inputmodal.go#L28-L36 |
151,248 | br0xen/termbox-util | termbox_inputmodal.go | Clear | func (c *InputModal) Clear() {
c.title = ""
c.text = ""
c.input.SetValue("")
c.isDone = false
c.isVisible = false
} | go | func (c *InputModal) Clear() {
c.title = ""
c.text = ""
c.input.SetValue("")
c.isDone = false
c.isVisible = false
} | [
"func",
"(",
"c",
"*",
"InputModal",
")",
"Clear",
"(",
")",
"{",
"c",
".",
"title",
"=",
"\"",
"\"",
"\n",
"c",
".",
"text",
"=",
"\"",
"\"",
"\n",
"c",
".",
"input",
".",
"SetValue",
"(",
"\"",
"\"",
")",
"\n",
"c",
".",
"isDone",
"=",
"f... | // Clear Resets all non-positional parameters of the modal | [
"Clear",
"Resets",
"all",
"non",
"-",
"positional",
"parameters",
"of",
"the",
"modal"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_inputmodal.go#L197-L203 |
151,249 | br0xen/termbox-util | termbox_inputmodal.go | HandleEvent | func (c *InputModal) HandleEvent(event termbox.Event) bool {
if event.Key == termbox.KeyEnter {
if !c.input.IsMultiline() || !c.inputSelected {
// Done editing
c.isDone = true
c.isAccepted = true
} else {
c.input.HandleEvent(event)
}
return true
} else if event.Key == termbox.KeyTab {
if c.input.IsMultiline() {
c.inputSelected = !c.inputSelected
}
} else if event.Key == termbox.KeyEsc {
// Done editing
c.isDone = true
c.isAccepted = false
return true
}
return c.input.HandleEvent(event)
} | go | func (c *InputModal) HandleEvent(event termbox.Event) bool {
if event.Key == termbox.KeyEnter {
if !c.input.IsMultiline() || !c.inputSelected {
// Done editing
c.isDone = true
c.isAccepted = true
} else {
c.input.HandleEvent(event)
}
return true
} else if event.Key == termbox.KeyTab {
if c.input.IsMultiline() {
c.inputSelected = !c.inputSelected
}
} else if event.Key == termbox.KeyEsc {
// Done editing
c.isDone = true
c.isAccepted = false
return true
}
return c.input.HandleEvent(event)
} | [
"func",
"(",
"c",
"*",
"InputModal",
")",
"HandleEvent",
"(",
"event",
"termbox",
".",
"Event",
")",
"bool",
"{",
"if",
"event",
".",
"Key",
"==",
"termbox",
".",
"KeyEnter",
"{",
"if",
"!",
"c",
".",
"input",
".",
"IsMultiline",
"(",
")",
"||",
"!... | // HandleEvent Handle the termbox event, return true if it was consumed | [
"HandleEvent",
"Handle",
"the",
"termbox",
"event",
"return",
"true",
"if",
"it",
"was",
"consumed"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_inputmodal.go#L206-L227 |
151,250 | br0xen/termbox-util | termbox_inputmodal.go | Draw | func (c *InputModal) Draw() {
if c.isVisible {
// First blank out the area we'll be putting the modal
FillWithChar(' ', c.x, c.y, c.x+c.width, c.y+c.height, c.fg, c.bg)
nextY := c.y + 1
// The title
if c.title != "" {
if len(c.title) > c.width {
diff := c.width - len(c.title)
DrawStringAtPoint(c.title[:len(c.title)+diff-1], c.x+1, nextY, c.fg, c.bg)
} else {
DrawStringAtPoint(c.title, c.x+1, nextY, c.fg, c.bg)
}
nextY++
FillWithChar('-', c.x+1, nextY, c.x+c.width-1, nextY, c.fg, c.bg)
nextY++
}
if c.text != "" {
DrawStringAtPoint(c.text, c.x+1, nextY, c.fg, c.bg)
nextY++
}
c.input.SetY(nextY)
c.input.Draw()
nextY += 3
if c.showHelp {
helpString := " (ENTER) to Accept. (ESC) to Cancel. "
helpX := (c.x + c.width - len(helpString)) - 1
DrawStringAtPoint(helpString, helpX, nextY, c.fg, c.bg)
}
if c.bordered {
// Now draw the border
DrawBorder(c.x, c.y, c.x+c.width, c.y+c.height, c.fg, c.bg)
}
}
} | go | func (c *InputModal) Draw() {
if c.isVisible {
// First blank out the area we'll be putting the modal
FillWithChar(' ', c.x, c.y, c.x+c.width, c.y+c.height, c.fg, c.bg)
nextY := c.y + 1
// The title
if c.title != "" {
if len(c.title) > c.width {
diff := c.width - len(c.title)
DrawStringAtPoint(c.title[:len(c.title)+diff-1], c.x+1, nextY, c.fg, c.bg)
} else {
DrawStringAtPoint(c.title, c.x+1, nextY, c.fg, c.bg)
}
nextY++
FillWithChar('-', c.x+1, nextY, c.x+c.width-1, nextY, c.fg, c.bg)
nextY++
}
if c.text != "" {
DrawStringAtPoint(c.text, c.x+1, nextY, c.fg, c.bg)
nextY++
}
c.input.SetY(nextY)
c.input.Draw()
nextY += 3
if c.showHelp {
helpString := " (ENTER) to Accept. (ESC) to Cancel. "
helpX := (c.x + c.width - len(helpString)) - 1
DrawStringAtPoint(helpString, helpX, nextY, c.fg, c.bg)
}
if c.bordered {
// Now draw the border
DrawBorder(c.x, c.y, c.x+c.width, c.y+c.height, c.fg, c.bg)
}
}
} | [
"func",
"(",
"c",
"*",
"InputModal",
")",
"Draw",
"(",
")",
"{",
"if",
"c",
".",
"isVisible",
"{",
"// First blank out the area we'll be putting the modal",
"FillWithChar",
"(",
"' '",
",",
"c",
".",
"x",
",",
"c",
".",
"y",
",",
"c",
".",
"x",
"+",
"c... | // Draw Draw the modal | [
"Draw",
"Draw",
"the",
"modal"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_inputmodal.go#L230-L264 |
151,251 | br0xen/termbox-util | termbox_frame.go | CreateFrame | func CreateFrame(x, y, w, h int, fg, bg termbox.Attribute) *Frame {
c := Frame{x: x, y: y, width: w, height: h,
fg: fg, bg: bg, activeFg: fg, activeBg: bg,
bordered: true,
}
return &c
} | go | func CreateFrame(x, y, w, h int, fg, bg termbox.Attribute) *Frame {
c := Frame{x: x, y: y, width: w, height: h,
fg: fg, bg: bg, activeFg: fg, activeBg: bg,
bordered: true,
}
return &c
} | [
"func",
"CreateFrame",
"(",
"x",
",",
"y",
",",
"w",
",",
"h",
"int",
",",
"fg",
",",
"bg",
"termbox",
".",
"Attribute",
")",
"*",
"Frame",
"{",
"c",
":=",
"Frame",
"{",
"x",
":",
"x",
",",
"y",
":",
"y",
",",
"width",
":",
"w",
",",
"heigh... | // CreateFrame creates a Frame at x, y that is w by h | [
"CreateFrame",
"creates",
"a",
"Frame",
"at",
"x",
"y",
"that",
"is",
"w",
"by",
"h"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_frame.go#L21-L27 |
151,252 | br0xen/termbox-util | termbox_frame.go | SetActiveFgColor | func (c *Frame) SetActiveFgColor(fg termbox.Attribute) {
c.activeFg = fg
for _, v := range c.controls {
v.SetActiveFgColor(fg)
}
} | go | func (c *Frame) SetActiveFgColor(fg termbox.Attribute) {
c.activeFg = fg
for _, v := range c.controls {
v.SetActiveFgColor(fg)
}
} | [
"func",
"(",
"c",
"*",
"Frame",
")",
"SetActiveFgColor",
"(",
"fg",
"termbox",
".",
"Attribute",
")",
"{",
"c",
".",
"activeFg",
"=",
"fg",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"c",
".",
"controls",
"{",
"v",
".",
"SetActiveFgColor",
"(",
"fg... | // Setting color attributes on a frame trickles down to its controls | [
"Setting",
"color",
"attributes",
"on",
"a",
"frame",
"trickles",
"down",
"to",
"its",
"controls"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_frame.go#L32-L37 |
151,253 | br0xen/termbox-util | termbox_frame.go | GetActiveControl | func (c *Frame) GetActiveControl() termboxControl {
if len(c.controls) >= c.tabIdx {
if c.controls[c.tabIdx].IsTabSkipped() {
c.FindNextTabStop()
}
return c.controls[c.tabIdx]
}
return nil
} | go | func (c *Frame) GetActiveControl() termboxControl {
if len(c.controls) >= c.tabIdx {
if c.controls[c.tabIdx].IsTabSkipped() {
c.FindNextTabStop()
}
return c.controls[c.tabIdx]
}
return nil
} | [
"func",
"(",
"c",
"*",
"Frame",
")",
"GetActiveControl",
"(",
")",
"termboxControl",
"{",
"if",
"len",
"(",
"c",
".",
"controls",
")",
">=",
"c",
".",
"tabIdx",
"{",
"if",
"c",
".",
"controls",
"[",
"c",
".",
"tabIdx",
"]",
".",
"IsTabSkipped",
"("... | // GetActiveControl returns the control at tabIdx | [
"GetActiveControl",
"returns",
"the",
"control",
"at",
"tabIdx"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_frame.go#L145-L153 |
151,254 | br0xen/termbox-util | termbox_frame.go | GetControl | func (c *Frame) GetControl(idx int) termboxControl {
if len(c.controls) >= idx {
return c.controls[idx]
}
return nil
} | go | func (c *Frame) GetControl(idx int) termboxControl {
if len(c.controls) >= idx {
return c.controls[idx]
}
return nil
} | [
"func",
"(",
"c",
"*",
"Frame",
")",
"GetControl",
"(",
"idx",
"int",
")",
"termboxControl",
"{",
"if",
"len",
"(",
"c",
".",
"controls",
")",
">=",
"idx",
"{",
"return",
"c",
".",
"controls",
"[",
"idx",
"]",
"\n",
"}",
"\n",
"return",
"nil",
"\... | // GetControl returns the control at index i | [
"GetControl",
"returns",
"the",
"control",
"at",
"index",
"i"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_frame.go#L161-L166 |
151,255 | br0xen/termbox-util | termbox_frame.go | GetBottomY | func (c *Frame) GetBottomY() int {
var ret int
for idx := range c.controls {
if c.controls[idx].GetY()+c.controls[idx].GetHeight() > ret {
ret = c.controls[idx].GetY() + c.controls[idx].GetHeight()
}
}
return ret
} | go | func (c *Frame) GetBottomY() int {
var ret int
for idx := range c.controls {
if c.controls[idx].GetY()+c.controls[idx].GetHeight() > ret {
ret = c.controls[idx].GetY() + c.controls[idx].GetHeight()
}
}
return ret
} | [
"func",
"(",
"c",
"*",
"Frame",
")",
"GetBottomY",
"(",
")",
"int",
"{",
"var",
"ret",
"int",
"\n",
"for",
"idx",
":=",
"range",
"c",
".",
"controls",
"{",
"if",
"c",
".",
"controls",
"[",
"idx",
"]",
".",
"GetY",
"(",
")",
"+",
"c",
".",
"co... | // GetBottomY returns the y of the lowest control in the frame | [
"GetBottomY",
"returns",
"the",
"y",
"of",
"the",
"lowest",
"control",
"in",
"the",
"frame"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_frame.go#L195-L203 |
151,256 | br0xen/termbox-util | termbox_frame.go | FindNextTabStop | func (c *Frame) FindNextTabStop() bool {
startTab := c.tabIdx
c.tabIdx = (c.tabIdx + 1) % len(c.controls)
for c.controls[c.tabIdx].IsTabSkipped() {
c.tabIdx = (c.tabIdx + 1) % len(c.controls)
if c.tabIdx == startTab {
break
}
}
return c.tabIdx != startTab
} | go | func (c *Frame) FindNextTabStop() bool {
startTab := c.tabIdx
c.tabIdx = (c.tabIdx + 1) % len(c.controls)
for c.controls[c.tabIdx].IsTabSkipped() {
c.tabIdx = (c.tabIdx + 1) % len(c.controls)
if c.tabIdx == startTab {
break
}
}
return c.tabIdx != startTab
} | [
"func",
"(",
"c",
"*",
"Frame",
")",
"FindNextTabStop",
"(",
")",
"bool",
"{",
"startTab",
":=",
"c",
".",
"tabIdx",
"\n",
"c",
".",
"tabIdx",
"=",
"(",
"c",
".",
"tabIdx",
"+",
"1",
")",
"%",
"len",
"(",
"c",
".",
"controls",
")",
"\n",
"for",... | // FindNextTabStop finds the next control that can be tabbed to
// A return of true means it found a different one than we started on. | [
"FindNextTabStop",
"finds",
"the",
"next",
"control",
"that",
"can",
"be",
"tabbed",
"to",
"A",
"return",
"of",
"true",
"means",
"it",
"found",
"a",
"different",
"one",
"than",
"we",
"started",
"on",
"."
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_frame.go#L216-L226 |
151,257 | br0xen/termbox-util | termbox_frame.go | IsOnLastControl | func (c *Frame) IsOnLastControl() bool {
for _, v := range c.controls[c.tabIdx+1:] {
if !v.IsTabSkipped() {
return false
}
}
return true
} | go | func (c *Frame) IsOnLastControl() bool {
for _, v := range c.controls[c.tabIdx+1:] {
if !v.IsTabSkipped() {
return false
}
}
return true
} | [
"func",
"(",
"c",
"*",
"Frame",
")",
"IsOnLastControl",
"(",
")",
"bool",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"c",
".",
"controls",
"[",
"c",
".",
"tabIdx",
"+",
"1",
":",
"]",
"{",
"if",
"!",
"v",
".",
"IsTabSkipped",
"(",
")",
"{",
"r... | // IsOnLastControl returns true if the active control
// is the last control that isn't tab skippable. | [
"IsOnLastControl",
"returns",
"true",
"if",
"the",
"active",
"control",
"is",
"the",
"last",
"control",
"that",
"isn",
"t",
"tab",
"skippable",
"."
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_frame.go#L230-L237 |
151,258 | br0xen/termbox-util | termbox_alertmodal.go | CreateAlertModal | func CreateAlertModal(title string, x, y, width, height int, fg, bg termbox.Attribute) *AlertModal {
i := AlertModal{title: title, x: x, y: y, width: width, height: height, fg: fg, bg: bg, bordered: true}
i.activeFg, i.activeBg = fg, bg
if i.title == "" {
i.title = "Alert!"
}
i.showHelp = true
return &i
} | go | func CreateAlertModal(title string, x, y, width, height int, fg, bg termbox.Attribute) *AlertModal {
i := AlertModal{title: title, x: x, y: y, width: width, height: height, fg: fg, bg: bg, bordered: true}
i.activeFg, i.activeBg = fg, bg
if i.title == "" {
i.title = "Alert!"
}
i.showHelp = true
return &i
} | [
"func",
"CreateAlertModal",
"(",
"title",
"string",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
"int",
",",
"fg",
",",
"bg",
"termbox",
".",
"Attribute",
")",
"*",
"AlertModal",
"{",
"i",
":=",
"AlertModal",
"{",
"title",
":",
"title",
",",
"x",... | // CreateAlertModal Creates a confirmation modal with the specified attributes | [
"CreateAlertModal",
"Creates",
"a",
"confirmation",
"modal",
"with",
"the",
"specified",
"attributes"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_alertmodal.go#L27-L35 |
151,259 | br0xen/termbox-util | termbox_menu.go | CreateMenu | func CreateMenu(title string, options []string, x, y, width, height int, fg, bg termbox.Attribute) *Menu {
c := Menu{
title: title,
x: x, y: y, width: width, height: height,
fg: fg, bg: bg, selectedFg: bg, selectedBg: fg,
disabledFg: bg, disabledBg: bg,
activeFg: fg, activeBg: bg,
bordered: true,
}
for _, line := range options {
c.options = append(c.options, MenuOption{text: line})
}
if len(c.options) > 0 {
c.SetSelectedOption(&c.options[0])
}
return &c
} | go | func CreateMenu(title string, options []string, x, y, width, height int, fg, bg termbox.Attribute) *Menu {
c := Menu{
title: title,
x: x, y: y, width: width, height: height,
fg: fg, bg: bg, selectedFg: bg, selectedBg: fg,
disabledFg: bg, disabledBg: bg,
activeFg: fg, activeBg: bg,
bordered: true,
}
for _, line := range options {
c.options = append(c.options, MenuOption{text: line})
}
if len(c.options) > 0 {
c.SetSelectedOption(&c.options[0])
}
return &c
} | [
"func",
"CreateMenu",
"(",
"title",
"string",
",",
"options",
"[",
"]",
"string",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
"int",
",",
"fg",
",",
"bg",
"termbox",
".",
"Attribute",
")",
"*",
"Menu",
"{",
"c",
":=",
"Menu",
"{",
"title",
"... | // CreateMenu Creates a menu with the specified attributes | [
"CreateMenu",
"Creates",
"a",
"menu",
"with",
"the",
"specified",
"attributes"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_menu.go#L26-L42 |
151,260 | br0xen/termbox-util | termbox_menu.go | SetOptionsFromStrings | func (c *Menu) SetOptionsFromStrings(opts []string) {
var newOpts []MenuOption
for _, v := range opts {
newOpts = append(newOpts, *CreateOptionFromText(v))
}
c.SetOptions(newOpts)
c.SetSelectedOption(c.GetOptionFromIndex(0))
} | go | func (c *Menu) SetOptionsFromStrings(opts []string) {
var newOpts []MenuOption
for _, v := range opts {
newOpts = append(newOpts, *CreateOptionFromText(v))
}
c.SetOptions(newOpts)
c.SetSelectedOption(c.GetOptionFromIndex(0))
} | [
"func",
"(",
"c",
"*",
"Menu",
")",
"SetOptionsFromStrings",
"(",
"opts",
"[",
"]",
"string",
")",
"{",
"var",
"newOpts",
"[",
"]",
"MenuOption",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"opts",
"{",
"newOpts",
"=",
"append",
"(",
"newOpts",
",",
... | // SetOptionsFromStrings sets the options of this menu from a slice of strings | [
"SetOptionsFromStrings",
"sets",
"the",
"options",
"of",
"this",
"menu",
"from",
"a",
"slice",
"of",
"strings"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_menu.go#L83-L90 |
151,261 | br0xen/termbox-util | termbox_menu.go | GetSelectedOption | func (c *Menu) GetSelectedOption() *MenuOption {
idx := c.GetSelectedIndex()
if idx != -1 {
return &c.options[idx]
}
return nil
} | go | func (c *Menu) GetSelectedOption() *MenuOption {
idx := c.GetSelectedIndex()
if idx != -1 {
return &c.options[idx]
}
return nil
} | [
"func",
"(",
"c",
"*",
"Menu",
")",
"GetSelectedOption",
"(",
")",
"*",
"MenuOption",
"{",
"idx",
":=",
"c",
".",
"GetSelectedIndex",
"(",
")",
"\n",
"if",
"idx",
"!=",
"-",
"1",
"{",
"return",
"&",
"c",
".",
"options",
"[",
"idx",
"]",
"\n",
"}"... | // GetSelectedOption returns the current selected option | [
"GetSelectedOption",
"returns",
"the",
"current",
"selected",
"option"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_menu.go#L125-L131 |
151,262 | br0xen/termbox-util | termbox_menu.go | GetOptionFromIndex | func (c *Menu) GetOptionFromIndex(idx int) *MenuOption {
if idx >= 0 && idx < len(c.options) {
return &c.options[idx]
}
return nil
} | go | func (c *Menu) GetOptionFromIndex(idx int) *MenuOption {
if idx >= 0 && idx < len(c.options) {
return &c.options[idx]
}
return nil
} | [
"func",
"(",
"c",
"*",
"Menu",
")",
"GetOptionFromIndex",
"(",
"idx",
"int",
")",
"*",
"MenuOption",
"{",
"if",
"idx",
">=",
"0",
"&&",
"idx",
"<",
"len",
"(",
"c",
".",
"options",
")",
"{",
"return",
"&",
"c",
".",
"options",
"[",
"idx",
"]",
... | // GetOptionFromIndex Returns the | [
"GetOptionFromIndex",
"Returns",
"the"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_menu.go#L134-L139 |
151,263 | br0xen/termbox-util | termbox_menu.go | GetOptionFromText | func (c *Menu) GetOptionFromText(v string) *MenuOption {
for idx := range c.options {
testOption := &c.options[idx]
if testOption.GetText() == v {
return testOption
}
}
return nil
} | go | func (c *Menu) GetOptionFromText(v string) *MenuOption {
for idx := range c.options {
testOption := &c.options[idx]
if testOption.GetText() == v {
return testOption
}
}
return nil
} | [
"func",
"(",
"c",
"*",
"Menu",
")",
"GetOptionFromText",
"(",
"v",
"string",
")",
"*",
"MenuOption",
"{",
"for",
"idx",
":=",
"range",
"c",
".",
"options",
"{",
"testOption",
":=",
"&",
"c",
".",
"options",
"[",
"idx",
"]",
"\n",
"if",
"testOption",
... | // GetOptionFromText Returns the first option with the text v | [
"GetOptionFromText",
"Returns",
"the",
"first",
"option",
"with",
"the",
"text",
"v"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_menu.go#L142-L150 |
151,264 | br0xen/termbox-util | termbox_menu.go | GetSelectedIndex | func (c *Menu) GetSelectedIndex() int {
for idx := range c.options {
if c.options[idx].IsSelected() {
return idx
}
}
return -1
} | go | func (c *Menu) GetSelectedIndex() int {
for idx := range c.options {
if c.options[idx].IsSelected() {
return idx
}
}
return -1
} | [
"func",
"(",
"c",
"*",
"Menu",
")",
"GetSelectedIndex",
"(",
")",
"int",
"{",
"for",
"idx",
":=",
"range",
"c",
".",
"options",
"{",
"if",
"c",
".",
"options",
"[",
"idx",
"]",
".",
"IsSelected",
"(",
")",
"{",
"return",
"idx",
"\n",
"}",
"\n",
... | // GetSelectedIndex returns the index of the selected option
// Returns -1 if nothing is selected | [
"GetSelectedIndex",
"returns",
"the",
"index",
"of",
"the",
"selected",
"option",
"Returns",
"-",
"1",
"if",
"nothing",
"is",
"selected"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_menu.go#L154-L161 |
151,265 | br0xen/termbox-util | termbox_menu.go | SetSelectedIndex | func (c *Menu) SetSelectedIndex(idx int) {
if len(c.options) > 0 {
if idx < 0 {
idx = 0
} else if idx >= len(c.options) {
idx = len(c.options) - 1
}
c.SetSelectedOption(&c.options[idx])
}
} | go | func (c *Menu) SetSelectedIndex(idx int) {
if len(c.options) > 0 {
if idx < 0 {
idx = 0
} else if idx >= len(c.options) {
idx = len(c.options) - 1
}
c.SetSelectedOption(&c.options[idx])
}
} | [
"func",
"(",
"c",
"*",
"Menu",
")",
"SetSelectedIndex",
"(",
"idx",
"int",
")",
"{",
"if",
"len",
"(",
"c",
".",
"options",
")",
">",
"0",
"{",
"if",
"idx",
"<",
"0",
"{",
"idx",
"=",
"0",
"\n",
"}",
"else",
"if",
"idx",
">=",
"len",
"(",
"... | // SetSelectedIndex sets the selection to setIdx | [
"SetSelectedIndex",
"sets",
"the",
"selection",
"to",
"setIdx"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_menu.go#L164-L173 |
151,266 | br0xen/termbox-util | termbox_menu.go | SelectPageUpOption | func (c *Menu) SelectPageUpOption() {
idx := c.GetSelectedIndex()
idx -= c.height
if idx < 0 {
idx = 0
}
c.SetSelectedIndex(idx)
return
} | go | func (c *Menu) SelectPageUpOption() {
idx := c.GetSelectedIndex()
idx -= c.height
if idx < 0 {
idx = 0
}
c.SetSelectedIndex(idx)
return
} | [
"func",
"(",
"c",
"*",
"Menu",
")",
"SelectPageUpOption",
"(",
")",
"{",
"idx",
":=",
"c",
".",
"GetSelectedIndex",
"(",
")",
"\n",
"idx",
"-=",
"c",
".",
"height",
"\n",
"if",
"idx",
"<",
"0",
"{",
"idx",
"=",
"0",
"\n",
"}",
"\n",
"c",
".",
... | // SelectPageUpOption Goes up 'menu height' options | [
"SelectPageUpOption",
"Goes",
"up",
"menu",
"height",
"options"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_menu.go#L213-L221 |
151,267 | br0xen/termbox-util | termbox_menu.go | SelectPageDownOption | func (c *Menu) SelectPageDownOption() {
idx := c.GetSelectedIndex()
idx += c.height
if idx >= len(c.options) {
idx = len(c.options) - 1
}
c.SetSelectedIndex(idx)
return
} | go | func (c *Menu) SelectPageDownOption() {
idx := c.GetSelectedIndex()
idx += c.height
if idx >= len(c.options) {
idx = len(c.options) - 1
}
c.SetSelectedIndex(idx)
return
} | [
"func",
"(",
"c",
"*",
"Menu",
")",
"SelectPageDownOption",
"(",
")",
"{",
"idx",
":=",
"c",
".",
"GetSelectedIndex",
"(",
")",
"\n",
"idx",
"+=",
"c",
".",
"height",
"\n",
"if",
"idx",
">=",
"len",
"(",
"c",
".",
"options",
")",
"{",
"idx",
"=",... | // SelectPageDownOption Goes down 'menu height' options | [
"SelectPageDownOption",
"Goes",
"down",
"menu",
"height",
"options"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_menu.go#L224-L232 |
151,268 | br0xen/termbox-util | termbox_menu.go | SetOptionDisabled | func (c *Menu) SetOptionDisabled(idx int) {
if len(c.options) > idx {
c.GetOptionFromIndex(idx).Disable()
}
} | go | func (c *Menu) SetOptionDisabled(idx int) {
if len(c.options) > idx {
c.GetOptionFromIndex(idx).Disable()
}
} | [
"func",
"(",
"c",
"*",
"Menu",
")",
"SetOptionDisabled",
"(",
"idx",
"int",
")",
"{",
"if",
"len",
"(",
"c",
".",
"options",
")",
">",
"idx",
"{",
"c",
".",
"GetOptionFromIndex",
"(",
"idx",
")",
".",
"Disable",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // SetOptionDisabled Disables the specified option | [
"SetOptionDisabled",
"Disables",
"the",
"specified",
"option"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_menu.go#L247-L251 |
151,269 | br0xen/termbox-util | termbox_menu.go | SetOptionEnabled | func (c *Menu) SetOptionEnabled(idx int) {
if len(c.options) > idx {
c.GetOptionFromIndex(idx).Enable()
}
} | go | func (c *Menu) SetOptionEnabled(idx int) {
if len(c.options) > idx {
c.GetOptionFromIndex(idx).Enable()
}
} | [
"func",
"(",
"c",
"*",
"Menu",
")",
"SetOptionEnabled",
"(",
"idx",
"int",
")",
"{",
"if",
"len",
"(",
"c",
".",
"options",
")",
">",
"idx",
"{",
"c",
".",
"GetOptionFromIndex",
"(",
"idx",
")",
".",
"Enable",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // SetOptionEnabled Enables the specified option | [
"SetOptionEnabled",
"Enables",
"the",
"specified",
"option"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_menu.go#L254-L258 |
151,270 | br0xen/termbox-util | termbox_menu.go | AddToSubMenu | func (c *MenuOption) AddToSubMenu(sub *MenuOption) {
c.subMenu = append(c.subMenu, *sub)
} | go | func (c *MenuOption) AddToSubMenu(sub *MenuOption) {
c.subMenu = append(c.subMenu, *sub)
} | [
"func",
"(",
"c",
"*",
"MenuOption",
")",
"AddToSubMenu",
"(",
"sub",
"*",
"MenuOption",
")",
"{",
"c",
".",
"subMenu",
"=",
"append",
"(",
"c",
".",
"subMenu",
",",
"*",
"sub",
")",
"\n",
"}"
] | // AddToSubMenu adds a slice of MenuOptions to this option | [
"AddToSubMenu",
"adds",
"a",
"slice",
"of",
"MenuOptions",
"to",
"this",
"option"
] | c168c0df31ca080a787dbb4b5ca341517cd07499 | https://github.com/br0xen/termbox-util/blob/c168c0df31ca080a787dbb4b5ca341517cd07499/termbox_menu.go#L513-L515 |
151,271 | basho/riak-go-client | logging.go | logDebug | func logDebug(source, format string, v ...interface{}) {
if EnableDebugLogging {
stdLogger.Printf(fmt.Sprintf("[DEBUG] %s %s", source, format), v...)
}
} | go | func logDebug(source, format string, v ...interface{}) {
if EnableDebugLogging {
stdLogger.Printf(fmt.Sprintf("[DEBUG] %s %s", source, format), v...)
}
} | [
"func",
"logDebug",
"(",
"source",
",",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"EnableDebugLogging",
"{",
"stdLogger",
".",
"Printf",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"source",
",",
"format",
")",
... | // logDebug writes formatted string debug messages using Printf only if debug logging is enabled | [
"logDebug",
"writes",
"formatted",
"string",
"debug",
"messages",
"using",
"Printf",
"only",
"if",
"debug",
"logging",
"is",
"enabled"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/logging.go#L49-L53 |
151,272 | basho/riak-go-client | logging.go | logWarn | func logWarn(source, format string, v ...interface{}) {
stdLogger.Printf(fmt.Sprintf("[WARNING] %s %s", source, format), v...)
} | go | func logWarn(source, format string, v ...interface{}) {
stdLogger.Printf(fmt.Sprintf("[WARNING] %s %s", source, format), v...)
} | [
"func",
"logWarn",
"(",
"source",
",",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"stdLogger",
".",
"Printf",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"source",
",",
"format",
")",
",",
"v",
"...",
")",
"\n",
"... | // logWarn writes formatted string warning messages using Printf | [
"logWarn",
"writes",
"formatted",
"string",
"warning",
"messages",
"using",
"Printf"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/logging.go#L63-L65 |
151,273 | basho/riak-go-client | logging.go | logError | func logError(source, format string, v ...interface{}) {
errLogger.Printf(fmt.Sprintf("[ERROR] %s %s", source, format), v...)
} | go | func logError(source, format string, v ...interface{}) {
errLogger.Printf(fmt.Sprintf("[ERROR] %s %s", source, format), v...)
} | [
"func",
"logError",
"(",
"source",
",",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"errLogger",
".",
"Printf",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"source",
",",
"format",
")",
",",
"v",
"...",
")",
"\n",
... | // logError writes formatted string error messages using Printf | [
"logError",
"writes",
"formatted",
"string",
"error",
"messages",
"using",
"Printf"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/logging.go#L73-L75 |
151,274 | basho/riak-go-client | ts_commands.go | GetDataType | func (c *TsCell) GetDataType() string {
var dType string
switch {
case c.cell.VarcharValue != nil:
switch c.columnType {
case riak_ts.TsColumnType_VARCHAR:
dType = riak_ts.TsColumnType_VARCHAR.String()
case riak_ts.TsColumnType_BLOB:
dType = riak_ts.TsColumnType_BLOB.String()
default:
dType = riak_ts.TsColumnType_VARCHAR.String()
}
case c.cell.Sint64Value != nil:
dType = riak_ts.TsColumnType_SINT64.String()
case c.cell.TimestampValue != nil:
dType = riak_ts.TsColumnType_TIMESTAMP.String()
case c.cell.BooleanValue != nil:
dType = riak_ts.TsColumnType_BOOLEAN.String()
case c.cell.DoubleValue != nil:
dType = riak_ts.TsColumnType_DOUBLE.String()
}
return dType
} | go | func (c *TsCell) GetDataType() string {
var dType string
switch {
case c.cell.VarcharValue != nil:
switch c.columnType {
case riak_ts.TsColumnType_VARCHAR:
dType = riak_ts.TsColumnType_VARCHAR.String()
case riak_ts.TsColumnType_BLOB:
dType = riak_ts.TsColumnType_BLOB.String()
default:
dType = riak_ts.TsColumnType_VARCHAR.String()
}
case c.cell.Sint64Value != nil:
dType = riak_ts.TsColumnType_SINT64.String()
case c.cell.TimestampValue != nil:
dType = riak_ts.TsColumnType_TIMESTAMP.String()
case c.cell.BooleanValue != nil:
dType = riak_ts.TsColumnType_BOOLEAN.String()
case c.cell.DoubleValue != nil:
dType = riak_ts.TsColumnType_DOUBLE.String()
}
return dType
} | [
"func",
"(",
"c",
"*",
"TsCell",
")",
"GetDataType",
"(",
")",
"string",
"{",
"var",
"dType",
"string",
"\n",
"switch",
"{",
"case",
"c",
".",
"cell",
".",
"VarcharValue",
"!=",
"nil",
":",
"switch",
"c",
".",
"columnType",
"{",
"case",
"riak_ts",
".... | // GetDataType returns the data type of the value stored within the cell | [
"GetDataType",
"returns",
"the",
"data",
"type",
"of",
"the",
"value",
"stored",
"within",
"the",
"cell"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/ts_commands.go#L34-L57 |
151,275 | basho/riak-go-client | ts_commands.go | GetTimeValue | func (c *TsCell) GetTimeValue() time.Time {
ts := c.cell.GetTimestampValue()
s := ts / int64(1000)
ms := time.Duration(ts%int64(1000)) * time.Millisecond
return time.Unix(s, ms.Nanoseconds())
} | go | func (c *TsCell) GetTimeValue() time.Time {
ts := c.cell.GetTimestampValue()
s := ts / int64(1000)
ms := time.Duration(ts%int64(1000)) * time.Millisecond
return time.Unix(s, ms.Nanoseconds())
} | [
"func",
"(",
"c",
"*",
"TsCell",
")",
"GetTimeValue",
"(",
")",
"time",
".",
"Time",
"{",
"ts",
":=",
"c",
".",
"cell",
".",
"GetTimestampValue",
"(",
")",
"\n",
"s",
":=",
"ts",
"/",
"int64",
"(",
"1000",
")",
"\n",
"ms",
":=",
"time",
".",
"D... | // GetTimeValue returns the timestamp value stored within the cell as a time.Time | [
"GetTimeValue",
"returns",
"the",
"timestamp",
"value",
"stored",
"within",
"the",
"cell",
"as",
"a",
"time",
".",
"Time"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/ts_commands.go#L85-L90 |
151,276 | basho/riak-go-client | ts_commands.go | NewStringTsCell | func NewStringTsCell(v string) TsCell {
tsc := riak_ts.TsCell{VarcharValue: []byte(v)}
tsct := riak_ts.TsColumnType_VARCHAR
return TsCell{columnType: tsct, cell: &tsc}
} | go | func NewStringTsCell(v string) TsCell {
tsc := riak_ts.TsCell{VarcharValue: []byte(v)}
tsct := riak_ts.TsColumnType_VARCHAR
return TsCell{columnType: tsct, cell: &tsc}
} | [
"func",
"NewStringTsCell",
"(",
"v",
"string",
")",
"TsCell",
"{",
"tsc",
":=",
"riak_ts",
".",
"TsCell",
"{",
"VarcharValue",
":",
"[",
"]",
"byte",
"(",
"v",
")",
"}",
"\n",
"tsct",
":=",
"riak_ts",
".",
"TsColumnType_VARCHAR",
"\n",
"return",
"TsCell"... | // NewStringTsCell creates a TsCell from a string | [
"NewStringTsCell",
"creates",
"a",
"TsCell",
"from",
"a",
"string"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/ts_commands.go#L103-L107 |
151,277 | basho/riak-go-client | ts_commands.go | NewBooleanTsCell | func NewBooleanTsCell(v bool) TsCell {
tsc := riak_ts.TsCell{BooleanValue: &v}
tsct := riak_ts.TsColumnType_BOOLEAN
return TsCell{columnType: tsct, cell: &tsc}
} | go | func NewBooleanTsCell(v bool) TsCell {
tsc := riak_ts.TsCell{BooleanValue: &v}
tsct := riak_ts.TsColumnType_BOOLEAN
return TsCell{columnType: tsct, cell: &tsc}
} | [
"func",
"NewBooleanTsCell",
"(",
"v",
"bool",
")",
"TsCell",
"{",
"tsc",
":=",
"riak_ts",
".",
"TsCell",
"{",
"BooleanValue",
":",
"&",
"v",
"}",
"\n",
"tsct",
":=",
"riak_ts",
".",
"TsColumnType_BOOLEAN",
"\n",
"return",
"TsCell",
"{",
"columnType",
":",
... | // NewBooleanTsCell creates a TsCell from a boolean | [
"NewBooleanTsCell",
"creates",
"a",
"TsCell",
"from",
"a",
"boolean"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/ts_commands.go#L117-L121 |
151,278 | basho/riak-go-client | ts_commands.go | NewDoubleTsCell | func NewDoubleTsCell(v float64) TsCell {
tsc := riak_ts.TsCell{DoubleValue: &v}
tsct := riak_ts.TsColumnType_DOUBLE
return TsCell{columnType: tsct, cell: &tsc}
} | go | func NewDoubleTsCell(v float64) TsCell {
tsc := riak_ts.TsCell{DoubleValue: &v}
tsct := riak_ts.TsColumnType_DOUBLE
return TsCell{columnType: tsct, cell: &tsc}
} | [
"func",
"NewDoubleTsCell",
"(",
"v",
"float64",
")",
"TsCell",
"{",
"tsc",
":=",
"riak_ts",
".",
"TsCell",
"{",
"DoubleValue",
":",
"&",
"v",
"}",
"\n",
"tsct",
":=",
"riak_ts",
".",
"TsColumnType_DOUBLE",
"\n",
"return",
"TsCell",
"{",
"columnType",
":",
... | // NewDoubleTsCell creates a TsCell from an floating point number | [
"NewDoubleTsCell",
"creates",
"a",
"TsCell",
"from",
"an",
"floating",
"point",
"number"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/ts_commands.go#L124-L128 |
151,279 | basho/riak-go-client | ts_commands.go | NewSint64TsCell | func NewSint64TsCell(v int64) TsCell {
tsc := riak_ts.TsCell{Sint64Value: &v}
tsct := riak_ts.TsColumnType_SINT64
return TsCell{columnType: tsct, cell: &tsc}
} | go | func NewSint64TsCell(v int64) TsCell {
tsc := riak_ts.TsCell{Sint64Value: &v}
tsct := riak_ts.TsColumnType_SINT64
return TsCell{columnType: tsct, cell: &tsc}
} | [
"func",
"NewSint64TsCell",
"(",
"v",
"int64",
")",
"TsCell",
"{",
"tsc",
":=",
"riak_ts",
".",
"TsCell",
"{",
"Sint64Value",
":",
"&",
"v",
"}",
"\n",
"tsct",
":=",
"riak_ts",
".",
"TsColumnType_SINT64",
"\n",
"return",
"TsCell",
"{",
"columnType",
":",
... | // NewSint64TsCell creates a TsCell from an integer | [
"NewSint64TsCell",
"creates",
"a",
"TsCell",
"from",
"an",
"integer"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/ts_commands.go#L131-L135 |
151,280 | basho/riak-go-client | ts_commands.go | NewTimestampTsCell | func NewTimestampTsCell(t time.Time) TsCell {
v := ToUnixMillis(t)
tsc := riak_ts.TsCell{TimestampValue: &v}
tsct := riak_ts.TsColumnType_TIMESTAMP
return TsCell{columnType: tsct, cell: &tsc}
} | go | func NewTimestampTsCell(t time.Time) TsCell {
v := ToUnixMillis(t)
tsc := riak_ts.TsCell{TimestampValue: &v}
tsct := riak_ts.TsColumnType_TIMESTAMP
return TsCell{columnType: tsct, cell: &tsc}
} | [
"func",
"NewTimestampTsCell",
"(",
"t",
"time",
".",
"Time",
")",
"TsCell",
"{",
"v",
":=",
"ToUnixMillis",
"(",
"t",
")",
"\n",
"tsc",
":=",
"riak_ts",
".",
"TsCell",
"{",
"TimestampValue",
":",
"&",
"v",
"}",
"\n",
"tsct",
":=",
"riak_ts",
".",
"Ts... | // NewTimestampTsCell creates a TsCell from a time.Time struct | [
"NewTimestampTsCell",
"creates",
"a",
"TsCell",
"from",
"a",
"time",
".",
"Time",
"struct"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/ts_commands.go#L138-L143 |
151,281 | basho/riak-go-client | ts_commands.go | ToUnixMillis | func ToUnixMillis(t time.Time) int64 {
return t.UnixNano() / (int64(time.Millisecond) / int64(time.Nanosecond))
} | go | func ToUnixMillis(t time.Time) int64 {
return t.UnixNano() / (int64(time.Millisecond) / int64(time.Nanosecond))
} | [
"func",
"ToUnixMillis",
"(",
"t",
"time",
".",
"Time",
")",
"int64",
"{",
"return",
"t",
".",
"UnixNano",
"(",
")",
"/",
"(",
"int64",
"(",
"time",
".",
"Millisecond",
")",
"/",
"int64",
"(",
"time",
".",
"Nanosecond",
")",
")",
"\n",
"}"
] | // ToUnixMillis converts a time.Time to Unix milliseconds since UTC epoch | [
"ToUnixMillis",
"converts",
"a",
"time",
".",
"Time",
"to",
"Unix",
"milliseconds",
"since",
"UTC",
"epoch"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/ts_commands.go#L154-L156 |
151,282 | basho/riak-go-client | ts_commands.go | GetType | func (c *TsColumnDescription) GetType() string {
return riak_ts.TsColumnType_name[int32(c.column.GetType())]
} | go | func (c *TsColumnDescription) GetType() string {
return riak_ts.TsColumnType_name[int32(c.column.GetType())]
} | [
"func",
"(",
"c",
"*",
"TsColumnDescription",
")",
"GetType",
"(",
")",
"string",
"{",
"return",
"riak_ts",
".",
"TsColumnType_name",
"[",
"int32",
"(",
"c",
".",
"column",
".",
"GetType",
"(",
")",
")",
"]",
"\n",
"}"
] | // GetType returns the data type for the column | [
"GetType",
"returns",
"the",
"data",
"type",
"for",
"the",
"column"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/ts_commands.go#L169-L171 |
151,283 | basho/riak-go-client | ts_commands.go | WithTable | func (builder *TsStoreRowsCommandBuilder) WithTable(table string) *TsStoreRowsCommandBuilder {
builder.protobuf.Table = []byte(table)
return builder
} | go | func (builder *TsStoreRowsCommandBuilder) WithTable(table string) *TsStoreRowsCommandBuilder {
builder.protobuf.Table = []byte(table)
return builder
} | [
"func",
"(",
"builder",
"*",
"TsStoreRowsCommandBuilder",
")",
"WithTable",
"(",
"table",
"string",
")",
"*",
"TsStoreRowsCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Table",
"=",
"[",
"]",
"byte",
"(",
"table",
")",
"\n",
"return",
"builder",
"\n... | // WithTable sets the table to use for the command | [
"WithTable",
"sets",
"the",
"table",
"to",
"use",
"for",
"the",
"command"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/ts_commands.go#L232-L235 |
151,284 | basho/riak-go-client | ts_commands.go | WithRows | func (builder *TsStoreRowsCommandBuilder) WithRows(rows [][]TsCell) *TsStoreRowsCommandBuilder {
builder.protobuf.Rows = convertFromTsRows(rows)
return builder
} | go | func (builder *TsStoreRowsCommandBuilder) WithRows(rows [][]TsCell) *TsStoreRowsCommandBuilder {
builder.protobuf.Rows = convertFromTsRows(rows)
return builder
} | [
"func",
"(",
"builder",
"*",
"TsStoreRowsCommandBuilder",
")",
"WithRows",
"(",
"rows",
"[",
"]",
"[",
"]",
"TsCell",
")",
"*",
"TsStoreRowsCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Rows",
"=",
"convertFromTsRows",
"(",
"rows",
")",
"\n",
"retu... | // WithRows sets the rows to be stored by the command | [
"WithRows",
"sets",
"the",
"rows",
"to",
"be",
"stored",
"by",
"the",
"command"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/ts_commands.go#L238-L241 |
151,285 | basho/riak-go-client | ts_commands.go | WithQuery | func (builder *TsQueryCommandBuilder) WithQuery(query string) *TsQueryCommandBuilder {
builder.protobuf.Query = &riak_ts.TsInterpolation{Base: []byte(query)}
return builder
} | go | func (builder *TsQueryCommandBuilder) WithQuery(query string) *TsQueryCommandBuilder {
builder.protobuf.Query = &riak_ts.TsInterpolation{Base: []byte(query)}
return builder
} | [
"func",
"(",
"builder",
"*",
"TsQueryCommandBuilder",
")",
"WithQuery",
"(",
"query",
"string",
")",
"*",
"TsQueryCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Query",
"=",
"&",
"riak_ts",
".",
"TsInterpolation",
"{",
"Base",
":",
"[",
"]",
"byte",... | // WithQuery sets the query to be used by the command | [
"WithQuery",
"sets",
"the",
"query",
"to",
"be",
"used",
"by",
"the",
"command"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/ts_commands.go#L617-L620 |
151,286 | basho/riak-go-client | ts_commands.go | convertFromPbTsRows | func convertFromPbTsRows(tsRows []*riak_ts.TsRow, tsCols []*riak_ts.TsColumnDescription) [][]TsCell {
var rows [][]TsCell
var row []TsCell
var cell TsCell
for _, tsRow := range tsRows {
row = make([]TsCell, 0)
for i, tsCell := range tsRow.Cells {
tsColumnType := riak_ts.TsColumnType_VARCHAR
if tsCols != nil {
tsColumnType = tsCols[i].GetType()
}
cell.setCell(tsCell, tsColumnType)
row = append(row, cell)
}
if len(rows) < 1 {
rows = make([][]TsCell, 0)
}
rows = append(rows, row)
}
return rows
} | go | func convertFromPbTsRows(tsRows []*riak_ts.TsRow, tsCols []*riak_ts.TsColumnDescription) [][]TsCell {
var rows [][]TsCell
var row []TsCell
var cell TsCell
for _, tsRow := range tsRows {
row = make([]TsCell, 0)
for i, tsCell := range tsRow.Cells {
tsColumnType := riak_ts.TsColumnType_VARCHAR
if tsCols != nil {
tsColumnType = tsCols[i].GetType()
}
cell.setCell(tsCell, tsColumnType)
row = append(row, cell)
}
if len(rows) < 1 {
rows = make([][]TsCell, 0)
}
rows = append(rows, row)
}
return rows
} | [
"func",
"convertFromPbTsRows",
"(",
"tsRows",
"[",
"]",
"*",
"riak_ts",
".",
"TsRow",
",",
"tsCols",
"[",
"]",
"*",
"riak_ts",
".",
"TsColumnDescription",
")",
"[",
"]",
"[",
"]",
"TsCell",
"{",
"var",
"rows",
"[",
"]",
"[",
"]",
"TsCell",
"\n",
"var... | // Converts a slice of riak_ts.TsRow to a slice of .TsRows | [
"Converts",
"a",
"slice",
"of",
"riak_ts",
".",
"TsRow",
"to",
"a",
"slice",
"of",
".",
"TsRows"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/ts_commands.go#L827-L852 |
151,287 | basho/riak-go-client | ts_commands.go | convertFromTsRows | func convertFromTsRows(tsRows [][]TsCell) []*riak_ts.TsRow {
var rows []*riak_ts.TsRow
var cells []*riak_ts.TsCell
for _, tsRow := range tsRows {
cells = make([]*riak_ts.TsCell, 0)
for _, tsCell := range tsRow {
cells = append(cells, tsCell.cell)
}
if len(rows) < 1 {
rows = make([]*riak_ts.TsRow, 0)
}
rows = append(rows, &riak_ts.TsRow{Cells: cells})
}
return rows
} | go | func convertFromTsRows(tsRows [][]TsCell) []*riak_ts.TsRow {
var rows []*riak_ts.TsRow
var cells []*riak_ts.TsCell
for _, tsRow := range tsRows {
cells = make([]*riak_ts.TsCell, 0)
for _, tsCell := range tsRow {
cells = append(cells, tsCell.cell)
}
if len(rows) < 1 {
rows = make([]*riak_ts.TsRow, 0)
}
rows = append(rows, &riak_ts.TsRow{Cells: cells})
}
return rows
} | [
"func",
"convertFromTsRows",
"(",
"tsRows",
"[",
"]",
"[",
"]",
"TsCell",
")",
"[",
"]",
"*",
"riak_ts",
".",
"TsRow",
"{",
"var",
"rows",
"[",
"]",
"*",
"riak_ts",
".",
"TsRow",
"\n",
"var",
"cells",
"[",
"]",
"*",
"riak_ts",
".",
"TsCell",
"\n",
... | // Converts a slice of .TsRows to a slice of riak_ts.TsRow | [
"Converts",
"a",
"slice",
"of",
".",
"TsRows",
"to",
"a",
"slice",
"of",
"riak_ts",
".",
"TsRow"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/ts_commands.go#L855-L873 |
151,288 | basho/riak-go-client | kv_commands.go | WithConflictResolver | func (builder *FetchValueCommandBuilder) WithConflictResolver(resolver ConflictResolver) *FetchValueCommandBuilder {
builder.resolver = resolver
return builder
} | go | func (builder *FetchValueCommandBuilder) WithConflictResolver(resolver ConflictResolver) *FetchValueCommandBuilder {
builder.resolver = resolver
return builder
} | [
"func",
"(",
"builder",
"*",
"FetchValueCommandBuilder",
")",
"WithConflictResolver",
"(",
"resolver",
"ConflictResolver",
")",
"*",
"FetchValueCommandBuilder",
"{",
"builder",
".",
"resolver",
"=",
"resolver",
"\n",
"return",
"builder",
"\n",
"}"
] | // WithConflictResolver builds the command object with a user defined ConflictResolver for handling conflicting key values | [
"WithConflictResolver",
"builds",
"the",
"command",
"object",
"with",
"a",
"user",
"defined",
"ConflictResolver",
"for",
"handling",
"conflicting",
"key",
"values"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L145-L148 |
151,289 | basho/riak-go-client | kv_commands.go | WithIfModified | func (builder *FetchValueCommandBuilder) WithIfModified(ifModified []byte) *FetchValueCommandBuilder {
builder.protobuf.IfModified = ifModified
return builder
} | go | func (builder *FetchValueCommandBuilder) WithIfModified(ifModified []byte) *FetchValueCommandBuilder {
builder.protobuf.IfModified = ifModified
return builder
} | [
"func",
"(",
"builder",
"*",
"FetchValueCommandBuilder",
")",
"WithIfModified",
"(",
"ifModified",
"[",
"]",
"byte",
")",
"*",
"FetchValueCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"IfModified",
"=",
"ifModified",
"\n",
"return",
"builder",
"\n",
"}"... | // WithIfModified tells Riak to only return the object if the vclock in Riak differs from what is
// provided | [
"WithIfModified",
"tells",
"Riak",
"to",
"only",
"return",
"the",
"object",
"if",
"the",
"vclock",
"in",
"Riak",
"differs",
"from",
"what",
"is",
"provided"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L215-L218 |
151,290 | basho/riak-go-client | kv_commands.go | WithHeadOnly | func (builder *FetchValueCommandBuilder) WithHeadOnly(headOnly bool) *FetchValueCommandBuilder {
builder.protobuf.Head = &headOnly
return builder
} | go | func (builder *FetchValueCommandBuilder) WithHeadOnly(headOnly bool) *FetchValueCommandBuilder {
builder.protobuf.Head = &headOnly
return builder
} | [
"func",
"(",
"builder",
"*",
"FetchValueCommandBuilder",
")",
"WithHeadOnly",
"(",
"headOnly",
"bool",
")",
"*",
"FetchValueCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Head",
"=",
"&",
"headOnly",
"\n",
"return",
"builder",
"\n",
"}"
] | // WithHeadOnly returns only the meta data for the value, useful when objects contain large amounts
// of data | [
"WithHeadOnly",
"returns",
"only",
"the",
"meta",
"data",
"for",
"the",
"value",
"useful",
"when",
"objects",
"contain",
"large",
"amounts",
"of",
"data"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L222-L225 |
151,291 | basho/riak-go-client | kv_commands.go | WithReturnDeletedVClock | func (builder *FetchValueCommandBuilder) WithReturnDeletedVClock(returnDeletedVClock bool) *FetchValueCommandBuilder {
builder.protobuf.Deletedvclock = &returnDeletedVClock
return builder
} | go | func (builder *FetchValueCommandBuilder) WithReturnDeletedVClock(returnDeletedVClock bool) *FetchValueCommandBuilder {
builder.protobuf.Deletedvclock = &returnDeletedVClock
return builder
} | [
"func",
"(",
"builder",
"*",
"FetchValueCommandBuilder",
")",
"WithReturnDeletedVClock",
"(",
"returnDeletedVClock",
"bool",
")",
"*",
"FetchValueCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Deletedvclock",
"=",
"&",
"returnDeletedVClock",
"\n",
"return",
"... | // WithReturnDeletedVClock sets the command to return a Tombstone if any our found for the key across
// all of the vnodes | [
"WithReturnDeletedVClock",
"sets",
"the",
"command",
"to",
"return",
"a",
"Tombstone",
"if",
"any",
"our",
"found",
"for",
"the",
"key",
"across",
"all",
"of",
"the",
"vnodes"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L229-L232 |
151,292 | basho/riak-go-client | kv_commands.go | WithConflictResolver | func (builder *StoreValueCommandBuilder) WithConflictResolver(resolver ConflictResolver) *StoreValueCommandBuilder {
builder.resolver = resolver
return builder
} | go | func (builder *StoreValueCommandBuilder) WithConflictResolver(resolver ConflictResolver) *StoreValueCommandBuilder {
builder.resolver = resolver
return builder
} | [
"func",
"(",
"builder",
"*",
"StoreValueCommandBuilder",
")",
"WithConflictResolver",
"(",
"resolver",
"ConflictResolver",
")",
"*",
"StoreValueCommandBuilder",
"{",
"builder",
".",
"resolver",
"=",
"resolver",
"\n",
"return",
"builder",
"\n",
"}"
] | // WithConflictResolver sets the ConflictResolver that should be used when sibling conflicts are found
// for this operation | [
"WithConflictResolver",
"sets",
"the",
"ConflictResolver",
"that",
"should",
"be",
"used",
"when",
"sibling",
"conflicts",
"are",
"found",
"for",
"this",
"operation"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L405-L408 |
151,293 | basho/riak-go-client | kv_commands.go | WithVClock | func (builder *StoreValueCommandBuilder) WithVClock(vclock []byte) *StoreValueCommandBuilder {
builder.protobuf.Vclock = vclock
return builder
} | go | func (builder *StoreValueCommandBuilder) WithVClock(vclock []byte) *StoreValueCommandBuilder {
builder.protobuf.Vclock = vclock
return builder
} | [
"func",
"(",
"builder",
"*",
"StoreValueCommandBuilder",
")",
"WithVClock",
"(",
"vclock",
"[",
"]",
"byte",
")",
"*",
"StoreValueCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Vclock",
"=",
"vclock",
"\n",
"return",
"builder",
"\n",
"}"
] | // WithVClock sets the vclock for the object to be stored, providing causal context for conflicts | [
"WithVClock",
"sets",
"the",
"vclock",
"for",
"the",
"object",
"to",
"be",
"stored",
"providing",
"causal",
"context",
"for",
"conflicts"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L429-L432 |
151,294 | basho/riak-go-client | kv_commands.go | WithIfNotModified | func (builder *StoreValueCommandBuilder) WithIfNotModified(ifNotModified bool) *StoreValueCommandBuilder {
builder.protobuf.IfNotModified = &ifNotModified
return builder
} | go | func (builder *StoreValueCommandBuilder) WithIfNotModified(ifNotModified bool) *StoreValueCommandBuilder {
builder.protobuf.IfNotModified = &ifNotModified
return builder
} | [
"func",
"(",
"builder",
"*",
"StoreValueCommandBuilder",
")",
"WithIfNotModified",
"(",
"ifNotModified",
"bool",
")",
"*",
"StoreValueCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"IfNotModified",
"=",
"&",
"ifNotModified",
"\n",
"return",
"builder",
"\n",
... | // WithIfNotModified tells Riak to only update the object in Riak if the vclock provided matches the
// one currently in Riak | [
"WithIfNotModified",
"tells",
"Riak",
"to",
"only",
"update",
"the",
"object",
"in",
"Riak",
"if",
"the",
"vclock",
"provided",
"matches",
"the",
"one",
"currently",
"in",
"Riak"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L488-L491 |
151,295 | basho/riak-go-client | kv_commands.go | WithIfNoneMatch | func (builder *StoreValueCommandBuilder) WithIfNoneMatch(ifNoneMatch bool) *StoreValueCommandBuilder {
builder.protobuf.IfNoneMatch = &ifNoneMatch
return builder
} | go | func (builder *StoreValueCommandBuilder) WithIfNoneMatch(ifNoneMatch bool) *StoreValueCommandBuilder {
builder.protobuf.IfNoneMatch = &ifNoneMatch
return builder
} | [
"func",
"(",
"builder",
"*",
"StoreValueCommandBuilder",
")",
"WithIfNoneMatch",
"(",
"ifNoneMatch",
"bool",
")",
"*",
"StoreValueCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"IfNoneMatch",
"=",
"&",
"ifNoneMatch",
"\n",
"return",
"builder",
"\n",
"}"
] | // WithIfNoneMatch tells Riak to store the object only if it does not already exist in the database | [
"WithIfNoneMatch",
"tells",
"Riak",
"to",
"store",
"the",
"object",
"only",
"if",
"it",
"does",
"not",
"already",
"exist",
"in",
"the",
"database"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L494-L497 |
151,296 | basho/riak-go-client | kv_commands.go | WithReturnHead | func (builder *StoreValueCommandBuilder) WithReturnHead(returnHead bool) *StoreValueCommandBuilder {
builder.protobuf.ReturnHead = &returnHead
return builder
} | go | func (builder *StoreValueCommandBuilder) WithReturnHead(returnHead bool) *StoreValueCommandBuilder {
builder.protobuf.ReturnHead = &returnHead
return builder
} | [
"func",
"(",
"builder",
"*",
"StoreValueCommandBuilder",
")",
"WithReturnHead",
"(",
"returnHead",
"bool",
")",
"*",
"StoreValueCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"ReturnHead",
"=",
"&",
"returnHead",
"\n",
"return",
"builder",
"\n",
"}"
] | // WithReturnHead returns only the meta data for the value, useful when objects contain large amounts
// of data | [
"WithReturnHead",
"returns",
"only",
"the",
"meta",
"data",
"for",
"the",
"value",
"useful",
"when",
"objects",
"contain",
"large",
"amounts",
"of",
"data"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L501-L504 |
151,297 | basho/riak-go-client | kv_commands.go | WithAsis | func (builder *StoreValueCommandBuilder) WithAsis(asis bool) *StoreValueCommandBuilder {
builder.protobuf.Asis = &asis
return builder
} | go | func (builder *StoreValueCommandBuilder) WithAsis(asis bool) *StoreValueCommandBuilder {
builder.protobuf.Asis = &asis
return builder
} | [
"func",
"(",
"builder",
"*",
"StoreValueCommandBuilder",
")",
"WithAsis",
"(",
"asis",
"bool",
")",
"*",
"StoreValueCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Asis",
"=",
"&",
"asis",
"\n",
"return",
"builder",
"\n",
"}"
] | // WithAsis sets the asis option
// Please note, this is an advanced feature, only use with caution | [
"WithAsis",
"sets",
"the",
"asis",
"option",
"Please",
"note",
"this",
"is",
"an",
"advanced",
"feature",
"only",
"use",
"with",
"caution"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L516-L519 |
151,298 | basho/riak-go-client | kv_commands.go | WithVClock | func (builder *DeleteValueCommandBuilder) WithVClock(vclock []byte) *DeleteValueCommandBuilder {
builder.protobuf.Vclock = vclock
return builder
} | go | func (builder *DeleteValueCommandBuilder) WithVClock(vclock []byte) *DeleteValueCommandBuilder {
builder.protobuf.Vclock = vclock
return builder
} | [
"func",
"(",
"builder",
"*",
"DeleteValueCommandBuilder",
")",
"WithVClock",
"(",
"vclock",
"[",
"]",
"byte",
")",
"*",
"DeleteValueCommandBuilder",
"{",
"builder",
".",
"protobuf",
".",
"Vclock",
"=",
"vclock",
"\n",
"return",
"builder",
"\n",
"}"
] | // WithVClock sets the vector clock.
//
// If not set siblings may be created depending on bucket properties. | [
"WithVClock",
"sets",
"the",
"vector",
"clock",
".",
"If",
"not",
"set",
"siblings",
"may",
"be",
"created",
"depending",
"on",
"bucket",
"properties",
"."
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L628-L631 |
151,299 | basho/riak-go-client | kv_commands.go | WithTimeout | func (builder *ListBucketsCommandBuilder) WithTimeout(timeout time.Duration) *ListBucketsCommandBuilder {
timeoutMilliseconds := uint32(timeout / time.Millisecond)
builder.protobuf.Timeout = &timeoutMilliseconds
return builder
} | go | func (builder *ListBucketsCommandBuilder) WithTimeout(timeout time.Duration) *ListBucketsCommandBuilder {
timeoutMilliseconds := uint32(timeout / time.Millisecond)
builder.protobuf.Timeout = &timeoutMilliseconds
return builder
} | [
"func",
"(",
"builder",
"*",
"ListBucketsCommandBuilder",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"ListBucketsCommandBuilder",
"{",
"timeoutMilliseconds",
":=",
"uint32",
"(",
"timeout",
"/",
"time",
".",
"Millisecond",
")",
"\n",
... | // WithTimeout sets a timeout in milliseconds to be used for this command operation | [
"WithTimeout",
"sets",
"a",
"timeout",
"in",
"milliseconds",
"to",
"be",
"used",
"for",
"this",
"command",
"operation"
] | 5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6 | https://github.com/basho/riak-go-client/blob/5587c16e0b8b944f6b9724a0df7712f8ec4d4ee6/kv_commands.go#L855-L859 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.