Skip to content

Commit

Permalink
Fix #47, help & statusbar don't obey theme. Also fix help text layout.
Browse files Browse the repository at this point in the history
  • Loading branch information
xxxserxxx committed Apr 16, 2020
1 parent 193b40f commit d22c36e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion widgets/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ func NewHelpMenu() *HelpMenu {

func (self *HelpMenu) Resize(termWidth, termHeight int) {
textWidth := 53
for _, line := range strings.Split(KEYBINDS, "\n") {
if textWidth < len(line) {
textWidth = len(line) + 2
}
}
textHeight := strings.Count(KEYBINDS, "\n") + 1
x := (termWidth - textWidth) / 2
y := (termHeight - textHeight) / 2
Expand All @@ -67,7 +72,7 @@ func (self *HelpMenu) Draw(buf *ui.Buffer) {
for y, line := range strings.Split(KEYBINDS, "\n") {
for x, rune := range line {
buf.SetCell(
ui.NewCell(rune, ui.NewStyle(7)),
ui.NewCell(rune, ui.Theme.Default),
image.Pt(self.Inner.Min.X+x, self.Inner.Min.Y+y-1),
)
}
Expand Down
6 changes: 3 additions & 3 deletions widgets/statusbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ func (self *StatusBar) Draw(buf *ui.Buffer) {
}
buf.SetString(
hostname,
ui.NewStyle(ui.ColorWhite),
ui.Theme.Default,
image.Pt(self.Inner.Min.X, self.Inner.Min.Y+(self.Inner.Dy()/2)),
)

currentTime := time.Now()
formattedTime := currentTime.Format("15:04:05")
buf.SetString(
formattedTime,
ui.NewStyle(ui.ColorWhite),
ui.Theme.Default,
image.Pt(
self.Inner.Min.X+(self.Inner.Dx()/2)-len(formattedTime)/2,
self.Inner.Min.Y+(self.Inner.Dy()/2),
Expand All @@ -46,7 +46,7 @@ func (self *StatusBar) Draw(buf *ui.Buffer) {

buf.SetString(
"gotop",
ui.NewStyle(ui.ColorWhite),
ui.Theme.Default,
image.Pt(
self.Inner.Max.X-6,
self.Inner.Min.Y+(self.Inner.Dy()/2),
Expand Down

0 comments on commit d22c36e

Please sign in to comment.