> On Fri, 05 May 2023 02:36:41 +0100 > Bram Moolenaar <b...@moolenaar.net> wrote: > > > > > For the value 7, ctermfg and ctermbg gives different colors. > > > > > 'ctermfg=7' gives non-bold white, which is expected. But > > > > > 'ctermbg=7' gives bold Black color. I'm assuming there is a > > > > > if-conditional somewhere that's causing this distinction. If > > > > > so, where is the conditional in the source code? If not, why > > > > > is this happening? > > > > > > > > Color support depends on the terminal. Background and foreground > > > > settings are often different, especially with older terminals and > > > > a low number of colors supported. Sometimes the "bold" flag > > > > changes the color between a darker and lighter color. You can > > > > find some information at ":help highlight-ctermfg". > > > > > > I shouldn't have said "bold black." That caused unnecessary > > > confusion. The 'cterm=' value is NONE. I was just trying to say > > > "darker" shade of black. > > > > > > > > P.S. I'm on Windows. I have a Linux laptop but haven't > > > > > checked if this behavior is reproducible on that OS. > > > > > > I checked on my Linux laptop. These are the behaviors: > > > > > > highlight | Linux | Windows > > > ------------+---------------+------------- > > > ctermfg=0 | Black | Black > > > ctermfg=7 | White | Black > > > ctermfg=8 | Bright black | Bright black > > > ctermfg=15 | Bright white | Bright white > > > > So what is the number of colors, set with the t_Co option in each > > case? > > > > > I run Windows Terminal on Windows and Suckless Terminal on Linux. > > > The colors in my WT are set in a JSON file, with 16 keys. > > > > Not sure what this means. Do you manually specify colors for the > > Windows Terminal? Obviously Vim cannot know what these colors are. > > > > For "ctermfg-7" the color should probably "grey", neither white or > > black. "Bright white" is just white, nothing is brighter than that. > > "Bright black" is some kind of grey. > > > > > But the colors in > > > my ST is a C array of strings, and the indices match with Vim's > > > behavior of 'ctermfg=<index>', i.e., 'ctermfg=0' is black and > > > 'ctermfg=8' brblack (that's how it's named in the comments in ST's > > > source code [1]). > > > > I don't understand any of this. If this is about a terminal with 8 or > > 16 colors, better follow the standard colors. Vim will not be able to > > handle any manually configured colors. > > I'm not an expert on terminal emulators, so this may be incorrect, but > as far as I know all modern terminal emulators let the user define 16 > colors, even if the terminal emulator supports true color (256 colors).
Usually when a terminal supports more than 16 colors, those first 16 colors may be very well different from terminals that only support 16 colors. True color is much more than 256 colors. 256 color support was an intermediate step, and most follow the colors that xterm uses (but not every one). > And as for Vim handling manually configured colors, note 'ctermfg=1' is > red . If I change the value of 'Red' in Suckless Terminal config to a > hex value of something green, 'ctermfg=1' shows green. I mean, this is > the expected behavior, right? Vim gives the terminal emulator a color > code; the terminal emulator decides how to render that, according to its > config. Although technically correct, this is also very confusing. Better keep the terminal at showing the default colors (e.g. the ANSI colors) and adjust the colors in Vim using a colorscheme. Otherwise you can't really use any colorscheme. > > > The fun part is: I ssh'd into my Linux laptop from my Windows > > > laptop. > > > > What do you set $TERM to then? I doubt a Linux system has any > > specific terminfo/termcap entry for that. I don't even know what ssh > > command would be able to make a connection from a Windows Terminal. > > I've used Putty (with varying success) and the Secure Shell built > > into Chrome, which works quite well. > > I ssh'd with MSYS's ssh binary. The $TERM value is undefined in Windows > Terminal. ':set term?' in Vim-in-Linux-over-SSH-on-Windows shows > 'xterm-256colors'. Don't know where that's being defined. I don't know the details about this ssh implementation. I very much doubt it actually simulates an xterm accurately. If it doesn't work, try another ssh. Trying to make this setup work with MSYS may be a waste of time. > > > Meaning, I ran Vim on the Linux machine but in WT. There, > > > 'ctermfg=7' still showed White, unlike the Vim on native Windows. > > > Seems like WT does show 'ctermfg=7' as white, but the > > > 'builtin_win32' term isn't supplying WT with proper > > > whatchamacallit. (I'm probably wrong. This was just a guess.) > > > > The 'builtin_win32" entry predates Windows Terminal by many years, it > > was made for the Windows console, and not for use with ssh. I don't > > know what best to use for Windows Terminal, it has been under > > development for quite a long time. Not sure if it can be considered > > "stable" now. And I have no idea what to expect from an ssh command > > running in Windows Terminal. What would it set $TERM to? What ssh > > command is even available for this? > > I think I covered this above. And anyway, I was not intending to dive > into terminal stuff. I thought 'ctermfg=7' was a case specially handled > in Vim source, basically something like this: > > if (do_ctermfg && arg == 7) { > arg = 0; // forcefully use black color > } > > This ^ is what I was expecting. If true, I was gonna comment it out. > Seems like this isn't the case. No problem. Thanks. It's much more complicated than that. E.g. search for "cterm_ansi_idx" in src/term.c, this is used specifically for MS-Windows. Thus if you use an MS-Windows console and ssh to a Linux system this mapping is missing and the colors are likely messed up. -- Bad fashion can discourage normal people from interacting with the engineer and talking about the cute things their children do. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// -- -- You received this message from the "vim_dev" 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_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/20230505152827.197461C1B21%40moolenaar.net.