Skip to content
Snippets Groups Projects
Commit 9adce4b38ed1 authored by Brodie Rao's avatar Brodie Rao
Browse files

color: for the sake of "less -R", default to ansi in auto mode (issue2792)

less with the -R option only supports ANSI color codes, and terminfo
mode issue non-ANSI color codes (depending on the database). The -r
option can work around this, but there are users currently using the
-R option, and defaulting to terminfo would break colorization in less
for them without warning.
parent 55db12e54450
No related branches found
No related tags found
No related merge requests found
......@@ -75,6 +75,14 @@
Some may not be available for a given terminal type, and will be
silently ignored.
Note that on some systems, terminfo mode may cause problems when using
color with the pager extension and less -R. less with the -R option
will only display ECMA-48 color codes, and terminfo mode may sometimes
emit codes that less doesn't understand. You can work around this by
either using ansi mode (or auto mode), or by using less -r (which will
pass through all terminal control codes, not just color control
codes).
Because there are only eight standard colors, this module allows you
to define color names for other color slots which might be available
for your terminal type, assuming terminfo mode. For instance::
......@@ -89,7 +97,8 @@
defined colors may then be used as any of the pre-defined eight,
including appending '_background' to set the background to that color.
The color extension will try to detect whether to use terminfo, ANSI
codes or Win32 console APIs, unless it is made explicit; e.g.::
By default, the color extension will use ANSI mode (or win32 mode on
Windows) if it detects a terminal. To override auto mode (to enable
terminfo mode, for example), set the following configuration option::
[color]
......@@ -94,6 +103,6 @@
[color]
mode = ansi
mode = terminfo
Any value other than 'ansi', 'win32', 'terminfo', or 'auto' will
disable color.
......@@ -97,7 +106,6 @@
Any value other than 'ansi', 'win32', 'terminfo', or 'auto' will
disable color.
'''
import os
......@@ -168,5 +176,5 @@
if os.name == 'nt' and 'TERM' not in os.environ:
# looks line a cmd.exe console, use win32 API or nothing
realmode = 'win32'
elif not formatted:
else:
realmode = 'ansi'
......@@ -172,6 +180,4 @@
realmode = 'ansi'
else:
realmode = 'terminfo'
if realmode == 'win32':
if not w32effects:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment