本文整理汇总了Golang中code/google/com/p/goplan9/plan9/acme.Win类的典型用法代码示例。如果您正苦于以下问题:Golang Win类的具体用法?Golang Win怎么用?Golang Win使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Win类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: handleWinEvents
func handleWinEvents(win *acme.Win) {
for ev := range win.EventChan() {
if ev.C2 == 'x' || ev.C2 == 'X' {
if ev.Flag&2 != 0 {
ev.Q0 = ev.OrigQ0
ev.Q1 = ev.OrigQ1
}
win.WriteEvent(ev)
if fs := strings.Fields(string(ev.Text)); len(fs) > 0 && fs[0] == "Del" {
os.Exit(0)
}
}
}
}
开发者ID:vivounicorn,项目名称:eaburns,代码行数:14,代码来源:main.go
示例2: readBody
// We would use win.ReadAll except for a bug in acme
// where it crashes when reading trying to read more
// than the negotiated 9P message size.
func readBody(win *acme.Win) ([]byte, error) {
var body []byte
buf := make([]byte, 8000)
for {
n, err := win.Read("body", buf)
if err == io.EOF {
break
}
if err != nil {
return nil, err
}
body = append(body, buf[0:n]...)
}
return body, nil
}
开发者ID:uvelichitel,项目名称:compl,代码行数:18,代码来源:acme.go
示例3: showCal
func showCal(win *acme.Win) {
cmd := exec.Command("9", "cal")
out, err := cmd.StdoutPipe()
if err != nil {
panic(err)
}
go cmd.Start()
if _, err := io.Copy(dataWriter{win}, out); err != nil {
panic(err)
}
if err := cmd.Wait(); err != nil {
panic(err)
}
win.Ctl("clean")
}
开发者ID:vivounicorn,项目名称:eaburns,代码行数:15,代码来源:main.go
示例4: copyBody
// We would use io.Copy except for a bug in acme
// where it crashes when reading trying to read more
// than the negotiated 9P message size.
func copyBody(w io.Writer, win *acme.Win) error {
buf := make([]byte, 8000)
for {
n, err := win.Read("body", buf)
if err == io.EOF {
break
}
if err != nil {
return err
}
if _, err := w.Write(buf[0:n]); err != nil {
return fmt.Errorf("write error: %v", err)
}
}
return nil
}
开发者ID:hdpe,项目名称:rog-go,代码行数:19,代码来源:acme.go
示例5: writeData
func writeData(win *acme.Win, data []byte) error {
if len(data) == 0 {
_, err := win.Write("data", nil)
return err
}
for len(data) > 0 {
d := data
if len(d) > 8000 {
d = trimIncompleteRune(d[0:8000])
}
n, err := win.Write("data", d)
if err != nil {
return err
}
data = data[n:]
}
return nil
}
开发者ID:hdpe,项目名称:rog-go,代码行数:18,代码来源:apply.go
示例6: events
func events(w *acme.Win) <-chan string {
c := make(chan string, 10)
go func() {
for e := range w.EventChan() {
switch e.C2 {
case 'x', 'X': // execute
if string(e.Text) == "Del" {
w.Ctl("delete")
}
w.WriteEvent(e)
case 'l', 'L': // look
w.Ctl("clean")
c <- string(e.Text)
}
}
w.CloseFiles()
close(c)
}()
return c
}
开发者ID:postfix,项目名称:GoProxyHunt,代码行数:20,代码来源:Dict.go
示例7: blinker
func blinker(w *acme.Win) chan bool {
c := make(chan bool)
go func() {
t := time.NewTicker(300 * time.Millisecond)
defer t.Stop()
dirty := false
for {
select {
case <-t.C:
dirty = !dirty
if dirty {
w.Ctl("dirty")
} else {
w.Ctl("clean")
}
case <-c:
if dirty {
w.Ctl("clean")
}
return
}
}
}()
return c
}
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:25,代码来源:run.go
示例8: main
func main() {
log.SetFlags(0)
log.SetPrefix("Run: ")
file := os.Getenv("samfile")
if file == "" {
log.Fatal("not running in acme")
}
id, _ := strconv.Atoi(os.Getenv("winid"))
wfile, err := acme.Open(id, nil)
if err != nil {
log.Fatal(err)
}
wfile.Ctl("put")
wfile.CloseFiles()
wname := "/go/run/" + strings.TrimSuffix(path.Base(file), ".go")
windows, _ := acme.Windows()
var w *acme.Win
for _, info := range windows {
if info.Name == wname {
ww, err := acme.Open(info.ID, nil)
if err != nil {
log.Fatal(err)
}
ww.Addr(",")
ww.Write("data", nil)
w = ww
break
}
}
if w == nil {
ww, err := acme.New()
if err != nil {
log.Fatal(err)
}
ww.Name(wname)
w = ww
}
w.Ctl("clean")
defer w.Ctl("clean")
cmd := exec.Command("go", append([]string{"run", os.Getenv("samfile")}, os.Args[1:]...)...)
cmd.Stdout = bodyWriter{w}
cmd.Stderr = cmd.Stdout
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
err = cmd.Start()
if err != nil {
w.Fprintf("body", "error starting command: %v\n", err)
return
}
//stop := blinker(w)
w.Ctl("cleartag")
w.Fprintf("tag", " Kill Stack")
done := make(chan bool)
go func() {
err := cmd.Wait()
if err != nil {
w.Fprintf("body", "\nerror running command: %v\n", err)
}
//stop <- true
done <- true
}()
deleted := make(chan bool, 1)
go func() {
for e := range w.EventChan() {
if e.C2 == 'x' || e.C2 == 'X' {
switch string(e.Text) {
case "Del":
select {
case deleted <- true:
default:
}
syscall.Kill(-cmd.Process.Pid, 2)
continue
case "Kill":
syscall.Kill(-cmd.Process.Pid, 2)
continue
case "Stack":
syscall.Kill(-cmd.Process.Pid, 3)
continue
}
w.WriteEvent(e)
}
}
}()
<-done
w.Ctl("cleartag")
select {
case <-deleted:
w.Ctl("delete")
default:
}
}
开发者ID:TheJumpCloud,项目名称:rsc,代码行数:99,代码来源:run.go
示例9: clear
func clear(win *acme.Win) {
win.Addr("0,$")
if _, err := win.Write("data", []byte{}); err != nil {
panic(err)
}
}
开发者ID:vivounicorn,项目名称:eaburns,代码行数:6,代码来源:main.go
注:本文中的code/google/com/p/goplan9/plan9/acme.Win类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论