Beispiel #1
0
func main() {
	log.SetFlags(0)
	log.SetPrefix("")
	wid, err := strconv.Atoi(os.Getenv("winid"))
	if err != nil {
		log.Fatal("unable to find window")
	}
	win, err := acme.Open(wid, nil)
	if err != nil {
		log.Fatalf("unable to open window: %v", err)
	}
	wis, _ := acme.Windows()
	var name string
	for _, wi := range wis {
		if wi.ID == wid {
			name = wi.Name
			break
		}
	}
	cmd := exec.Command("aspell", "-a")
	cmd.Stdin = prefixer.New(bodyReader{win}, "^")
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		log.Fatalf("unable to create pipe")
	}
	cmd.Start()
	p := printer{name}
	go p.scan(stdout)
	if err := cmd.Wait(); err != nil && err != io.EOF {
		log.Fatalf("error running \"aspell -a\": %v", err)
	}
}
Beispiel #2
0
Datei: main.go Projekt: aoeu/acme
func windowIDsByName() (map[string]int, error) {
	m := make(map[string]int, 0)
	w, err := acme.Windows()
	if err != nil {
		return m, err
	}
	for _, wi := range w {
		m[wi.Name] = wi.ID
	}
	return m, nil
}