TUI: implement "standout" attribute #8081

closes #8054
This commit is contained in:
Nimit Bhardwaj 2018-02-28 22:11:37 +05:30 committed by Justin M. Keyes
parent a9c94f7bb0
commit 8d5a46e77b
4 changed files with 45 additions and 4 deletions

View File

@ -450,7 +450,8 @@ static void update_attrs(UI *ui, HlAttrs attrs)
int attr = ui->rgb ? attrs.rgb_ae_attr : attrs.cterm_ae_attr;
bool bold = attr & HL_BOLD;
bool italic = attr & HL_ITALIC;
bool reverse = attr & (HL_INVERSE | HL_STANDOUT);
bool reverse = attr & HL_INVERSE;
bool standout = attr & HL_STANDOUT;
bool underline = attr & (HL_UNDERLINE), undercurl = attr & (HL_UNDERCURL);
if (unibi_get_str(data->ut, unibi_set_attributes)) {
@ -478,6 +479,9 @@ static void update_attrs(UI *ui, HlAttrs attrs)
if (underline || undercurl) {
unibi_out(ui, unibi_enter_underline_mode);
}
if (standout) {
unibi_out(ui, unibi_enter_standout_mode);
}
if (reverse) {
unibi_out(ui, unibi_enter_reverse_mode);
}

View File

@ -186,6 +186,10 @@ Dictionary hlattrs2dict(const HlAttrs *aep, bool use_rgb)
PUT(hl, "bold", BOOLEAN_OBJ(true));
}
if (mask & HL_STANDOUT) {
PUT(hl, "standout", BOOLEAN_OBJ(true));
}
if (mask & HL_UNDERLINE) {
PUT(hl, "underline", BOOLEAN_OBJ(true));
}
@ -198,7 +202,7 @@ Dictionary hlattrs2dict(const HlAttrs *aep, bool use_rgb)
PUT(hl, "italic", BOOLEAN_OBJ(true));
}
if (mask & (HL_INVERSE | HL_STANDOUT)) {
if (mask & HL_INVERSE) {
PUT(hl, "reverse", BOOLEAN_OBJ(true));
}

View File

@ -99,5 +99,14 @@ describe('highlight api',function()
eq(false, err)
eq('Invalid highlight name: ',
string.match(emsg, 'Invalid.*'))
-- Test "standout" attribute. #8054
eq({ underline = true, },
meths.get_hl_by_name('cursorline', 0));
command('hi CursorLine cterm=standout,underline term=standout,underline gui=standout,underline')
command('set cursorline')
eq({ underline = true, standout = true, },
meths.get_hl_by_name('cursorline', 0));
end)
end)

View File

@ -312,7 +312,7 @@ describe('highlight defaults', function()
end)
end)
describe('guisp (special/undercurl)', function()
describe('highlight', function()
local screen
before_each(function()
@ -321,7 +321,31 @@ describe('guisp (special/undercurl)', function()
screen:attach()
end)
it('can be set and is applied like foreground or background', function()
it('cterm=standout gui=standout', function()
screen:detach()
screen = Screen.new(20,5)
screen:attach()
screen:set_default_attr_ids({
[1] = {bold = true, foreground = Screen.colors.Blue1},
[2] = {standout = true, bold = true, underline = true,
background = Screen.colors.Gray90, foreground = Screen.colors.Blue1},
[3] = {standout = true, underline = true,
background = Screen.colors.Gray90}
})
feed_command('hi CursorLine cterm=standout,underline gui=standout,underline')
feed_command('set cursorline')
feed_command('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list')
feed('i\t abcd <cr>\t abcd <cr><esc>k')
screen:expect([[
{1:>-------.}abcd{1:*¬} |
{2:^>-------.}{3:abcd}{2:*¬}{3: }|
{1:¬} |
{1:~ }|
|
]])
end)
it('guisp (special/undercurl)', function()
feed_command('syntax on')
feed_command('syn keyword TmpKeyword neovim')
feed_command('syn keyword TmpKeyword1 special')