diff src/term.c @ 18679:fd95d4dbeb37 v8.1.2331

patch 8.1.2331: the option.c file is still very big Commit: https://github.com/vim/vim/commit/7bae0b1bc84a95d565ffab38cf7f82ad21c656b6 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 21 22:14:18 2019 +0100 patch 8.1.2331: the option.c file is still very big Problem: The option.c file is still very big. Solution: Move a few functions to where they fit better. (Yegappan Lakshmanan, closes #4895)
author Bram Moolenaar <Bram@vim.org>
date Thu, 21 Nov 2019 22:15:03 +0100
parents bbea1f108187
children 14d2a210fab1
line wrap: on
line diff
--- a/src/term.c
+++ b/src/term.c
@@ -2898,6 +2898,40 @@ term_bg_color(int n)
 	term_color(T_CSB, n);
 }
 
+/*
+ * 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.
+ */
+    char_u *
+term_bg_default(void)
+{
+#if defined(MSWIN)
+    /* DOS console is nearly always black */
+    return (char_u *)"dark";
+#else
+    char_u	*p;
+
+    if (STRCMP(T_NAME, "linux") == 0
+	    || STRCMP(T_NAME, "screen.linux") == 0
+	    || STRNCMP(T_NAME, "cygwin", 6) == 0
+	    || STRNCMP(T_NAME, "putty", 5) == 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
+}
+
 #if defined(FEAT_TERMGUICOLORS) || defined(PROTO)
 
 #define RED(rgb)   (((long_u)(rgb) >> 16) & 0xFF)