commit 7f6f230
Hubert Hirtz
·
2020-11-07 14:43:43 +0000 UTC
parent dffaae8
Handle Alt-Home and Alt-End To navigate to the first/last buffer
3 files changed,
+37,
-25
M
app.go
+27,
-24
1@@ -235,17 +235,7 @@ func (app *App) handleMouseEvent(ev *tcell.EventMouse) {
2 // TODO scroll chan list
3 } else {
4 app.win.ScrollUpBy(4)
5- if app.s == nil {
6- return
7- }
8- buffer := app.win.CurrentBuffer()
9- if app.win.IsAtTop() && buffer != Home {
10- at := time.Now()
11- if t := app.win.CurrentBufferOldestTime(); t != nil {
12- at = *t
13- }
14- app.s.RequestHistory(buffer, at)
15- }
16+ app.requestHistory()
17 }
18 }
19 if ev.Buttons()&tcell.WheelDown != 0 {
20@@ -274,17 +264,7 @@ func (app *App) handleKeyEvent(ev *tcell.EventKey) {
21 app.win.Resize()
22 case tcell.KeyCtrlU, tcell.KeyPgUp:
23 app.win.ScrollUp()
24- if app.s == nil {
25- return
26- }
27- buffer := app.win.CurrentBuffer()
28- if app.win.IsAtTop() && buffer != Home {
29- at := time.Now()
30- if t := app.win.CurrentBufferOldestTime(); t != nil {
31- at = *t
32- }
33- app.s.RequestHistory(buffer, at)
34- }
35+ app.requestHistory()
36 case tcell.KeyCtrlD, tcell.KeyPgDn:
37 app.win.ScrollDown()
38 case tcell.KeyCtrlN:
39@@ -320,9 +300,18 @@ func (app *App) handleKeyEvent(ev *tcell.EventKey) {
40 }
41 app.updatePrompt()
42 case tcell.KeyHome:
43- app.win.InputHome()
44+ if ev.Modifiers() == tcell.ModAlt {
45+ app.win.GoToBufferNo(0)
46+ } else {
47+ app.win.InputHome()
48+ }
49 case tcell.KeyEnd:
50- app.win.InputEnd()
51+ if ev.Modifiers() == tcell.ModAlt {
52+ maxInt := int(^uint(0) >> 1)
53+ app.win.GoToBufferNo(maxInt)
54+ } else {
55+ app.win.InputEnd()
56+ }
57 case tcell.KeyBackspace2:
58 ok := app.win.InputBackspace()
59 if ok {
60@@ -380,6 +369,20 @@ func (app *App) handleUIEvent(ev tcell.Event) {
61 }
62 }
63
64+func (app *App) requestHistory() {
65+ if app.s == nil {
66+ return
67+ }
68+ buffer := app.win.CurrentBuffer()
69+ if app.win.IsAtTop() && buffer != Home {
70+ at := time.Now()
71+ if t := app.win.CurrentBufferOldestTime(); t != nil {
72+ at = *t
73+ }
74+ app.s.RequestHistory(buffer, at)
75+ }
76+}
77+
78 func (app *App) isHighlight(content string) bool {
79 contentCf := strings.ToLower(content)
80 if app.highlights == nil {
+6,
-0
1@@ -78,6 +78,12 @@ of messages are in the timeline:
2 *CTRL-P*, *ALT-LEFT*
3 Go to the previous buffer.
4
5+*ALT-HOME*
6+ Go to the first buffer.
7+
8+*ALT-END*
9+ Go to the last buffer.
10+
11 *UP*, *DOWN*, *LEFT*, *RIGHT*, *HOME*, *END*, *BACKSPACE*, *DELETE*
12 Edit the text in the input field.
13
+4,
-1
1@@ -197,8 +197,11 @@ func (bs *BufferList) tlInnerWidth() int {
2 }
3
4 func (bs *BufferList) To(i int) {
5- if 0 <= i && i < len(bs.list) {
6+ if 0 <= i {
7 bs.current = i
8+ if len(bs.list) <= bs.current {
9+ bs.current = len(bs.list) - 1
10+ }
11 bs.list[bs.current].highlights = 0
12 bs.list[bs.current].unread = false
13 }