print string adjustments
This commit is contained in:
parent
e68977b393
commit
dcfdc16a41
|
@ -187,10 +187,11 @@ func (m *Menu) printAllDirectionsArrowSign(buffer *ui.Buffer, y int) {
|
|||
}
|
||||
|
||||
for i, a := range arrows {
|
||||
buffer.SetString(
|
||||
printString(
|
||||
a,
|
||||
ui.NewStyle(console.ColorOlive),
|
||||
getMiddlePoint(m.Block.Rectangle, a, i+y),
|
||||
buffer,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -213,9 +214,6 @@ func (m *Menu) renderOptions(buffer *ui.Buffer) {
|
|||
offset += 2
|
||||
point := getMiddlePoint(m.Block.Rectangle, string(option), offset-5)
|
||||
buffer.SetString(string(option), style, point)
|
||||
//if point.In(m.GetRect()) {
|
||||
// buffer.SetString(string(option), style, point)
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -247,3 +245,10 @@ func (m *Menu) drawInnerBorder(buffer *ui.Buffer) {
|
|||
func getMiddlePoint(rectangle image.Rectangle, text string, offset int) image.Point {
|
||||
return image.Pt(rectangle.Min.X+rectangle.Dx()/2-len(text)/2, rectangle.Max.Y-rectangle.Dy()/2+offset)
|
||||
}
|
||||
|
||||
// TODO move to utils
|
||||
func printString(s string, style ui.Style, p image.Point, buffer *ui.Buffer) {
|
||||
for i, char := range s {
|
||||
buffer.SetCell(ui.Cell{Rune: char, Style: style}, image.Pt(p.X+i, p.Y))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue