Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look at COLORFGBG for automatic background again (improved) #2764

Closed
blueyed opened this issue May 29, 2015 · 5 comments
Closed

Look at COLORFGBG for automatic background again (improved) #2764

blueyed opened this issue May 29, 2015 · 5 comments
Labels
complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md enhancement feature request tui
Milestone

Comments

@blueyed
Copy link
Contributor

blueyed commented May 29, 2015

Commit 3baba1e removed the feature where Vim looks at $COLORFGBG to auto-set the background to light/dark.

/*
 * 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(void)
{
  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 = (char_u *)os_getenv("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";
}

It would be nice to re-add this, but improve it (if possible), so that the
real value of a color would be used, i.e. depending on the terminal palette.

@fwalch fwalch added the tui label May 29, 2015
@blueyed
Copy link
Contributor Author

blueyed commented May 29, 2015

This should probably also try to query the terminals background color, e.g. for urxvt via printf '\e]11;?\e\\':

% stty -icanon -echo min 0 time 1 ; printf '\e]11;?\e\\'; read bg
% echo $bg | cat -A
^[]11;rgb:0000/2b00/3600^[$

@fwalch fwalch added the enhancement feature request label Jun 3, 2015
@justinmk justinmk added this to the 0.3 milestone Aug 19, 2015
@egmontkob
Copy link

@justinmk justinmk modified the milestones: 0.4, unplanned Apr 22, 2018
@justinmk justinmk added complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md good first issue labels Apr 22, 2018
@dquach217

This comment has been minimized.

@justinmk

This comment has been minimized.

@justinmk
Copy link
Member

Looks like urxvt and gnome-terminal support the "\x1b]11;?\x07" request, so there's no need to implement $COLORFGBG scraping.

Closed by #9509

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md enhancement feature request tui
Projects
None yet
Development

No branches or pull requests

5 participants