From 8aa134b8b23cf945f5a18e21e5fa4855e188d3c0 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 26 Mar 2019 00:37:35 +0200 Subject: Start moving to mauview --- ui/widget/border.go | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'ui/widget/border.go') diff --git a/ui/widget/border.go b/ui/widget/border.go index 8ec772d..f7f367f 100644 --- a/ui/widget/border.go +++ b/ui/widget/border.go @@ -17,8 +17,8 @@ package widget import ( + "maunium.net/go/mauview" "maunium.net/go/tcell" - "maunium.net/go/tview" ) // Border is a simple tview widget that renders a horizontal or vertical bar. @@ -27,24 +27,37 @@ import ( // If the height is 1, the bar will be horizontal. // If the width nor the height are 1, nothing will be rendered. type Border struct { - *tview.Box + Style tcell.Style } // NewBorder wraps a new tview Box into a new Border. func NewBorder() *Border { - return &Border{tview.NewBox()} + return &Border{ + Style: tcell.StyleDefault.Foreground(mauview.Styles.BorderColor), + } } -func (border *Border) Draw(screen tcell.Screen) { - background := tcell.StyleDefault.Background(border.GetBackgroundColor()).Foreground(border.GetBorderColor()) - x, y, width, height := border.GetRect() +func (border *Border) Draw(screen mauview.Screen) { + width, height := screen.Size() if width == 1 { - for borderY := y; borderY < y+height; borderY++ { - screen.SetContent(x, borderY, tview.Borders.Vertical, nil, background) + for borderY := 0; borderY < height; borderY++ { + screen.SetContent(0, borderY, mauview.Borders.Vertical, nil, border.Style) } } else if height == 1 { - for borderX := x; borderX < x+width; borderX++ { - screen.SetContent(borderX, y, tview.Borders.Horizontal, nil, background) + for borderX := 0; borderX < width; borderX++ { + screen.SetContent(borderX, 0, mauview.Borders.Horizontal, nil, border.Style) } } } + +func (border *Border) OnKeyEvent(event mauview.KeyEvent) bool { + return false +} + +func (border *Border) OnPasteEvent(event mauview.PasteEvent) bool { + return false +} + +func (border *Border) OnMouseEvent(event mauview.MouseEvent) bool { + return false +} -- cgit v1.2.3