walles/moar

Add backwards compatibility with LESS_TERMCAP color settings

khughitt opened this issue ยท 9 comments

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.

This feature would be of great value. Especially while viewing man pages.

Released in 0.9.9.

@caltlgin / @khughitt, has one of you tried the new version? If so, did it work as intended?

I think it should, but if either of you could confirm, that would be super!

Works great. man pages now showing in color.

Made a custom PKGBUILD in Arch so I could install the latest build.

Many thanks ๐Ÿ˜Š

@walles I just tested and the binary appears to work well!

Attempting to install from the AUR, which involves building from source (steps here), fails, however:

==> Starting check()...
--- FAIL: TestManPageFormatting (0.00s)
    pager_test.go:41: Expected 'N'/0x2000000, got 'N'/0x400004a02000000
    pager_test.go:41: Expected 'x'/0x10000000, got 'x'/0x400000202000000
FAIL
FAIL	github.com/walles/moar/m	8.251s
FAIL
==> ERROR: A failure occurred in check().
    Aborting...
Error making: moar

This appears to be due to pre-existing customizations to my LESS_TERMCAP_xx environmental variables. Indeed, unsetting all of them fixes the issue and the tests run successfully.

Perhaps the tests could be modified to either read the existing values or LESS_TERMCAP_xx and adjust expected results / to run the tests in an environment where those variables are not set?

@khughitt test failure fixed in 8e08e72, should work on master now.

@walles Great! Thanks for the quick fix -- I'll let you know if I run into any more issues.

I just recently switched over to moar from less and it seems that moar doesn't respect the standout color settings as less does. My standout color settings are set by:

export LESS_TERMCAP_so=$'\E[01;38;2;187;194;207;48;2;56;122;167m'

This should produce highlighting with a light blue background and white foreground text. However, moar appears to be only inverting the color of the text and background for standout mode.

Is this intentional?

walles commented

@danielclucas could you please open a new issue for this?

Is this intentional?

No, the intention is that the less compatibility functionality should work like less.