Commit Graph

94 Commits

Author SHA1 Message Date
Peter Arrenbrecht
421dba9540 color: fix --color=always when output is piped
Also restructures the mode determination as discussed on IRC.
I tried to simplify the code too, while keeping the original
semantics except for the case of --color=always.
2011-05-25 18:48:00 +02:00
Dan Villiom Podlaski Christiansen
261e0642d3 color: fix using multiple effects 2011-05-01 16:54:48 +02:00
timeless
ab34ee7694 remove unused imports 2011-05-01 15:21:57 +02:00
Brodie Rao
5a336c7b00 color: use ui.formatted() to test TTYness, not sys.stdout.isatty()
This fixes the color extension not working with pager (broken in
cab5f9b68e3a). The pager extension already sets ui.formatted=True to
allow this use case.
2011-05-01 12:14:22 +02:00
Augie Fackler
720e112a65 color: verify stdout is a tty before using curses
Without this change, curses complains when invoked in certain contexts
because stdout isn't a tty (such as emacs integration) but we ask it
to check for various bits of information from terminfo.
2011-04-30 11:18:43 -05:00
Patrick Mezard
44388c0fa1 color: code simplification 2011-04-24 23:06:19 +02:00
Danek Duvall
e826f21afa color: add support for terminfo-based attributes and color
Using terminfo instead of hard-coding ECMA-48 control sequences provides a
greater assurance that the terminal codes are correct for the current
terminal type; not everything supports the ANSI escape codes.

It also allows us to use a wider range of colors when a terminal emulator
supports it (such as 16- or 256-color xterm), and a few more non-color
attributes, such as the ever-popular blink.
2011-04-21 13:47:45 -07:00
Idan Kamara
35892dd390 color: reset win32 console color in a finally block 2011-04-09 23:53:23 +03:00
Martin Geisler
73d96c7696 ui: label prompts, default to yellow prompts 2011-03-27 12:59:25 +02:00
Matt Mackall
a1c69b99f5 merge with stable 2011-03-14 15:59:44 -05:00
Martin Geisler
2009744e21 color: wrap lines in docstring 2011-03-14 15:19:58 +01:00
Martin Geisler
e450b1ed50 color: don't mention internal function in docstring
The render_text function actually never existed, the docstring
probably meant the render_effects function instead.
2011-03-14 13:54:25 +01:00
Adrian Buehlmann
62ca9f7af6 color: port to using ctypes (issue2687)
replacing usage of pywin32, which was removed for Mercurial 1.8
2011-03-11 11:14:21 +01:00
Matt Mackall
574616ca42 bookmarks: move color style to color 2011-02-10 13:46:28 -06:00
Martin Geisler
f260637139 color: give hint to translators about untranslated keywords 2010-10-22 16:34:38 +02:00
Brodie Rao
32f9e577c3 color: add global option in extsetup() instead of globally
This prevents side effects from occurring when importing the color
extension.
2010-10-10 12:21:36 -05:00
Sune Foldager
060a59a3cc merge with stable 2010-09-13 16:25:13 +02:00
Sune Foldager
cd1204adbe color: add win32 support for non-black background
This complicates the code a bit, since attributes need to be masked together
correctly before they are applied. Perhaps the code should be redesigned at
some point, but this works well for now.
2010-09-13 16:12:25 +02:00
Brodie Rao
5a1e1994ac help: refer to user configuration file more consistently
Currently, a number of commands and help topics mention the user hgrc
file in different ways. Among these are following:

1. .hgrc - "please specify your commit editor/username in your .hgrc
file", bookmarks, color, hgk, pager, hg help environment

2. $HOME/.hgrc - hg help paths, hgrc(5), hg(1)

3. ~/.hgrc - hgrc(5)

In addition to being inconsistent, none of these make sense on
Windows. This patch replaces the above with a more general term of
"[your] configuration file".
2010-08-27 22:36:35 -04:00
Augie Fackler
2ad9623e97 color: accept usual boolean values as synonyms for always and never 2010-08-28 21:57:36 -05:00
Martin Geisler
c3c7fa090f Merge with stable 2010-08-30 13:00:22 +02:00
Steve Borho
17ad59ab74 color: handle more Windows console errors
If your application is being built as a non-console application,
stdout is not a valid handle and raises an exception:

pywintypes.error: (6, 'DuplicateHandle', 'The handle is invalid.')

Alternatively, non-console applications launched outside of a
console will return None from GetStdHandle instead of raising an
exception.
2010-08-27 22:24:47 -05:00
Brodie Rao
203cf2fbd9 cleanup: remove unused imports 2010-08-27 13:32:38 -04:00
Jeremy Whitlock
0a6d3a397f color: enable branches support
This commit updates the branches command to use ui.label for the branch names
and the changeset.  This implementation allows assigning colors to the four
states of a branch: active, closed, current and inactive.  While you can
configure color for the four states, only current and closed have default colors
of green and black bold respectively.
2010-07-28 23:05:03 -06:00
Brodie Rao
0f7e715bdb hgcia/color: remove star imports
This plays nicer with demandimport and allows pyflakes to detect undefined
names.
2010-08-03 13:02:11 -04:00
Brodie Rao
6d1ff05d76 color: call correct superclass method in write_err
Without this fix, any calls to write_err would go to stdout instead of
stderr, and calls during pushbuffer would cause unpack ValueErrors on
popbuffer.
2010-08-02 10:48:31 -04:00
Brodie Rao
52fb27575c color: pass write/write_err to win32print correctly (issue2312) 2010-08-01 16:26:02 -04:00
Brodie Rao
6f58bfc15e color/progress: subclass ui instead of using wrapfunction (issue2096)
This resolves the issue of hg cmd --mq not being colorized. This was due
to color wrapping only the instance of ui passed to dispatch._runcommand(),
which isn't the same ui object that mq.mqcommand() receives. After dispatch
calls extensions.loadall(), it makes sure any changes to ui.__class__ in
uisetup are propagated.

