Monday, May 25, 2015

Re: Changing vim graphical mode to handle colors like in color terminal mode

On Mon, May 25, 2015 at 08:06:49PM +0300, Nikolay Pavlov wrote:
> 2015-05-25 6:37 GMT+03:00 Michael Darling <darlingm@gmail.com>:
> > I'd like to have vim in graphical mode handle colors (default fg/bg color, syntax highlighting) handle it the same as in color terminal mode.
> >
> > What's the easiest way to do this? Is there an option, or do I need to change my local source?
> >
> > Where is the code that vim either grabs a cterm of gui color? I want to set it so in gui mode, it grabs the cterm color instead.
> >
> > I figure this would either be in src/syntax.c, or src/eval.c.
> >
> > src/syntax.c::highlight_has_attr() uses modec of 'g' for GUI, 'c' for cterm, 't' for (no color) term. But, it's just returning if the given attribute exists, so it's not what I'm looking for.
> >
> > src/syntax.c::highlight_color() is where I was sure I found what I needed. It also uses modec, and has code like if(modec == 'g') ... color = HL_TABLE()[id - 1].sg_gui_fg; ... if(modec == 'c') ... n = HL_TABLE()[id - 1].sg_cterm_fg - 1;
> >
> > But, I can make the first command in highlight_color() be "exit(0)" and vim works just fine in cli or graphical mode.
> >
> >
> > Ultimately, with the same .vimrc in vim or "vim -g"/"gvim", I just want it to look the same. I'm fine losing the #xxxxxx color ability. 256 colors is fine for me.
> >
> >
> > I've thought about changing the hard-coded and color/*.vim files, removing everything gui*= and duplicating the cterm*=. Perhaps that's an easier way to go than changing source. I figured there would be a "if gui use gui_fg, else if cterm use cterm_fg".

> ctermfg=136

> Vim in cterm mode emits escape sequences which are then parsed by a
> terminal. Escape sequences specify color *number* (name is trunslated
> to number using some C code), not color itself and Vim knows nothing
> about which color terminal will actually display.

> Color scheme authors expect terminals to display specific colors for
> each of the color codes: upper 240 colors are somewhat standard, lower
> 16 are less standard (e.g. konsole may switch ten of them in
> Appearence tab in terminal profile setting, usually all 16 are
> customizable).

> Also note that ctermfg=Red is ctermfg=9, guifg=Red translates given
> color using system/toolkit-specific function: search for
> gui_mch_get_color in vim sources.

> Thus if you want to translate colorschemes you need to do two things:

> 0. Transform color names into cterm color codes.
> 1. Transform cterm color codes into hexadecimal colors.

at some point someone has to point out how much of this is already done
for us -- have a look at Matt Wozniski's epic plugin CSApprox at

http://www.vim.org/scripts/script.php?script_id=2390

and be sure to notice the CSASnapshot function -- you can make a cterm
colorscheme that closely resembles your favorite gui colors, and choose
between the two in your .vimrc based on "if has('gui_running')"

--
_|_ _ __|_|_ ._ o|
|_(_)(_)|_| ||_)||<
|

--
--
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 the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: