gcla / gowid

Compositional widgets for terminal user interfaces, written in Go, inspired by urwid.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terminal widget crashes: invalid memory address or nil pointer dereference

Peter2121 opened this issue · comments

According to the document https://github.com/gcla/gowid/blob/master/docs/Widgets.md :
The terminal canvas implements io.Writer allowing a client to write ANSI codes using this standard Golang interface.

I'm trying to send something to a terminal widgets, adding the following code after

		_, err = t.Canvas().Write([]byte("ls -lisa \n"))
		if err != nil {
    		panic(err)
		}				

The application crashes as follows:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x88 pc=0x553546]

goroutine 1 [running]:
github.com/gcla/gowid/widgets/terminal.(*Canvas).ProcessByte(0x0, 0x6c)
	/home/peter/Programming/golang/gowid/widgets/terminal/term_canvas.go:1485 +0x26
github.com/gcla/gowid/widgets/terminal.(*Canvas).Write(0x0, {0xc0001d7b06, 0xa, 0xa})
	/home/peter/Programming/golang/gowid/widgets/terminal/term_canvas.go:427 +0x45
main.main()
	/home/peter/Programming/golang/gowid/examples/gowid-terminal/terminal.go:289 +0x1c98
exit status 2

OK, I see, the canvas is not created yet here.