Exemplo n.º 1
0
func get_buffer_from_tview(tv *gtk.TextView) *gtk.TextBuffer {
	buffer, err := tv.GetBuffer()
	if err != nil {
		log.Fatal("Unable to get buffer:", err)
	}
	return buffer
}
Exemplo n.º 2
0
func printMessages(msgView *gtk.TextView, msgs chan string) {
	for {
		msg := <-msgs
		buffer, err := msgView.GetBuffer()
		if err != nil {
			log.Fatal("Unable to load buffer:", err)
		}
		start, end := buffer.GetBounds()
		text, err := buffer.GetText(start, end, true)
		if err != nil {
			log.Fatal("Unable to save buffer as string:", err)
		}
		buffer.SetText(text + "\n" + msg)
	}
}