comparison src/option.c @ 26336:a2e6da79274d v8.2.3699

patch 8.2.3699: the +title feature adds a lot of #ifdef but little code Commit: https://github.com/vim/vim/commit/651fca85c71a4c5807f8f828f9ded30fbd754325 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Nov 29 20:39:38 2021 +0000 patch 8.2.3699: the +title feature adds a lot of #ifdef but little code Problem: The +title feature adds a lot of #ifdef but little code. Solution: Graduate the +title feature.
author Bram Moolenaar <Bram@vim.org>
date Mon, 29 Nov 2021 21:45:04 +0100
parents 3aa48d4e3dc8
children dbe615b75f15
comparison
equal deleted inserted replaced
26335:c12a888d1f63 26336:a2e6da79274d
1100 // Apply the first entry of 'fileformats' to the initial buffer. 1100 // Apply the first entry of 'fileformats' to the initial buffer.
1101 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET)) 1101 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET))
1102 set_fileformat(default_fileformat(), OPT_LOCAL); 1102 set_fileformat(default_fileformat(), OPT_LOCAL);
1103 } 1103 }
1104 1104
1105 #ifdef FEAT_TITLE
1106 set_title_defaults(); 1105 set_title_defaults();
1107 #endif
1108 } 1106 }
1109 1107
1110 #if defined(FEAT_MULTI_LANG) || defined(PROTO) 1108 #if defined(FEAT_MULTI_LANG) || defined(PROTO)
1111 /* 1109 /*
1112 * When 'helplang' is still at its default value, set it to "lang". 1110 * When 'helplang' is still at its default value, set it to "lang".
1146 options[idx].flags |= P_ALLOCED; 1144 options[idx].flags |= P_ALLOCED;
1147 } 1145 }
1148 } 1146 }
1149 #endif 1147 #endif
1150 1148
1151 #ifdef FEAT_TITLE
1152 /* 1149 /*
1153 * 'title' and 'icon' only default to true if they have not been set or reset 1150 * 'title' and 'icon' only default to true if they have not been set or reset
1154 * in .vimrc and we can read the old value. 1151 * in .vimrc and we can read the old value.
1155 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if 1152 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
1156 * they can be reset. This reduces startup time when using X on a remote 1153 * they can be reset. This reduces startup time when using X on a remote
1190 val = mch_can_restore_icon(); 1187 val = mch_can_restore_icon();
1191 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; 1188 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
1192 p_icon = val; 1189 p_icon = val;
1193 } 1190 }
1194 } 1191 }
1195 #endif
1196 1192
1197 void 1193 void
1198 ex_set(exarg_T *eap) 1194 ex_set(exarg_T *eap)
1199 { 1195 {
1200 int flags = 0; 1196 int flags = 0;
2270 if (multi_byte) 2266 if (multi_byte)
2271 return PTR2CHAR(arg); 2267 return PTR2CHAR(arg);
2272 return *arg; 2268 return *arg;
2273 } 2269 }
2274 2270
2275 #ifdef FEAT_TITLE
2276 /* 2271 /*
2277 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call 2272 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
2278 * maketitle() to create and display it. 2273 * maketitle() to create and display it.
2279 * When switching the title or icon off, call mch_restore_title() to get 2274 * When switching the title or icon off, call mch_restore_title() to get
2280 * the old value back. 2275 * the old value back.
2287 && !gui.starting 2282 && !gui.starting
2288 #endif 2283 #endif
2289 ) 2284 )
2290 maketitle(); 2285 maketitle();
2291 } 2286 }
2292 #endif
2293 2287
2294 /* 2288 /*
2295 * set_options_bin - called when 'bin' changes value. 2289 * set_options_bin - called when 'bin' changes value.
2296 */ 2290 */
2297 void 2291 void
2556 // Nothing special, return global flags field. 2550 // Nothing special, return global flags field.
2557 return &options[opt_idx].flags; 2551 return &options[opt_idx].flags;
2558 } 2552 }
2559 #endif 2553 #endif
2560 2554
2561 #if defined(FEAT_TITLE) || defined(PROTO)
2562 /* 2555 /*
2563 * Redraw the window title and/or tab page text later. 2556 * Redraw the window title and/or tab page text later.
2564 */ 2557 */
2565 void redraw_titles(void) 2558 void redraw_titles(void)
2566 { 2559 {
2567 need_maketitle = TRUE; 2560 need_maketitle = TRUE;
2568 redraw_tabline = TRUE; 2561 redraw_tabline = TRUE;
2569 } 2562 }
2570 #endif
2571 2563
2572 /* 2564 /*
2573 * Return TRUE if "val" is a valid name: only consists of alphanumeric ASCII 2565 * Return TRUE if "val" is a valid name: only consists of alphanumeric ASCII
2574 * characters or characters in "allowed". 2566 * characters or characters in "allowed".
2575 */ 2567 */
2807 2799
2808 // when 'readonly' is set may give W10 again 2800 // when 'readonly' is set may give W10 again
2809 if (curbuf->b_p_ro) 2801 if (curbuf->b_p_ro)
2810 curbuf->b_did_warn = FALSE; 2802 curbuf->b_did_warn = FALSE;
2811 2803
2812 #ifdef FEAT_TITLE
2813 redraw_titles(); 2804 redraw_titles();
2814 #endif
2815 } 2805 }
2816 2806
2817 #ifdef FEAT_GUI 2807 #ifdef FEAT_GUI
2818 else if ((int *)varp == &p_mh) 2808 else if ((int *)varp == &p_mh)
2819 { 2809 {
2832 { 2822 {
2833 curbuf->b_p_ma = FALSE; 2823 curbuf->b_p_ma = FALSE;
2834 return N_("E946: Cannot make a terminal with running job modifiable"); 2824 return N_("E946: Cannot make a terminal with running job modifiable");
2835 } 2825 }
2836 # endif 2826 # endif
2837 # ifdef FEAT_TITLE
2838 redraw_titles(); 2827 redraw_titles();
2839 # endif 2828 }
2840 }
2841 #ifdef FEAT_TITLE
2842 // when 'endofline' is changed, redraw the window title 2829 // when 'endofline' is changed, redraw the window title
2843 else if ((int *)varp == &curbuf->b_p_eol) 2830 else if ((int *)varp == &curbuf->b_p_eol)
2844 { 2831 {
2845 redraw_titles(); 2832 redraw_titles();
2846 } 2833 }
2852 // when 'bomb' is changed, redraw the window title and tab page text 2839 // when 'bomb' is changed, redraw the window title and tab page text
2853 else if ((int *)varp == &curbuf->b_p_bomb) 2840 else if ((int *)varp == &curbuf->b_p_bomb)
2854 { 2841 {
2855 redraw_titles(); 2842 redraw_titles();
2856 } 2843 }
2857 #endif
2858 2844
2859 // when 'bin' is set also set some other options 2845 // when 'bin' is set also set some other options
2860 else if ((int *)varp == &curbuf->b_p_bin) 2846 else if ((int *)varp == &curbuf->b_p_bin)
2861 { 2847 {
2862 set_options_bin(old_value, curbuf->b_p_bin, opt_flags); 2848 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
2863 #ifdef FEAT_TITLE
2864 redraw_titles(); 2849 redraw_titles();
2865 #endif
2866 } 2850 }
2867 2851
2868 // when 'buflisted' changes, trigger autocommands 2852 // when 'buflisted' changes, trigger autocommands
2869 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) 2853 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
2870 { 2854 {
2994 { 2978 {
2995 (void)buf_init_chartab(curbuf, FALSE); // ignore errors 2979 (void)buf_init_chartab(curbuf, FALSE); // ignore errors
2996 } 2980 }
2997 #endif 2981 #endif
2998 2982
2999 #ifdef FEAT_TITLE
3000 // when 'title' changed, may need to change the title; same for 'icon' 2983 // when 'title' changed, may need to change the title; same for 'icon'
3001 else if ((int *)varp == &p_title || (int *)varp == &p_icon) 2984 else if ((int *)varp == &p_title || (int *)varp == &p_icon)
3002 { 2985 {
3003 did_set_title(); 2986 did_set_title();
3004 } 2987 }
3005 #endif
3006 2988
3007 else if ((int *)varp == &curbuf->b_changed) 2989 else if ((int *)varp == &curbuf->b_changed)
3008 { 2990 {
3009 if (!value) 2991 if (!value)
3010 save_file_ff(curbuf); // Buffer is unchanged 2992 save_file_ff(curbuf); // Buffer is unchanged
3011 #ifdef FEAT_TITLE
3012 redraw_titles(); 2993 redraw_titles();
3013 #endif
3014 modified_was_set = value; 2994 modified_was_set = value;
3015 } 2995 }
3016 2996
3017 #ifdef BACKSLASH_IN_FILENAME 2997 #ifdef BACKSLASH_IN_FILENAME
3018 else if ((int *)varp == &p_ssl) 2998 else if ((int *)varp == &p_ssl)
3564 curbuf->b_p_imsearch = B_IMODE_NONE; 3544 curbuf->b_p_imsearch = B_IMODE_NONE;
3565 } 3545 }
3566 p_imsearch = curbuf->b_p_imsearch; 3546 p_imsearch = curbuf->b_p_imsearch;
3567 } 3547 }
3568 3548
3569 #ifdef FEAT_TITLE
3570 // if 'titlelen' has changed, redraw the title 3549 // if 'titlelen' has changed, redraw the title
3571 else if (pp == &p_titlelen) 3550 else if (pp == &p_titlelen)
3572 { 3551 {
3573 if (p_titlelen < 0) 3552 if (p_titlelen < 0)
3574 { 3553 {
3576 p_titlelen = 85; 3555 p_titlelen = 85;
3577 } 3556 }
3578 if (starting != NO_SCREEN && old_value != p_titlelen) 3557 if (starting != NO_SCREEN && old_value != p_titlelen)
3579 need_maketitle = TRUE; 3558 need_maketitle = TRUE;
3580 } 3559 }
3581 #endif
3582 3560
3583 // if p_ch changed value, change the command line height 3561 // if p_ch changed value, change the command line height
3584 else if (pp == &p_ch) 3562 else if (pp == &p_ch)
3585 { 3563 {
3586 if (p_ch < 1) 3564 if (p_ch < 1)
4969 * Reset a few things before clearing the old options. This may cause 4947 * Reset a few things before clearing the old options. This may cause
4970 * outputting a few things that the terminal doesn't understand, but the 4948 * outputting a few things that the terminal doesn't understand, but the
4971 * screen will be cleared later, so this is OK. 4949 * screen will be cleared later, so this is OK.
4972 */ 4950 */
4973 mch_setmouse(FALSE); // switch mouse off 4951 mch_setmouse(FALSE); // switch mouse off
4974 #ifdef FEAT_TITLE
4975 mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles 4952 mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles
4976 #endif
4977 #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI) 4953 #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
4978 // When starting the GUI close the display opened for the clipboard. 4954 // When starting the GUI close the display opened for the clipboard.
4979 // After restoring the title, because that will need the display. 4955 // After restoring the title, because that will need the display.
4980 if (gui.starting) 4956 if (gui.starting)
4981 clear_xterm_clip(); 4957 clear_xterm_clip();