MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / showMessage

Method showMessage

internal/ui/components/dialogs.go:13–33  ·  view source on GitHub ↗

showMessage displays a message to the user. This simplified version sets focus directly without QueueUpdateDraw, which eliminates potential deadlocks when called from menu handlers or other UI event contexts. SetFocus will trigger a redraw automatically.

(message string)

Source from the content-addressed store, hash-verified

11// which eliminates potential deadlocks when called from menu handlers
12// or other UI event contexts. SetFocus will trigger a redraw automatically.
13func (a *App) showMessage(message string) {
14 // Save current focus before showing modal
15 a.lastFocus = a.GetFocus()
16
17 modal := tview.NewModal().
18 SetText(message).
19 // SetBackgroundColor(theme.Colors.Background).
20 SetTextColor(theme.Colors.Primary).
21 AddButtons([]string{"OK"}).
22 SetDoneFunc(func(buttonIndex int, buttonLabel string) {
23 a.removePageIfPresent("message")
24 // Restore focus to the last focused element
25 if a.lastFocus != nil {
26 a.SetFocus(a.lastFocus)
27 }
28 })
29
30 a.pages.AddPage("message", modal, false, true)
31 // Set focus directly - this triggers a redraw without queuing
32 a.SetFocus(modal)
33}
34
35// showMessageSafe is now an alias to showMessage for backwards compatibility.
36// Both use the same safe implementation that avoids QueueUpdateDraw deadlocks.

Callers 4

showMessageSafeMethod · 0.95
ShowMessageMethod · 0.95
ShowMessageSafeMethod · 0.95

Calls 6

removePageIfPresentMethod · 0.95
SetDoneFuncMethod · 0.80
AddButtonsMethod · 0.80
SetTextColorMethod · 0.80
SetFocusMethod · 0.65
SetTextMethod · 0.45

Tested by

no test coverage detected