Last active
June 10, 2021 00:20
-
-
Save halfwit/a91ff4be6b30a570f299858d3adc6bca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"github.com/altid/client" | |
"github.com/altid/client/driver/gtk" | |
) | |
func init() { | |
client.Register("gtk", gtk.Driver) | |
} | |
func main() { | |
// A session will connect to the given 9p server | |
// and yield information automatically to the driver | |
// based on the drivers configuration | |
session, err := session.NewSession(127.0.0.1, 564) | |
if err != nil { | |
log.Fatal(err) | |
} | |
// WithSession starts a goroutine with a given session | |
// It will return any errors on initialization\ | |
// otherwise will draw all the common UI elements | |
if _, e := WithSession("gtk", session); e != nil { | |
log.Fatal(e) | |
} | |
// We could re-use the handler from WithSession as well | |
ui, err := Open("gtk") | |
if err != nil { | |
log.Fatal(err) | |
} | |
// gtk standard menu, | |
menu, err := ui.Conn("menu") | |
if err != nil { | |
log.Fatal("menu element not available") | |
} | |
msg := client.Msg{ | |
Payload: `foo\nbar\nbaz\n` | |
} | |
// Returns a value from the menu, once selection is made | |
var select string | |
if e := menu.SendMsg(msg).Scan(&select); e != nil { | |
log.Fatal(e) | |
} | |
fmt.Println(select) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment