Skip to content

Commit fa651bf

Browse files
committed
Catch too small popup width
1 parent 04c3020 commit fa651bf

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

cfg/cfg.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const (
2323
)
2424

2525
// Cfg holds basic configuration settings
26-
// WARNING: Should only be instantiated via GetInstance
26+
// Should only be instantiated via GetInstance
2727
type Cfg struct {
2828
ModBasePath string `json:"mod_base_path"`
2929
ModExtensions map[string]int `json:"mod_extensions"`
@@ -53,6 +53,7 @@ func init() {
5353
firstStart()
5454
GetInstance()
5555
loadConfig()
56+
Persist()
5657
}
5758

5859
func firstStart() {

tui/youSure.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,19 @@ func makeYouSureBox(question string, onOk func(), xOffset int, yOffset int) *tvi
3131
// youSureBox.SetBackgroundColor(tview.Styles.ContrastBackgroundColor)
3232
youSureBox.SetBorder(true)
3333

34+
width := len(question) + 4
35+
minWidth := 11 + len(confirmText) + len(abortText)
36+
if width < minWidth {
37+
width = minWidth
38+
}
39+
40+
// TODO - catch yOffset if popup flows out of the windows
41+
3442
youSureLayout := tview.NewFlex().SetDirection(tview.FlexRow).
3543
AddItem(nil, yOffset, 1, false).
3644
AddItem(tview.NewFlex().SetDirection(tview.FlexColumn).
3745
AddItem(nil, xOffset, 1, false).
38-
AddItem(youSureBox, len(question)+4, 0, true).
46+
AddItem(youSureBox, width, 0, true).
3947
AddItem(nil, 0, 1, false),
4048
7, 1, true).
4149
AddItem(nil, 0, 1, false)

0 commit comments

Comments
 (0)