Skip to content

Commit

Permalink
Implemented navigation using u/b, d/f as suggested in #1
Browse files Browse the repository at this point in the history
  • Loading branch information
mrusme committed Apr 9, 2021
1 parent 84eef88 commit ae49a9f
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,38 @@ func TUI(tuiCore TUICore) {
tuiCore.UpdateTimeline(true)
return nil
case tcell.KeyRune:
switch event.Rune() {
eventRune := event.Rune()
switch eventRune {
case ':':
if tuiCore.EnterCommandMode() == true {
return nil
}
case 'u', 'd', 'b', 'f':
if tuiCore.Mode == NormalMode {
_, _, _, h := tuiCore.Stream.Box.GetRect()
currentLine, _ := tuiCore.Stream.GetScrollOffset()

var scrollLength int = 0
if eventRune == 'u' || eventRune == 'd' {
scrollLength = int((h / 2))
} else if eventRune == 'b' || eventRune == 'f' {
scrollLength = h
}

var scrollTo int = currentLine

if eventRune == 'u' || eventRune == 'b' {
scrollTo = currentLine - scrollLength
} else if eventRune == 'd' || eventRune == 'f' {
scrollTo = currentLine + scrollLength
}

if scrollTo < 0 {
scrollTo = 0
}

tuiCore.Stream.ScrollTo(scrollTo, 0)
}
}
case tcell.KeyEscape:
if tuiCore.ExitCommandMode(false) == true {
Expand Down

0 comments on commit ae49a9f

Please sign in to comment.