1
1
mirror of https://github.com/walles/moar.git synced 2024-11-27 01:05:23 +03:00

Add command line switch for hiding line numbers

This commit is contained in:
Johan Walles 2021-06-03 21:49:02 +02:00
parent 24776d7fe3
commit 4552bfd79c

View File

@ -140,6 +140,7 @@ func main() {
styleOption := flagSet.String("style", "native",
"Highlighting style from https://xyproto.github.io/splash/docs/longer/all.html")
colorsOption := flagSet.String("colors", "16M", "Highlighting palette size: 8, 16, 256, 16M")
noLineNumbers := flagSet.Bool("no-linenumbers", false, "Hide line numbers on startup, press left arrow key to show")
// Combine flags from environment and from command line
flags := os.Args[1:]
@ -236,7 +237,7 @@ func main() {
if stdinIsRedirected {
// Display input pipe contents
reader := m.NewReaderFromStream("", os.Stdin)
startPaging(reader, *wrap)
startPaging(reader, *wrap, *noLineNumbers)
return
}
@ -246,10 +247,10 @@ func main() {
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
os.Exit(1)
}
startPaging(reader, *wrap)
startPaging(reader, *wrap, *noLineNumbers)
}
func startPaging(reader *m.Reader, wrapLongLines bool) {
func startPaging(reader *m.Reader, wrapLongLines bool, noLineNumbers bool) {
screen, e := twin.NewScreen()
if e != nil {
panic(e)
@ -279,5 +280,6 @@ func startPaging(reader *m.Reader, wrapLongLines bool) {
log.SetOutput(&loglines)
pager := m.NewPager(reader)
pager.WrapLongLines = wrapLongLines
pager.ShowLineNumbers = !noLineNumbers
pager.StartPaging(screen)
}