mirror of
https://github.com/hibiken/asynq.git
synced 2025-10-03 05:12:01 +08:00
(cli): Fix withModal helper
This commit is contained in:
@@ -614,7 +614,6 @@ type rowContent struct {
|
||||
}
|
||||
|
||||
func withModal(d *ScreenDrawer, contents []*rowContent) {
|
||||
modalStyle := baseStyle //.Background(tcell.ColorDarkMagenta)
|
||||
w, h := d.Screen().Size()
|
||||
var (
|
||||
modalWidth = int(math.Floor(float64(w) * 0.6))
|
||||
@@ -626,26 +625,27 @@ func withModal(d *ScreenDrawer, contents []*rowContent) {
|
||||
return // no content can be shown
|
||||
}
|
||||
d.Goto(colOffset, rowOffset)
|
||||
d.Print(string(tcell.RuneULCorner), modalStyle)
|
||||
d.Print(strings.Repeat(string(tcell.RuneHLine), modalWidth-2), modalStyle)
|
||||
d.Print(string(tcell.RuneURCorner), modalStyle)
|
||||
d.Print(string(tcell.RuneULCorner), baseStyle)
|
||||
d.Print(strings.Repeat(string(tcell.RuneHLine), modalWidth-2), baseStyle)
|
||||
d.Print(string(tcell.RuneURCorner), baseStyle)
|
||||
d.NL()
|
||||
contentWidth := modalWidth - 4 /* borders + paddings */
|
||||
for i := 1; i < modalHeight-1; i++ {
|
||||
d.Goto(colOffset, rowOffset+i)
|
||||
d.Print(string(tcell.RuneVLine), modalStyle)
|
||||
cnt := &rowContent{strings.Repeat(" ", modalWidth-2), baseStyle}
|
||||
d.Print(fmt.Sprintf("%c ", tcell.RuneVLine), baseStyle)
|
||||
cnt := &rowContent{strings.Repeat(" ", contentWidth), baseStyle}
|
||||
if i <= len(contents) {
|
||||
cnt = contents[i-1]
|
||||
cnt.s = adjustWidth(cnt.s, modalWidth-2)
|
||||
cnt.s = adjustWidth(cnt.s, contentWidth)
|
||||
}
|
||||
d.Print(truncate(cnt.s, modalWidth-2), cnt.style)
|
||||
d.Print(string(tcell.RuneVLine), modalStyle)
|
||||
d.Print(truncate(cnt.s, contentWidth), cnt.style)
|
||||
d.Print(fmt.Sprintf(" %c", tcell.RuneVLine), baseStyle)
|
||||
d.NL()
|
||||
}
|
||||
d.Goto(colOffset, rowOffset+modalHeight-1)
|
||||
d.Print(string(tcell.RuneLLCorner), modalStyle)
|
||||
d.Print(strings.Repeat(string(tcell.RuneHLine), modalWidth-2), modalStyle)
|
||||
d.Print(string(tcell.RuneLRCorner), modalStyle)
|
||||
d.Print(string(tcell.RuneLLCorner), baseStyle)
|
||||
d.Print(strings.Repeat(string(tcell.RuneHLine), modalWidth-2), baseStyle)
|
||||
d.Print(string(tcell.RuneLRCorner), baseStyle)
|
||||
d.NL()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user