Mercurial > vim
comparison src/highlight.c @ 26145:3da380450cce v8.2.3605
patch 8.2.3605: cannot clear and unlinke a highlight group with hlset()
Commit: https://github.com/vim/vim/commit/2a16dc6613368c54d526850bcbcd03c3fec1be67
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Tue Nov 16 17:19:30 2021 +0000
patch 8.2.3605: cannot clear and unlinke a highlight group with hlset()
Problem: Cannot clear and unlinke a highlight group with hlset() in a
single call.
Solution: Add the "force" option. (Yegappan Lakshmanan, closes #9117)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 16 Nov 2021 18:30:04 +0100 |
parents | bb87ce13e7d6 |
children | c83460a14407 |
comparison
equal
deleted
inserted
replaced
26144:18cbc3a4d8b9 | 26145:3da380450cce |
---|---|
4174 char_u *link; | 4174 char_u *link; |
4175 | 4175 |
4176 link = HL_TABLE()[sgp->sg_link - 1].sg_name; | 4176 link = HL_TABLE()[sgp->sg_link - 1].sg_name; |
4177 if (link != NULL && dict_add_string(dict, "linksto", link) == FAIL) | 4177 if (link != NULL && dict_add_string(dict, "linksto", link) == FAIL) |
4178 goto error; | 4178 goto error; |
4179 | |
4180 if (sgp->sg_deflink) | |
4181 dict_add_bool(dict, "default", VVAL_TRUE); | |
4179 } | 4182 } |
4180 if (dict_len(dict) == 2) | 4183 if (dict_len(dict) == 2) |
4181 // If only 'name' is present, then the highlight group is cleared. | 4184 // If only 'name' is present, then the highlight group is cleared. |
4182 dict_add_bool(dict, "cleared", VVAL_TRUE); | 4185 dict_add_bool(dict, "cleared", VVAL_TRUE); |
4183 | 4186 |
4335 char_u *guibg; | 4338 char_u *guibg; |
4336 char_u *guisp; | 4339 char_u *guisp; |
4337 # ifdef FEAT_GUI | 4340 # ifdef FEAT_GUI |
4338 char_u *font; | 4341 char_u *font; |
4339 # endif | 4342 # endif |
4343 int forceit = FALSE; | |
4344 int dodefault = FALSE; | |
4345 int done = FALSE; | |
4340 | 4346 |
4341 name = hldict_get_string(dict, (char_u *)"name", &error); | 4347 name = hldict_get_string(dict, (char_u *)"name", &error); |
4342 if (name == NULL || error) | 4348 if (name == NULL || error) |
4343 return FALSE; | 4349 return FALSE; |
4350 | |
4351 if (dict_get_bool(dict, (char_u *)"force", VVAL_FALSE) == VVAL_TRUE) | |
4352 forceit = TRUE; | |
4353 | |
4354 if (dict_get_bool(dict, (char_u *)"default", VVAL_FALSE) == VVAL_TRUE) | |
4355 dodefault = TRUE; | |
4356 | |
4357 if (dict_find(dict, (char_u *)"cleared", -1) != NULL) | |
4358 { | |
4359 varnumber_T cleared; | |
4360 | |
4361 // clear a highlight group | |
4362 cleared = dict_get_bool(dict, (char_u *)"cleared", FALSE); | |
4363 if (cleared == TRUE) | |
4364 { | |
4365 vim_snprintf((char *)IObuff, IOSIZE, "clear %s", name); | |
4366 do_highlight(IObuff, forceit, FALSE); | |
4367 done = TRUE; | |
4368 } | |
4369 } | |
4344 | 4370 |
4345 if (dict_find(dict, (char_u *)"linksto", -1) != NULL) | 4371 if (dict_find(dict, (char_u *)"linksto", -1) != NULL) |
4346 { | 4372 { |
4347 char_u *linksto; | 4373 char_u *linksto; |
4348 | 4374 |
4349 // link highlight groups | 4375 // link highlight groups |
4350 linksto = hldict_get_string(dict, (char_u *)"linksto", &error); | 4376 linksto = hldict_get_string(dict, (char_u *)"linksto", &error); |
4351 if (linksto == NULL || error) | 4377 if (linksto == NULL || error) |
4352 return FALSE; | 4378 return FALSE; |
4353 | 4379 |
4354 vim_snprintf((char *)IObuff, IOSIZE, "link %s %s", name, linksto); | 4380 vim_snprintf((char *)IObuff, IOSIZE, "%slink %s %s", |
4355 do_highlight(IObuff, FALSE, FALSE); | 4381 dodefault ? "default " : "", name, linksto); |
4356 | 4382 do_highlight(IObuff, forceit, FALSE); |
4383 | |
4384 done = TRUE; | |
4385 } | |
4386 | |
4387 // If 'cleared' or 'linksto' are specified, then don't process the other | |
4388 // attributes. | |
4389 if (done) | |
4357 return TRUE; | 4390 return TRUE; |
4358 } | |
4359 | |
4360 if (dict_find(dict, (char_u *)"cleared", -1) != NULL) | |
4361 { | |
4362 varnumber_T cleared; | |
4363 | |
4364 // clear a highlight group | |
4365 cleared = dict_get_bool(dict, (char_u *)"cleared", FALSE); | |
4366 if (cleared == TRUE) | |
4367 { | |
4368 vim_snprintf((char *)IObuff, IOSIZE, "clear %s", name); | |
4369 do_highlight(IObuff, FALSE, FALSE); | |
4370 } | |
4371 | |
4372 return TRUE; | |
4373 } | |
4374 | 4391 |
4375 start = hldict_get_string(dict, (char_u *)"start", &error); | 4392 start = hldict_get_string(dict, (char_u *)"start", &error); |
4376 if (error) | 4393 if (error) |
4377 return FALSE; | 4394 return FALSE; |
4378 | 4395 |
4432 && guifg == NULL && guibg == NULL && guisp == NULL | 4449 && guifg == NULL && guibg == NULL && guisp == NULL |
4433 ) | 4450 ) |
4434 return TRUE; | 4451 return TRUE; |
4435 | 4452 |
4436 vim_snprintf((char *)IObuff, IOSIZE, | 4453 vim_snprintf((char *)IObuff, IOSIZE, |
4437 "%s %s%s %s%s %s%s %s%s %s%s %s%s %s%s %s%s %s%s %s%s %s%s %s%s", | 4454 "%s%s %s%s %s%s %s%s %s%s %s%s %s%s %s%s %s%s %s%s %s%s %s%s %s%s", |
4455 dodefault ? "default " : "", | |
4438 name, | 4456 name, |
4439 term_attr[0] != NUL ? "term=" : "", | 4457 term_attr[0] != NUL ? "term=" : "", |
4440 term_attr[0] != NUL ? term_attr : (char_u *)"", | 4458 term_attr[0] != NUL ? term_attr : (char_u *)"", |
4441 start != NULL ? "start=" : "", | 4459 start != NULL ? "start=" : "", |
4442 start != NULL ? start : (char_u *)"", | 4460 start != NULL ? start : (char_u *)"", |
4464 guibg != NULL ? guibg : (char_u *)"", | 4482 guibg != NULL ? guibg : (char_u *)"", |
4465 guisp != NULL ? "guisp=" : "", | 4483 guisp != NULL ? "guisp=" : "", |
4466 guisp != NULL ? guisp : (char_u *)"" | 4484 guisp != NULL ? guisp : (char_u *)"" |
4467 ); | 4485 ); |
4468 | 4486 |
4469 do_highlight(IObuff, FALSE, FALSE); | 4487 do_highlight(IObuff, forceit, FALSE); |
4470 | 4488 |
4471 return TRUE; | 4489 return TRUE; |
4472 } | 4490 } |
4473 | 4491 |
4474 /* | 4492 /* |