To: vim-dev@vim.org Subject: Patch 6.1.136 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.136 Problem: When $TERM is "linux" the default for 'background' is "dark", even though the GUI uses a light background. (Hugh Allen) Solution: Don't mark the option as set when defaulting to "dark" for the linux console. Also reset 'background' to "light" when the GUI has a light background. Files: src/option.c *** ../vim61.135/src/option.c Sat Jun 29 16:35:43 2002 --- src/option.c Thu Jul 11 21:40:13 2002 *************** *** 2786,2792 **** --- 2794,2805 ---- */ idx4 = findoption((char_u *)"bg"); if (!(options[idx4].flags & P_WAS_SET) && STRCMP(T_NAME, "linux") == 0) + { set_string_option_direct(NULL, idx4, (char_u *)"dark", OPT_FREE); + /* don't mark it as set, when starting the GUI it may be changed + * again */ + options[idx4].flags &= ~P_WAS_SET; + } } #endif } *************** *** 2941,2946 **** --- 2954,2969 ---- } #ifdef FEAT_GUI + static char_u *gui_bg_default __ARGS((void)); + + static char_u * + gui_bg_default() + { + if (gui_get_lightness(gui.back_pixel) < 127) + return (char_u *)"dark"; + return (char_u *)"light"; + } + /* * Option initializations that can only be done after opening the GUI window. */ *************** *** 2948,2958 **** init_gui_options() { /* Set the 'background' option according to the lightness of the ! * background color. */ ! if (!option_was_set((char_u *)"bg") ! && gui_get_lightness(gui.back_pixel) < 127) { ! set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0); highlight_changed(); } } --- 2971,2980 ---- init_gui_options() { /* Set the 'background' option according to the lightness of the ! * background color, unless the user has set it already. */ ! if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0) { ! set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0); highlight_changed(); } } *************** *** 3443,3457 **** ? VI_DEFAULT : VIM_DEFAULT]; if ((char_u **)varp == &p_bg) { #ifdef FEAT_GUI if (gui.in_use) ! { ! /* guess the value of 'background' */ ! if (gui_get_lightness(gui.back_pixel) < 127) ! newval = (char_u *)"dark"; ! else ! newval = (char_u *)"light"; ! } else #endif if (STRCMP(T_NAME, "linux") == 0) --- 3465,3474 ---- ? VI_DEFAULT : VIM_DEFAULT]; if ((char_u **)varp == &p_bg) { + /* guess the value of 'background' */ #ifdef FEAT_GUI if (gui.in_use) ! newval = gui_bg_default(); else #endif if (STRCMP(T_NAME, "linux") == 0) *** ../vim61.135/src/version.c Sun Jul 21 21:04:38 2002 --- src/version.c Sun Jul 21 21:13:35 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 136, /**/ -- hundred-and-one symptoms of being an internet addict: 17. You turn on your intercom when leaving the room so you can hear if new e-mail arrives. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///