out of range text print fixes

This commit is contained in:
sqshq 2019-02-10 23:06:48 -05:00
parent f8a641d22c
commit f9a73817c3
3 changed files with 10 additions and 11 deletions

View File

@ -52,8 +52,8 @@ runcharts:
x: 0 x: 0
y: 15 y: 15
size: size:
x: 4 x: 15
y: 4 y: 15
- title: MONGO COLLECTIONS COUNT - title: MONGO COLLECTIONS COUNT
items: items:
- label: POSTS - label: POSTS

View File

@ -81,7 +81,7 @@ func (l *Layout) HandleConsoleEvent(e string) {
l.menu.idle() l.menu.idle()
chart := l.getSelectedComponent().Drawable.(*RunChart) chart := l.getSelectedComponent().Drawable.(*RunChart)
chart.MoveSelection(0) chart.MoveSelection(0)
case MenuOptionExit: case MenuOptionResume:
l.mode = ModeDefault l.mode = ModeDefault
l.menu.idle() l.menu.idle()
} }

View File

@ -29,7 +29,7 @@ const (
MenuOptionMove MenuOption = "MOVE" MenuOptionMove MenuOption = "MOVE"
MenuOptionResize MenuOption = "RESIZE" MenuOptionResize MenuOption = "RESIZE"
MenuOptionPinpoint MenuOption = "PINPOINT" MenuOptionPinpoint MenuOption = "PINPOINT"
MenuOptionExit MenuOption = "EXIT" MenuOptionResume MenuOption = "RESUME"
) )
func NewMenu() *Menu { func NewMenu() *Menu {
@ -38,7 +38,7 @@ func NewMenu() *Menu {
block.BorderStyle = ui.NewStyle(console.ColorDarkGrey) block.BorderStyle = ui.NewStyle(console.ColorDarkGrey)
return &Menu{ return &Menu{
Block: block, Block: block,
options: []MenuOption{MenuOptionMove, MenuOptionResize, MenuOptionPinpoint, MenuOptionExit}, options: []MenuOption{MenuOptionMove, MenuOptionResize, MenuOptionPinpoint, MenuOptionResume},
mode: MenuModeIdle, mode: MenuModeIdle,
option: MenuOptionMove, option: MenuOptionMove,
} }
@ -181,7 +181,7 @@ func (m *Menu) printAllDirectionsArrowSign(buffer *ui.Buffer, y int) {
func (m *Menu) renderOptions(buffer *ui.Buffer) { func (m *Menu) renderOptions(buffer *ui.Buffer) {
// TODO extract styles to console.Palette // TODO extract styles to console.Palette
highlightedStyle := ui.NewStyle(console.ColorWhite, console.ColorClear, ui.ModifierReverse) highlightedStyle := ui.NewStyle(console.ColorOlive, console.ColorBlack, ui.ModifierReverse)
regularStyle := ui.NewStyle(console.ColorWhite) regularStyle := ui.NewStyle(console.ColorWhite)
offset := 1 offset := 1
@ -194,11 +194,10 @@ func (m *Menu) renderOptions(buffer *ui.Buffer) {
if option != MenuOptionPinpoint || m.component.Type == TypeRunChart { if option != MenuOptionPinpoint || m.component.Type == TypeRunChart {
offset += 2 offset += 2
buffer.SetString( point := getMiddlePoint(m.Block, string(option), offset-5)
string(option), if point.In(m.GetRect()) {
style, buffer.SetString(string(option), style, point)
getMiddlePoint(m.Block, string(option), offset-5), }
)
} }
} }
} }