tui/modals/modal_info.go

32 lines
578 B
Go
Raw Normal View History

2023-04-24 11:41:38 +02:00
package modals
import (
"git.tordarus.net/Tordarus/tui"
"git.tordarus.net/Tordarus/tui/views"
"github.com/gdamore/tcell"
)
type InfoModal struct {
*views.FrameView
}
func NewInfoModal(message string) *InfoModal {
tv := views.NewTextView(message)
bv := views.NewBorderView(views.NewMarginView(tv, 0, 1, 0, 1))
fv := views.NewFrameView(bv)
fv.DontClearBuffer = true
m := &InfoModal{
FrameView: fv,
}
m.KeyPressed = func(event *tui.KeyEvent) (consumed bool) {
if event.Key() == tcell.KeyEnter || event.Key() == tcell.KeyESC {
}
return true
}
return m
}