On 2024-05-23, at 13:25, Paul J. Lucas <
pa...@lucasmail.org> wrote:
>
> After more poking around, I discovered I had this in my .vimrc file:
>
> se t_Co=8
>
> I changed it to:
>
> se t_Co=256
>
> and the colors reverted to being correct (matching vim in Terminal).
>
> But why should that matter? Why should 8 make the colors appear _so_ different? This all worked fine before iTerm 3.5.0.
I'm not sure what changed in iTerm2 (I don't recall anything changing with regards to colour when I upgraded) and I *rarely* use vi/vim (I use "nano" or BBEdit), but I have spent some time playing with ANSI colours, which are what vi/vim/nano/etc. use to tell the terminal what colour to draw the characters it sends.
With that said, here are some things you can check on, if you're inclined to continue investigating what happened.
The standard ANSI colour set has 16 colours, not 8. If you were setting it to 8 before, maybe vi/vim was getting confused? Did you upgrade vi/vim anywhere along the way, and maybe that changed how `t_co=8` was being processed?
Something else that comes to mind is, the first 16 "slots" in the 256-colour palette normally contain the same 16 colour values as the ANSI colours. If you customize the ANSI colours in "Settings -> Profiles -> Colors" for the profile you're using, I don't know if that *also* affects the 256-colour palette. iTerm2 isn't open-source so I can't look at the code for myself, if only there were somebody around who knows how this works, or who CAN check the source code ... ;)
Also ... looking at
https://vimhelp.org/term.txt.html , it looks like they recommend setting `t_Co` as early as possible in your `.vimrc` file, especially before setting any other options which have anything to do with colours (custom colours, syntax highlighting, etc.) If you're setting `t_Co` at the end of the file, it may be that it's resetting some things back to a default state and un-doing any customizations which came before it in the file. Again, I don't use vi/vim enough to have ever messed around with any kind of custom configuration (especially since I found out about editorconfig) so I could be totally wrong about this - I'm just pointing out things you can check in your own investigation.
If it helps ... years ago I wrote a Perl script called 'colors', as a quick way to see what the various ANSI colour combinations looked like. Since then I added support for the 256-colour palette, then added a quick demo of what 24-bit colour looks like. This is how I know that iTerm2 supports 24-bit colour but not double-high/double-width or blinking text, and that Terminal.app supports double-high/double-width and blinking text but not 24-bit colour (or at least, not very well.)
I just uploaded the script and some screenshots to Keybase, see
https://jms1.pub/colors/ if you're curious.
Good luck, and if you do uncover anything more, be sure to let us know.
--
John Simpson - KG4ZOW
https://jms1.net/