walles / moar

Moar is a pager. It's designed to just do the right thing without any configuration.
Other
587 stars 17 forks source link

Visual Bug for some digits #83

Closed chrisgrieser closed 2 years ago

chrisgrieser commented 2 years ago

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 🤔

walles commented 2 years ago

Thanks for the screenshots!

The white-on-red question marks indicate invalid UTF-8 sequences: https://github.com/walles/moar/blob/fb9f8efbe6b7554e1d7d3af7d0236b425e098e61/m/ansiTokenizer.go#L180-L184

Do you have any kind of sources for what the man page looks like?

chrisgrieser commented 2 years ago

Do you have any kind of sources for what the man page looks like? Do you mean the man page source? Not sure how to get those for the pre-installed commands like pwd, but since the same problem also occurs for manually installed CLIs, I tried out a few of them.

And indeed, the man page for fasd looks especially bad. looking through the repo, it looks like the man page is created from this file: https://github.com/clvv/fasd/blob/master/fasd.1


Screenshot 2022-02-23 23 24 24
walles commented 2 years ago

Are you on an UTF-8 locale? What does locale tell you?

Here's mine:

~ $ locale
LANG="sv_SE.UTF-8"
LC_COLLATE="sv_SE.UTF-8"
LC_CTYPE="sv_SE.UTF-8"
LC_MESSAGES="sv_SE.UTF-8"
LC_MONETARY="sv_SE.UTF-8"
LC_NUMERIC="sv_SE.UTF-8"
LC_TIME="sv_SE.UTF-8"
LC_ALL=
~ $
chrisgrieser commented 2 years ago

yep, everything utf-8 here.

LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL=
walles commented 2 years ago

I'm unsure what to do with this on the moar side.

Do you have any suggestions for changes to moar that would make it better for you in this case?

I kind of like highlighting invalid UTF-8, but in this case it's just annoying.

chrisgrieser commented 2 years ago

Not sure. Maybe simply have an environment variable to turn the highlighting of invalid UTF-8 off? Then every user can decide for themselves, depending on their use case.

chrisgrieser commented 2 years ago

Thanks!

chrisgrieser commented 2 years ago

What's the env variable and the values for it I have to add to my rc file? Isn't in the readme yet

walles commented 2 years ago

Try this:

export MOAR='--render-unprintable=whitespace'

See moar --help for what else you can set it to.

Docs added, thanks for pointing out they were missing! https://github.com/walles/moar#configuring