Skip to content

Instantly share code, notes, and snippets.

@yoshikaw
Created December 5, 2012 21:36
Show Gist options
  • Save yoshikaw/4219730 to your computer and use it in GitHub Desktop.
Save yoshikaw/4219730 to your computer and use it in GitHub Desktop.
vim73/src/option.c
/*
* Return "dark" or "light" depending on the kind of terminal.
* This is just guessing! Recognized are:
* "linux" Linux console
* "screen.linux" Linux console with screen
* "cygwin" Cygwin shell
* "putty" Putty program
* We also check the COLORFGBG environment variable, which is set by
* rxvt and derivatives. This variable contains either two or three
* values separated by semicolons; we want the last value in either
* case. If this value is 0-6 or 8, our background is dark.
*/
static char_u *
term_bg_default()
{
#if defined(MSDOS) || defined(OS2) || defined(WIN3264)
/* DOS console nearly always black */
return (char_u *)"dark";
#else
char_u *p;
if (STRCMP(T_NAME, "linux") == 0
|| STRCMP(T_NAME, "screen.linux") == 0
|| STRCMP(T_NAME, "cygwin") == 0
|| STRCMP(T_NAME, "putty") == 0
|| ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
&& (p = vim_strrchr(p, ';')) != NULL
&& ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
&& p[2] == NUL))
return (char_u *)"dark";
return (char_u *)"light";
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment