(title, content string, onDone func())
| 2275 | } |
| 2276 | |
| 2277 | func (p *Plugin) showOutput(title, content string, onDone func()) { |
| 2278 | pages := p.app.Pages() |
| 2279 | pages.RemovePage(menuPageName) |
| 2280 | |
| 2281 | output := tview.NewTextView() |
| 2282 | output.SetBorder(true) |
| 2283 | output.SetBorderColor(theme.Colors.Border) |
| 2284 | output.SetTitle(" " + title + " ") |
| 2285 | output.SetTitleColor(theme.Colors.Primary) |
| 2286 | output.SetDynamicColors(true) |
| 2287 | output.SetScrollable(true) |
| 2288 | output.SetWrap(true) |
| 2289 | output.SetWordWrap(true) |
| 2290 | output.SetText(content + "\n\n[secondary]esc/backspace/q: close[-]") |
| 2291 | |
| 2292 | closeOutput := func() { |
| 2293 | pages.RemovePage(outputPageName) |
| 2294 | if onDone != nil { |
| 2295 | onDone() |
| 2296 | } |
| 2297 | } |
| 2298 | |
| 2299 | output.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { |
| 2300 | if isBackKey(event) { |
| 2301 | closeOutput() |
| 2302 | return nil |
| 2303 | } |
| 2304 | if event.Key() == tcell.KeyRune && (event.Rune() == 'q' || event.Rune() == 'Q') { |
| 2305 | closeOutput() |
| 2306 | return nil |
| 2307 | } |
| 2308 | return event |
| 2309 | }) |
| 2310 | |
| 2311 | pages.AddPage(outputPageName, p.centerModal(output, 110, 30), true, true) |
| 2312 | p.app.SetFocus(output) |
| 2313 | } |
| 2314 | |
| 2315 | func (p *Plugin) previewInventory(inventory coreansible.InventoryResult) { |
| 2316 | if coreansible.NormalizeInventorySource(inventory.Source) != coreansible.InventorySourceProxmox { |
no test coverage detected