Giter Site home page Giter Site logo

moar's Introduction

Linux CI Windows CI

Moar is a pager. It reads and displays UTF-8 encoded text from files or pipelines.

moar is designed to just do the right thing without any configuration:

Moar displaying its own source code

The intention is that Moar should be trivial to get into if you have previously been using Less. If you come from Less and find Moar confusing or hard to migrate to, please report it!

Doing the right thing includes:

  • Syntax highlight source code by default using Chroma
  • 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 | riff for example)
  • Supports UTF-8 input and output
  • Automatic decompression when viewing compressed text files (.gz, .bz2, .xz, .zst, .zstd)
  • The position in the file is always shown
  • Supports word wrapping (on actual word boundaries) if requested using --wrap or by pressing w
  • Follows output as long as you are on the last line, just like tail -f
  • Renders terminal hyperlinks properly
  • Mouse Scrolling works out of the box (but look here for tradeoffs)

For compatibility reasons, moar uses the formats declared in these environment variables if present:

For configurability reasons, moar reads extra command line options from the MOAR environment variable.

Moar is used as the default pager by:

  • px / ptop, ps and top for human beings
  • riff, a diff filter highlighting which line parts have changed

Installing

Using Homebrew

brew install moar

Then whenever you want to upgrade to the latest release:

brew upgrade

Using MacPorts

sudo port install moar

More info here.

Using Gentoo

emerge --ask --verbose sys-apps/moar

More info here.

yay -S moar

More info here.

Manual Install

  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/moar

And now you can just invoke moar from the prompt!

Try moar --help to see options.

If a binary for your platform is not available, please file a ticket or contact [email protected].

Debian / Ubuntu

A Request for Packaging is open, please help!

Configuring

Do moar --help for an up to date list of options.

Environment variable MOAR can be used to set default options.

For example:

export MOAR='--statusbar=bold --no-linenumbers'

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 [email protected].

Packaging

If you package moar, do include the man page in your package.

Embedding

Here's one way to embed moar in your app:

package main

import (
	"bytes"
	"fmt"

	"github.com/walles/moar/m"
)

func main() {
	buf := new(bytes.Buffer)
	for range [99]struct{}{} {
		fmt.Fprintln(buf, "Moar")
	}

	err := m.NewPager(m.NewReaderFromStream("Moar", buf)).Page()
	if err != nil {
		// Handle paging problems
		panic(err)
	}
}

m.Reader can also be initialized using NewReaderFromText() or NewReaderFromFilename().

Developing

You need the go tools.

Run tests:

./test.sh

To run tests in 32 bit mode, either do GOARCH=386 ./test.sh if you're on Linux, or docker build . -f Dockerfile-test-386 (tested on macOS).

Run microbenchmarks:

go test -benchmem -run='^$' -bench=. . ./...

Profiling BenchmarkPlainTextSearch(). Try replacing -alloc_objects with -alloc_space or change the -focus function:

go test -memprofilerate 1 -memprofile profile.out -benchmem -run='^$' -bench '^BenchmarkPlainTextSearch$' github.com/walles/moar/m && go tool pprof -alloc_objects -focus findFirstHit -relative_percentages -web profile.out

Build + run:

./moar.sh ...

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

./install.sh

Making a new Release

Make sure that screenshot.png matches moar's current UI. If it doesn't, scale a window to 81x16 characters and make a new one.

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 file.txt:42

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

  • Showing unicode search hits should highlight the correct chars

  • Word wrap text rather than character wrap it.

  • Arrow keys up / down while in line wrapping mode should scroll by screen line, not by input file line.

  • Define 'g' to prompt for a line number to go to.

moar's People

Contributors

dependabot[bot] avatar emanuel-skrenkovic avatar herbygillot avatar ilyagr avatar m154k1 avatar mtvrsh avatar postsolar avatar thesamesam avatar walles avatar wallunen avatar zmc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moar's Issues

Word wrapping?

Only because the README says moar is a drop-in replacement for less...

less wraps lines; moar does not, and I can't find a setting to make moar wrap lines. If I pipe files through fmt first, I can get wrapped lines, but then moar won't apply highlighting to STDIN data.

Is there a setting I'm missing to make moar wrap lines, rather than having to scroll horizontally to read long lines?

Unrecognized ANSI SGR code <22>

Please post the following report at <https://github.com/walles/moar/issues>,
or e-mail it to [email protected].

Version: 0.9.22-2-g6ec7df0
LANG   : sv_SE.UTF-8
TERM   : xterm-256color

GOOS    : darwin
GOARCH  : amd64
Compiler: gc
NumCPU  : 8

