From 2b5828275c45cbbb29b029840279787e5c758063 Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Sun, 4 Aug 2019 07:40:26 +0200 Subject: [PATCH] Exit search on scroll keypresses --- README.md | 9 ++++++--- m/pager.go | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7b4ff41..f4169c1 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/m/pager.go b/m/pager.go index 3490160..bd4e11a 100644 --- a/m/pager.go +++ b/m/pager.go @@ -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) }