Fixing residual characters.

Fixing residual characters issue at end of list, with screen size.

Increasing keyboard buffer size

Increasing steps in a scroll, similar to htop
master
root 3 years ago
parent 4a080bfc3f
commit 6f57bd3697
  1. 7
      cmd/mop/main.go
  2. 13
      screen.go

@ -51,7 +51,7 @@ func mainLoop(screen *mop.Screen, profile *mop.Profile) {
termbox.SetInputMode(termbox.InputMouse)
// use buffered channel for keyboard event queue
keyboardQueue := make(chan termbox.Event, 16)
keyboardQueue := make(chan termbox.Event, 128)
timestampQueue := time.NewTicker(1 * time.Second)
quotesQueue := time.NewTicker(5 * time.Second)
@ -142,10 +142,10 @@ loop:
if lineEditor == nil && columnEditor == nil && !showingHelp {
switch event.Key {
case termbox.MouseWheelUp:
screen.DecreaseOffset(1)
screen.DecreaseOffset(5)
redrawQuotesFlag = true
case termbox.MouseWheelDown:
screen.IncreaseOffset(1, len(profile.Tickers))
screen.IncreaseOffset(5, len(profile.Tickers))
redrawQuotesFlag = true
}
}
@ -169,6 +169,7 @@ loop:
if redrawQuotesFlag && len(keyboardQueue) == 0 {
screen.Draw(quotes)
redrawQuotesFlag = false
}
}
}

@ -179,6 +179,8 @@ func (screen *Screen) draw(str string, offset bool) {
var allLines []string
drewHeading := false
screen.width, screen.height = termbox.Size()
tempFormat := "%" + strconv.Itoa(screen.width) + "s"
blankLine := fmt.Sprintf(tempFormat, "")
allLines = strings.Split(str, "\n")
@ -189,16 +191,23 @@ func (screen *Screen) draw(str string, offset bool) {
// Did we draw the underlined heading row? This is a crude
// check, but--see comments below...
// --- Heading row only appears for quotes, so offset is true
if !drewHeading {
if strings.Contains(allLines[row], "Ticker") &&
strings.Contains(allLines[row], "Last") &&
strings.Contains(allLines[row], "Change") {
drewHeading = true
screen.headerLine = row
screen.DrawLine(0, row, allLines[row])
// move on to the point to offset to
row += screen.offset
}
} else {
if row+screen.offset < len(allLines) &&
// only write the necessary lines
if row <= len(allLines) &&
row > screen.headerLine {
screen.DrawLine(0, row, allLines[row+screen.offset])
screen.DrawLine(0, row-screen.offset, allLines[row])
} else if row > len(allLines) {
row = len(allLines)
}
}
} else {

Loading…
Cancel
Save