Comments (4)
When
256 88
means base-256 but only the first 87, then why doesn't256 8 4
mean base-256 but only the first 4?
It makes sense (I believe) if you keep in mind that each Color
declaration has three values:
- a βGUIβ value for terminals supporting millions of colors;
- an βxtermβ value for terminals supporting more than 16 colors (but not millions of colors);
- and an ANSI color value for terminal with no more than 16 colors.
When you write Variant: 256 88
you are instructing Colortemplate to apply the definitions following that directive to terminals supporting 256 colors and 88 colors, that is, terminals of category 2. Similarly, Variant: 256 8 4
means that Colortemplate should generate definitions for terminals supporting 256 colors (category 2) and terminals supporting 8 and 4 colors (category 3). When two or more variants fall in the same category, the one with least colors is the one that limits you.
Consider this (incorrect) example:
Color: foo #fafafa 236 7
Variant: 256 88 8 4
Normal foo foo
Simplifying a bit, this would generate the following code:
if &t_Co >= 256
hi Normal ctermfg=236 ctermbg=236 cterm=NONE
finish
endif
if &t_Co >= 88
" This is out of range:
hi Normal ctermfg=236 ctermbg=236 cterm=NONE
finish
endif
if &t_Co >= 8
hi Normal ctermfg=7 ctermbg=7 cterm=NONE
finish
endif
if &t_Co >= 4
" This is out of range:
hi Normal ctermfg=7 ctermbg=7 cterm=NONE
finish
endif
But the following is fine:
Color: foo #fafafa 87 3
Variant: 256 88 8 4
Normal foo foo
and results in something like:
if &t_Co >= 256
hi Normal ctermfg=87 ctermbg=87 cterm=NONE
finish
endif
if &t_Co >= 88
hi Normal ctermfg=87 ctermbg=87 cterm=NONE
finish
endif
if &t_Co >= 8
hi Normal ctermfg=3 ctermbg=3 cterm=NONE
finish
endif
if &t_Co >= 4
hi Normal ctermfg=3 ctermbg=3 cterm=NONE
finish
endif
declaring multiple values just renders multiple
t_Co
blocks.
Correct.
That would imply that declaring multiple number values for the same Variant is redundant since if color definitions apply to a
t_Co >= 8
they automatically also apply for256
.
The value that applies for β€16 colors is not necessarily the same as the value that applies for 256 colors (see above). For example:
Color: foo #fafafa 236 7
Variant: 8
Normal foo foo
generates only:
if &t_Co >= 8
hi Normal ctermfg=7 ctermbg=7 cterm=NONE
finish
endif
Compare with:
Color: foo #fafafa 236 7
Variant: 256 8
Normal foo foo
which generates:
if &t_Co >= 256
hi Normal ctermfg=236 ctermbg=236 cterm=NONE
finish
endif
if &t_Co >= 8
hi Normal ctermfg=7 ctermbg=7 cterm=NONE
finish
endif
Meaning
256 8 4
wouldn't make much sense since the>= 4
includes the8
and256
anyway.
The difference between 4
/8
and 256
should be clear from the previous example. Declaring 4
and 8
together is just for convenience. Consider the following example:
Color: foo #fafafa 236 3
Color: bar #00000 0 1
Variant: 8 4
Normal foo foo
Variant: 8
Debug foo bar
Variant: 4
Debug bar foo
which expands to:
if &t_Co >= 8
hi Normal ctermfg=3 ctermbg=3 cterm=NONE
hi Debug ctermfg=3 ctermbg=1 cterm=NONE
finish
endif
if &t_Co >= 4
hi Normal ctermfg=3 ctermbg=3 cterm=NONE
hi Debug ctermfg=1 ctermbg=3 cterm=NONE
finish
endif
In this case, declaring multiple variants allows you to avoid repeating the same definition for the Normal
group.
from vim-colortemplate.
Hm alright but I still don't see how the code below, taken from the docs, would apply:
if &t_Co >= 256
hi Normal ctermfg=231 ctermbg=16 cterm=NONE
finish
endif
if &t_Co >= 8
hi Normal ctermfg=LightGray ctermbg=Brown cterm=NONE
finish
endif
If t_Co
is 256 then the 2nd if block would also apply and thereby generate a competing Normal
highlight group.
from vim-colortemplate.
If t_Co is 256 then the 2nd if block would also apply and thereby generate a competing Normal highlight group.
No, the finish
command ends the script at that point, so the if
blocks are mutually exclusive. Using finish
is a just an optimization to make the color scheme load faster.
from vim-colortemplate.
Oh wow I totally overlooked that, sorry! Thank you for clarifying this π
from vim-colortemplate.
Related Issues (20)
- Variant: 0 HOT 1
- cterm definitions for templates with dark and light backgrounds HOT 5
- Feature request: change meaning of term=/t= and add cterm=/c= HOT 2
- Commit `c7f0542` breaks compilation of vim-solarized8 HOT 3
- New highlight group added: CurSearch HOT 1
- alternative to changing saturation? HOT 3
- Invalid expression error when loading colorscheme HOT 3
- Neovim error for option balloonexpr HOT 3
- :h CTRL-L shadows built-in tag HOT 1
- Handling multiple palettes in a single template for a given background HOT 3
- gitignore tags file? HOT 5
- Verbatim is copied once for every variant HOT 3
- E518: Unknown option: <truncated file path> HOT 5
- Help moving Colortemplate v3 into production HOT 5
- Q: Can you elaborate on the Neovim compatibility directive? And why doesn't it exist in v3? HOT 5
- Not working in Neovim HOT 4
- "Unexpected token" from imported file HOT 1
- Allow color index to be in the range [0, 15] for the 256 variant? (v3) HOT 8
- The `Check` interface seems to disallow scrolling down (v3) HOT 2
- Higlight group definitions with discriminators and without variant restrictions check `has('gui_running')` (v3) HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-colortemplate.