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

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

Loading…
Cancel
Save