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

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Michael Darling
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".

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

John Little-4
On Monday, May 25, 2015 at 8:13:56 PM UTC+12, Michael Darling wrote:
> 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?

You definitely don't want to change C source code. Vim's colors are specified in color scheme files, which are in vimscript, not in C.

It sounds like you don't understand vim color schemes; my apologies if you do.  What color schemes are you using in color terminal mode and gvim? I suggest you have a look at the files in $VIMRUNTIME/colors, particularly the README.txt there.

If you are using the same colorscheme in both modes, and the colors don't match, the mapping from XTerm 16, 88 and 256 color modes to RGB can be determined, so you could edit a colorscheme so that they match.

Regards, John Little

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Reid Thompson
In reply to this post by Michael Darling
See color file xterm16



If you have received the message in error, please advise the sender by reply email and please delete the message.  This message contains information which may be confidential or otherwise protected.  Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy, or disclose to anyone the message or any information contained in the message.

Sent from Divide on Galaxy Note III

On May 25, 2015 4:13:55 AM, Michael Darling <[hidden email]> wrote:

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".

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Nikolay Aleksandrovich Pavlov
In reply to this post by Michael Darling
2015-05-25 6:37 GMT+03:00 Michael Darling <[hidden email]>:

> 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.

Note: it is much easier to do this with the help of the vim itself:
launch vim in terminal, do :redir => colors | hi | redir END<CR> and
parse `colors` variable which unlike colorschemes has well-defined
format and does not have cterm color names.

>
> --
> --
> 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 [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

tooth pik
On Mon, May 25, 2015 at 08:06:49PM +0300, Nikolay Pavlov wrote:

> 2015-05-25 6:37 GMT+03:00 Michael Darling <[hidden email]>:
> > 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Nikolay Aleksandrovich Pavlov
2015-05-25 21:03 GMT+03:00 toothpik <[hidden email]>:

> On Mon, May 25, 2015 at 08:06:49PM +0300, Nikolay Pavlov wrote:
>> 2015-05-25 6:37 GMT+03:00 Michael Darling <[hidden email]>:
>> > 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')"

I know CSApprox. But the initial request was the opposite: *not* use
GUI colorscheme in terminal, but use *terminal* colorscheme in GUI.

>
> --
> _|_ _  __|_|_ ._ 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 [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

tooth pik
On Mon, May 25, 2015 at 10:08:03PM +0300, Nikolay Pavlov wrote:

> 2015-05-25 21:03 GMT+03:00 toothpik <[hidden email]>:
> > On Mon, May 25, 2015 at 08:06:49PM +0300, Nikolay Pavlov wrote:
> >> 2015-05-25 6:37 GMT+03:00 Michael Darling <[hidden email]>:
> >> > 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')"

> I know CSApprox. But the initial request was the opposite: *not* use
> GUI colorscheme in terminal, but use *terminal* colorscheme in GUI.

what part of the colorscheme created by CSASnapshot is not a *terminal*
colorscheme?

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Nikolay Aleksandrovich Pavlov
2015-05-25 22:23 GMT+03:00 toothpik <[hidden email]>:

> On Mon, May 25, 2015 at 10:08:03PM +0300, Nikolay Pavlov wrote:
>> 2015-05-25 21:03 GMT+03:00 toothpik <[hidden email]>:
>> > On Mon, May 25, 2015 at 08:06:49PM +0300, Nikolay Pavlov wrote:
>> >> 2015-05-25 6:37 GMT+03:00 Michael Darling <[hidden email]>:
>> >> > 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')"
>
>> I know CSApprox. But the initial request was the opposite: *not* use
>> GUI colorscheme in terminal, but use *terminal* colorscheme in GUI.
>
> what part of the colorscheme created by CSASnapshot is not a *terminal*
> colorscheme?

Did you read? Request is *not* to have a terminal colorscheme. Request
is to have a *GUI* colorscheme. Out of terminal one.

CSApprox is creating *terminal* colorcheme out of GUI.

Try the following test:

    vim --cmd 'set rtp=~/.vam/CSApprox' -u NORC -i NONE -N
    :CSApproxSnapshot /tmp/foo.vim

. What happens now is that /tmp/foo.vim contains colorscheme that starts with …

    CSAHi Normal term=NONE cterm=NONE ctermbg=231 ctermfg=16 gui=NONE
guibg=white guifg=black

. Precisely:

    … guibg=white …

. &background was dark, terminal background color is black. EPIC FAIL.
This is absolutely not what was requested.

>
> --
> --
> 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 [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

tooth pik
On Mon, May 25, 2015 at 10:43:15PM +0300, Nikolay Pavlov wrote:

> 2015-05-25 22:23 GMT+03:00 toothpik <[hidden email]>:
> > On Mon, May 25, 2015 at 10:08:03PM +0300, Nikolay Pavlov wrote:
> >> 2015-05-25 21:03 GMT+03:00 toothpik <[hidden email]>:
> >> > On Mon, May 25, 2015 at 08:06:49PM +0300, Nikolay Pavlov wrote:
> >> >> 2015-05-25 6:37 GMT+03:00 Michael Darling <[hidden email]>:
> >> >> > 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')"
> >
> >> I know CSApprox. But the initial request was the opposite: *not* use
> >> GUI colorscheme in terminal, but use *terminal* colorscheme in GUI.
> >
> > what part of the colorscheme created by CSASnapshot is not a *terminal*
> > colorscheme?

> Did you read? Request is *not* to have a terminal colorscheme. Request
> is to have a *GUI* colorscheme. Out of terminal one.

in that case I missed the point -- sorry for the noise



--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.