From f9a73817c3db0e8c28875329ee536bbbd95abfa6 Mon Sep 17 00:00:00 2001 From: sqshq Date: Sun, 10 Feb 2019 23:06:48 -0500 Subject: [PATCH] out of range text print fixes --- config.yml | 4 ++-- widgets/layout.go | 2 +- widgets/menu.go | 15 +++++++-------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/config.yml b/config.yml index 865bdb3..acb09ff 100644 --- a/config.yml +++ b/config.yml @@ -52,8 +52,8 @@ runcharts: x: 0 y: 15 size: - x: 4 - y: 4 + x: 15 + y: 15 - title: MONGO COLLECTIONS COUNT items: - label: POSTS diff --git a/widgets/layout.go b/widgets/layout.go index 7c9dd62..069d3d4 100644 --- a/widgets/layout.go +++ b/widgets/layout.go @@ -81,7 +81,7 @@ func (l *Layout) HandleConsoleEvent(e string) { l.menu.idle() chart := l.getSelectedComponent().Drawable.(*RunChart) chart.MoveSelection(0) - case MenuOptionExit: + case MenuOptionResume: l.mode = ModeDefault l.menu.idle() } diff --git a/widgets/menu.go b/widgets/menu.go index d2d5245..888cc37 100644 --- a/widgets/menu.go +++ b/widgets/menu.go @@ -29,7 +29,7 @@ const ( MenuOptionMove MenuOption = "MOVE" MenuOptionResize MenuOption = "RESIZE" MenuOptionPinpoint MenuOption = "PINPOINT" - MenuOptionExit MenuOption = "EXIT" + MenuOptionResume MenuOption = "RESUME" ) func NewMenu() *Menu { @@ -38,7 +38,7 @@ func NewMenu() *Menu { block.BorderStyle = ui.NewStyle(console.ColorDarkGrey) return &Menu{ Block: block, - options: []MenuOption{MenuOptionMove, MenuOptionResize, MenuOptionPinpoint, MenuOptionExit}, + options: []MenuOption{MenuOptionMove, MenuOptionResize, MenuOptionPinpoint, MenuOptionResume}, mode: MenuModeIdle, option: MenuOptionMove, } @@ -181,7 +181,7 @@ func (m *Menu) printAllDirectionsArrowSign(buffer *ui.Buffer, y int) { func (m *Menu) renderOptions(buffer *ui.Buffer) { // 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) offset := 1 @@ -194,11 +194,10 @@ func (m *Menu) renderOptions(buffer *ui.Buffer) { if option != MenuOptionPinpoint || m.component.Type == TypeRunChart { offset += 2 - buffer.SetString( - string(option), - style, - getMiddlePoint(m.Block, string(option), offset-5), - ) + point := getMiddlePoint(m.Block, string(option), offset-5) + if point.In(m.GetRect()) { + buffer.SetString(string(option), style, point) + } } } }