time="2020-10-29T08:37:48+01:00" level=warning msg="Unrecognized ANSI SGR code <22>"
time="2020-10-29T08:37:48+01:00" level=warning msg="Unrecognized ANSI SGR code <22>"
time="2020-10-29T08:37:48+01:00" level=warning msg="Unrecognized ANSI SGR code <22>"
time="2020-10-29T08:37:49+01:00" level=warning msg="Unrecognized ANSI SGR code <22>"
time="2020-10-29T08:37:49+01:00" level=warning msg="Unrecognized ANSI SGR code <22>"
time="2020-10-29T08:37:49+01:00" level=warning msg="Unrecognized ANSI SGR code <22>"
time="2020-10-29T08:37:49+01:00" level=warning msg="Unrecognized ANSI SGR code <22>"
time="2020-10-29T08:37:50+01:00" level=warning msg="Unrecognized ANSI SGR code <22>"
time="2020-10-29T08:37:50+01:00" level=warning msg="Unrecognized ANSI SGR code <22>"
time="2020-10-29T08:37:50+01:00" level=warning msg="Unrecognized ANSI SGR code <22>"
time="2020-10-29T08:37:50+01:00" level=warning msg="Unrecognized ANSI SGR code <22>"
time="2020-10-29T08:37:50+01:00" level=warning msg="Unrecognized ANSI SGR code <22>"
time="2020-10-29T08:37:50+01:00" level=warning msg="Unrecognized ANSI SGR code <22>"
time="2020-10-29T08:37:50+01:00" level=warning msg="Unrecognized ANSI SGR code <22>"
time="2020-10-29T08:37:50+01:00" level=warning msg="Unrecognized ANSI SGR code <22>"

Add backwards compatibility with LESS_TERMCAP color settings

Currently, less can be configured to print manpages, etc. in color using the LESS_TERMCAP_xx environment variables, e.g.:

export LESS_TERMCAP_mb=$'\E[01;31m'       # begin blinking
export LESS_TERMCAP_md=$'\E[01;38;5;74m'  # begin bold
export LESS_TERMCAP_me=$'\E[0m'           # end mode
export LESS_TERMCAP_se=$'\E[0m'           # end standout-mode
export LESS_TERMCAP_so=$'\E[38;5;204m'    # begin standout-mode - info/highlight
export LESS_TERMCAP_ue=$'\E[0m'           # end underline
export LESS_TERMCAP_us=$'\E[01;32m'       # begin underline

It would be really nice if moar supported these as well so that it could be swapped with less without any need to modify the existing configuration.

Crash on 'moar /var/log/syslog'

How to reproduce:

  1. moar /var/log/syslog
  2. use '>' to go to end of document
Version: 0.9.10
LANG   : en_US.UTF-8
TERM   : xterm-256color

GOOS    : linux
GOARCH  : 386
Compiler: gc
NumCPU  : 8

panic: runtime error: slice bounds out of range [:-2147483591] [recovered]
        panic: runtime error: slice bounds out of range [:-2147483591] [recovered]
        panic: runtime error: slice bounds out of range [:-2147483591]

goroutine 1 [running]:
main.main.func1()
        /Users/johan/src/moar/moar.go:85 +0x51f
panic(0x81c76a0, 0xad9c000)
        /usr/local/Cellar/go/1.13.3/libexec/src/runtime/panic.go:679 +0x16b
main._StartPaging.func1(0x820a300, 0xa40a0f0, 0xa40c400)
        /Users/johan/src/moar/moar.go:160 +0xe4
panic(0x81c76a0, 0xad9c000)
        /usr/local/Cellar/go/1.13.3/libexec/src/runtime/panic.go:679 +0x16b
github.com/walles/moar/m.(*Reader)._GetLinesUnlocked(0xa456120, 0x7fffffff, 0x3b, 0x80af40b)
        /Users/johan/src/moar/m/reader.go:357 +0x1ec
github.com/walles/moar/m.(*Reader).GetLines(0xa456120, 0x7fffffff, 0x3b, 0x0)
        /Users/johan/src/moar/m/reader.go:318 +0x75
github.com/walles/moar/m.(*Pager)._AddLines(0xa456180, 0xa456150, 0x0, 0x0)
        /Users/johan/src/moar/m/pager.go:178 +0x56
github.com/walles/moar/m.(*Pager)._Redraw(0xa456180, 0xa456150, 0x0, 0x0)
        /Users/johan/src/moar/m/pager.go:236 +0x4b
github.com/walles/moar/m.(*Pager).StartPaging(0xa456180, 0xa456150, 0x820a300, 0xa40a0f0)
        /Users/johan/src/moar/m/pager.go:696 +0x1a6
main._StartPaging(0xa456120)
        /Users/johan/src/moar/moar.go:172 +0x12e
