minor visual improvements

pull/137/head
Simon Let 6 years ago
parent 8b2e45c748
commit 7905252762
  1. 4
      cmd/cli/item.go
  2. 9
      cmd/cli/main.go

@ -126,7 +126,7 @@ func (i item) drawItemColumns(compactRendering bool) itemColumns {
}
}
func (ic itemColumns) produceLine(dateLength int, locationLength int, flagLength int, showDate bool) (string, int) {
func (ic itemColumns) produceLine(dateLength int, locationLength int, flagLength int, header bool, showDate bool) (string, int) {
line := ""
if showDate {
date := ic.date
@ -156,7 +156,7 @@ func (ic itemColumns) produceLine(dateLength int, locationLength int, flagLength
flags += " "
}
spacer := " "
if flagLength > 5 {
if flagLength > 5 || header {
// use shorter spacer
// because there is likely a long flag like E130 in the view
spacer = " "

@ -453,12 +453,17 @@ func (m manager) normalMode(g *gocui.Gui, v *gocui.View) error {
longestDateLen := len(header.date)
longestLocationLen := len(header.host) + len(header.pwdTilde)
longestFlagsLen := 2
maxPossibleMainViewHeight := maxY - 3 - 1 - 1 - 1 // - top box - header - status - help
for i, itm := range m.s.data {
if i == maxY {
break
}
ic := itm.drawItemColumns(compactRenderingMode)
data = append(data, ic)
if i > maxPossibleMainViewHeight {
// do not stretch columns because of results that will end up outside of the page
continue
}
if len(ic.date) > longestDateLen {
longestDateLen = len(ic.date)
}
@ -494,7 +499,7 @@ func (m manager) normalMode(g *gocui.Gui, v *gocui.View) error {
// header
// header := getHeader()
dispStr, _ := header.produceLine(longestDateLen, longestLocationLen, longestFlagsLen, true)
dispStr, _ := header.produceLine(longestDateLen, longestLocationLen, longestFlagsLen, true, true)
dispStr = doHighlightHeader(dispStr, maxX*2)
v.WriteString(dispStr + "\n")
@ -506,7 +511,7 @@ func (m manager) normalMode(g *gocui.Gui, v *gocui.View) error {
break
}
displayStr, _ := itm.produceLine(longestDateLen, longestLocationLen, longestFlagsLen, true)
displayStr, _ := itm.produceLine(longestDateLen, longestLocationLen, longestFlagsLen, false, true)
if m.s.highlightedItem == index {
// maxX * 2 because there are escape sequences that make it hard to tell the real string lenght
displayStr = doHighlightString(displayStr, maxX*3)

Loading…
Cancel
Save