progress is updated to wrap ui in the same manner because wrapfunction
doesn't play well when ui.__class__ has been replaced by another extension
(orig will point to the old class method instead of color's).
2010-07-01 19:23:26 -05:00
Dan Villiom Podlaski Christiansen
eb569c8b47 color: use ui.formatted(). 2010-06-07 15:28:54 +02:00
FUJIWARA Katsunori
ce06b102df help: show value requirement and multiple occurrence of options
this helps users to know what kind of option is:

  - no value is required(flag option)
  - value is required
  - value is required, and multiple occurrences are allowed

each kinds are shown as below:

 -f --force              force push
 -e --ssh CMD            specify ssh command to use
 -b --branch BRANCH [+]  a specific branch you would like to push

if one or more 3rd type options are shown, explanation for '[+]' mark
is also shown as footnote.
2010-06-06 17:25:00 +09:00
Steve Borho
b82bd4f289 Backed out changeset: 1bfde817782c 2010-06-08 15:52:41 -05:00
Steve Borho
e91613380a color: labeled text should be passed to ui.write() as ui.labeled
Some implementations of ui.label() (HTML versions in particular) must escape
the provided text and then markup the text with their tags.  When this marked
up text is then passed to ui.write(), we must label the text as 'ui.labeled'
so the implementation knows not to escape it a second time (exposing the initial
markup).

This required the addition of a 'ui.plain' label for text that is purposefully
not marked up.

I was a little pedantic here, passing even ' ' strings to ui.label() when it
would be included with other labeled text in a ui.write() call.   But it seemed
appropriate to lean to the side of caution.
2010-06-03 23:18:18 -05:00
Yuya Nishihara
be0949be33 color: bring back colors with pager
It's introduced by f77a63ba3f8f, but missing in merge changeset
at fe99ec3fe2d0.
2010-05-18 18:55:14 +09:00
Stanimir Stamenkov
268f6af2e2 color: add some missing background colors for win32 console 2010-05-07 15:19:37 -05:00
Steve Borho
146627c709 color: fix typo in w32effect for bold_background 2010-05-01 16:57:02 -05:00
Patrick Mezard
ed31d6901d color: handle non-standard stdout on win32 2010-04-23 14:29:44 +02:00
Steve Borho
bde27d9380 color: respect HGPLAIN 2010-04-06 08:54:18 -05:00
Steve Borho
898c5adf56 color: add support for Windows consoles
Introduces color.mode configurable with values 'auto', 'ansi', or 'win32'.  Any
other value disables coloring.  When 'auto' is selected, the win32 console
method will be used if the win32console Python module is detected (requires
pywin32 to be installed).
2010-04-06 08:49:19 -05:00
Steve Borho
b2f2de10b6 color: remove unused import 2010-04-06 08:44:13 -05:00
Brodie Rao
2f064ecab9 color: concatenate effects correctly and avoid printing empty effects 2010-04-04 22:53:50 -05:00
Brodie Rao
1ad67ea95f color: don't split colors across lines (which confuses less -R)
Currently, less -R doesn't support colors spanning multiple lines; only
the first line will be colorized.

Instead of allowing colors to span multiple lines, the color extension
now applies colors to each line it receives, even when ui.write() is
given multiple lines in one call.
2010-04-02 15:22:19 -05:00
Brodie Rao
e46074c7b3 color: colorize based on output labels instead of parsing output
By overriding ui.write(), ui.write_err(), ui.popbuffer(), and ui.label(),
the color extension can avoid parsing command output and simply colorize
output based on labels.

As before, the color extension provides a list of default colors for
core commands/labels. Other extensions can provide their own defaults by
specifying a colortable dict (similar to cmdtable).

In this process, --color is promoted to a global option and the deprecated
--no-color option is removed.
2010-04-02 15:22:17 -05:00
Martin Geisler
eeedee37da Merge with default 2010-02-15 00:14:16 +01:00
Brodie Rao
459206adee color: don't crash on invalid status codes (issue2036)
If an unknown file with a newline appears in the status output, color
shouldn't raise a KeyError trying to parse second line in the filename.
2010-02-14 17:08:52 -05:00
Brodie Rao
892ba5a830 remove unused imports 2010-02-14 01:52:31 -05:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Georg Brandl
c212597377 color: colorize output of hg resolve -l 2010-01-09 10:47:47 +01:00
Benoit Boissinot
3153270fb3 color: improve coding style 2010-01-08 20:56:28 +01:00
David Soria Parra
f9a3794d26 color: Add support for bookmarks 2009-12-11 11:04:31 +01:00
David Soria Parra
ac2717c956 color: Do not pass --color, --no-color parameters to wrapped function
Passing the --color and --no-color parameter to the wrapped function
can cause a invalid argument exception if the wrapped function doesn't
accepts a **opts dict.
2009-12-11 11:04:31 +01:00