summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app.go13
-rw-r--r--doc/senpai.1.scd7
-rw-r--r--ui/buffers.go30
-rw-r--r--ui/ui.go8
4 files changed, 56 insertions, 2 deletions
diff --git a/app.go b/app.go
index bc96f0f..4b9d3e8 100644
--- a/app.go
+++ b/app.go
@@ -489,8 +489,17 @@ func (app *App) handleKeyEvent(ev *tcell.EventKey) {
})
}
case tcell.KeyRune:
- app.win.InputRune(ev.Rune())
- app.typing()
+ if ev.Modifiers() == tcell.ModAlt {
+ switch ev.Rune() {
+ case 'n':
+ app.win.ScrollDownHighlight()
+ case 'p':
+ app.win.ScrollUpHighlight()
+ }
+ } else {
+ app.win.InputRune(ev.Rune())
+ app.typing()
+ }
default:
return
}
diff --git a/doc/senpai.1.scd b/doc/senpai.1.scd
index d5f5b92..df943aa 100644
--- a/doc/senpai.1.scd
+++ b/doc/senpai.1.scd
@@ -86,6 +86,13 @@ of messages are in the timeline:
*ALT-END*
Go to the last buffer.
+*ALT-P*
+ Go to the previous highlight
+
+*ALT-N*
+ Go to the next highlight, or to the (most recent) end of the timeline if
+ there is none.
+
*UP*, *DOWN*, *LEFT*, *RIGHT*, *HOME*, *END*, *BACKSPACE*, *DELETE*
Edit the text in the input field.
diff --git a/ui/buffers.go b/ui/buffers.go
index 0c24248..c126408 100644
--- a/ui/buffers.go
+++ b/ui/buffers.go
@@ -374,6 +374,36 @@ func (bs *BufferList) ScrollDown(n int) {
}
}
+func (bs *BufferList) ScrollUpHighlight() bool {
+ b := &bs.list[bs.current]
+ ymin := b.scrollAmt + bs.tlHeight
+ y := 0
+ for i := len(b.lines) - 1; 0 <= i; i-- {
+ line := &b.lines[i]
+ if ymin <= y && line.Highlight {
+ b.scrollAmt = y - bs.tlHeight + 1
+ return true
+ }
+ y += len(line.NewLines(bs.tlInnerWidth)) + 1
+ }
+ return false
+}
+
+func (bs *BufferList) ScrollDownHighlight() bool {
+ b := &bs.list[bs.current]
+ yLastHighlight := 0
+ y := 0
+ for i := len(b.lines) - 1; 0 <= i && y < b.scrollAmt; i-- {
+ line := &b.lines[i]
+ if line.Highlight {
+ yLastHighlight = y
+ }
+ y += len(line.NewLines(bs.tlInnerWidth)) + 1
+ }
+ b.scrollAmt = yLastHighlight
+ return b.scrollAmt != 0
+}
+
func (bs *BufferList) IsAtTop() bool {
b := &bs.list[bs.current]
return b.isAtTop
diff --git a/ui/ui.go b/ui/ui.go
index 7291042..ef81827 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -132,6 +132,14 @@ func (ui *UI) ScrollDownBy(n int) {
ui.bs.ScrollDown(n)
}
+func (ui *UI) ScrollUpHighlight() bool {
+ return ui.bs.ScrollUpHighlight()
+}
+
+func (ui *UI) ScrollDownHighlight() bool {
+ return ui.bs.ScrollDownHighlight()
+}
+
func (ui *UI) ScrollMemberUpBy(n int) {
ui.memberOffset -= n
if ui.memberOffset < 0 {