package dialogs
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/rivo/tview"
|
|
)
|
|
|
|
const (
|
|
DialogFormHeight = 3
|
|
DialogMinWidth = 40
|
|
DialogPadding = 3
|
|
TableHeightOffset = 3
|
|
)
|
|
|
|
type Dialog interface {
|
|
tview.Primitive
|
|
Display()
|
|
Hide()
|
|
IsDisplay() bool
|
|
}
|
|
|
|
func getMessageWidth(message string) int {
|
|
var messageWidth int
|
|
|
|
for _, msg := range strings.Split(message, "\n") {
|
|
if len(msg) > messageWidth {
|
|
messageWidth = len(msg)
|
|
}
|
|
}
|
|
|
|
return messageWidth
|
|
}
|
|
|
|
func CheckDialogFocus(dialogs ...Dialog) bool {
|
|
for _, dia := range dialogs {
|
|
if dia.HasFocus() {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|