1
1
mirror of https://github.com/walles/moar.git synced 2024-08-16 23:40:35 +03:00

Exit search on scroll keypresses

This commit is contained in:
Johan Walles 2019-08-04 07:40:26 +02:00
parent 19f477b8e7
commit 2b5828275c
2 changed files with 26 additions and 3 deletions

View File

@ -1,6 +1,7 @@
Moar is a pager. It's designed to just do the right thing without any
configuration:
FIXME: Update this to the Go version
![Moar displaying its own test suite](http://walles.github.io/moar/images/moar.png)
The intention is that Moar should work as a drop-in replacement for
@ -89,9 +90,7 @@ FIXME: Go release instructions
TODO
----
* Exit search on pressing up / down / pageup / pagedown keys and
scroll. I attempted to do that spontaneously, so it's probably a
good idea.
* Remedy all FIXMEs in this README file
* Release the `go` version as the new `moar`, replacing the previous Ruby
implementation
@ -141,3 +140,7 @@ Done
* Change out-of-file visualization to writing --- after the end of the
file and leaving the rest of the screen blank.
* Exit search on pressing up / down / pageup / pagedown keys and
scroll. I attempted to do that spontaneously, so it's probably a
good idea.

View File

@ -411,6 +411,26 @@ func (p *_Pager) _OnSearchKey(logger *log.Logger, key tcell.Key) {
p.searchString = p.searchString[:len(p.searchString)-1]
p._UpdateSearchPattern()
case tcell.KeyUp:
// Clipping is done in _AddLines()
p.firstLineOneBased--
p.mode = _Viewing
case tcell.KeyDown:
// Clipping is done in _AddLines()
p.firstLineOneBased++
p.mode = _Viewing
case tcell.KeyPgUp:
_, height := p.screen.Size()
p.firstLineOneBased -= (height - 1)
p.mode = _Viewing
case tcell.KeyPgDn:
_, height := p.screen.Size()
p.firstLineOneBased += (height - 1)
p.mode = _Viewing
default:
logger.Printf("Unhandled search key event %v", key)
}