main.main()
        /Users/johan/src/moar/moar.go:143 +0x24c

Avoid tokensFromString() calls

In profiling, tokensFromString() turns up hot when I mouse scroll vigorously up and down.

Currently, our Readers provide strings.

What they should provide is Lines.

A Line should be initialised using a string, and should implement Tokens() and PlainString().

The Line should do the tokenisation on demand, cache it when done and throw away the original string after it has been tokenised.

This should improve scrolling-up-and-down performance without too much work.

syntax highlighting unreadable on light background

Moar seems to hardcode some (but not all) of its colors. For example a light grey is used for variables and function arguments, but this is almost invisible when using a light background color. Not all Terminals have white font on black background.

Easy-ish solution: don't use hardcoded rgb- or 256-color values anywhere, exclusively use one of the 16 colors set by the terminal. This ensures moar's colors change accordingly when the terminal's colorscheme changes.

(Note: I know dealing with syntax highlighting and colorschemes is hard, especially if you want to support a growing number of programming languages and user-customizable colorschemes (with more than 16colors). I could possibly write you a little summary on how to deal with this, if you're interested.)

Backspace key not delete the character

Hi Expert,

In moar pager if accidentally type wrong search keyword and try to delete through backspace or delete key. it's not deleting the character instead every delete key press it create ? symbol. can we fix it and how do we upgrade the moar app for future release. do i need manual download and replace all time. can we add syntax highlighting support in moar app in future

Crash

Please post the following crash report at <https://github.com/walles/moar/issues>,
or e-mail it to [email protected].

Version: 0.9.8-4-g719942c
LANG   : sv_SE.UTF-8
TERM   : xterm-256color

GOOS    : darwin
GOARCH  : amd64
Compiler: gc
NumCPU  : 8

panic: error parsing regexp: invalid UTF-8: `�` [recovered]
	panic: error parsing regexp: invalid UTF-8: `�` [recovered]
	panic: error parsing regexp: invalid UTF-8: `�`

goroutine 1 [running]:
main.main.func1()
	/Users/walles/src/moar/moar.go:85 +0x548
panic(0x118e2c0, 0xc00044e320)
	/usr/local/Cellar/go/1.12.9/libexec/src/runtime/panic.go:522 +0x1b5
main._StartPaging.func1(0x11efe00, 0xc00012c000, 0xc0000a8720)
	/Users/walles/src/moar/moar.go:160 +0x110
panic(0x118e2c0, 0xc00044e320)
	/usr/local/Cellar/go/1.12.9/libexec/src/runtime/panic.go:522 +0x1b5
github.com/walles/moar/m.ToPattern(0xc000478430, 0x5, 0x11c6d60)
	/Users/walles/src/moar/m/pager.go:398 +0x236
github.com/walles/moar/m.(*_Pager)._UpdateSearchPattern(0xc000098180)
	/Users/walles/src/moar/m/pager.go:352 +0x38
github.com/walles/moar/m.(*_Pager)._OnSearchKey(0xc000098180, 0xc00009c190, 0xc0000a007f)
	/Users/walles/src/moar/m/pager.go:412 +0x5e
github.com/walles/moar/m.(*_Pager)._OnKey(0xc000098180, 0xc00009c190, 0xc00044007f)
	/Users/walles/src/moar/m/pager.go:441 +0x268
github.com/walles/moar/m.(*_Pager).StartPaging(0xc000098180, 0xc00009c190, 0x11efe00, 0xc00012c000)
	/Users/walles/src/moar/m/pager.go:606 +0x274
main._StartPaging(0xc00009c0f0)
	/Users/walles/src/moar/moar.go:172 +0x15a
main.main()
	/Users/walles/src/moar/moar.go:111 +0x55d

Unrecognized ANSI SGR code <2>

I have executed following command in terminal (alacritty).

stash list --pretty=format:\"%C(red)%h%C(reset) - %C(dim yellow)(%C(bold magenta)%gd%C(dim yellow))%C(reset) %<(70,trunc)%s %C(gree  n)(%cr) %C(bold blue)<%an>%C(reset)\"

output is as follows :

Version: 0.9.23
LANG : en_US.UTF-8
TERM : xterm-256color

GOOS : linux
GOARCH : 386
Compiler: gc
NumCPU : 4

time="2020-12-23T19:18:53+05:30" level=warning msg="Unrecognized ANSI SGR code <2>"
time="2020-12-23T19:18:53+05:30" level=warning msg="Unrecognized ANSI SGR code <2>"
time="2020-12-23T19:18:53+05:30" level=warning msg="Unrecognized ANSI SGR code <2>"
time="2020-12-23T19:18:53+05:30" level=warning msg="Unrecognized ANSI SGR code <2>"
time="2020-12-23T19:18:53+05:30" level=warning msg="Unrecognized ANSI SGR code <2>"
time="2020-12-23T19:18:53+05:30" level=warning msg="Unrecognized ANSI SGR code <2>"
time="2020-12-23T19:18:53+05:30" level=warning msg="Unrecognized ANSI SGR code <2>"
time="2020-12-23T19:18:53+05:30" level=warning msg="Unrecognized ANSI SGR code <2>"
time="2020-12-23T19:18:54+05:30" level=warning msg="Unrecognized ANSI SGR code <2>"
time="2020-12-23T19:18:54+05:30" level=warning msg="Unrecognized ANSI SGR code <2>"

[suggestion] Only page when output has more lines than terminal instance has rows.

I had run an update command on one of my packages, and in pulling its Git commits since I'd last updated it, each one-line git log message was opening, synchronously, within moar, despite (and quite hilariously so) that the informative boundaries displayed by moar inhabited more screen space than each one-line message did.

It's a very nice pager so far, but perhaps it could do that thing more and less tend to do when the document has less than one full page's worth of content, and fall back to cat with color output in those cases?

Mouse scroll artifacts

Try this:

  • moar --debug /etc/passwd (file name doesn't matter, can be any text file)
  • Scroll mouse wheel a bit up / down
  • Press q to quit

Expected result

Not much

Current result

Lots of Unhandled rune keypress log messages.

I'm guessing this is really a problem with https://github.com/gdamore/tcell, but it could also be something else.

Tests fail

When trying to install in Arch via AUR the tests (go test github.com/walles/moar/m) fail:

--- FAIL: TestCodeHighlighting (0.24s)
panic: exit status 1 [recovered]
	panic: exit status 1

goroutine 94 [running]:
testing.tRunner.func1.1(0x6b2700, 0xc000304bc0)
	/usr/lib/go/src/testing/testing.go:941 +0x3d0
testing.tRunner.func1(0xc000186120)
	/usr/lib/go/src/testing/testing.go:944 +0x3f9
panic(0x6b2700, 0xc000304bc0)
	/usr/lib/go/src/runtime/panic.go:967 +0x166
github.com/walles/moar/m.TestCodeHighlighting(0xc000186120)
	/home/michi/.cache/yay/moar/src/moar-0.9.18/m/pager_test.go:174 +0x2ca
testing.tRunner(0xc000186120, 0x6d7a98)
	/usr/lib/go/src/testing/testing.go:992 +0xdc
created by testing.(*T).Run
	/usr/lib/go/src/testing/testing.go:1043 +0x357
FAIL	github.com/walles/moar/m	2.011s
FAIL

Homebrew packaging <- This means you!

It would be nice if one could just brew install moar and have moar being kept up to date automatically rather than downloading binaries.

For this to happen, moar needs to be packaged for Homebrew.

And since the Homebrew maintainers frown on authors submitting their own work unless it is very popular, and moar might not be "very popular", this has to be done by $NOT_JOHAN.

Help Wanted <- This means you!

Kindly package moar for Homebrew because I (being moar's main author) can't.

Crash on master

Please post the following report at <https://github.com/walles/moar/issues>,
or e-mail it to [email protected].

Version: v1.7.1-15-g962235d
LANG   : sv_SE.UTF-8
TERM   : xterm-256color

GOOS    : darwin
GOARCH  : amd64
Compiler: gc
NumCPU  : 16

panic: screen lines rendering failed, first 1-based input line available was 0 [recovered]
	panic: screen lines rendering failed, first 1-based input line available was 0 [recovered]
	panic: screen lines rendering failed, first 1-based input line available was 0

goroutine 1 [running]:
main.main.func1()
	/Users/walles/src/moar/moar.go:129 +0x6e
panic(0x131ad60, 0xc000010020)
	/usr/local/Cellar/go/1.16.4/libexec/src/runtime/panic.go:965 +0x1b9
main.startPaging.func1(0x14ab948, 0xc0000bc600, 0xc000070020)
	/Users/walles/src/moar/moar.go:266 +0x125
panic(0x131ad60, 0xc000010020)
	/usr/local/Cellar/go/1.16.4/libexec/src/runtime/panic.go:965 +0x1b9
github.com/walles/moar/m.(*ScreenLines).renderScreenLines(0xc0000b1bf0, 0x1, 0x3a, 0xc00034a000, 0x61c375c5)
	/Users/walles/src/moar/m/screenLines.go:42 +0x168
github.com/walles/moar/m.(*Pager)._Redraw(0xc000076000, 0x0, 0x0)
	/Users/walles/src/moar/m/pager.go:171 +0x148
github.com/walles/moar/m.(*Pager).StartPaging(0xc000076000, 0x14ab948, 0xc0000bc600)
	/Users/walles/src/moar/m/pager.go:663 +0x639
main.startPaging(0xc0000eb3b0, 0x0)
	/Users/walles/src/moar/moar.go:282 +0x125
main.main()
	/Users/walles/src/moar/moar.go:239 +0x765

Avoid screen refreshes

Using this: gdamore/tcell#422

I did some profiling, and my terminal app is maxing out the CPU while I'm scrolling.

If I could not update the screen when there are pending events, that would improve things. I have experimented and it was nice!

Ref:

moar/m/pager.go

Lines 781 to 782 in db4acb5

// FIXME: If more events are ready, skip this redraw, that
// should speed up mouse wheel scrolling

Mouse/Trackpad Scroll Support

On macOS (Darwin), less allows using the mouse or trackpad to scroll up & down. However, this feature is not provided by moar. Do we have any insight on how this feature is implemented? Judging by the output of symbols $(which less), less uses the POSIX terminal interface (i.e., termios.h), since it mentions multiple functions from tcsetattr(3). This may indicate one potential implementation path.

2to3 stderr output clobbers display

If you run 2to3 on some code base and pipe the output into moar, moar's display gets clobbered by the stderr output of 2to3.

This needs to be handled somehow.

Wrapping long lines

Is is possible to switch between wrapping long lines and chopping them (in less, achieved with "-S")?
Haven't find this feature.

[suggestion] Don't clear the screen when exiting

Leave the last screen of output on screen when exiting so that it can be referenced for the next command.

Less does this with the -X option, for example.

❯ moar install.sh
❯
❯ less -X install.sh
#!/bin/bash

set -e -o pipefail

./test.sh

echo

echo 'Installing into /usr/local/bin...'
cp moar /usr/local/bin/moar

echo
echo 'Installed, try "moar moar.go" to see moar in action!'
❯

Compile Tests Failing on Arch Linux

I'm currently unable to pass tests for 0.9.23, or HEAD on Arch Linux.

$ git clone [email protected]:walles/moar.git
Cloning into 'moar'...
remote: Enumerating objects: 83, done.
remote: Counting objects: 100% (83/83), done.
remote: Compressing objects: 100% (55/55), done.
remote: Total 1999 (delta 45), reused 57 (delta 28), pack-reused 1916
Receiving objects: 100% (1999/1999), 3.92 MiB | 7.75 MiB/s, done.
Resolving deltas: 100% (1138/1138), done.

$ cd moar && ./test.sh
--- FAIL: TestGetLongLine (0.09s)
    reader_test.go:161: assertion failed: expression is false: strings.HasPrefix(line, "1 2 3 4")
FAIL
FAIL    github.com/walles/moar/m        13.138s
FAIL

$ highlight --version

 highlight version 3.59
 Copyright (C) 2002-2020 Andre Simon <a dot simon at mailbox.org>

 Argparser class
 Copyright (C) 2006-2008 Antonio Diaz Diaz <ant_diaz at teleline.es>

 Artistic Style Classes (3.1 rev. 672)
 Copyright (C) 2006-2018 by Jim Pattee <jimp03 at email.com>
 Copyright (C) 1998-2002 by Tal Davidson

 Diluculum Lua wrapper (1.0)
 Copyright (C) 2005-2013 by Leandro Motta Barros

 xterm 256 color matching functions
 Copyright (C) 2006 Wolfgang Frisch <wf at frexx.de>

 This software is released under the terms of the GNU General Public License.
 For more information about these matters, see the file named COPYING.
highlight --out-format=esc -i m/pager_test.go

Seems to work correctly.

hg log produces "Unrecognized ANSI SGR code <95>" with TERM=screen-256color

$ hg log
Please post the following report at <https://github.com/walles/moar/issues>,
or e-mail it to [email protected].

Version: 0.9.21
LANG   : en_US.UTF-8
TERM   : screen-256color

GOOS    : linux
GOARCH  : amd64
Compiler: gc
NumCPU  : 32

time="2020-04-22T00:37:36Z" level=warning msg="Unrecognized ANSI SGR code <95>"
time="2020-04-22T00:37:37Z" level=warning msg="Unrecognized ANSI SGR code <95>"
time="2020-04-22T00:37:37Z" level=warning msg="Unrecognized ANSI SGR code <95>"
time="2020-04-22T00:37:37Z" level=warning msg="Unrecognized ANSI SGR code <95>"

Paste in search field not working

Hi Walles,

Can you please address an issue in moar pager where when one try to copy/paste any search keyword in search field by pressing "/" not working.

Hang searching in slow pipes

Try this:

  • Pipe some long-running and slow command output into moar
  • Try searching for something

Expected behaviour:

  • When moar gets to the end of the input so far it should wrap the search

Current behaviour:

  • moar tries to go to the end of the input and gets stuck forever

Mouse copying

This text is now maintained here:
https://github.com/walles/moar/blob/master/MOUSE.md

--

At least on my Mac, if I want to copy something using the mouse i need to hold alt while marking for the mark to work.

The reason is that moar requests mouse events from the terminal, and that makes the terminal not accept mark / copy any more.

less --mouse has the same problems, see comments.

Workarounds

  • Alacritty: Use use shift + mouse selection to make it work. Cred to @chrisgrieser for this tip.
  • Contour: Use shift + mouse selection to mark text. Cred to @postsolar for this tip.
  • Foot: Use use shift + mouse selection to make it work. Cred to @postsolar for this tip.
  • Hyper on macOS: Set macOptionSelectionMode: 'force' in your config file, then hold the Option Key while marking
  • iTerm: Preferences / Profiles / Default / Terminal / uncheck "Report mouse clicks & drags"
  • macOS Terminal on a laptop: Hold down the fn key while marking with the mouse
  • kitty on macOS: Holding shift or fn while marking. Cred to @PrayagS for this tip.
  • Konsole Use use shift + mouse selection. Cred to @cig0 for this tip.
  • Terminator: Use use shift + mouse selection to make it work. Cred to @felix-seifert for this tip.
  • Tilix: Use use shift + mouse selection. Cred to @Macr0Nerd for this tip.
  • Warp: Preferences / Settings / Features / Terminal / uncheck "Enable Mouse Reporting"
  • Windows: Use Shift to make a selection. If you click the wrong initial spot, you can clear the selection with Esc. Just be careful, if you hit Esc without a selection, the pager will exit. Cred to @89z for this one.

less' screen initialization sequence

Recorded using iTerm's Automatically log session input to files feature.

less is version 487 that comes with macOS 11.3 Big Sur.

All linebreaks are mine, added for readability. The ^Ms are not.

less /etc/passwd
^G<ESC>[30m<ESC>(B<ESC>[m^M
<ESC>[?1049h
<ESC>[?1h
<ESC>=^M
##

moar's screen initialization sequence

moar /etc/passwd /Users/johan/src/moar
^G<ESC>[30m<ESC>(B<ESC>[m^M
<ESC>[?1049h
<ESC>[?1006;1000h
<ESC>[?25l
<ESC>[1;1H
<ESC>[m<ESC>[2m  1 <ESC>[22m##

Analysis of less

The line starting with ^G is probably from from fish since it's the same for both less and moar.

<ESC>[?1049h switches to the Alternate Screen Buffer, search here for 1 0 4 9 for info.

Then less does [?1h, which apparently is DECCKM Cursor Keys Mode, send ESC O A for cursor up, followed by =, meaning DECKPAM - Set keypad to applications mode (ESCape instead of digits).

NOTE that this means that less version 487 that comes with macOS 11.3 Big Sur doesn't even try to enable any mouse reporting, but relies on the terminal to convert scroll wheel events into arrow keypresses.

Analysis of moar

Same as less up until the Alternate Screen Buffer is enabled.

<ESC>[?1006;1000h enables SGR Mouse Mode and the X11 xterm mouse protocol (search for 1 0 0 0).

<ESC>[?25l hides the cursor. NOTE Maybe we don't need this? It might be implicit when we enable the Alternate Screen Buffer.

<ESC>[1;1H moves the cursor to the top left corner.

Then it's the first line with its line number in faint type.

Visual Bug for some digits

Thanks for this pager – I looked ages for an alternative to less...

I noticed some weird visual bug where a red question mark is printed in moar. I tried man pwd
Screenshot 2022-02-23 14 42 29

The same in less:
Screenshot 2022-02-23 14 42 50

The colorizing (less_termcap) doesn't seem to be the cause of this, turning of all coloring still creates those questions marks
Screenshot 2022-02-23 14 49 42

Unfortunately, I cannot really pin down when the bug occurs. it seems to be related to digits, but does not affect all digits 🤔

Crash in v1.8.0

Please post the following report at <https://github.com/walles/moar/issues>,
or e-mail it to [email protected].

Version: v1.8.0
LANG   : sv_SE.UTF-8
TERM   : xterm-256color

GOOS    : darwin
GOARCH  : amd64
Compiler: gc
NumCPU  : 16

panic: firstInputLineOneBased 82 not found in allPossibleLines size 58 [recovered]
	panic: firstInputLineOneBased 82 not found in allPossibleLines size 58 [recovered]
	panic: firstInputLineOneBased 82 not found in allPossibleLines size 58

goroutine 1 [running]:
main.main.func1()
	/Users/walles/src/moar/moar.go:136 +0x6e
panic(0x131b420, 0xc000010010)
	/usr/local/Cellar/go/1.16.4/libexec/src/runtime/panic.go:965 +0x1b9
main.startPaging.func1(0x14ac228, 0xc0000bc600, 0xc000218000)
	/Users/walles/src/moar/moar.go:274 +0x125
panic(0x131b420, 0xc000010010)
	/usr/local/Cellar/go/1.16.4/libexec/src/runtime/panic.go:965 +0x1b9
github.com/walles/moar/m.(*ScreenLines).renderScreenLines(0xc0000b1be8, 0x52, 0x3a, 0xc000400060, 0x0)
	/Users/walles/src/moar/m/screenLines.go:60 +0x5c8
github.com/walles/moar/m.(*Pager)._Redraw(0xc00021a000, 0x0, 0x0)
	/Users/walles/src/moar/m/pager.go:171 +0x148
github.com/walles/moar/m.(*Pager).StartPaging(0xc00021a000, 0x14ac228, 0xc0000bc600)
	/Users/walles/src/moar/m/pager.go:663 +0x639
main.startPaging(0xc0000eb3b0, 0x0)
	/Users/walles/src/moar/moar.go:291 +0x12c
main.main()
	/Users/walles/src/moar/moar.go:247 +0x7e5

Windows binary?

Hi, I'm interested in using moar but it appears there are no Windows binaries available. Do you have any plans to build for Windows?

Line numbers glitches

First one

Load an empty file. The bottom of the screen says: Lines 1-0. It should say something else.

Second one:

  • Load a huge file.
  • Go to the end of it.

The bottom of the screen says: Lines 1036120-1036149/1036149.

Those numbers should get commas in them and say: Lines 1,036,120-1,036,149/1,036,149.
See suggested implementation here: http://stackoverflow.com/a/24335216/473672

`require': cannot load such file -- curses (LoadError)

@Hund wrote in #5:

Ops. I was trying out several options and it looks like I mixed up moar and most. It was moar that I couldn't use.

$ ./moar-0.9.6.rb
/usr/lib64/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- curses (LoadError)
from /usr/lib64/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from ./moar-0.9.6.rb:9:in `<main>'
Do you want me to create a new issue for it? :)

Use at least three columns for line numbers

That would enable us to scroll files longer than 99 lines without shifting everything right. There will still be a shift at 1000 lines, but running into that will be less common than the 100 lines bump.

FrozenError: can't modify frozen String

Running on Xubuntu 18.04
Cloned git repo.
Ran ./moar.rb test.rb from the 'src' subdirectory
Tried to do a search via '/' key. Got error below on entering second character of search term:

FrozenError: can't modify frozen String
  /home/jms/bin/moar:93:in `enter_char'
  /home/jms/bin/moar:1004:in `handle_search_keypress'
  /home/jms/bin/moar:1116:in `run'
  /home/jms/bin/moar:1333:in `<main>'

Moar version: UNKNOWN
Ruby version: 2.5.1
Ruby platform: x86_64-linux-gnu
LANG=<en_GB.UTF-8>

Search Problem

Try this:

  • export PAGER=moar
  • git help log
  • Search (/) for PRETTY, end up on the first hit (on line 569 in my case)
  • Press RETURN to exit search mode
  • Press N for the next hit

Current result: Not found: PRETTY

Expected result: Find PRETTY FORMATS heading on line 765.

Note: PRETTY FORMATS is highlighted correctly on line 765, but the search never ends up there.

fish: command help warns about unrecognized ANSI

Fish shell builtin commands come with a --help option. In many cases, moar handles the output fine. In some cases, it warns about "unrecognized ANSI". Is this an issue with moar or the output itself?

> fish --version
fish, version 3.1.0

> functions --help     # works fine?
> type --help          # works fine?
> set --help           # displays warnings

Press q immediately to close the pager.

Please post the following report at <https://github.com/walles/moar/issues>,
or e-mail it to [email protected].

Version: 0.9.18
LANG   : en_US.UTF-8
TERM   : xterm-256color

GOOS    : darwin
GOARCH  : amd64
Compiler: gc
NumCPU  : 8

time="2020-03-24T20:07:12-05:00" level=warning msg="Unrecognized ANSI SGR code <24>"
time="2020-03-24T20:07:12-05:00" level=warning msg="Unrecognized ANSI SGR code <24>"
time="2020-03-24T20:07:12-05:00" level=warning msg="Unrecognized ANSI SGR code <24>"
time="2020-03-24T20:07:12-05:00" level=warning msg="Unrecognized ANSI SGR code <24>"
time="2020-03-24T20:07:12-05:00" level=warning msg="Unrecognized ANSI SGR code <24>"

Here's how most handles the output. It looks like there is something wrong with the output itself.

fish-functions-most

fish-set-most

Install should probably rename

In the README the instructions says to sudo mv moar---* /usr/local/bin` but that should probably be

sudo mv moar-*-*-* /usr/local/bin/moar

Feature Request

Hi Experts,

Can we have style options like we have in BAT tool to render a file in a way looks in screnshot or can be refer BAT style options.

image

Error Warning on Moar running on macOS 12.2

Hi Walles

I got this message on console while reading and closing the log

Please post the following report at https://github.com/walles/moar/issues,
or e-mail it to [email protected].

Version: v1.8.4
LANG : en_US.UTF-8
TERM : screen-256color

GOOS : darwin
GOARCH : amd64
Compiler: gc
NumCPU : 12

time="2022-02-10T23:48:56.218109+05:30" level=warning msg="Got invalid UTF-8 sequence on ttyin: \x1b[<65;132;22M\x1b[<65;132;22M\x1b[Ma\xa46\x1b[Ma\xa46"

Terminal entry not found with "tmux-256color"

Hi! My error said to come report this:

Version: 0.9.18
LANG   : en_US.UTF-8
TERM   : tmux-256color

GOOS    : darwin
GOARCH  : amd64
Compiler: gc
NumCPU  : 16

panic: terminal entry not found [recovered]
        panic: terminal entry not found

goroutine 1 [running]:
main.main.func1()
        /Users/johan/src/moar/moar.go:88 +0x6b
panic(0x119e4c0, 0xc00009e4c0)
        /usr/local/Cellar/go/1.13.4/libexec/src/runtime/panic.go:679 +0x1b2
main._StartPaging(0xc0000cc140)
        /Users/johan/src/moar/moar.go:158 +0x183
main.main()
        /Users/johan/src/moar/moar.go:120 +0x605

Seems like theres a problem with some custom terminals...

Suggestion: horizontal scrolling with Vim keys

I've just discovered moar, and it does exactly what it advertises itself for, but having to scroll horizontally with arrow keys is very cumbersome. I would suggest having vim keys for horizontal scrolling (h - left, l - right). The help keybinding could be moved anywhere else (maybe question mark key or F1?), it's not used very often and I would argue that more people hit 'h' thinking it's horizontal scroll than those who actually need help.

Fix shutdown hang

Try this

  • Open moar on a large file
  • Mouse scroll a lot
  • Press q while the mouse scroll is catching up (#34)

Current result

moar closes its display, but then hangs without giving any prompt back. Ctrl-C doesn't help, it has to be killed.

Expected result

A clean exit.

moar pager not showing complete content of big files

Hi Expert,

Today while using moar app for reading big size log which have 8339 lines log file moar skipped the output of last few lines even moar search was not producing any result but same time when i open the very same file in normal text editor like BBedit .. it's showing complete context of file thats how i came to know moar is skipping file contents. this seems to be a bug or buffer limit .. i don't know. please have a look.

I am running moar version 1.8.4 on macOS 12.1.

here in below screenshot you can see moar is telling this file have 8339 lines but it skipping the lines only 8338 and missed last one ...Also when i was searching Dec 23 in this file search result was saying no match found which is strange. I can't share this complete file as it have some sensitive data

image

Feature request for pattern search like VIM

Hi Team,

Can we have pattern search feature in moar like we have in vim where we use :g/pattern to match the keyword and list all the lines match to search pattern then we use vim jump feature to jump on the matched line

Second issue i have noticed when i try to search any keyword in moar by click / the search box appear then if any keyword which i have selected and wants to paste. i am not able to do it. I have to type the search keyword all time. Thanks

Unhandled search key event <...>

Trying out moar on my macOS Catalina workstation. I reproed this both with HEAD and the 0.9.17 official release:

  1. export PAGER=moar
  2. man bash
  3. hit '/', then ctrl-c, ctrl-r, other keypresses that don't do anything

After quitting I see in my terminal, e.g.

$ man bash
Please post the following report at <https://github.com/walles/moar/issues>,
or e-mail it to [email protected].

Version: 0.9.17
LANG   : en_US.UTF-8
TERM   : xterm-256color

GOOS    : darwin
GOARCH  : amd64
Compiler: gc
NumCPU  : 4

2019/12/06 00:25:56 Unhandled key event 18
2019/12/06 00:25:57 Unhandled rune keypress 'l'
2019/12/06 00:25:57 Unhandled rune keypress 's'
2019/12/06 00:25:57 Unhandled rune keypress 's'
2019/12/06 00:25:58 Unhandled key event 3
2019/12/06 00:25:58 Unhandled key event 18

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.