AnsiEsc can not show background

147 views
Skip to first unread message

Peng Yu

unread,
Dec 12, 2013, 12:08:19 PM12/12/13
to vim...@googlegroups.com
Hi,

The following code shows that vim can not show background color correctly form Ansi Color. Is there a command to enable background color? Thanks.

~/linux/test/python/man/library/termcolor/colored/on_red$ cat main.py
#!/usr/bin/env python

from termcolor import colored
print colored('hello', 'white', 'on_red'), colored('world', 'white', 'on_green')

~/linux/test/python/man/library/termcolor/colored/on_red$ type less
less is aliased to `vim -R -c AnsiEsc -'
~/linux/test/python/man/library/termcolor/colored/on_red$ ./main.py |less

Regards,
Peng

Charles Campbell

unread,
Dec 12, 2013, 1:33:57 PM12/12/13
to vim...@googlegroups.com
I get...
Traceback (most recent call last):
File "./junk.pm", line 3, in <module>
from termcolor import colored
ImportError: No module named termcolor
Vim: Reading from stdin...

Regards,
C Campbell

Peng Yu

unread,
Dec 12, 2013, 3:29:27 PM12/12/13
to vim_use
You need to install termcolor (https://pypi.python.org/pypi/termcolor)
first by pip or something else.
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> --- You received this message because you are subscribed to a topic in the
> Google Groups "vim_use" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/vim_use/OaASJlRyOGo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> vim_use+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Regards,
Peng

Charles Campbell

unread,
Dec 12, 2013, 3:31:48 PM12/12/13
to vim...@googlegroups.com
Peng Yu wrote:
> You need to install termcolor (https://pypi.python.org/pypi/termcolor)
> first by pip or something else.
>
Why not capture the ansi escape sequence involved and tell me what it
is? If its not an ansi escape sequence, then that likely is beyond the
purview of AnsiEsc.

Regards,
C Campbell

Peng Yu

unread,
Dec 12, 2013, 3:50:15 PM12/12/13
to vim_use
> Why not capture the ansi escape sequence involved and tell me what it is?
> If its not an ansi escape sequence, then that likely is beyond the purview
> of AnsiEsc.

Here is the output of the python script.
[31mhello [0m [32mworld [0m

--
Regards,
Peng

Charles Campbell

unread,
Dec 12, 2013, 4:13:28 PM12/12/13
to vim...@googlegroups.com
Interpreting this manually:
<chg to red fgd>hello <reset to normal terminal colorization><chg to
green fgd>world <reset to normal terminal colorization>

When I placed that into a file, inserted the missing escape characters,
and applied AnsiEsc to the file, I got a red "hello", a space, and a
green "world" as I'd expect. The background is not specified in these
ansi-escape sequences, and so AnsiEsc would be wrong if it did change
the background.

Regards,
C Campbell

Peng Yu

unread,
Dec 12, 2013, 4:17:27 PM12/12/13
to vim_use
I'm sorry. The previous output is wrong. Here is the correct output.

^[[41m^[[37mhello^[[0m ^[[42m^[[37mworld^[[0m

Christian Brabandt

unread,
Dec 12, 2013, 5:40:23 PM12/12/13
to vim_use
Hi Peng!

On Do, 12 Dez 2013, Peng Yu wrote:

> I'm sorry. The previous output is wrong. Here is the correct output.
>
> ^[[41m^[[37mhello^[[0m ^[[42m^[[37mworld^[[0m

You can also try my Colorizer plugin
(https://github.com/chrisbra/Color_highlight)
That should be able to handle it.

Best,
Christian
--
Der Verstand ist wie eine Fahrkarte: Sie hat nur dann einen Sinn, wenn
sie benutzt wird.
-- Ernst R. Hauschka

Charles E Campbell

unread,
Dec 14, 2013, 12:25:37 PM12/14/13
to vim...@googlegroups.com
Peng Yu wrote:
> I'm sorry. The previous output is wrong. Here is the correct output.
>
> ^[[41m^[[37mhello^[[0m ^[[42m^[[37mworld^[[0m
>
I see the problem and will try to fix it.

Thanks!
Chip Campbell

Charles E Campbell

unread,
Dec 11, 2014, 11:03:33 PM12/11/14
to vim...@googlegroups.com
Peng Yu wrote:
> I'm sorry. The previous output is wrong. Here is the correct output.
>
> ^[[41m^[[37mhello^[[0m ^[[42m^[[37mworld^[[0m
>
Hello, Peng:

Sorry it took so long -- but I think I have AnsiEsc able to handle the
above.

I've attached a copy.

Regards,
Chip Campbell

AnsiEsc.vba.gz

Peng Yu

unread,
May 29, 2015, 11:21:53 PM5/29/15
to vim_use, Charles E Campbell Jr
I got the following error. Do you know what is wrong?

Also, could you please post it at
<http://www.vim.org/scripts/script.php?script_id=302>.

***vimball*** Source this file to extract it! (:so %)
removed 4 files
Vimball Archive
extracted <plugin/AnsiEscPlugin.vim>: 30 lines
wrote /Users/pengy/.vim/plugin/AnsiEscPlugin.vim
extracted <autoload/AnsiEsc.vim>: 1211 lines
wrote /Users/pengy/.vim/autoload/AnsiEsc.vim
extracted <plugin/cecutil.vim>: 536 lines
wrote /Users/pengy/.vim/plugin/cecutil.vim
extracted <doc/AnsiEsc.txt>: 175 lines
wrote /Users/pengy/.vim/doc/AnsiEsc.txt
did helptags
Error detected while processing SourceCmd Auto commands for "*.vba.gz":
E444: Cannot close last window
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> --- You received this message because you are subscribed to a topic in the
> Google Groups "vim_use" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/vim_use/OaASJlRyOGo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> vim_use+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Regards,
Peng

Charles Campbell

unread,
Jun 1, 2015, 10:37:43 AM6/1/15
to vim...@googlegroups.com
Peng Yu wrote:
> I got the following error. Do you know what is wrong?
>
> Also, could you please post it at
> <http://www.vim.org/scripts/script.php?script_id=302>.
>
> ***vimball*** Source this file to extract it! (:so %)
> removed 4 files
> Vimball Archive
> extracted <plugin/AnsiEscPlugin.vim>: 30 lines
> wrote /Users/pengy/.vim/plugin/AnsiEscPlugin.vim
> extracted <autoload/AnsiEsc.vim>: 1211 lines
> wrote /Users/pengy/.vim/autoload/AnsiEsc.vim
> extracted <plugin/cecutil.vim>: 536 lines
> wrote /Users/pengy/.vim/plugin/cecutil.vim
> extracted <doc/AnsiEsc.txt>: 175 lines
> wrote /Users/pengy/.vim/doc/AnsiEsc.txt
> did helptags
> Error detected while processing SourceCmd Auto commands for "*.vba.gz":
> E444: Cannot close last window
>
I am able to duplicate the message "Cannot close last window", so I'll
look into it. Nonetheless, the AnsiEsc extraction was successful and
helptags generated.

Regards,
Chip Campbell

Reply all
Reply to author
Forward
0 new messages