cansi-colors

how does vim get system colors for it's syntax highlighting?


I am writing a terminal text editor in c and I am trying implement syntax highlighting. To do this I am using ANSI Colors in the terminal like this

printf(“\033[0;31m”); //Set the text to the color red
printf(“Hello\n”); //Display Hello in red
printf(“\033[0m”); //Resets the text to default color

I would like to use the system colors or the terminal theme colors in my program. I was wondering if anyone has any idea how to do this?

I can't find any information on this by googling. I am using debian linux.


Solution

  • Vim does not get "system colors". Vim has configuration of colors, in colorscheme, that it uses to display. For example peachpuff https://github.com/vim/vim/blob/master/runtime/colors/peachpuff.vim#L29

    The colorscheme is translated to ANSI sequences ESC[38;2;⟨r⟩;⟨g⟩;⟨b⟩m and sent. Vim does not "get" anything, except it's own configuration, that has hardcoded values of colors in hex #ffdab9. Defualt list of vim color names to hex: https://github.com/vim/vim/blob/367499c5c39057bca267716d9aad20554d4d83fd/runtime/colors/lists/default.vim#L48

    Set the text to the color red

    The "red" color already is the red color the terminal uses. From the description, just use it, it is the color your want to use.