Skip to content

Commit 44a8271

Browse files
committed
Directly include AnsiEsc dependency.
1 parent 084d159 commit 44a8271

File tree

6 files changed

+2502
-5
lines changed

6 files changed

+2502
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/doc/tags

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
Automatically displays image files (png, jpg, gif, bmp) when opened with Vim.
44

55
## Dependencies
6-
- img2txt
7-
- [AnsiEsc.vim][1]
6+
- [img2txt][1]
7+
- [AnsiEsc.vim][2] (bundled)
88

99
## Related
10-
[image.vim][2]
10+
[image.vim][3]
1111

12-
[1]: https://github.com/vim-scripts/AnsiEsc.vim
13-
[2]: https://github.com/ashisha/image.vim
12+
[1]: https://linux.die.net/man/1/img2txt
13+
[2]: http://www.drchip.org/astronaut/vim/index.html#ANSIESC
14+
[3]: https://github.com/ashisha/image.vim

autoload/AnsiEsc.vim

Lines changed: 1631 additions & 0 deletions
Large diffs are not rendered by default.

doc/AnsiEsc.txt

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
*AnsiEsc.txt* Ansi Escape Sequence Visualization Jul 21, 2020
2+
3+
Author: Charles E. Campbell <NcampObell@SdrPchip.AorgM-NOSPAM>
4+
(remove NOSPAM from Campbell's email first)
5+
Copyright: (c) 2004-2017 by Charles E. Campbell *AnsiEsc-copyright*
6+
The VIM LICENSE applies to AnsiEsc.vim and AnsiEsc.txt
7+
(see |copyright|) except use "AnsiEsc" instead of "Vim".
8+
No warranty, express or implied. Use At-Your-Own-Risk.
9+
10+
==============================================================================
11+
1. Contents *AnsiEsc* *AnsiEsc-contents*
12+
1. Contents ...................................|AnsiEsc-contents|
13+
2. AnsiEsc Manual ...................................|AnsiEsc|
14+
3. AnsiEsc Method ...................................|AnsiEsc-Method|
15+
4. AnsiEsc History ...................................|AnsiEsc-history|
16+
17+
==============================================================================
18+
2. Manual *AnsiEsc-manual*
19+
20+
21+
CONCEAL~
22+
The best option: for this, your vim must have +conceal. Try either >
23+
:version
24+
:echo has("conceal")
25+
< if you have vim v7.3. Your vim needs to have been compiled
26+
for "big" or "huge" and to support syntax highlighting.
27+
28+
Vim: (v7.2 or earlier) -- ansi escape sequences themselves are Ignore'd~
29+
Ansi escape sequences have the expected effect on subsequent
30+
text, but the ansi escape sequences themselves still take up
31+
screen columns. The sequences are displayed using "Ignore"
32+
highlighting; depending on your colorscheme, this should either
33+
make the sequences blend into your background or be visually
34+
suppressed. If the sequences aren't suppressed, you need to
35+
improve your colorscheme!
36+
37+
*:AnsiEsc*
38+
USAGE~
39+
:AnsiEsc -- toggles Ansi escape sequence highlighting
40+
:AnsiEsc! -- rebuilds highlighting for new/removed three
41+
or more element Ansi escape sequences.
42+
43+
RESULT~
44+
Ansi escape sequences become concealed or ignored (depending
45+
on whether your vim supports Negri's conceal mode), and their
46+
effect on subsequent text is emulated with Vim's syntax
47+
highlighting.
48+
49+
Syntax highlighting for one and two element codes are
50+
hard-coded into AnsiEsc.vim. There are too many possibilities
51+
for three or more element codes; these are supported by
52+
examining the file for such sequences and only building syntax
53+
highlighting rules for such sequences as are actually present
54+
in the document.
55+
56+
57+
CUSTOMIZATION~
58+
AnsiEsc does not know how to read what your terminal does with
59+
several escape sequences. One may customize what AnsiEsc does
60+
with these by specifying global variables which specify the
61+
desired highlighting:
62+
63+
*g:ansiNone* use this variable to specify what should be done
64+
with <esc>[0m and <esc>[m. Example: >
65+
let g:ansiNone="hi gui=NONE cterm=NONE fg=white bg=black ctermfg=7"
66+
<
67+
*g:ansiBold* use this variable to specify what should be
68+
done with <esc>[1m
69+
70+
*g:ansiItalic* use this variable to specify what should be
71+
done with <esc>[3m
72+
73+
*g:ansiUnderline* use this variable to specify what should be
74+
done with <esc>[4m
75+
76+
EXAMPLE~
77+
78+
You'll want to use :AnsiEsc to see the following properly!
79+
80+
Color Escape Sequences
81+
 -   1   2   3   4   5   7 
82+
black black black black black black black
83+
red red red red red red red
84+
green green green green green green green
85+
yellow yellow yellow yellow yellow yellow yellow
86+
blue blue blue blue blue blue blue
87+
magenta magenta magenta magenta magenta magenta magenta
88+
cyan cyan cyan cyan cyan cyan cyan
89+
white white white white white white white
90+
91+
Black B B B B B B B B
92+
Red R R R R R R R R
93+
Green G G G G G G G G
94+
Yellow Y Y Y Y Y Y Y Y
95+
Blue B B B B B B B B
96+
Magenta M M M M M M M M
97+
Cyan C C C C C C C C
98+
White W W W W W W W W
99+
100+
Here's the vim logo:
101+
102+
/ \
103+
/ \
104+
/ \
105+
/ \
106+
+----+ +----+ \
107+
++ ++ +- | \
108+
/| | / / \
109+
X | | / /O \
110+
\| | / /+-+ +-\//-+
111+
| |/ / | | | v |
112+
| / / | | | + +|
113+
| / | |/| |\/||
114+
+----\ +-+ +-+ ++
115+
\ /
116+
\ /
117+
118+
PROBLEM WITH EMBEDDING:
119+
120+
AnsiEsc plugin highlighting cannot be embedded in another
121+
syntax language.
122+
123+
AnsiEsc uses the syntax highlighting engine, so it is
124+
effectively another syntax highlighting language. But,
125+
there are major differences:
126+
127+
* It supports being turned on and off
128+
129+
* AnsiEsc is not a syntax highlighting file, it
130+
is a plugin
131+
132+
* AnsiEsc dynamically determines some syntax
133+
highlighting by analyzing what's needed in the
134+
current file.
135+
136+
To do a syntax highlighting file would involve an inordinate
137+
quantity of permutations, resulting in a file that would take
138+
much time to load (about a half hour with only a partially
139+
complete set of permutations on my system).
140+
141+
Normally to embed a syntax highlighting language in another
142+
would involve a pair of syntax highlighting commands such as:
143+
144+
syn include @AnsiEsc
145+
syn region ... defines the region where AnsiEsc
146+
\ highlighting is to occur ... contains=@AnsiEsc
147+
148+
placed in the other syntax file's definitions. That won't
149+
work with AnsiEc because, again, AnsiEsc is not a syntax
150+
highlighting file.
151+
152+
153+
==============================================================================
154+
3. AnsiEsc Method *AnsiEsc-Method* {{{1
155+
156+
Method 1: AnsiEsc implements syntax highlighting rules for highlighting the
157+
basic eight colors (black-red-green-yellow-blue-magenta-cyan-white, plus gray)
158+
atop the same basic eight colors, and rules for italic, bold, and underline.
159+
These comprise a fixed set of syntax highlighting rules.
160+
161+
Method 2: Ansi escape codes may also represent a 6x6x6 color cube for an
162+
additional 216 colors, plus 25 grayscale colors. To handle these, AnsiEsc
163+
analyzes the file and builds custom syntax highlighting rules. These comprise
164+
a variable set of syntax highlighting rules. I did it this way because things
165+
166+
a) broke (ie. vim was unable to handle 262000+ syntax highlighting rules),
167+
and
168+
169+
b) took excessive amounts of time to load a fixed set of rules for
170+
256 foreground atop 256 background syntax highlighting rules with
171+
variants for italic, underline, and bold.
172+
173+
174+
==============================================================================
175+
4. AnsiEsc History *AnsiEsc-history* {{{1
176+
v13 Apr 12, 2012 * (Peter Brant) a "conceal" was left on a syntax
177+
definition in a no-conceal-support if block.
178+
Fixed.
179+
Apr 17, 2012 * (Ingo Karkat) support for the "reverse" attribute
180+
May 13, 2014 * (Jason Schmidt) reported that <esc>[39m didn't work.
181+
This means revert to default foreground. Similarly,
182+
<esc>[49m didn't work (which means revert to default
183+
background).
184+
Dec 11, 2014 * Implemented implicit foreground/background
185+
Jan 10, 2015 * (Evgeny Lukianchikov) provided XUbuntu support for
186+
no-ansi-sequence (AnsiNone)
187+
Sep 06, 2016 * Implemented bold/italic/underline without color
188+
specification
189+
Feb 18, 2017 * ansiConceal priority overruled foregroup specs
190+
containing background specs.
191+
(reported by Lucas Hoffman)
192+
Apr 10, 2018 * (James McCoy) provided a patch so that the
193+
|'highlight'| option is no longer used when
194+
conceal is available (see |'conceallevel'|)
195+
May 01, 2019 * (barrie) reported that <esc>[24m was showing up as
196+
a "stray m". Reason: ansiSuppress wasn't handling
197+
the code.
198+
Jul 21, 2020 * (Sergey Vlasov) reported that bold text atop
199+
variously colored backgrounds wasn't being
200+
highlighted.
201+
v12 Jul 23, 2010 * changed conc to |'cole'| to correspond to vim 7.3's
202+
change
203+
* for menus, &go =~# used to insure correct case
204+
Aug 10, 2010 * (Rainer M Schmid) changed conceallevel setting to
205+
depend on whether the version is before vim 7.3;
206+
for 7.3, also sets concealcursor
207+
* Restores conc/cole/cocu settings when AnsiEsc is
208+
toggled off.
209+
Dec 13, 2010 * Included some additional sequences involving 0
210+
Feb 22, 2011 * for menus, &go =~# used to insure correct case
211+
v11 Apr 20, 2010 * AnsiEsc now supports enabling/disabling via a menu
212+
* <esc>[K and <esc>[00m now supported (as
213+
grep --color=always issues them)
214+
v10 May 06, 2009 * Three or more codes in an ANSI escape sequence are
215+
supported by building custom syntax and highlighting
216+
commands.
217+
May 20, 2009 * cecutil bugfix
218+
v9 May 12, 2008 * Now in plugin + autoload format. Provides :AnsiEsc
219+
command to toggle Ansi-escape sequence processing.
220+
Jan 01, 2009 * Applies Ignore highlighting to extended Ansi escape
221+
sequences support 256-colors.
222+
Mar 18, 2009 * Includes "rapid blink" ansi escape sequences. Vim
223+
doesn't have a blinking attribute, so such text uses
224+
"standout" for vim and "undercurl" for gvim.
225+
v8 Aug 16, 2006 * Uses undercurl, and so is only available for vim 7.0
226+
v7 Dec 14, 2004 * Works better with vim2ansi output and Vince Negri's
227+
conceal patch for vim 6.x.
228+
v2 Nov 24, 2004 * This version didn't use Vince Negri's conceal patch
229+
(used Ignore highlighting)
230+
231+
==============================================================================
232+
Modelines: {{{1
233+
vim:tw=78:ts=8:ft=help:fdm=marker:

plugin/AnsiEscPlugin.vim

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
" AnsiEscPlugin.vim
2+
" Author: Charles E. Campbell
3+
" Date: Apr 07, 2010
4+
" Version: 13t
5+
" ---------------------------------------------------------------------
6+
" Load Once: {{{1
7+
if &cp || exists("g:loaded_AnsiEscPlugin")
8+
finish
9+
endif
10+
let g:loaded_AnsiEscPlugin = "v13t"
11+
let s:keepcpo = &cpo
12+
set cpo&vim
13+
14+
" ---------------------------------------------------------------------
15+
" Public Interface: {{{1
16+
com! -bang -nargs=0 AnsiEsc :call AnsiEsc#AnsiEsc(<bang>0)
17+
18+
" DrChip Menu Support: {{{2
19+
if has("gui_running") && has("menu") && &go =~ 'm'
20+
if !exists("g:DrChipTopLvlMenu")
21+
let g:DrChipTopLvlMenu= "DrChip."
22+
endif
23+
exe 'menu '.g:DrChipTopLvlMenu.'AnsiEsc.Start<tab>:AnsiEsc :AnsiEsc<cr>'
24+
endif
25+
26+
" ---------------------------------------------------------------------
27+
" Restore: {{{1
28+
let &cpo= s:keepcpo
29+
unlet s:keepcpo
30+
" vim: ts=4 fdm=marker

0 commit comments

Comments
 (0)