Esempio n. 1
0
func events(win *acme.Win, rerun chan<- struct{}) {
	for e := range win.EventChan() {
		debugPrint("Acme event: %+v\n", e)
		switch e.C2 {
		case 'x', 'X':
			switch string(e.Text) {
			case "Get":
				kill()
				rerun <- struct{}{}

			case "Del":
				kill()
				if err := win.Ctl("delete"); err != nil {
					log.Fatalln("Failed to delete the window:", err)
				}

			default:
				win.WriteEvent(e)
			}

		default:
			win.WriteEvent(e)
		}
	}
	os.Exit(0)
}
Esempio n. 2
0
File: main.go Progetto: aoeu/acme
func writeEvents(w *acme.Win, wg *sync.WaitGroup) {
	defer wg.Done()
	for {
		select {
		case e, ok := <-w.EventChan():
			if !ok {
				return
			}
			w.WriteEvent(e)
			if string(e.Text) == "Del" {
				return
			}
		}

	}
}
Esempio n. 3
0
File: Dict.go Progetto: rjkroege/go
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
}