1
1
mirror of https://github.com/walles/moar.git synced 2024-09-21 09:01:30 +03:00
Moar is a pager. It's designed to just do the right thing without any configuration.
Go to file
Johan Walles 7fcf99b006 Handle mouse events
Fixes #16
diff --git m/pager.go m/pager.go
index b7cce09..16e91e7 100644
--- m/pager.go
+++ m/pager.go
@@ -611,6 +611,7 @@ func (p *Pager) StartPaging(logger *log.Logger, screen tcell.Screen) {
 	}

 	p.screen = screen
+	screen.EnableMouse()
 	screen.Show()
 	p._Redraw(logger, "")

@@ -672,6 +673,17 @@ func (p *Pager) StartPaging(logger *log.Logger, screen tcell.Screen) {
 				p._OnKey(logger, ev.Key())
 			}

+		case *tcell.EventMouse:
+			switch ev.Buttons() {
+			case tcell.WheelUp:
+				// Clipping is done in _AddLines()
+				p.firstLineOneBased--
+
+			case tcell.WheelDown:
+				// Clipping is done in _AddLines()
+				p.firstLineOneBased++
+			}
+
 		case *tcell.EventResize:
 			// We'll be implicitly redrawn just by taking another lap in the loop

Change-Id: I3c9971077de9a720b90d6d91960f7f33a3a089e3
2019-11-14 07:45:15 +01:00
m Handle mouse events 2019-11-14 07:45:15 +01:00
sample-files Add sample file for color handling 2019-10-28 21:54:57 +01:00
.gitignore Add a script for making new releases 2019-08-04 19:07:14 +02:00
.travis.yml Add highlight to the Travis runs 2019-06-19 07:13:05 +02:00
.whitesource Reboot in Go 2019-06-08 22:12:52 +02:00
build.sh Now using annotated tags for releases 2019-08-05 07:29:06 +02:00
go.mod Show file name and line numbers 2019-06-21 23:24:53 +02:00
go.sum Show file name and line numbers 2019-06-21 23:24:53 +02:00
install.sh Add two comments 2019-07-08 08:58:53 +02:00
LICENSE Reboot in Go 2019-06-08 22:12:52 +02:00
moar.go Fix PAGER= setting detection 2019-07-15 22:47:36 +02:00
moar.sh Write version number into executable 2019-07-07 18:35:55 +02:00
README.md README: Unicode search hits done 2019-11-06 21:42:20 +01:00
release.sh Release script tuning 2019-11-13 16:26:08 +01:00
screenshot.png Add a screenshot 2019-08-04 07:57:09 +02:00
test.sh Add a script for making new releases 2019-08-04 19:07:14 +02:00

Moar is a pager. It's designed to just do the right thing without any configuration:

Moar displaying its own source code

The intention is that Moar should work as a drop-in replacement for Less. If you find that Moar doesn't work that way, please report it!

Doing the right thing includes:

  • Syntax highlight source code by default if Highlight is installed.
  • Search is incremental / find-as-you-type just like in Chrome or Emacs
  • Search becomes case sensitive if you add any UPPER CASE characters to your search terms, just like in Emacs
  • Regexp search if your search string is a valid regexp
  • Supports displaying ANSI color coded texts (like the output from git diff for example)
  • Supports UTF-8 input and output
  • The position in the file is always shown

For compatibility reasons, moar uses the formats declared in these environment variables when viewing man pages:

  • LESS_TERMCAP_md: Bold
  • LESS_TERMCAP_us: Underline

See here for usage examples.

Installing

  1. Download moar for your platform from https://github.com/walles/moar/releases/latest
  2. chmod a+x moar-*-*-*
  3. sudo mv moar-*-*-* /usr/local/bin

And now you can just invoke moar from the prompt!

If a binary for your platform is not available, please file a ticket or contact johan.walles@gmail.com.

Setting Moar as Your Default Pager

Set it as your default pager by adding...

export PAGER=/usr/local/bin/moar

... to your .bashrc.

Issues

Issues are tracked here, or you can send questions to johan.walles@gmail.com.

Developing

First, install Highlight, otherwise the test suite won't pass:

Also, you need the go tools.

Run tests:

./test.sh

Build + run:

./moar.sh ...

Install (into /usr/local/bin) from source:

./install.sh

Making a new Release

Execute release.sh and follow instructions.

TODO

  • Searching for something above us should wrap the search.

  • Enable exiting using ^c (without restoring the screen).

  • Start at a certain line if run as "moar.rb file.txt:42"

  • Redefine 'g' without any prefix to prompt for which line to go to. This definition makes more sense to me than having to prefix 'g' to jump.

  • Handle search hits to the right of the right screen edge. Searching forwards should move first right, then to the left edge and down. Searching backwards should move first left, then up and to the right edge (if needed for showing search hits).

  • Support viewing multiple files by pushing them in reverse order on the view stack.

  • Incremental search using ^s and ^r like in Emacs

  • Retain the search string when pressing / to search a second time.

Done

  • Add '>' markers at the end of lines being cut because they are too long

  • Doing moar on an arbitrary binary (like /bin/ls) should put all line-continuation markers at the rightmost column. This really means our truncation code must work even with things like tabs and various control characters.

  • Make sure search hits are highlighted even when we have to scroll right to see them

  • 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.

  • Remedy all FIXMEs in this README file

  • Release the go version as the new moar, replacing the previous Ruby implementation

  • Add licensing information (same as for the Ruby branch)

  • Make sure "git grep" output gets highlighted properly.

  • Handle all kinds of line endings.

  • Make sure version information is printed if there are warnings.

  • Add spinners while file is still loading

  • Make tail -f /dev/null exit properly, fix https://github.com/walles/moar/issues/7.

  • Showing unicode search hits should highlight the correct chars