mirror of
https://github.com/CosmicStar98/bedrocktool.git
synced 2024-06-09 14:39:44 +00:00
37 lines
578 B
Go
37 lines
578 B
Go
|
package gui
|
||
|
|
||
|
import (
|
||
|
"io"
|
||
|
"os"
|
||
|
|
||
|
"fyne.io/fyne/v2"
|
||
|
"fyne.io/fyne/v2/widget"
|
||
|
"github.com/fyne-io/terminal"
|
||
|
"github.com/sirupsen/logrus"
|
||
|
)
|
||
|
|
||
|
type consoleWidget struct {
|
||
|
widget.BaseWidget
|
||
|
|
||
|
term *terminal.Terminal
|
||
|
}
|
||
|
|
||
|
func (c *consoleWidget) CreateRenderer() fyne.WidgetRenderer {
|
||
|
return widget.NewSimpleRenderer(c.term)
|
||
|
}
|
||
|
|
||
|
func newConsoleWidget() *consoleWidget {
|
||
|
rp, w := io.Pipe()
|
||
|
r := io.TeeReader(rp, os.Stdout)
|
||
|
logrus.SetOutput(w)
|
||
|
|
||
|
term := terminal.New()
|
||
|
go term.RunWithConnection(nil, r)
|
||
|
|
||
|
c := &consoleWidget{
|
||
|
term: term,
|
||
|
}
|
||
|
c.ExtendBaseWidget(c)
|
||
|
return c
|
||
|
}
|