Mercurial > vim
comparison src/option.c @ 31996:ca6bc7c04163 v9.0.1330
patch 9.0.1330: handling new value of an option has a long "else if" chain
Commit: https://github.com/vim/vim/commit/af93691b53f38784efce0b93fe7644c44a7e382e
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Mon Feb 20 12:16:39 2023 +0000
patch 9.0.1330: handling new value of an option has a long "else if" chain
Problem: Handling new value of an option has a long "else if" chain.
Solution: Use a function pointer. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/12015)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 20 Feb 2023 13:30:05 +0100 |
parents | 4efcb5c68112 |
children | 6095218c9056 |
comparison
equal
deleted
inserted
replaced
31995:95971aa5e525 | 31996:ca6bc7c04163 |
---|---|
950 options[idx].flags &= ~P_WAS_SET; | 950 options[idx].flags &= ~P_WAS_SET; |
951 } | 951 } |
952 #endif | 952 #endif |
953 | 953 |
954 #ifdef CURSOR_SHAPE | 954 #ifdef CURSOR_SHAPE |
955 parse_shape_opt(SHAPE_CURSOR); // set cursor shapes from 'guicursor' | 955 parse_shape_opt(SHAPE_CURSOR); // set cursor shapes from 'guicursor' |
956 #endif | 956 #endif |
957 #ifdef FEAT_MOUSESHAPE | 957 #ifdef FEAT_MOUSESHAPE |
958 parse_shape_opt(SHAPE_MOUSE); // set mouse shapes from 'mouseshape' | 958 parse_shape_opt(SHAPE_MOUSE); // set mouse shapes from 'mouseshape' |
959 #endif | 959 #endif |
960 #ifdef FEAT_PRINTER | 960 #ifdef FEAT_PRINTER |
961 (void)parse_printoptions(); // parse 'printoptions' default value | 961 (void)parse_printoptions(NULL); // parse 'printoptions' default value |
962 #endif | 962 #endif |
963 } | 963 } |
964 | 964 |
965 /* | 965 /* |
966 * Initialize the options, part three: After reading the .vimrc | 966 * Initialize the options, part three: After reading the .vimrc |
2030 | 2030 |
2031 // Handle side effects, and set the global value for ":set" on local | 2031 // Handle side effects, and set the global value for ":set" on local |
2032 // options. Note: when setting 'syntax' or 'filetype' autocommands may | 2032 // options. Note: when setting 'syntax' or 'filetype' autocommands may |
2033 // be triggered that can cause havoc. | 2033 // be triggered that can cause havoc. |
2034 *errmsg = did_set_string_option( | 2034 *errmsg = did_set_string_option( |
2035 opt_idx, (char_u **)varp, oldval, errbuf, | 2035 opt_idx, (char_u **)varp, oldval, newval, errbuf, |
2036 opt_flags, value_checked); | 2036 opt_flags, value_checked); |
2037 | 2037 |
2038 secure = secure_saved; | 2038 secure = secure_saved; |
2039 } | 2039 } |
2040 | 2040 |
2842 (void)spell_check_sps(); | 2842 (void)spell_check_sps(); |
2843 (void)compile_cap_prog(curwin->w_s); | 2843 (void)compile_cap_prog(curwin->w_s); |
2844 (void)did_set_spell_option(TRUE); | 2844 (void)did_set_spell_option(TRUE); |
2845 #endif | 2845 #endif |
2846 // set cedit_key | 2846 // set cedit_key |
2847 (void)check_cedit(); | 2847 (void)did_set_cedit(NULL); |
2848 #ifdef FEAT_LINEBREAK | 2848 #ifdef FEAT_LINEBREAK |
2849 // initialize the table for 'breakat'. | 2849 // initialize the table for 'breakat'. |
2850 fill_breakat_flags(); | 2850 did_set_breakat(NULL); |
2851 #endif | 2851 #endif |
2852 after_copy_winopt(curwin); | 2852 after_copy_winopt(curwin); |
2853 } | 2853 } |
2854 | 2854 |
2855 /* | 2855 /* |
2870 // Parse default for 'fillchars'. | 2870 // Parse default for 'fillchars'. |
2871 (void)set_chars_option(curwin, &curwin->w_p_fcs, TRUE); | 2871 (void)set_chars_option(curwin, &curwin->w_p_fcs, TRUE); |
2872 | 2872 |
2873 #ifdef FEAT_CLIPBOARD | 2873 #ifdef FEAT_CLIPBOARD |
2874 // Parse default for 'clipboard' | 2874 // Parse default for 'clipboard' |
2875 (void)check_clipboard_option(); | 2875 (void)did_set_clipboard(NULL); |
2876 #endif | 2876 #endif |
2877 #ifdef FEAT_VARTABS | 2877 #ifdef FEAT_VARTABS |
2878 vim_free(curbuf->b_p_vsts_array); | 2878 vim_free(curbuf->b_p_vsts_array); |
2879 (void)tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_array); | 2879 (void)tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_array); |
2880 vim_free(curbuf->b_p_vts_array); | 2880 vim_free(curbuf->b_p_vts_array); |
3138 #endif | 3138 #endif |
3139 | 3139 |
3140 /* | 3140 /* |
3141 * Process the updated 'compatible' option value. | 3141 * Process the updated 'compatible' option value. |
3142 */ | 3142 */ |
3143 static void | 3143 char * |
3144 did_set_compatible(void) | 3144 did_set_compatible(optset_T *args UNUSED) |
3145 { | 3145 { |
3146 compatible_set(); | 3146 compatible_set(); |
3147 } | 3147 return NULL; |
3148 | 3148 } |
3149 #ifdef FEAT_LANGMAP | 3149 |
3150 #if defined(FEAT_LANGMAP) || defined(PROTO) | |
3150 /* | 3151 /* |
3151 * Process the updated 'langremap' option value. | 3152 * Process the updated 'langremap' option value. |
3152 */ | 3153 */ |
3153 static void | 3154 char * |
3154 did_set_langremap(void) | 3155 did_set_langremap(optset_T *args UNUSED) |
3155 { | 3156 { |
3156 // 'langremap' -> !'langnoremap' | 3157 // 'langremap' -> !'langnoremap' |
3157 p_lnr = !p_lrm; | 3158 p_lnr = !p_lrm; |
3159 return NULL; | |
3158 } | 3160 } |
3159 | 3161 |
3160 /* | 3162 /* |
3161 * Process the updated 'langnoremap' option value. | 3163 * Process the updated 'langnoremap' option value. |
3162 */ | 3164 */ |
3163 static void | 3165 char * |
3164 did_set_langnoremap(void) | 3166 did_set_langnoremap(optset_T *args UNUSED) |
3165 { | 3167 { |
3166 // 'langnoremap' -> !'langremap' | 3168 // 'langnoremap' -> !'langremap' |
3167 p_lrm = !p_lnr; | 3169 p_lrm = !p_lnr; |
3168 } | 3170 return NULL; |
3169 #endif | 3171 } |
3170 | 3172 #endif |
3171 #ifdef FEAT_PERSISTENT_UNDO | 3173 |
3174 #if defined(FEAT_PERSISTENT_UNDO) || defined(PROTO) | |
3172 /* | 3175 /* |
3173 * Process the updated 'undofile' option value. | 3176 * Process the updated 'undofile' option value. |
3174 */ | 3177 */ |
3175 static void | 3178 char * |
3176 did_set_undofile(int opt_flags) | 3179 did_set_undofile(optset_T *args) |
3177 { | 3180 { |
3178 // Only take action when the option was set. | 3181 // Only take action when the option was set. |
3179 if (!curbuf->b_p_udf && !p_udf) | 3182 if (!curbuf->b_p_udf && !p_udf) |
3180 return; | 3183 return NULL; |
3181 | 3184 |
3182 // When reset we do not delete the undo file, the option may be set again | 3185 // When reset we do not delete the undo file, the option may be set again |
3183 // without making any changes in between. | 3186 // without making any changes in between. |
3184 char_u hash[UNDO_HASH_SIZE]; | 3187 char_u hash[UNDO_HASH_SIZE]; |
3185 buf_T *save_curbuf = curbuf; | 3188 buf_T *save_curbuf = curbuf; |
3189 // When 'undofile' is set globally: for every buffer, otherwise | 3192 // When 'undofile' is set globally: for every buffer, otherwise |
3190 // only for the current buffer: Try to read in the undofile, | 3193 // only for the current buffer: Try to read in the undofile, |
3191 // if one exists, the buffer wasn't changed and the buffer was | 3194 // if one exists, the buffer wasn't changed and the buffer was |
3192 // loaded | 3195 // loaded |
3193 if ((curbuf == save_curbuf | 3196 if ((curbuf == save_curbuf |
3194 || (opt_flags & OPT_GLOBAL) || opt_flags == 0) | 3197 || (args->os_flags & OPT_GLOBAL) |
3198 || args->os_flags == 0) | |
3195 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) | 3199 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) |
3196 { | 3200 { |
3197 #ifdef FEAT_CRYPT | 3201 #ifdef FEAT_CRYPT |
3198 if (crypt_get_method_nr(curbuf) == CRYPT_M_SOD) | 3202 if (crypt_get_method_nr(curbuf) == CRYPT_M_SOD) |
3199 continue; | 3203 continue; |
3201 u_compute_hash(hash); | 3205 u_compute_hash(hash); |
3202 u_read_undo(NULL, hash, curbuf->b_fname); | 3206 u_read_undo(NULL, hash, curbuf->b_fname); |
3203 } | 3207 } |
3204 } | 3208 } |
3205 curbuf = save_curbuf; | 3209 curbuf = save_curbuf; |
3210 | |
3211 return NULL; | |
3206 } | 3212 } |
3207 #endif | 3213 #endif |
3208 | 3214 |
3209 /* | 3215 /* |
3210 * Process the updated 'readonly' option value. | 3216 * Process the updated 'readonly' option value. |
3211 */ | 3217 */ |
3212 static void | 3218 char * |
3213 did_set_readonly(int opt_flags) | 3219 did_set_readonly(optset_T *args) |
3214 { | 3220 { |
3215 // when 'readonly' is reset globally, also reset readonlymode | 3221 // when 'readonly' is reset globally, also reset readonlymode |
3216 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) | 3222 if (!curbuf->b_p_ro && (args->os_flags & OPT_LOCAL) == 0) |
3217 readonlymode = FALSE; | 3223 readonlymode = FALSE; |
3218 | 3224 |
3219 // when 'readonly' is set may give W10 again | 3225 // when 'readonly' is set may give W10 again |
3220 if (curbuf->b_p_ro) | 3226 if (curbuf->b_p_ro) |
3221 curbuf->b_did_warn = FALSE; | 3227 curbuf->b_did_warn = FALSE; |
3222 | 3228 |
3223 redraw_titles(); | 3229 redraw_titles(); |
3224 } | 3230 |
3225 | 3231 return NULL; |
3226 #ifdef FEAT_GUI | 3232 } |
3233 | |
3234 #if defined(FEAT_GUI) || defined(PROTO) | |
3227 /* | 3235 /* |
3228 * Process the updated 'mousehide' option value. | 3236 * Process the updated 'mousehide' option value. |
3229 */ | 3237 */ |
3230 static void | 3238 char * |
3231 did_set_mousehide(void) | 3239 did_set_mousehide(optset_T *args UNUSED) |
3232 { | 3240 { |
3233 if (!p_mh) | 3241 if (!p_mh) |
3234 gui_mch_mousehide(FALSE); | 3242 gui_mch_mousehide(FALSE); |
3243 return NULL; | |
3235 } | 3244 } |
3236 #endif | 3245 #endif |
3237 | 3246 |
3238 /* | 3247 /* |
3239 * Process the updated 'modifiable' option value. | 3248 * Process the updated 'modifiable' option value. |
3240 */ | 3249 */ |
3241 static char * | 3250 char * |
3242 did_set_modifiable(int *doskip UNUSED) | 3251 did_set_modifiable(optset_T *args UNUSED) |
3243 { | 3252 { |
3244 // when 'modifiable' is changed, redraw the window title | 3253 // when 'modifiable' is changed, redraw the window title |
3245 | 3254 |
3246 # ifdef FEAT_TERMINAL | 3255 # ifdef FEAT_TERMINAL |
3247 // Cannot set 'modifiable' when in Terminal mode. | 3256 // Cannot set 'modifiable' when in Terminal mode. |
3248 if (curbuf->b_p_ma && (term_in_normal_mode() || (bt_terminal(curbuf) | 3257 if (curbuf->b_p_ma && (term_in_normal_mode() || (bt_terminal(curbuf) |
3249 && curbuf->b_term != NULL && !term_is_finished(curbuf)))) | 3258 && curbuf->b_term != NULL && !term_is_finished(curbuf)))) |
3250 { | 3259 { |
3251 curbuf->b_p_ma = FALSE; | 3260 curbuf->b_p_ma = FALSE; |
3252 *doskip = TRUE; | 3261 args->os_doskip = TRUE; |
3253 return e_cannot_make_terminal_with_running_job_modifiable; | 3262 return e_cannot_make_terminal_with_running_job_modifiable; |
3254 } | 3263 } |
3255 # endif | 3264 # endif |
3256 redraw_titles(); | 3265 redraw_titles(); |
3257 | 3266 |
3260 | 3269 |
3261 /* | 3270 /* |
3262 * Process the updated 'endoffile' or 'endofline' or 'fixendofline' or 'bomb' | 3271 * Process the updated 'endoffile' or 'endofline' or 'fixendofline' or 'bomb' |
3263 * option value. | 3272 * option value. |
3264 */ | 3273 */ |
3265 static void | 3274 char * |
3266 did_set_eof_eol_fixeol_bomb(void) | 3275 did_set_eof_eol_fixeol_bomb(optset_T *args UNUSED) |
3267 { | 3276 { |
3268 // redraw the window title and tab page text | 3277 // redraw the window title and tab page text |
3269 redraw_titles(); | 3278 redraw_titles(); |
3279 return NULL; | |
3270 } | 3280 } |
3271 | 3281 |
3272 /* | 3282 /* |
3273 * Process the updated 'binary' option value. | 3283 * Process the updated 'binary' option value. |
3274 */ | 3284 */ |
3275 static void | 3285 char * |
3276 did_set_binary(int opt_flags, long old_value) | 3286 did_set_binary(optset_T *args) |
3277 { | 3287 { |
3278 // when 'bin' is set also set some other options | 3288 // when 'bin' is set also set some other options |
3279 set_options_bin(old_value, curbuf->b_p_bin, opt_flags); | 3289 set_options_bin(args->os_oldval.boolean, curbuf->b_p_bin, args->os_flags); |
3280 redraw_titles(); | 3290 redraw_titles(); |
3291 | |
3292 return NULL; | |
3281 } | 3293 } |
3282 | 3294 |
3283 /* | 3295 /* |
3284 * Process the updated 'buflisted' option value. | 3296 * Process the updated 'buflisted' option value. |
3285 */ | 3297 */ |
3286 static void | 3298 char * |
3287 did_set_buflisted(long old_value) | 3299 did_set_buflisted(optset_T *args) |
3288 { | 3300 { |
3289 // when 'buflisted' changes, trigger autocommands | 3301 // when 'buflisted' changes, trigger autocommands |
3290 if (old_value != curbuf->b_p_bl) | 3302 if (args->os_oldval.boolean != curbuf->b_p_bl) |
3291 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, | 3303 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, |
3292 NULL, NULL, TRUE, curbuf); | 3304 NULL, NULL, TRUE, curbuf); |
3305 return NULL; | |
3293 } | 3306 } |
3294 | 3307 |
3295 /* | 3308 /* |
3296 * Process the updated 'swapfile' option value. | 3309 * Process the updated 'swapfile' option value. |
3297 */ | 3310 */ |
3298 static void | 3311 char * |
3299 did_set_swapfile(void) | 3312 did_set_swapfile(optset_T *args UNUSED) |
3300 { | 3313 { |
3301 // when 'swf' is set, create swapfile, when reset remove swapfile | 3314 // when 'swf' is set, create swapfile, when reset remove swapfile |
3302 if (curbuf->b_p_swf && p_uc) | 3315 if (curbuf->b_p_swf && p_uc) |
3303 ml_open_file(curbuf); // create the swap file | 3316 ml_open_file(curbuf); // create the swap file |
3304 else | 3317 else |
3305 // no need to reset curbuf->b_may_swap, ml_open_file() will check | 3318 // no need to reset curbuf->b_may_swap, ml_open_file() will check |
3306 // buf->b_p_swf | 3319 // buf->b_p_swf |
3307 mf_close_file(curbuf, TRUE); // remove the swap file | 3320 mf_close_file(curbuf, TRUE); // remove the swap file |
3321 return NULL; | |
3308 } | 3322 } |
3309 | 3323 |
3310 /* | 3324 /* |
3311 * Process the updated 'terse' option value. | 3325 * Process the updated 'terse' option value. |
3312 */ | 3326 */ |
3313 static void | 3327 char * |
3314 did_set_terse(void) | 3328 did_set_terse(optset_T *args UNUSED) |
3315 { | 3329 { |
3316 char_u *p; | 3330 char_u *p; |
3317 | 3331 |
3318 // when 'terse' is set change 'shortmess' | 3332 // when 'terse' is set change 'shortmess' |
3319 p = vim_strchr(p_shm, SHM_SEARCH); | 3333 p = vim_strchr(p_shm, SHM_SEARCH); |
3326 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); | 3340 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); |
3327 } | 3341 } |
3328 // remove 's' from p_shm | 3342 // remove 's' from p_shm |
3329 else if (!p_terse && p != NULL) | 3343 else if (!p_terse && p != NULL) |
3330 STRMOVE(p, p + 1); | 3344 STRMOVE(p, p + 1); |
3345 return NULL; | |
3331 } | 3346 } |
3332 | 3347 |
3333 /* | 3348 /* |
3334 * Process the updated 'paste' option value. | 3349 * Process the updated 'paste' option value. |
3335 */ | 3350 */ |
3336 static void | 3351 char * |
3337 did_set_paste(void) | 3352 did_set_paste(optset_T *args UNUSED) |
3338 { | 3353 { |
3339 // when 'paste' is set or reset also change other options | 3354 // when 'paste' is set or reset also change other options |
3340 paste_option_changed(); | 3355 paste_option_changed(); |
3356 return NULL; | |
3341 } | 3357 } |
3342 | 3358 |
3343 /* | 3359 /* |
3344 * Process the updated 'insertmode' option value. | 3360 * Process the updated 'insertmode' option value. |
3345 */ | 3361 */ |
3346 static void | 3362 char * |
3347 did_set_insertmode(long old_value) | 3363 did_set_insertmode(optset_T *args) |
3348 { | 3364 { |
3349 // when 'insertmode' is set from an autocommand need to do work here | 3365 // when 'insertmode' is set from an autocommand need to do work here |
3350 if (p_im) | 3366 if (p_im) |
3351 { | 3367 { |
3352 if ((State & MODE_INSERT) == 0) | 3368 if ((State & MODE_INSERT) == 0) |
3353 need_start_insertmode = TRUE; | 3369 need_start_insertmode = TRUE; |
3354 stop_insert_mode = FALSE; | 3370 stop_insert_mode = FALSE; |
3355 } | 3371 } |
3356 // only reset if it was set previously | 3372 // only reset if it was set previously |
3357 else if (old_value) | 3373 else if (args->os_oldval.boolean) |
3358 { | 3374 { |
3359 need_start_insertmode = FALSE; | 3375 need_start_insertmode = FALSE; |
3360 stop_insert_mode = TRUE; | 3376 stop_insert_mode = TRUE; |
3361 if (restart_edit != 0 && mode_displayed) | 3377 if (restart_edit != 0 && mode_displayed) |
3362 clear_cmdline = TRUE; // remove "(insert)" | 3378 clear_cmdline = TRUE; // remove "(insert)" |
3363 restart_edit = 0; | 3379 restart_edit = 0; |
3364 } | 3380 } |
3381 | |
3382 return NULL; | |
3365 } | 3383 } |
3366 | 3384 |
3367 /* | 3385 /* |
3368 * Process the updated 'ignorecase' option value. | 3386 * Process the updated 'ignorecase' option value. |
3369 */ | 3387 */ |
3370 static void | 3388 char * |
3371 did_set_ignorecase(void) | 3389 did_set_ignorecase(optset_T *args UNUSED) |
3372 { | 3390 { |
3373 // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw | 3391 // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw |
3374 if (p_hls) | 3392 if (p_hls) |
3375 redraw_all_later(UPD_SOME_VALID); | 3393 redraw_all_later(UPD_SOME_VALID); |
3376 } | 3394 return NULL; |
3377 | 3395 } |
3378 #ifdef FEAT_SEARCH_EXTRA | 3396 |
3397 #if defined(FEAT_SEARCH_EXTRA) || defined(PROTO) | |
3379 /* | 3398 /* |
3380 * Process the updated 'hlsearch' option value. | 3399 * Process the updated 'hlsearch' option value. |
3381 */ | 3400 */ |
3382 static void | 3401 char * |
3383 did_set_hlsearch(void) | 3402 did_set_hlsearch(optset_T *args UNUSED) |
3384 { | 3403 { |
3385 // when 'hlsearch' is set or reset: reset no_hlsearch | 3404 // when 'hlsearch' is set or reset: reset no_hlsearch |
3386 set_no_hlsearch(FALSE); | 3405 set_no_hlsearch(FALSE); |
3406 return NULL; | |
3387 } | 3407 } |
3388 #endif | 3408 #endif |
3389 | 3409 |
3390 /* | 3410 /* |
3391 * Process the updated 'scrollbind' option value. | 3411 * Process the updated 'scrollbind' option value. |
3392 */ | 3412 */ |
3393 static void | 3413 char * |
3394 did_set_scrollbind(void) | 3414 did_set_scrollbind(optset_T *args UNUSED) |
3395 { | 3415 { |
3396 // when 'scrollbind' is set: snapshot the current position to avoid a jump | 3416 // when 'scrollbind' is set: snapshot the current position to avoid a jump |
3397 // at the end of normal_cmd() | 3417 // at the end of normal_cmd() |
3398 if (!curwin->w_p_scb) | 3418 if (!curwin->w_p_scb) |
3399 return; | 3419 return NULL; |
3420 | |
3400 do_check_scrollbind(FALSE); | 3421 do_check_scrollbind(FALSE); |
3401 curwin->w_scbind_pos = curwin->w_topline; | 3422 curwin->w_scbind_pos = curwin->w_topline; |
3423 return NULL; | |
3402 } | 3424 } |
3403 | 3425 |
3404 #ifdef FEAT_QUICKFIX | 3426 #ifdef FEAT_QUICKFIX |
3405 /* | 3427 /* |
3406 * Process the updated 'previewwindow' option value. | 3428 * Process the updated 'previewwindow' option value. |
3407 */ | 3429 */ |
3408 static char * | 3430 char * |
3409 did_set_previewwindow(int *doskip) | 3431 did_set_previewwindow(optset_T *args) |
3410 { | 3432 { |
3411 if (!curwin->w_p_pvw) | 3433 if (!curwin->w_p_pvw) |
3412 return NULL; | 3434 return NULL; |
3413 | 3435 |
3414 // There can be only one window with 'previewwindow' set. | 3436 // There can be only one window with 'previewwindow' set. |
3416 | 3438 |
3417 FOR_ALL_WINDOWS(win) | 3439 FOR_ALL_WINDOWS(win) |
3418 if (win->w_p_pvw && win != curwin) | 3440 if (win->w_p_pvw && win != curwin) |
3419 { | 3441 { |
3420 curwin->w_p_pvw = FALSE; | 3442 curwin->w_p_pvw = FALSE; |
3421 *doskip = TRUE; | 3443 args->os_doskip = TRUE; |
3422 return e_preview_window_already_exists; | 3444 return e_preview_window_already_exists; |
3423 } | 3445 } |
3424 | 3446 |
3425 return NULL; | 3447 return NULL; |
3426 } | 3448 } |
3427 #endif | 3449 #endif |
3428 | 3450 |
3429 /* | 3451 /* |
3430 * Process the updated 'smoothscroll' option value. | 3452 * Process the updated 'smoothscroll' option value. |
3431 */ | 3453 */ |
3432 static void | 3454 char * |
3433 did_set_smoothscroll(void) | 3455 did_set_smoothscroll(optset_T *args UNUSED) |
3434 { | 3456 { |
3435 if (curwin->w_p_sms) | 3457 if (curwin->w_p_sms) |
3436 return; | 3458 return NULL; |
3459 | |
3437 curwin->w_skipcol = 0; | 3460 curwin->w_skipcol = 0; |
3438 changed_line_abv_curs(); | 3461 changed_line_abv_curs(); |
3462 return NULL; | |
3439 } | 3463 } |
3440 | 3464 |
3441 /* | 3465 /* |
3442 * Process the updated 'textmode' option value. | 3466 * Process the updated 'textmode' option value. |
3443 */ | 3467 */ |
3444 static void | 3468 char * |
3445 did_set_textmode(int opt_flags) | 3469 did_set_textmode(optset_T *args) |
3446 { | 3470 { |
3447 // when 'textmode' is set or reset also change 'fileformat' | 3471 // when 'textmode' is set or reset also change 'fileformat' |
3448 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags); | 3472 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, args->os_flags); |
3473 | |
3474 return NULL; | |
3449 } | 3475 } |
3450 | 3476 |
3451 /* | 3477 /* |
3452 * Process the updated 'textauto' option value. | 3478 * Process the updated 'textauto' option value. |
3453 */ | 3479 */ |
3454 static void | 3480 char * |
3455 did_set_textauto(int opt_flags) | 3481 did_set_textauto(optset_T *args) |
3456 { | 3482 { |
3457 // when 'textauto' is set or reset also change 'fileformats' | 3483 // when 'textauto' is set or reset also change 'fileformats' |
3458 set_string_option_direct((char_u *)"ffs", -1, | 3484 set_string_option_direct((char_u *)"ffs", -1, |
3459 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", | 3485 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", |
3460 OPT_FREE | opt_flags, 0); | 3486 OPT_FREE | args->os_flags, 0); |
3487 | |
3488 return NULL; | |
3461 } | 3489 } |
3462 | 3490 |
3463 /* | 3491 /* |
3464 * Process the updated 'lisp' option value. | 3492 * Process the updated 'lisp' option value. |
3465 */ | 3493 */ |
3466 static void | 3494 char * |
3467 did_set_lisp(void) | 3495 did_set_lisp(optset_T *args UNUSED) |
3468 { | 3496 { |
3469 // When 'lisp' option changes include/exclude '-' in keyword characters. | 3497 // When 'lisp' option changes include/exclude '-' in keyword characters. |
3470 (void)buf_init_chartab(curbuf, FALSE); // ignore errors | 3498 (void)buf_init_chartab(curbuf, FALSE); // ignore errors |
3499 return NULL; | |
3471 } | 3500 } |
3472 | 3501 |
3473 /* | 3502 /* |
3474 * Process the updated 'title' or the 'icon' option value. | 3503 * Process the updated 'title' or the 'icon' option value. |
3475 */ | 3504 */ |
3476 static void | 3505 char * |
3477 did_set_title_icon(void) | 3506 did_set_title_icon(optset_T *args UNUSED) |
3478 { | 3507 { |
3479 // when 'title' changed, may need to change the title; same for 'icon' | 3508 // when 'title' changed, may need to change the title; same for 'icon' |
3480 did_set_title(); | 3509 did_set_title(); |
3510 return NULL; | |
3481 } | 3511 } |
3482 | 3512 |
3483 /* | 3513 /* |
3484 * Process the updated 'modified' option value. | 3514 * Process the updated 'modified' option value. |
3485 */ | 3515 */ |
3486 static void | 3516 char * |
3487 did_set_modified(long value) | 3517 did_set_modified(optset_T *args) |
3488 { | 3518 { |
3489 if (!value) | 3519 if (!args->os_newval.boolean) |
3490 save_file_ff(curbuf); // Buffer is unchanged | 3520 save_file_ff(curbuf); // Buffer is unchanged |
3491 redraw_titles(); | 3521 redraw_titles(); |
3492 modified_was_set = value; | 3522 modified_was_set = args->os_newval.boolean; |
3493 } | 3523 return NULL; |
3494 | 3524 } |
3495 #ifdef BACKSLASH_IN_FILENAME | 3525 |
3526 #if defined(BACKSLASH_IN_FILENAME) || defined(PROTO) | |
3496 /* | 3527 /* |
3497 * Process the updated 'shellslash' option value. | 3528 * Process the updated 'shellslash' option value. |
3498 */ | 3529 */ |
3499 static void | 3530 char * |
3500 did_set_shellslash(void) | 3531 did_set_shellslash(optset_T *args UNUSED) |
3501 { | 3532 { |
3502 if (p_ssl) | 3533 if (p_ssl) |
3503 { | 3534 { |
3504 psepc = '/'; | 3535 psepc = '/'; |
3505 psepcN = '\\'; | 3536 psepcN = '\\'; |
3516 buflist_slash_adjust(); | 3547 buflist_slash_adjust(); |
3517 alist_slash_adjust(); | 3548 alist_slash_adjust(); |
3518 # ifdef FEAT_EVAL | 3549 # ifdef FEAT_EVAL |
3519 scriptnames_slash_adjust(); | 3550 scriptnames_slash_adjust(); |
3520 # endif | 3551 # endif |
3552 return NULL; | |
3521 } | 3553 } |
3522 #endif | 3554 #endif |
3523 | 3555 |
3524 /* | 3556 /* |
3525 * Process the updated 'wrap' option value. | 3557 * Process the updated 'wrap' option value. |
3526 */ | 3558 */ |
3527 static void | 3559 char * |
3528 did_set_wrap(void) | 3560 did_set_wrap(optset_T *args UNUSED) |
3529 { | 3561 { |
3530 // If 'wrap' is set, set w_leftcol to zero. | 3562 // If 'wrap' is set, set w_leftcol to zero. |
3531 if (curwin->w_p_wrap) | 3563 if (curwin->w_p_wrap) |
3532 curwin->w_leftcol = 0; | 3564 curwin->w_leftcol = 0; |
3565 return NULL; | |
3533 } | 3566 } |
3534 | 3567 |
3535 /* | 3568 /* |
3536 * Process the updated 'equalalways' option value. | 3569 * Process the updated 'equalalways' option value. |
3537 */ | 3570 */ |
3538 static void | 3571 char * |
3539 did_set_equalalways(long old_value) | 3572 did_set_equalalways(optset_T *args) |
3540 { | 3573 { |
3541 if (p_ea && !old_value) | 3574 if (p_ea && !args->os_oldval.boolean) |
3542 win_equal(curwin, FALSE, 0); | 3575 win_equal(curwin, FALSE, 0); |
3576 | |
3577 return NULL; | |
3543 } | 3578 } |
3544 | 3579 |
3545 /* | 3580 /* |
3546 * Process the updated 'weirdinvert' option value. | 3581 * Process the updated 'weirdinvert' option value. |
3547 */ | 3582 */ |
3548 static void | 3583 char * |
3549 did_set_weirdinvert(long old_value) | 3584 did_set_weirdinvert(optset_T *args) |
3550 { | 3585 { |
3551 // When 'weirdinvert' changed, set/reset 't_xs'. | 3586 // When 'weirdinvert' changed, set/reset 't_xs'. |
3552 // Then set 'weirdinvert' according to value of 't_xs'. | 3587 // Then set 'weirdinvert' according to value of 't_xs'. |
3553 if (p_wiv && !old_value) | 3588 if (p_wiv && !args->os_oldval.boolean) |
3554 T_XS = (char_u *)"y"; | 3589 T_XS = (char_u *)"y"; |
3555 else if (!p_wiv && old_value) | 3590 else if (!p_wiv && args->os_oldval.boolean) |
3556 T_XS = empty_option; | 3591 T_XS = empty_option; |
3557 p_wiv = (*T_XS != NUL); | 3592 p_wiv = (*T_XS != NUL); |
3558 } | 3593 |
3559 | 3594 return NULL; |
3560 #ifdef FEAT_BEVAL_GUI | 3595 } |
3596 | |
3597 #if defined(FEAT_BEVAL_GUI) || defined(PROTO) | |
3561 /* | 3598 /* |
3562 * Process the updated 'ballooneval' option value. | 3599 * Process the updated 'ballooneval' option value. |
3563 */ | 3600 */ |
3564 static void | 3601 char * |
3565 did_set_ballooneval(long old_value) | 3602 did_set_ballooneval(optset_T *args) |
3566 { | 3603 { |
3567 if (balloonEvalForTerm) | 3604 if (balloonEvalForTerm) |
3568 return; | 3605 return NULL; |
3569 if (p_beval && !old_value) | 3606 |
3607 if (p_beval && !args->os_oldval.boolean) | |
3570 gui_mch_enable_beval_area(balloonEval); | 3608 gui_mch_enable_beval_area(balloonEval); |
3571 else if (!p_beval && old_value) | 3609 else if (!p_beval && args->os_oldval.boolean) |
3572 gui_mch_disable_beval_area(balloonEval); | 3610 gui_mch_disable_beval_area(balloonEval); |
3573 } | 3611 |
3574 #endif | 3612 return NULL; |
3575 | 3613 } |
3576 #ifdef FEAT_BEVAL_TERM | 3614 #endif |
3615 | |
3616 #if defined(FEAT_BEVAL_TERM) || defined(PROTO) | |
3577 /* | 3617 /* |
3578 * Process the updated 'balloonevalterm' option value. | 3618 * Process the updated 'balloonevalterm' option value. |
3579 */ | 3619 */ |
3580 static void | 3620 char * |
3581 did_set_balloonevalterm(void) | 3621 did_set_balloonevalterm(optset_T *args UNUSED) |
3582 { | 3622 { |
3583 mch_bevalterm_changed(); | 3623 mch_bevalterm_changed(); |
3584 } | 3624 return NULL; |
3585 #endif | 3625 } |
3586 | 3626 #endif |
3587 #ifdef FEAT_AUTOCHDIR | 3627 |
3628 #if defined(FEAT_AUTOCHDIR) || defined(PROTO) | |
3588 /* | 3629 /* |
3589 * Process the updated 'autochdir' option value. | 3630 * Process the updated 'autochdir' option value. |
3590 */ | 3631 */ |
3591 static void | 3632 char * |
3592 did_set_autochdir(void) | 3633 did_set_autochdir(optset_T *args UNUSED) |
3593 { | 3634 { |
3594 // Change directories when the 'acd' option is set now. | 3635 // Change directories when the 'acd' option is set now. |
3595 DO_AUTOCHDIR; | 3636 DO_AUTOCHDIR; |
3596 } | 3637 return NULL; |
3597 #endif | 3638 } |
3598 | 3639 #endif |
3599 #ifdef FEAT_DIFF | 3640 |
3641 #if defined(FEAT_DIFF) || defined(PROTO) | |
3600 /* | 3642 /* |
3601 * Process the updated 'diff' option value. | 3643 * Process the updated 'diff' option value. |
3602 */ | 3644 */ |
3603 static void | 3645 char * |
3604 did_set_diff(void) | 3646 did_set_diff(optset_T *args UNUSED) |
3605 { | 3647 { |
3606 // May add or remove the buffer from the list of diff buffers. | 3648 // May add or remove the buffer from the list of diff buffers. |
3607 diff_buf_adjust(curwin); | 3649 diff_buf_adjust(curwin); |
3608 # ifdef FEAT_FOLDING | 3650 # ifdef FEAT_FOLDING |
3609 if (foldmethodIsDiff(curwin)) | 3651 if (foldmethodIsDiff(curwin)) |
3610 foldUpdateAll(curwin); | 3652 foldUpdateAll(curwin); |
3611 # endif | 3653 # endif |
3612 } | 3654 return NULL; |
3613 #endif | 3655 } |
3614 | 3656 #endif |
3615 #ifdef HAVE_INPUT_METHOD | 3657 |
3658 #if defined(HAVE_INPUT_METHOD) || defined(PROTO) | |
3616 /* | 3659 /* |
3617 * Process the updated 'imdisable' option value. | 3660 * Process the updated 'imdisable' option value. |
3618 */ | 3661 */ |
3619 static void | 3662 char * |
3620 did_set_imdisable(void) | 3663 did_set_imdisable(optset_T *args UNUSED) |
3621 { | 3664 { |
3622 // Only de-activate it here, it will be enabled when changing mode. | 3665 // Only de-activate it here, it will be enabled when changing mode. |
3623 if (p_imdisable) | 3666 if (p_imdisable) |
3624 im_set_active(FALSE); | 3667 im_set_active(FALSE); |
3625 else if (State & MODE_INSERT) | 3668 else if (State & MODE_INSERT) |
3626 // When the option is set from an autocommand, it may need to take | 3669 // When the option is set from an autocommand, it may need to take |
3627 // effect right away. | 3670 // effect right away. |
3628 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); | 3671 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); |
3629 } | 3672 return NULL; |
3630 #endif | 3673 } |
3631 | 3674 #endif |
3632 #ifdef FEAT_SPELL | 3675 |
3676 #if defined(FEAT_SPELL) || defined(PROTO) | |
3633 /* | 3677 /* |
3634 * Process the updated 'spell' option value. | 3678 * Process the updated 'spell' option value. |
3635 */ | 3679 */ |
3636 static char * | 3680 char * |
3637 did_set_spell(void) | 3681 did_set_spell(optset_T *args UNUSED) |
3638 { | 3682 { |
3639 if (curwin->w_p_spell) | 3683 if (curwin->w_p_spell) |
3640 return did_set_spelllang(curwin); | 3684 return parse_spelllang(curwin); |
3641 | 3685 |
3642 return NULL; | 3686 return NULL; |
3643 } | 3687 } |
3644 #endif | 3688 #endif |
3645 | 3689 |
3646 #ifdef FEAT_ARABIC | 3690 #if defined(FEAT_ARABIC) || defined(PROTO) |
3647 /* | 3691 /* |
3648 * Process the updated 'arabic' option value. | 3692 * Process the updated 'arabic' option value. |
3649 */ | 3693 */ |
3650 static char * | 3694 char * |
3651 did_set_arabic(void) | 3695 did_set_arabic(optset_T *args UNUSED) |
3652 { | 3696 { |
3653 char *errmsg = NULL; | 3697 char *errmsg = NULL; |
3654 | 3698 |
3655 if (curwin->w_p_arab) | 3699 if (curwin->w_p_arab) |
3656 { | 3700 { |
3726 | 3770 |
3727 return errmsg; | 3771 return errmsg; |
3728 } | 3772 } |
3729 #endif | 3773 #endif |
3730 | 3774 |
3731 #if defined(FEAT_SIGNS) && defined(FEAT_GUI) | |
3732 /* | 3775 /* |
3733 * Process the updated 'number' or 'relativenumber' option value. | 3776 * Process the updated 'number' or 'relativenumber' option value. |
3734 */ | 3777 */ |
3735 static void | 3778 char * |
3736 did_set_number_relativenumber(char_u *varp) | 3779 did_set_number_relativenumber(optset_T *args UNUSED) |
3737 { | 3780 { |
3781 #if (defined(FEAT_SIGNS) && defined(FEAT_GUI)) || defined(PROTO) | |
3738 if (gui.in_use | 3782 if (gui.in_use |
3739 && (*curwin->w_p_scl == 'n' && *(curwin->w_p_scl + 1) == 'u') | 3783 && (*curwin->w_p_scl == 'n' && *(curwin->w_p_scl + 1) == 'u') |
3740 && curbuf->b_signlist != NULL) | 3784 && curbuf->b_signlist != NULL) |
3741 { | 3785 { |
3742 // If the 'number' or 'relativenumber' options are modified and | 3786 // If the 'number' or 'relativenumber' options are modified and |
3743 // 'signcolumn' is set to 'number', then clear the screen for a full | 3787 // 'signcolumn' is set to 'number', then clear the screen for a full |
3744 // refresh. Otherwise the sign icons are not displayed properly in the | 3788 // refresh. Otherwise the sign icons are not displayed properly in the |
3745 // number column. If the 'number' option is set and only the | 3789 // number column. If the 'number' option is set and only the |
3746 // 'relativenumber' option is toggled, then don't refresh the screen | 3790 // 'relativenumber' option is toggled, then don't refresh the screen |
3747 // (optimization). | 3791 // (optimization). |
3748 if (!(curwin->w_p_nu && ((int *)varp == &curwin->w_p_rnu))) | 3792 if (!(curwin->w_p_nu && ((int *)args->os_varp == &curwin->w_p_rnu))) |
3749 redraw_all_later(UPD_CLEAR); | 3793 redraw_all_later(UPD_CLEAR); |
3750 } | 3794 } |
3751 } | 3795 #endif |
3752 #endif | 3796 return NULL; |
3797 } | |
3753 | 3798 |
3754 #ifdef FEAT_TERMGUICOLORS | 3799 #ifdef FEAT_TERMGUICOLORS |
3755 static char * | 3800 char * |
3756 did_set_termguicolors(int *doskip UNUSED) | 3801 did_set_termguicolors(optset_T *args UNUSED) |
3757 { | 3802 { |
3758 # ifdef FEAT_VTP | 3803 # ifdef FEAT_VTP |
3759 // Do not turn on 'tgc' when 24-bit colors are not supported. | 3804 // Do not turn on 'tgc' when 24-bit colors are not supported. |
3760 if ( | 3805 if ( |
3761 # ifdef VIMDLL | 3806 # ifdef VIMDLL |
3762 !gui.in_use && !gui.starting && | 3807 !gui.in_use && !gui.starting && |
3763 # endif | 3808 # endif |
3764 !has_vtp_working()) | 3809 !has_vtp_working()) |
3765 { | 3810 { |
3766 p_tgc = 0; | 3811 p_tgc = 0; |
3767 *doskip = TRUE; | 3812 args->os_doskip = TRUE; |
3768 return e_24_bit_colors_are_not_supported_on_this_environment; | 3813 return e_24_bit_colors_are_not_supported_on_this_environment; |
3769 } | 3814 } |
3770 if (is_term_win32()) | 3815 if (is_term_win32()) |
3771 swap_tcap(); | 3816 swap_tcap(); |
3772 # endif | 3817 # endif |
3792 return NULL; | 3837 return NULL; |
3793 } | 3838 } |
3794 #endif | 3839 #endif |
3795 | 3840 |
3796 /* | 3841 /* |
3797 * When some boolean options are changed, need to take some action. | |
3798 */ | |
3799 static char * | |
3800 did_set_bool_option( | |
3801 char_u *varp, | |
3802 int opt_flags, | |
3803 long value, | |
3804 long old_value, | |
3805 int *doskip) | |
3806 { | |
3807 char *errmsg = NULL; | |
3808 | |
3809 if ((int *)varp == &p_cp) // 'compatible' | |
3810 did_set_compatible(); | |
3811 #ifdef FEAT_LANGMAP | |
3812 else if ((int *)varp == &p_lrm) // 'langremap' | |
3813 did_set_langremap(); | |
3814 else if ((int *)varp == &p_lnr) // 'langnoremap' | |
3815 did_set_langnoremap(); | |
3816 #endif | |
3817 #ifdef FEAT_PERSISTENT_UNDO | |
3818 else if ((int *)varp == &curbuf->b_p_udf // buffer local 'undofile' | |
3819 || (int *)varp == &p_udf) // 'undofile' | |
3820 did_set_undofile(opt_flags); | |
3821 #endif | |
3822 else if ((int *)varp == &curbuf->b_p_ro) // 'readonly' | |
3823 did_set_readonly(opt_flags); | |
3824 #ifdef FEAT_GUI | |
3825 else if ((int *)varp == &p_mh) // 'mousehide' | |
3826 did_set_mousehide(); | |
3827 #endif | |
3828 else if ((int *)varp == &curbuf->b_p_ma) | |
3829 errmsg = did_set_modifiable(doskip); // 'modifiable' | |
3830 else if ((int *)varp == &curbuf->b_p_eof // 'endoffile' | |
3831 || (int *)varp == &curbuf->b_p_eol // 'endofline' | |
3832 || (int *)varp == &curbuf->b_p_fixeol // 'fixendofline' | |
3833 || (int *)varp == &curbuf->b_p_bomb) // 'bomb' | |
3834 did_set_eof_eol_fixeol_bomb(); | |
3835 else if ((int *)varp == &curbuf->b_p_bin) // 'binary' | |
3836 did_set_binary(opt_flags, old_value); | |
3837 else if ((int *)varp == &curbuf->b_p_bl) // 'buflisted' | |
3838 did_set_buflisted(old_value); | |
3839 else if ((int *)varp == &curbuf->b_p_swf) // 'swapfile' | |
3840 did_set_swapfile(); | |
3841 else if ((int *)varp == &p_terse) // 'terse' | |
3842 did_set_terse(); | |
3843 else if ((int *)varp == &p_paste) // 'paste' | |
3844 did_set_paste(); | |
3845 else if ((int *)varp == &p_im) // 'insertmode' | |
3846 did_set_insertmode(old_value); | |
3847 else if ((int *)varp == &p_ic) // 'ignorecase' | |
3848 did_set_ignorecase(); | |
3849 #ifdef FEAT_SEARCH_EXTRA | |
3850 else if ((int *)varp == &p_hls) // 'hlsearch' | |
3851 did_set_hlsearch(); | |
3852 #endif | |
3853 else if ((int *)varp == &curwin->w_p_scb) // 'scrollbind' | |
3854 did_set_scrollbind(); | |
3855 #ifdef FEAT_QUICKFIX | |
3856 else if ((int *)varp == &curwin->w_p_pvw) // 'previewwindow' | |
3857 errmsg = did_set_previewwindow(doskip); | |
3858 #endif | |
3859 else if ((int *)varp == &curwin->w_p_sms) // 'smoothscroll' | |
3860 did_set_smoothscroll(); | |
3861 else if ((int *)varp == &curbuf->b_p_tx) // 'textmode' | |
3862 did_set_textmode(opt_flags); | |
3863 else if ((int *)varp == &p_ta) // 'textauto' | |
3864 did_set_textauto(opt_flags); | |
3865 else if (varp == (char_u *)&(curbuf->b_p_lisp)) // 'lisp' | |
3866 did_set_lisp(); | |
3867 else if ( (int *)varp == &p_title // 'title' | |
3868 || (int *)varp == &p_icon) // 'icon' | |
3869 did_set_title_icon(); | |
3870 else if ((int *)varp == &curbuf->b_changed) // 'modified' | |
3871 did_set_modified(value); | |
3872 #ifdef BACKSLASH_IN_FILENAME | |
3873 else if ((int *)varp == &p_ssl) // 'shellslash' | |
3874 did_set_shellslash(); | |
3875 #endif | |
3876 else if ((int *)varp == &curwin->w_p_wrap) // 'wrap' | |
3877 did_set_wrap(); | |
3878 else if ((int *)varp == &p_ea) // 'equalalways' | |
3879 did_set_equalalways(old_value); | |
3880 else if ((int *)varp == &p_wiv) // weirdinvert' | |
3881 did_set_weirdinvert(old_value); | |
3882 #ifdef FEAT_BEVAL_GUI | |
3883 else if ((int *)varp == &p_beval) // 'ballooneval' | |
3884 did_set_ballooneval(old_value); | |
3885 #endif | |
3886 #ifdef FEAT_BEVAL_TERM | |
3887 else if ((int *)varp == &p_bevalterm) // 'balloonevalterm' | |
3888 did_set_balloonevalterm(); | |
3889 #endif | |
3890 #ifdef FEAT_AUTOCHDIR | |
3891 else if ((int *)varp == &p_acd) // 'autochdir' | |
3892 did_set_autochdir(); | |
3893 #endif | |
3894 #ifdef FEAT_DIFF | |
3895 else if ((int *)varp == &curwin->w_p_diff) // 'diff' | |
3896 did_set_diff(); | |
3897 #endif | |
3898 #ifdef HAVE_INPUT_METHOD | |
3899 else if ((int *)varp == &p_imdisable) // 'imdisable' | |
3900 did_set_imdisable(); | |
3901 #endif | |
3902 #ifdef FEAT_SPELL | |
3903 else if ((int *)varp == &curwin->w_p_spell) // 'spell' | |
3904 errmsg = did_set_spell(); | |
3905 #endif | |
3906 #ifdef FEAT_ARABIC | |
3907 else if ((int *)varp == &curwin->w_p_arab) // 'arabic' | |
3908 errmsg = did_set_arabic(); | |
3909 #endif | |
3910 #if defined(FEAT_SIGNS) && defined(FEAT_GUI) | |
3911 else if ( (int *)varp == &curwin->w_p_nu // 'number' | |
3912 || (int *)varp == &curwin->w_p_rnu) // 'relativenumber' | |
3913 did_set_number_relativenumber(varp); | |
3914 #endif | |
3915 #ifdef FEAT_TERMGUICOLORS | |
3916 else if ((int *)varp == &p_tgc) // 'termguicolors' | |
3917 errmsg = did_set_termguicolors(doskip); | |
3918 #endif | |
3919 | |
3920 return errmsg; | |
3921 } | |
3922 | |
3923 /* | |
3924 * Set the value of a boolean option, and take care of side effects. | 3842 * Set the value of a boolean option, and take care of side effects. |
3925 * Returns NULL for success, or an error message for an error. | 3843 * Returns NULL for success, or an error message for an error. |
3926 */ | 3844 */ |
3927 static char * | 3845 static char * |
3928 set_bool_option( | 3846 set_bool_option( |
3969 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; | 3887 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; |
3970 | 3888 |
3971 /* | 3889 /* |
3972 * Handle side effects of changing a bool option. | 3890 * Handle side effects of changing a bool option. |
3973 */ | 3891 */ |
3974 int doskip = FALSE; | 3892 if (options[opt_idx].opt_did_set_cb != NULL) |
3975 errmsg = did_set_bool_option(varp, opt_flags, value, old_value, &doskip); | 3893 { |
3976 if (doskip) | 3894 optset_T args; |
3977 return errmsg; | 3895 |
3896 args.os_varp = varp; | |
3897 args.os_flags = opt_flags; | |
3898 args.os_oldval.boolean = old_value; | |
3899 args.os_newval.boolean = value; | |
3900 args.os_doskip = FALSE; | |
3901 errmsg = options[opt_idx].opt_did_set_cb(&args); | |
3902 if (args.os_doskip) | |
3903 return errmsg; | |
3904 } | |
3978 | 3905 |
3979 // after handling side effects, call autocommand | 3906 // after handling side effects, call autocommand |
3980 | 3907 |
3981 options[opt_idx].flags |= P_WAS_SET; | 3908 options[opt_idx].flags |= P_WAS_SET; |
3982 | 3909 |
3999 } | 3926 } |
4000 | 3927 |
4001 /* | 3928 /* |
4002 * Process the new 'winheight' or the 'helpheight' option value. | 3929 * Process the new 'winheight' or the 'helpheight' option value. |
4003 */ | 3930 */ |
4004 static char * | 3931 char * |
4005 did_set_winheight_helpheight(long *pp, char *errmsg) | 3932 did_set_winheight_helpheight(optset_T *args) |
4006 { | 3933 { |
3934 long *pp = (long *)args->os_varp; | |
3935 char *errmsg = NULL; | |
3936 | |
4007 if (p_wh < 1) | 3937 if (p_wh < 1) |
4008 { | 3938 { |
4009 errmsg = e_argument_must_be_positive; | 3939 errmsg = e_argument_must_be_positive; |
4010 p_wh = 1; | 3940 p_wh = 1; |
4011 } | 3941 } |
4033 } | 3963 } |
4034 | 3964 |
4035 /* | 3965 /* |
4036 * Process the new 'winminheight' option value. | 3966 * Process the new 'winminheight' option value. |
4037 */ | 3967 */ |
4038 static char * | 3968 char * |
4039 did_set_winminheight(char *errmsg) | 3969 did_set_winminheight(optset_T *args UNUSED) |
4040 { | 3970 { |
3971 char *errmsg = NULL; | |
3972 | |
4041 if (p_wmh < 0) | 3973 if (p_wmh < 0) |
4042 { | 3974 { |
4043 errmsg = e_argument_must_be_positive; | 3975 errmsg = e_argument_must_be_positive; |
4044 p_wmh = 0; | 3976 p_wmh = 0; |
4045 } | 3977 } |
4054 } | 3986 } |
4055 | 3987 |
4056 /* | 3988 /* |
4057 * Process the new 'winwidth' option value. | 3989 * Process the new 'winwidth' option value. |
4058 */ | 3990 */ |
4059 static char * | 3991 char * |
4060 did_set_winwidth(char *errmsg) | 3992 did_set_winwidth(optset_T *args UNUSED) |
4061 { | 3993 { |
3994 char *errmsg = NULL; | |
3995 | |
4062 if (p_wiw < 1) | 3996 if (p_wiw < 1) |
4063 { | 3997 { |
4064 errmsg = e_argument_must_be_positive; | 3998 errmsg = e_argument_must_be_positive; |
4065 p_wiw = 1; | 3999 p_wiw = 1; |
4066 } | 4000 } |
4078 } | 4012 } |
4079 | 4013 |
4080 /* | 4014 /* |
4081 * Process the new 'winminwidth' option value. | 4015 * Process the new 'winminwidth' option value. |
4082 */ | 4016 */ |
4083 static char * | 4017 char * |
4084 did_set_winminwidth(char *errmsg) | 4018 did_set_winminwidth(optset_T *args UNUSED) |
4085 { | 4019 { |
4020 char *errmsg = NULL; | |
4021 | |
4086 if (p_wmw < 0) | 4022 if (p_wmw < 0) |
4087 { | 4023 { |
4088 errmsg = e_argument_must_be_positive; | 4024 errmsg = e_argument_must_be_positive; |
4089 p_wmw = 0; | 4025 p_wmw = 0; |
4090 } | 4026 } |
4099 } | 4035 } |
4100 | 4036 |
4101 /* | 4037 /* |
4102 * Process the new 'laststatus' option value. | 4038 * Process the new 'laststatus' option value. |
4103 */ | 4039 */ |
4104 static void | 4040 char * |
4105 did_set_laststatus(void) | 4041 did_set_laststatus(optset_T *args UNUSED) |
4106 { | 4042 { |
4107 last_status(FALSE); // (re)set last window status line | 4043 last_status(FALSE); // (re)set last window status line |
4044 return NULL; | |
4108 } | 4045 } |
4109 | 4046 |
4110 /* | 4047 /* |
4111 * Process the new 'showtabline' option value. | 4048 * Process the new 'showtabline' option value. |
4112 */ | 4049 */ |
4113 static void | 4050 char * |
4114 did_set_showtabline(void) | 4051 did_set_showtabline(optset_T *args UNUSED) |
4115 { | 4052 { |
4116 shell_new_rows(); // recompute window positions and heights | 4053 shell_new_rows(); // recompute window positions and heights |
4117 } | 4054 return NULL; |
4118 | 4055 } |
4119 #ifdef FEAT_GUI | 4056 |
4057 #if defined(FEAT_GUI) || defined(PROTO) | |
4120 /* | 4058 /* |
4121 * Process the new 'linespace' option value. | 4059 * Process the new 'linespace' option value. |
4122 */ | 4060 */ |
4123 static void | 4061 char * |
4124 did_set_linespace(void) | 4062 did_set_linespace(optset_T *args UNUSED) |
4125 { | 4063 { |
4126 // Recompute gui.char_height and resize the Vim window to keep the | 4064 // Recompute gui.char_height and resize the Vim window to keep the |
4127 // same number of lines. | 4065 // same number of lines. |
4128 if (gui.in_use && gui_mch_adjust_charheight() == OK) | 4066 if (gui.in_use && gui_mch_adjust_charheight() == OK) |
4129 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); | 4067 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); |
4130 } | 4068 return NULL; |
4131 #endif | 4069 } |
4132 | 4070 #endif |
4133 #ifdef FEAT_FOLDING | 4071 |
4072 #if defined(FEAT_FOLDING) || defined(PROTO) | |
4134 /* | 4073 /* |
4135 * Process the new 'foldlevel' option value. | 4074 * Process the new 'foldlevel' option value. |
4136 */ | 4075 */ |
4137 static void | 4076 char * |
4138 did_set_foldlevel(void) | 4077 did_set_foldlevel(optset_T *args UNUSED) |
4139 { | 4078 { |
4140 if (curwin->w_p_fdl < 0) | 4079 if (curwin->w_p_fdl < 0) |
4141 curwin->w_p_fdl = 0; | 4080 curwin->w_p_fdl = 0; |
4142 newFoldLevel(); | 4081 newFoldLevel(); |
4082 return NULL; | |
4143 } | 4083 } |
4144 | 4084 |
4145 /* | 4085 /* |
4146 * Process the new 'foldminlines' option value. | 4086 * Process the new 'foldminlines' option value. |
4147 */ | 4087 */ |
4148 static void | 4088 char * |
4149 did_set_foldminlines(void) | 4089 did_set_foldminlines(optset_T *args UNUSED) |
4150 { | 4090 { |
4151 foldUpdateAll(curwin); | 4091 foldUpdateAll(curwin); |
4092 return NULL; | |
4152 } | 4093 } |
4153 | 4094 |
4154 /* | 4095 /* |
4155 * Process the new 'foldnestmax' option value. | 4096 * Process the new 'foldnestmax' option value. |
4156 */ | 4097 */ |
4157 static void | 4098 char * |
4158 did_set_foldnestmax(void) | 4099 did_set_foldnestmax(optset_T *args UNUSED) |
4159 { | 4100 { |
4160 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) | 4101 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) |
4161 foldUpdateAll(curwin); | 4102 foldUpdateAll(curwin); |
4103 return NULL; | |
4162 } | 4104 } |
4163 | 4105 |
4164 /* | 4106 /* |
4165 * Process the new 'foldcolumn' option value. | 4107 * Process the new 'foldcolumn' option value. |
4166 */ | 4108 */ |
4167 static char * | 4109 char * |
4168 did_set_foldcolumn(char *errmsg) | 4110 did_set_foldcolumn(optset_T *args UNUSED) |
4169 { | 4111 { |
4112 char *errmsg = NULL; | |
4113 | |
4170 if (curwin->w_p_fdc < 0) | 4114 if (curwin->w_p_fdc < 0) |
4171 { | 4115 { |
4172 errmsg = e_argument_must_be_positive; | 4116 errmsg = e_argument_must_be_positive; |
4173 curwin->w_p_fdc = 0; | 4117 curwin->w_p_fdc = 0; |
4174 } | 4118 } |
4183 #endif | 4127 #endif |
4184 | 4128 |
4185 /* | 4129 /* |
4186 * Process the new 'shiftwidth' or the 'tabstop' option value. | 4130 * Process the new 'shiftwidth' or the 'tabstop' option value. |
4187 */ | 4131 */ |
4188 static void | 4132 char * |
4189 did_set_shiftwidth_tabstop(long *pp) | 4133 did_set_shiftwidth_tabstop(optset_T *args) |
4190 { | 4134 { |
4135 long *pp = (long *)args->os_varp; | |
4136 char *errmsg = NULL; | |
4137 | |
4138 if (curbuf->b_p_sw < 0) | |
4139 { | |
4140 errmsg = e_argument_must_be_positive; | |
4141 #ifdef FEAT_VARTABS | |
4142 // Use the first 'vartabstop' value, or 'tabstop' if vts isn't in use. | |
4143 curbuf->b_p_sw = tabstop_count(curbuf->b_p_vts_array) > 0 | |
4144 ? tabstop_first(curbuf->b_p_vts_array) | |
4145 : curbuf->b_p_ts; | |
4146 #else | |
4147 curbuf->b_p_sw = curbuf->b_p_ts; | |
4148 #endif | |
4149 } | |
4150 | |
4191 #ifdef FEAT_FOLDING | 4151 #ifdef FEAT_FOLDING |
4192 if (foldmethodIsIndent(curwin)) | 4152 if (foldmethodIsIndent(curwin)) |
4193 foldUpdateAll(curwin); | 4153 foldUpdateAll(curwin); |
4194 #endif | 4154 #endif |
4195 // When 'shiftwidth' changes, or it's zero and 'tabstop' changes: | 4155 // When 'shiftwidth' changes, or it's zero and 'tabstop' changes: |
4196 // parse 'cinoptions'. | 4156 // parse 'cinoptions'. |
4197 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) | 4157 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) |
4198 parse_cino(curbuf); | 4158 parse_cino(curbuf); |
4159 | |
4160 return errmsg; | |
4199 } | 4161 } |
4200 | 4162 |
4201 /* | 4163 /* |
4202 * Process the new 'maxcombine' option value. | 4164 * Process the new 'maxcombine' option value. |
4203 */ | 4165 */ |
4204 static void | 4166 char * |
4205 did_set_maxcombine(void) | 4167 did_set_maxcombine(optset_T *args UNUSED) |
4206 { | 4168 { |
4207 if (p_mco > MAX_MCO) | 4169 if (p_mco > MAX_MCO) |
4208 p_mco = MAX_MCO; | 4170 p_mco = MAX_MCO; |
4209 else if (p_mco < 0) | 4171 else if (p_mco < 0) |
4210 p_mco = 0; | 4172 p_mco = 0; |
4211 screenclear(); // will re-allocate the screen | 4173 screenclear(); // will re-allocate the screen |
4174 return NULL; | |
4212 } | 4175 } |
4213 | 4176 |
4214 /* | 4177 /* |
4215 * Process the new 'iminsert' option value. | 4178 * Process the new 'iminsert' option value. |
4216 */ | 4179 */ |
4217 static char * | 4180 char * |
4218 did_set_iminsert(char *errmsg) | 4181 did_set_iminsert(optset_T *args UNUSED) |
4219 { | 4182 { |
4183 char *errmsg = NULL; | |
4184 | |
4220 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) | 4185 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) |
4221 { | 4186 { |
4222 errmsg = e_invalid_argument; | 4187 errmsg = e_invalid_argument; |
4223 curbuf->b_p_iminsert = B_IMODE_NONE; | 4188 curbuf->b_p_iminsert = B_IMODE_NONE; |
4224 } | 4189 } |
4231 #endif | 4196 #endif |
4232 | 4197 |
4233 return errmsg; | 4198 return errmsg; |
4234 } | 4199 } |
4235 | 4200 |
4236 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) | 4201 #if (defined(FEAT_XIM) && defined(FEAT_GUI_GTK)) || defined(PROTO) |
4237 /* | 4202 /* |
4238 * Process the new 'imstyle' option value. | 4203 * Process the new 'imstyle' option value. |
4239 */ | 4204 */ |
4240 static char * | 4205 char * |
4241 did_set_imstyle(char *errmsg) | 4206 did_set_imstyle(optset_T *args UNUSED) |
4242 { | 4207 { |
4208 char *errmsg = NULL; | |
4209 | |
4243 if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT) | 4210 if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT) |
4244 errmsg = e_invalid_argument; | 4211 errmsg = e_invalid_argument; |
4245 | 4212 |
4246 return errmsg; | 4213 return errmsg; |
4247 } | 4214 } |
4248 #endif | 4215 #endif |
4249 | 4216 |
4250 /* | 4217 /* |
4251 * Process the new 'window' option value. | 4218 * Process the new 'window' option value. |
4252 */ | 4219 */ |
4253 static void | 4220 char * |
4254 did_set_window(void) | 4221 did_set_window(optset_T *args UNUSED) |
4255 { | 4222 { |
4256 if (p_window < 1) | 4223 if (p_window < 1) |
4257 p_window = 1; | 4224 p_window = 1; |
4258 else if (p_window >= Rows) | 4225 else if (p_window >= Rows) |
4259 p_window = Rows - 1; | 4226 p_window = Rows - 1; |
4227 return NULL; | |
4260 } | 4228 } |
4261 | 4229 |
4262 /* | 4230 /* |
4263 * Process the new 'imsearch' option value. | 4231 * Process the new 'imsearch' option value. |
4264 */ | 4232 */ |
4265 static char * | 4233 char * |
4266 did_set_imsearch(char *errmsg) | 4234 did_set_imsearch(optset_T *args UNUSED) |
4267 { | 4235 { |
4236 char *errmsg = NULL; | |
4237 | |
4268 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) | 4238 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) |
4269 { | 4239 { |
4270 errmsg = e_invalid_argument; | 4240 errmsg = e_invalid_argument; |
4271 curbuf->b_p_imsearch = B_IMODE_NONE; | 4241 curbuf->b_p_imsearch = B_IMODE_NONE; |
4272 } | 4242 } |
4276 } | 4246 } |
4277 | 4247 |
4278 /* | 4248 /* |
4279 * Process the new 'titlelen' option value. | 4249 * Process the new 'titlelen' option value. |
4280 */ | 4250 */ |
4281 static char * | 4251 char * |
4282 did_set_titlelen(long old_value, char *errmsg) | 4252 did_set_titlelen(optset_T *args) |
4283 { | 4253 { |
4254 long old_value = args->os_oldval.number; | |
4255 char *errmsg = NULL; | |
4256 | |
4284 // if 'titlelen' has changed, redraw the title | 4257 // if 'titlelen' has changed, redraw the title |
4285 if (p_titlelen < 0) | 4258 if (p_titlelen < 0) |
4286 { | 4259 { |
4287 errmsg = e_argument_must_be_positive; | 4260 errmsg = e_argument_must_be_positive; |
4288 p_titlelen = 85; | 4261 p_titlelen = 85; |
4294 } | 4267 } |
4295 | 4268 |
4296 /* | 4269 /* |
4297 * Process the new 'cmdheight' option value. | 4270 * Process the new 'cmdheight' option value. |
4298 */ | 4271 */ |
4299 static char * | 4272 char * |
4300 did_set_cmdheight(long old_value, char *errmsg) | 4273 did_set_cmdheight(optset_T *args) |
4301 { | 4274 { |
4275 long old_value = args->os_oldval.number; | |
4276 char *errmsg = NULL; | |
4277 | |
4302 // if p_ch changed value, change the command line height | 4278 // if p_ch changed value, change the command line height |
4303 if (p_ch < 1) | 4279 if (p_ch < 1) |
4304 { | 4280 { |
4305 errmsg = e_argument_must_be_positive; | 4281 errmsg = e_argument_must_be_positive; |
4306 p_ch = 1; | 4282 p_ch = 1; |
4323 } | 4299 } |
4324 | 4300 |
4325 /* | 4301 /* |
4326 * Process the new 'updatecount' option value. | 4302 * Process the new 'updatecount' option value. |
4327 */ | 4303 */ |
4328 static char * | 4304 char * |
4329 did_set_updatecount(long old_value, char *errmsg) | 4305 did_set_updatecount(optset_T *args) |
4330 { | 4306 { |
4307 long old_value = args->os_oldval.number; | |
4308 char *errmsg = NULL; | |
4309 | |
4331 // when 'updatecount' changes from zero to non-zero, open swap files | 4310 // when 'updatecount' changes from zero to non-zero, open swap files |
4332 if (p_uc < 0) | 4311 if (p_uc < 0) |
4333 { | 4312 { |
4334 errmsg = e_argument_must_be_positive; | 4313 errmsg = e_argument_must_be_positive; |
4335 p_uc = 100; | 4314 p_uc = 100; |
4338 ml_open_files(); | 4317 ml_open_files(); |
4339 | 4318 |
4340 return errmsg; | 4319 return errmsg; |
4341 } | 4320 } |
4342 | 4321 |
4343 #ifdef FEAT_CONCEAL | 4322 #if defined(FEAT_CONCEAL) || defined(PROTO) |
4344 /* | 4323 /* |
4345 * Process the new 'conceallevel' option value. | 4324 * Process the new 'conceallevel' option value. |
4346 */ | 4325 */ |
4347 static char * | 4326 char * |
4348 did_set_conceallevel(char *errmsg) | 4327 did_set_conceallevel(optset_T *args UNUSED) |
4349 { | 4328 { |
4329 char *errmsg = NULL; | |
4330 | |
4350 if (curwin->w_p_cole < 0) | 4331 if (curwin->w_p_cole < 0) |
4351 { | 4332 { |
4352 errmsg = e_argument_must_be_positive; | 4333 errmsg = e_argument_must_be_positive; |
4353 curwin->w_p_cole = 0; | 4334 curwin->w_p_cole = 0; |
4354 } | 4335 } |
4360 | 4341 |
4361 return errmsg; | 4342 return errmsg; |
4362 } | 4343 } |
4363 #endif | 4344 #endif |
4364 | 4345 |
4365 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) | 4346 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
4366 /* | 4347 /* |
4367 * Process the new 'pyxversion' option value. | 4348 * Process the new 'pyxversion' option value. |
4368 */ | 4349 */ |
4369 static char * | 4350 char * |
4370 did_set_pyxversion(char *errmsg) | 4351 did_set_pyxversion(optset_T *args UNUSED) |
4371 { | 4352 { |
4353 char *errmsg = NULL; | |
4354 | |
4372 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3) | 4355 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3) |
4373 errmsg = e_invalid_argument; | 4356 errmsg = e_invalid_argument; |
4374 | 4357 |
4375 return errmsg; | 4358 return errmsg; |
4376 } | 4359 } |
4400 curbuf->b_p_ul = old_value; | 4383 curbuf->b_p_ul = old_value; |
4401 u_sync(TRUE); | 4384 u_sync(TRUE); |
4402 curbuf->b_p_ul = value; | 4385 curbuf->b_p_ul = value; |
4403 } | 4386 } |
4404 | 4387 |
4405 #ifdef FEAT_LINEBREAK | 4388 #if defined(FEAT_LINEBREAK) || defined(PROTO) |
4406 /* | 4389 /* |
4407 * Process the new 'numberwidth' option value. | 4390 * Process the new 'numberwidth' option value. |
4408 */ | 4391 */ |
4409 static char * | 4392 char * |
4410 did_set_numberwidth(char *errmsg) | 4393 did_set_numberwidth(optset_T *args UNUSED) |
4411 { | 4394 { |
4395 char *errmsg = NULL; | |
4396 | |
4412 // 'numberwidth' must be positive | 4397 // 'numberwidth' must be positive |
4413 if (curwin->w_p_nuw < 1) | 4398 if (curwin->w_p_nuw < 1) |
4414 { | 4399 { |
4415 errmsg = e_argument_must_be_positive; | 4400 errmsg = e_argument_must_be_positive; |
4416 curwin->w_p_nuw = 1; | 4401 curwin->w_p_nuw = 1; |
4427 #endif | 4412 #endif |
4428 | 4413 |
4429 /* | 4414 /* |
4430 * Process the new 'textwidth' option value. | 4415 * Process the new 'textwidth' option value. |
4431 */ | 4416 */ |
4432 static char * | 4417 char * |
4433 did_set_textwidth(char *errmsg) | 4418 did_set_textwidth(optset_T *args UNUSED) |
4434 { | 4419 { |
4420 char *errmsg = NULL; | |
4421 | |
4435 if (curbuf->b_p_tw < 0) | 4422 if (curbuf->b_p_tw < 0) |
4436 { | 4423 { |
4437 errmsg = e_argument_must_be_positive; | 4424 errmsg = e_argument_must_be_positive; |
4438 curbuf->b_p_tw = 0; | 4425 curbuf->b_p_tw = 0; |
4439 } | 4426 } |
4449 | 4436 |
4450 return errmsg; | 4437 return errmsg; |
4451 } | 4438 } |
4452 | 4439 |
4453 /* | 4440 /* |
4454 * When some number options are changed, need to take some action. | 4441 * Process the new 'undolevels' option value. |
4455 */ | 4442 */ |
4456 static char * | 4443 char * |
4457 did_set_num_option(long *pp, long value, long old_value, char *errmsg) | 4444 did_set_undolevels(optset_T *args) |
4458 { | 4445 { |
4459 if (pp == &p_wh // 'winheight' | 4446 long *pp = (long *)args->os_varp; |
4460 || pp == &p_hh) // 'helpheight' | 4447 |
4461 errmsg = did_set_winheight_helpheight(pp, errmsg); | 4448 if (pp == &p_ul) // global 'undolevels' |
4462 else if (pp == &p_wmh) // 'winminheight' | 4449 did_set_global_undolevels(args->os_newval.number, |
4463 errmsg = did_set_winminheight(errmsg); | 4450 args->os_oldval.number); |
4464 else if (pp == &p_wiw) // 'winwidth' | 4451 else if (pp == &curbuf->b_p_ul) // buffer local 'undolevels' |
4465 errmsg = did_set_winwidth(errmsg); | 4452 did_set_buflocal_undolevels(args->os_newval.number, |
4466 else if (pp == &p_wmw) // 'winminwidth' | 4453 args->os_oldval.number); |
4467 errmsg = did_set_winminwidth(errmsg); | 4454 |
4468 else if (pp == &p_ls) | 4455 return NULL; |
4469 did_set_laststatus(); // 'laststatus' | |
4470 else if (pp == &p_stal) | |
4471 did_set_showtabline(); // 'showtabline' | |
4472 #ifdef FEAT_GUI | |
4473 else if (pp == &p_linespace) // 'linespace' | |
4474 did_set_linespace(); | |
4475 #endif | |
4476 #ifdef FEAT_FOLDING | |
4477 else if (pp == &curwin->w_p_fdl) // 'foldlevel' | |
4478 did_set_foldlevel(); | |
4479 else if (pp == &curwin->w_p_fml) // 'foldminlines' | |
4480 did_set_foldminlines(); | |
4481 else if (pp == &curwin->w_p_fdn) // 'foldnestmax' | |
4482 did_set_foldnestmax(); | |
4483 else if (pp == &curwin->w_p_fdc) // 'foldcolumn' | |
4484 errmsg = did_set_foldcolumn(errmsg); | |
4485 #endif // FEAT_FOLDING | |
4486 else if ( pp == &curbuf->b_p_sw // 'shiftwidth' | |
4487 || pp == &curbuf->b_p_ts) // 'tabstop' | |
4488 did_set_shiftwidth_tabstop(pp); | |
4489 else if (pp == &p_mco) // 'maxcombine' | |
4490 did_set_maxcombine(); | |
4491 else if (pp == &curbuf->b_p_iminsert) // 'iminsert' | |
4492 errmsg = did_set_iminsert(errmsg); | |
4493 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) | |
4494 else if (pp == &p_imst) // 'imstyle' | |
4495 errmsg = did_set_imstyle(errmsg); | |
4496 #endif | |
4497 else if (pp == &p_window) // 'window' | |
4498 did_set_window(); | |
4499 else if (pp == &curbuf->b_p_imsearch) // 'imsearch' | |
4500 errmsg = did_set_imsearch(errmsg); | |
4501 else if (pp == &p_titlelen) // 'titlelen' | |
4502 errmsg = did_set_titlelen(old_value, errmsg); | |
4503 else if (pp == &p_ch) // 'cmdheight' | |
4504 errmsg = did_set_cmdheight(old_value, errmsg); | |
4505 else if (pp == &p_uc) // 'updatecount' | |
4506 errmsg = did_set_updatecount(old_value, errmsg); | |
4507 #ifdef FEAT_CONCEAL | |
4508 else if (pp == &curwin->w_p_cole) // 'conceallevel' | |
4509 errmsg = did_set_conceallevel(errmsg); | |
4510 #endif | |
4511 #ifdef MZSCHEME_GUI_THREADS | |
4512 else if (pp == &p_mzq) // 'mzquantum' | |
4513 mzvim_reset_timer(); | |
4514 #endif | |
4515 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) | |
4516 else if (pp == &p_pyx) // 'pyxversion' | |
4517 errmsg = did_set_pyxversion(errmsg); | |
4518 #endif | |
4519 else if (pp == &p_ul) // global 'undolevels' | |
4520 did_set_global_undolevels(value, old_value); | |
4521 else if (pp == &curbuf->b_p_ul) // buffer local 'undolevels' | |
4522 did_set_buflocal_undolevels(value, old_value); | |
4523 #ifdef FEAT_LINEBREAK | |
4524 else if (pp == &curwin->w_p_nuw) // 'numberwidth' | |
4525 errmsg = did_set_numberwidth(errmsg); | |
4526 #endif | |
4527 else if (pp == &curbuf->b_p_tw) // 'textwidth' | |
4528 errmsg = did_set_textwidth(errmsg); | |
4529 | |
4530 return errmsg; | |
4531 } | 4456 } |
4532 | 4457 |
4533 /* | 4458 /* |
4534 * Check the bounds of numeric options. | 4459 * Check the bounds of numeric options. |
4535 */ | 4460 */ |
4732 #endif | 4657 #endif |
4733 #ifdef FEAT_GUI | 4658 #ifdef FEAT_GUI |
4734 need_mouse_correct = TRUE; | 4659 need_mouse_correct = TRUE; |
4735 #endif | 4660 #endif |
4736 | 4661 |
4737 if (curbuf->b_p_sw < 0) | 4662 // Invoke the option specific callback function to validate and apply the |
4738 { | 4663 // new value. |
4739 errmsg = e_argument_must_be_positive; | 4664 if (options[opt_idx].opt_did_set_cb != NULL) |
4740 #ifdef FEAT_VARTABS | 4665 { |
4741 // Use the first 'vartabstop' value, or 'tabstop' if vts isn't in use. | 4666 optset_T args; |
4742 curbuf->b_p_sw = tabstop_count(curbuf->b_p_vts_array) > 0 | 4667 |
4743 ? tabstop_first(curbuf->b_p_vts_array) | 4668 args.os_varp = varp; |
4744 : curbuf->b_p_ts; | 4669 args.os_flags = opt_flags; |
4745 #else | 4670 args.os_oldval.number = old_value; |
4746 curbuf->b_p_sw = curbuf->b_p_ts; | 4671 args.os_newval.number = value; |
4747 #endif | 4672 errmsg = options[opt_idx].opt_did_set_cb(&args); |
4748 } | 4673 } |
4749 | 4674 |
4750 /* | 4675 // Check the bounds for numeric options here |
4751 * Number options that need some action when changed | |
4752 */ | |
4753 errmsg = did_set_num_option(pp, value, old_value, errmsg); | |
4754 | |
4755 /* | |
4756 * Check the bounds for numeric options here | |
4757 */ | |
4758 errmsg = check_num_option_bounds(pp, old_value, old_Rows, old_Columns, | 4676 errmsg = check_num_option_bounds(pp, old_value, old_Rows, old_Columns, |
4759 errbuf, errbuflen, errmsg); | 4677 errbuf, errbuflen, errmsg); |
4760 | 4678 |
4761 // May set global value for local option. | 4679 // May set global value for local option. |
4762 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) | 4680 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
6528 return (char_u *)options[opt_idx].fullname; | 6446 return (char_u *)options[opt_idx].fullname; |
6529 } | 6447 } |
6530 #endif | 6448 #endif |
6531 | 6449 |
6532 /* | 6450 /* |
6451 * Return the did_set callback function for the option at 'opt_idx' | |
6452 */ | |
6453 opt_did_set_cb_T | |
6454 get_option_did_set_cb(int opt_idx) | |
6455 { | |
6456 return options[opt_idx].opt_did_set_cb; | |
6457 } | |
6458 | |
6459 /* | |
6533 * Get the value of 'equalprg', either the buffer-local one or the global one. | 6460 * Get the value of 'equalprg', either the buffer-local one or the global one. |
6534 */ | 6461 */ |
6535 char_u * | 6462 char_u * |
6536 get_equalprg(void) | 6463 get_equalprg(void) |
6537 { | 6464 { |
8060 } | 7987 } |
8061 | 7988 |
8062 #if defined(FEAT_LINEBREAK) || defined(PROTO) | 7989 #if defined(FEAT_LINEBREAK) || defined(PROTO) |
8063 | 7990 |
8064 /* | 7991 /* |
8065 * fill_breakat_flags() -- called when 'breakat' changes value. | 7992 * Called when the 'breakat' option changes value. |
8066 */ | 7993 */ |
8067 void | 7994 char * |
8068 fill_breakat_flags(void) | 7995 did_set_breakat(optset_T *args UNUSED) |
8069 { | 7996 { |
8070 char_u *p; | 7997 char_u *p; |
8071 int i; | 7998 int i; |
8072 | 7999 |
8073 for (i = 0; i < 256; i++) | 8000 for (i = 0; i < 256; i++) |
8074 breakat_flags[i] = FALSE; | 8001 breakat_flags[i] = FALSE; |
8075 | 8002 |
8076 if (p_breakat != NULL) | 8003 if (p_breakat != NULL) |
8077 for (p = p_breakat; *p; p++) | 8004 for (p = p_breakat; *p; p++) |
8078 breakat_flags[*p] = TRUE; | 8005 breakat_flags[*p] = TRUE; |
8006 | |
8007 return NULL; | |
8079 } | 8008 } |
8080 #endif | 8009 #endif |
8081 | 8010 |
8082 /* | 8011 /* |
8083 * Check if backspacing over something is allowed. | 8012 * Check if backspacing over something is allowed. |