1
1
mirror of https://github.com/walles/moar.git synced 2024-09-11 12:15:43 +03:00

Fix scroll hint options parsing

This commit is contained in:
Johan Walles 2022-08-07 17:57:13 +02:00
parent 1e192779f7
commit 0cd33532f9
2 changed files with 19 additions and 3 deletions

View File

@ -225,7 +225,7 @@ func parseScrollHint(scrollHint string, flagSet *flag.FlagSet) twin.Cell {
}
fmt.Fprintln(os.Stderr,
"ERROR: Scroll hint must be exactly one (highlighted) character, try for example 'ESC[2m…'")
"ERROR: Scroll hint must be exactly one (optionally highlighted) character. For example: 'ESC[2m…'")
fmt.Fprintln(os.Stderr)
printUsage(os.Stderr, flagSet, true)
@ -263,9 +263,9 @@ func main() {
statusBarStyleOption := flagSet.String("statusbar", "inverse", "Status bar style: inverse, plain or bold")
UnprintableStyleOption := flagSet.String("render-unprintable", "highlight",
"How unprintable characters are rendered: highlight or whitespace")
scrollLeftHintOption := flagSet.String("scroll-left-hint", "ESC[7m;<",
scrollLeftHintOption := flagSet.String("scroll-left-hint", "ESC[7m<",
"Shown when view can scroll left. One character with optional ANSI highlighting.")
scrollRightHintOption := flagSet.String("scroll-right-hint", "ESC[7m;>",
scrollRightHintOption := flagSet.String("scroll-right-hint", "ESC[7m>",
"Shown when view can scroll right. One character with optional ANSI highlighting.")
// Combine flags from environment and from command line

16
moar_test.go Normal file
View File

@ -0,0 +1,16 @@
package main
import (
"testing"
"github.com/walles/moar/twin"
"gotest.tools/assert"
)
func TestParseScrollHint(t *testing.T) {
token := parseScrollHint("ESC[7m>", nil)
assert.Equal(t, token, twin.Cell{
Rune: '>',
Style: twin.StyleDefault.WithAttr(twin.AttrReverse),
})
}