diff --git a/ui/containers/commands.go b/ui/containers/commands.go index bb2969321..a05fe736c 100644 --- a/ui/containers/commands.go +++ b/ui/containers/commands.go @@ -579,7 +579,7 @@ func (cnt *Containers) diff() { cnt.messageDialog.SetTitle("podman container diff") cnt.messageDialog.SetText(dialogs.MessageContainerInfo, headerLabel, strings.Join(data, "\n")) - cnt.messageDialog.Display() + cnt.messageDialog.DisplayFullSize() } func (cnt *Containers) inspect() { @@ -601,7 +601,7 @@ func (cnt *Containers) inspect() { cnt.messageDialog.SetTitle("podman container inspect") cnt.messageDialog.SetText(dialogs.MessageContainerInfo, headerLabel, data) - cnt.messageDialog.Display() + cnt.messageDialog.DisplayFullSize() } func (cnt *Containers) kill() { @@ -663,7 +663,7 @@ func (cnt *Containers) logs() { cnt.messageDialog.SetTitle("podman container logs") cnt.messageDialog.SetText(dialogs.MessageContainerInfo, headerLabel, cntLogs) cnt.messageDialog.TextScrollToEnd() - cnt.messageDialog.Display() + cnt.messageDialog.DisplayFullSize() } go getLogs() diff --git a/ui/containers/draw.go b/ui/containers/draw.go index e6c331621..7bfef8ddc 100644 --- a/ui/containers/draw.go +++ b/ui/containers/draw.go @@ -60,7 +60,12 @@ func (cnt *Containers) Draw(screen tcell.Screen) { //nolint:cyclop // message dialog if cnt.messageDialog.IsDisplay() { - cnt.messageDialog.SetRect(x, y, width, height+1) + if cnt.messageDialog.IsDisplayFullSize() { + cnt.messageDialog.SetRect(cntViewX, cntViewY, cntViewW, cntViewH) + } else { + cnt.messageDialog.SetRect(x, y, width, height+1) + } + cnt.messageDialog.Draw(screen) return diff --git a/ui/dialogs/message.go b/ui/dialogs/message.go index 3078e5950..32fc0752b 100644 --- a/ui/dialogs/message.go +++ b/ui/dialogs/message.go @@ -13,13 +13,14 @@ import ( // MessageDialog is a simaple message dialog primitive. type MessageDialog struct { *tview.Box - layout *tview.Flex - infoType *tview.InputField - textview *tview.TextView - form *tview.Form - display bool - message string - cancelHandler func() + layout *tview.Flex + infoType *tview.InputField + textview *tview.TextView + form *tview.Form + display bool + displayFullSize bool + message string + cancelHandler func() } type messageInfo int @@ -38,10 +39,11 @@ const ( // NewMessageDialog returns new message dialog primitive. func NewMessageDialog(text string) *MessageDialog { dialog := &MessageDialog{ - Box: tview.NewBox(), - infoType: tview.NewInputField(), - display: false, - message: text, + Box: tview.NewBox(), + infoType: tview.NewInputField(), + display: false, + displayFullSize: false, + message: text, } dialog.infoType.SetBackgroundColor(style.DialogBgColor) @@ -65,7 +67,6 @@ func NewMessageDialog(text string) *MessageDialog { tlayout.AddItem(utils.EmptyBoxSpace(style.DialogBgColor), 1, 0, false) tlayout.AddItem(tview.NewFlex().SetDirection(tview.FlexRow). AddItem(dialog.infoType, 1, 0, false). - AddItem(utils.EmptyBoxSpace(style.DialogBgColor), 1, 0, false). AddItem(dialog.textview, 0, 1, true), 0, 1, true) tlayout.AddItem(utils.EmptyBoxSpace(style.DialogBgColor), 1, 0, false) @@ -78,7 +79,6 @@ func NewMessageDialog(text string) *MessageDialog { dialog.form.SetButtonBackgroundColor(style.ButtonBgColor) dialog.layout = tview.NewFlex().SetDirection(tview.FlexRow) - dialog.layout.AddItem(utils.EmptyBoxSpace(style.DialogBgColor), 1, 0, true) dialog.layout.AddItem(tlayout, 0, 1, true) dialog.layout.AddItem(dialog.form, DialogFormHeight, 0, true) dialog.layout.SetBorder(true) @@ -91,6 +91,13 @@ func NewMessageDialog(text string) *MessageDialog { // Display displays this primitive. func (d *MessageDialog) Display() { d.display = true + d.displayFullSize = false +} + +// DisplayFullSize displays this primitive in full size. +func (d *MessageDialog) DisplayFullSize() { + d.display = true + d.displayFullSize = true } // IsDisplay returns true if primitive is shown. @@ -98,6 +105,11 @@ func (d *MessageDialog) IsDisplay() bool { return d.display } +// IsDisplayFullSize returns true if primitive is shown in full size. +func (d *MessageDialog) IsDisplayFullSize() bool { + return d.displayFullSize +} + // Hide stops displaying this primitive. func (d *MessageDialog) Hide() { d.message = "" @@ -169,6 +181,17 @@ func (d *MessageDialog) HasFocus() bool { // SetRect set rects for this primitive. func (d *MessageDialog) SetRect(x, y, width, height int) { + if d.displayFullSize { + dX := x + 1 + dY := y + 1 + dWidth := width - 2 //nolint:mnd + dHeight := height - 2 //nolint:mnd + + d.Box.SetRect(dX, dY, dWidth, dHeight) + + return + } + messageHeight := 0 if d.message != "" { messageHeight = len(strings.Split(d.message, "\n")) + 3 //nolint:mnd diff --git a/ui/images/commands.go b/ui/images/commands.go index 7b300e6fd..f4664c9c1 100644 --- a/ui/images/commands.go +++ b/ui/images/commands.go @@ -117,7 +117,7 @@ func (img *Images) diff() { img.messageDialog.SetTitle("podman image diff") img.messageDialog.SetText(dialogs.MessageImageInfo, headerLabel, strings.Join(data, "\n")) - img.messageDialog.Display() + img.messageDialog.DisplayFullSize() } go diff() @@ -192,7 +192,7 @@ func (img *Images) inspect() { img.messageDialog.SetTitle("podman image inspect") img.messageDialog.SetText(dialogs.MessageImageInfo, headerLabel, data) - img.messageDialog.Display() + img.messageDialog.DisplayFullSize() } func (img *Images) cprune() { diff --git a/ui/images/draw.go b/ui/images/draw.go index 8dac08bad..9509f7307 100644 --- a/ui/images/draw.go +++ b/ui/images/draw.go @@ -10,13 +10,13 @@ func (img *Images) Draw(screen tcell.Screen) { //nolint:cyclop img.Box.DrawForSubclass(screen, img) img.Box.SetBorder(false) - x, y, width, height := img.GetInnerRect() + imagewViewX, imagewViewY, imagewViewW, imagewViewH := img.GetInnerRect() - img.table.SetRect(x, y, width, height) + img.table.SetRect(imagewViewX, imagewViewY, imagewViewW, imagewViewH) img.table.SetBorder(true) img.table.Draw(screen) - x, y, width, height = img.table.GetInnerRect() + x, y, width, height := img.table.GetInnerRect() // error dialog if img.errorDialog.IsDisplay() { @@ -44,7 +44,12 @@ func (img *Images) Draw(screen tcell.Screen) { //nolint:cyclop // message dialog if img.messageDialog.IsDisplay() { - img.messageDialog.SetRect(x, y, width, height+1) + if img.messageDialog.IsDisplayFullSize() { + img.messageDialog.SetRect(imagewViewX, imagewViewY, imagewViewW, imagewViewH) + } else { + img.messageDialog.SetRect(x, y, width, height+1) + } + img.messageDialog.Draw(screen) return @@ -60,7 +65,7 @@ func (img *Images) Draw(screen tcell.Screen) { //nolint:cyclop // search dialog if img.searchDialog.IsDisplay() { - img.searchDialog.SetRect(x, y, width, height) + img.searchDialog.SetRect(imagewViewX, imagewViewY, imagewViewW, imagewViewH) img.searchDialog.Draw(screen) } @@ -72,7 +77,7 @@ func (img *Images) Draw(screen tcell.Screen) { //nolint:cyclop // history dialog if img.historyDialog.IsDisplay() { - img.historyDialog.SetRect(x, y, width, height) + img.historyDialog.SetRect(imagewViewX, imagewViewY, imagewViewW, imagewViewH) img.historyDialog.Draw(screen) return diff --git a/ui/images/imgdialogs/history.go b/ui/images/imgdialogs/history.go index 6116c14c7..546121f05 100644 --- a/ui/images/imgdialogs/history.go +++ b/ui/images/imgdialogs/history.go @@ -146,23 +146,15 @@ func (d *ImageHistoryDialog) InputHandler() func(event *tcell.EventKey, setFocus // SetRect set rects for this primitive. func (d *ImageHistoryDialog) SetRect(x, y, width, height int) { - dX := x + dialogs.DialogPadding - dWidth := width - (2 * dialogs.DialogPadding) //nolint:mnd - dHeight := len(d.results) + dialogs.DialogFormHeight + 5 //nolint:mnd - - if dHeight > height { - dHeight = height - } - - tableHeight := dHeight - dialogs.DialogFormHeight - 2 //nolint:mnd - - hs := ((height - dHeight) / 2) //nolint:mnd - dY := y + hs + dX := x + 1 + dY := y + 1 + dWidth := width - 2 //nolint:mnd + dHeight := height - 2 //nolint:mnd d.Box.SetRect(dX, dY, dWidth, dHeight) // set table height size - d.layout.ResizeItem(d.table, tableHeight, 0) + d.layout.ResizeItem(d.table, dHeight, 0) cWidth := d.getCreatedByWidth() for i := range d.table.GetRowCount() { diff --git a/ui/networks/commands.go b/ui/networks/commands.go index 869a438be..fe28ee45f 100644 --- a/ui/networks/commands.go +++ b/ui/networks/commands.go @@ -170,7 +170,7 @@ func (nets *Networks) inspect() { nets.messageDialog.SetTitle("podman network inspect") nets.messageDialog.SetText(dialogs.MessageNetworkInfo, headerLabel, data) - nets.messageDialog.Display() + nets.messageDialog.DisplayFullSize() } func (nets *Networks) cprune() { diff --git a/ui/networks/draw.go b/ui/networks/draw.go index cfdaade99..ce125990a 100644 --- a/ui/networks/draw.go +++ b/ui/networks/draw.go @@ -9,14 +9,14 @@ func (nets *Networks) Draw(screen tcell.Screen) { nets.Box.DrawForSubclass(screen, nets) nets.Box.SetBorder(false) - x, y, width, height := nets.GetInnerRect() + netViewX, netViewY, netViewW, netViewH := nets.GetInnerRect() - nets.table.SetRect(x, y, width, height) + nets.table.SetRect(netViewX, netViewY, netViewW, netViewH) nets.table.SetBorder(true) nets.table.Draw(screen) - x, y, width, height = nets.table.GetInnerRect() + x, y, width, height := nets.table.GetInnerRect() // error dialog if nets.errorDialog.IsDisplay() { @@ -60,7 +60,12 @@ func (nets *Networks) Draw(screen tcell.Screen) { // message dialog if nets.messageDialog.IsDisplay() { - nets.messageDialog.SetRect(x, y, width, height+1) + if nets.messageDialog.IsDisplayFullSize() { + nets.messageDialog.SetRect(netViewX, netViewY, netViewW, netViewH) + } else { + nets.messageDialog.SetRect(x, y, width, height+1) + } + nets.messageDialog.Draw(screen) return diff --git a/ui/pods/commands.go b/ui/pods/commands.go index 0d03bcef5..d39e1fc25 100644 --- a/ui/pods/commands.go +++ b/ui/pods/commands.go @@ -104,7 +104,7 @@ func (p *Pods) inspect() { p.messageDialog.SetTitle("podman pod inspect") p.messageDialog.SetText(dialogs.MessagePodInfo, headerLabel, data) - p.messageDialog.Display() + p.messageDialog.DisplayFullSize() } func (p *Pods) kill() { diff --git a/ui/pods/draw.go b/ui/pods/draw.go index 94ddb5450..00fa0b131 100644 --- a/ui/pods/draw.go +++ b/ui/pods/draw.go @@ -10,14 +10,14 @@ func (pods *Pods) Draw(screen tcell.Screen) { pods.Box.DrawForSubclass(screen, pods) pods.Box.SetBorder(false) - x, y, width, height := pods.GetInnerRect() + podViewX, podViewY, podViewW, podViewH := pods.GetInnerRect() - pods.table.SetRect(x, y, width, height) + pods.table.SetRect(podViewX, podViewY, podViewW, podViewH) pods.table.SetBorder(true) pods.table.Draw(screen) - x, y, width, height = pods.table.GetInnerRect() + x, y, width, height := pods.table.GetInnerRect() // error dialog if pods.errorDialog.IsDisplay() { @@ -53,7 +53,12 @@ func (pods *Pods) Draw(screen tcell.Screen) { // message dialog if pods.messageDialog.IsDisplay() { - pods.messageDialog.SetRect(x, y, width, height+1) + if pods.messageDialog.IsDisplayFullSize() { + pods.messageDialog.SetRect(podViewX, podViewY, podViewW, podViewH) + } else { + pods.messageDialog.SetRect(x, y, width, height+1) + } + pods.messageDialog.Draw(screen) return @@ -75,7 +80,7 @@ func (pods *Pods) Draw(screen tcell.Screen) { // stats dialogs if pods.statsDialog.IsDisplay() { - pods.statsDialog.SetRect(x, y, width, height) + pods.statsDialog.SetRect(podViewX, podViewY, podViewW, podViewH) pods.statsDialog.Draw(screen) return diff --git a/ui/pods/poddialogs/stats.go b/ui/pods/poddialogs/stats.go index 0e9df58df..9c35a29b2 100644 --- a/ui/pods/poddialogs/stats.go +++ b/ui/pods/poddialogs/stats.go @@ -297,10 +297,10 @@ func (d *PodStatsDialog) Draw(screen tcell.Screen) { // SetRect set rects for this primitive. func (d *PodStatsDialog) SetRect(x, y, width, height int) { - dX := x + dialogs.DialogPadding - dY := y + dialogs.DialogPadding - 1 - dWidth := width - (2 * dialogs.DialogPadding) //nolint:mnd - dHeight := height - (2 * (dialogs.DialogPadding - 1)) //nolint:mnd + dX := x + 1 + dY := y + 1 + dWidth := width - 2 //nolint:mnd + dHeight := height - 2 //nolint:mnd d.Box.SetRect(dX, dY, dWidth, dHeight) } diff --git a/ui/secrets/commands.go b/ui/secrets/commands.go index 057db392b..2510490ac 100644 --- a/ui/secrets/commands.go +++ b/ui/secrets/commands.go @@ -72,7 +72,7 @@ func (s *Secrets) inspect() { s.messageDialog.SetTitle("podman secret inspect") s.messageDialog.SetText(dialogs.MessageSecretInfo, headerLabel, data) - s.messageDialog.Display() + s.messageDialog.DisplayFullSize() } func (s *Secrets) rm() { diff --git a/ui/secrets/draw.go b/ui/secrets/draw.go index 740627a4c..666798b86 100644 --- a/ui/secrets/draw.go +++ b/ui/secrets/draw.go @@ -7,13 +7,13 @@ func (s *Secrets) Draw(screen tcell.Screen) { s.Box.DrawForSubclass(screen, s) s.Box.SetBorder(false) - x, y, width, height := s.GetInnerRect() + secretViewX, secretViewY, secretViewW, secretViewH := s.GetInnerRect() - s.table.SetRect(x, y, width, height) + s.table.SetRect(secretViewX, secretViewY, secretViewW, secretViewH) s.table.SetBorder(true) s.table.Draw(screen) - x, y, width, height = s.table.GetInnerRect() + x, y, width, height := s.table.GetInnerRect() // error dialog if s.errorDialog.IsDisplay() { @@ -31,7 +31,12 @@ func (s *Secrets) Draw(screen tcell.Screen) { // message dialog if s.messageDialog.IsDisplay() { - s.messageDialog.SetRect(x, y, width, height+1) + if s.messageDialog.IsDisplayFullSize() { + s.messageDialog.SetRect(secretViewX, secretViewY, secretViewW, secretViewH) + } else { + s.messageDialog.SetRect(x, y, width, height+1) + } + s.messageDialog.Draw(screen) return diff --git a/ui/system/command.go b/ui/system/command.go index 4bd10e276..1c3b7312c 100644 --- a/ui/system/command.go +++ b/ui/system/command.go @@ -138,7 +138,7 @@ func (sys *System) info() { sys.messageDialog.SetTitle("SYSTEM INFORMATION") sys.messageDialog.SetText(dialogs.MessageSystemInfo, connName, data) - sys.messageDialog.Display() + sys.messageDialog.DisplayFullSize() } func (sys *System) cprune() { diff --git a/ui/system/draw.go b/ui/system/draw.go index d6f709793..865e593d8 100644 --- a/ui/system/draw.go +++ b/ui/system/draw.go @@ -5,16 +5,16 @@ import ( ) // Draw draws this primitive onto the screen. -func (sys *System) Draw(screen tcell.Screen) { +func (sys *System) Draw(screen tcell.Screen) { //nolint:cyclop sys.refresh() sys.Box.DrawForSubclass(screen, sys) - x, y, width, height := sys.GetInnerRect() + sysViewX, sysViewY, sysViewW, sysViewH := sys.GetInnerRect() - sys.connTable.SetRect(x, y, width, height) + sys.connTable.SetRect(sysViewX, sysViewY, sysViewW, sysViewH) sys.connTable.Draw(screen) - x, y, width, height = sys.connTable.GetInnerRect() + x, y, width, height := sys.connTable.GetInnerRect() // error dialog if sys.errorDialog.IsDisplay() { @@ -50,7 +50,12 @@ func (sys *System) Draw(screen tcell.Screen) { // message dialog if sys.messageDialog.IsDisplay() { - sys.messageDialog.SetRect(x, y, width, height) + if sys.messageDialog.IsDisplayFullSize() { + sys.messageDialog.SetRect(sysViewX, sysViewY, sysViewW, sysViewH) + } else { + sys.messageDialog.SetRect(x, y, width, height) + } + sys.messageDialog.Draw(screen) return @@ -82,7 +87,7 @@ func (sys *System) Draw(screen tcell.Screen) { // event dialog if sys.eventDialog.IsDisplay() { - sys.eventDialog.SetRect(x, y, width, height) + sys.eventDialog.SetRect(sysViewX, sysViewY, sysViewW, sysViewH) sys.eventDialog.Draw(screen) } } diff --git a/ui/system/sysdialogs/df.go b/ui/system/sysdialogs/df.go index 8dc351ee7..11b9d939d 100644 --- a/ui/system/sysdialogs/df.go +++ b/ui/system/sysdialogs/df.go @@ -74,9 +74,7 @@ func NewDfDialog() *DfDialog { tableLayout.AddItem(utils.EmptyBoxSpace(style.DialogBgColor), 1, 0, true) tableLayout.AddItem(tview.NewFlex().SetDirection(tview.FlexRow). - AddItem(utils.EmptyBoxSpace(style.DialogBgColor), 1, 0, false). AddItem(dialog.serviceName, 1, 0, false). - AddItem(utils.EmptyBoxSpace(style.DialogBgColor), 1, 0, false). AddItem(dialog.table, 0, 1, true), 0, 1, true) tableLayout.AddItem(utils.EmptyBoxSpace(style.DialogBgColor), 1, 0, true) diff --git a/ui/system/sysdialogs/event.go b/ui/system/sysdialogs/event.go index c0d4dc88e..556c14ed7 100644 --- a/ui/system/sysdialogs/event.go +++ b/ui/system/sysdialogs/event.go @@ -69,10 +69,8 @@ func NewEventDialog() *EventsDialog { tlayout.AddItem(utils.EmptyBoxSpace(style.DialogBgColor), 1, 0, false) tlayout.AddItem(tview.NewFlex().SetDirection(tview.FlexRow). - AddItem(utils.EmptyBoxSpace(style.DialogBgColor), 1, 0, false). AddItem(tview.NewFlex().SetDirection(tview.FlexRow). AddItem(eventsDialog.serviceName, 1, 0, false). - AddItem(utils.EmptyBoxSpace(style.DialogBgColor), 1, 0, false). AddItem(eventsDialog.textview, 0, 1, true), 0, 1, true), 0, 1, true) @@ -163,19 +161,10 @@ func (d *EventsDialog) HasFocus() bool { // SetRect set rects for this primitive. func (d *EventsDialog) SetRect(x, y, width, height int) { - dWidth := width - (2 * dialogs.DialogPadding) //nolint:mnd - if dWidth < 0 { - dWidth = 0 - } - - dX := x + dialogs.DialogPadding - - dHeight := height - (2 * dialogs.DialogPadding) //nolint:mnd - if dHeight < 0 { - dHeight = 0 - } - - dY := y + dialogs.DialogPadding + dX := x + 1 + dY := y + 1 + dWidth := width - 2 //nolint:mnd + dHeight := height - 2 //nolint:mnd d.Box.SetRect(dX, dY, dWidth, dHeight) }