mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 19:03:38 +08:00
Step coloring for fish_pager introduces new variable
fish_pager_color_secondary to set background of every second completion line. It simplifies finding the options corresponding to given description. Default color is 151515.
This commit is contained in:
parent
3ab26a5d40
commit
a02aa7a316
|
@ -1004,6 +1004,7 @@ highlighting in the completion pager:
|
||||||
- \c fish_pager_color_completion, the color of the completion itself
|
- \c fish_pager_color_completion, the color of the completion itself
|
||||||
- \c fish_pager_color_description, the color of the completion description
|
- \c fish_pager_color_description, the color of the completion description
|
||||||
- \c fish_pager_color_progress, the color of the progress bar at the bottom left corner
|
- \c fish_pager_color_progress, the color of the progress bar at the bottom left corner
|
||||||
|
- \c fish_pager_color_secondary, the background color of the every second completion
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
@ -1227,8 +1228,8 @@ fish_color_substitution, \c fish_color_redirection, \c fish_color_end,
|
||||||
\c fish_color_error, \c fish_color_param, \c fish_color_comment, \c
|
\c fish_color_error, \c fish_color_param, \c fish_color_comment, \c
|
||||||
fish_color_match, \c fish_color_search_match, \c fish_color_cwd, \c
|
fish_color_match, \c fish_color_search_match, \c fish_color_cwd, \c
|
||||||
fish_pager_color_prefix, \c fish_pager_color_completion, \c
|
fish_pager_color_prefix, \c fish_pager_color_completion, \c
|
||||||
fish_pager_color_description and \c
|
fish_pager_color_description, \c fish_pager_color_progress
|
||||||
fish_pager_color_progress. Usually, the value of these variables will
|
and \c fish_pager_color_secondary. Usually, the value of these variables will
|
||||||
be one of \c black, \c red, \c green, \c brown, \c yellow, \c blue, \c
|
be one of \c black, \c red, \c green, \c brown, \c yellow, \c blue, \c
|
||||||
magenta, \c purple, \c cyan, \c white or \c normal, but they can be an
|
magenta, \c purple, \c cyan, \c white or \c normal, but they can be an
|
||||||
array containing any color options for the set_color command.
|
array containing any color options for the set_color command.
|
||||||
|
|
|
@ -77,7 +77,8 @@ enum
|
||||||
HIGHLIGHT_PAGER_PREFIX,
|
HIGHLIGHT_PAGER_PREFIX,
|
||||||
HIGHLIGHT_PAGER_COMPLETION,
|
HIGHLIGHT_PAGER_COMPLETION,
|
||||||
HIGHLIGHT_PAGER_DESCRIPTION,
|
HIGHLIGHT_PAGER_DESCRIPTION,
|
||||||
HIGHLIGHT_PAGER_PROGRESS
|
HIGHLIGHT_PAGER_PROGRESS,
|
||||||
|
HIGHLIGHT_PAGER_SECONDARY
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -152,7 +153,8 @@ static const wchar_t *hightlight_var[] =
|
||||||
L"fish_pager_color_prefix",
|
L"fish_pager_color_prefix",
|
||||||
L"fish_pager_color_completion",
|
L"fish_pager_color_completion",
|
||||||
L"fish_pager_color_description",
|
L"fish_pager_color_description",
|
||||||
L"fish_pager_color_progress"
|
L"fish_pager_color_progress",
|
||||||
|
L"fish_pager_color_secondary"
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -206,7 +208,7 @@ static rgb_color_t get_color( int highlight )
|
||||||
|
|
||||||
if( highlight < 0 )
|
if( highlight < 0 )
|
||||||
return rgb_color_t::normal();
|
return rgb_color_t::normal();
|
||||||
if( highlight >= (4) )
|
if( highlight >= (5) )
|
||||||
return rgb_color_t::normal();
|
return rgb_color_t::normal();
|
||||||
|
|
||||||
val = wgetenv( hightlight_var[highlight]);
|
val = wgetenv( hightlight_var[highlight]);
|
||||||
|
@ -389,7 +391,7 @@ static int print_max( const wchar_t *str, int max, int has_more )
|
||||||
/**
|
/**
|
||||||
Print the specified item using at the specified amount of space
|
Print the specified item using at the specified amount of space
|
||||||
*/
|
*/
|
||||||
static void completion_print_item( const wchar_t *prefix, comp_t *c, int width )
|
static void completion_print_item( const wchar_t *prefix, comp_t *c, int width, bool primary )
|
||||||
{
|
{
|
||||||
int comp_width=0, desc_width=0;
|
int comp_width=0, desc_width=0;
|
||||||
int written=0;
|
int written=0;
|
||||||
|
@ -422,14 +424,15 @@ static void completion_print_item( const wchar_t *prefix, comp_t *c, int width )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rgb_color_t bg = primary ? rgb_color_t::normal() : get_color(HIGHLIGHT_PAGER_SECONDARY);
|
||||||
for( size_t i=0; i<c->comp.size(); i++ )
|
for( size_t i=0; i<c->comp.size(); i++ )
|
||||||
{
|
{
|
||||||
const wcstring &comp = c->comp.at(i);
|
const wcstring &comp = c->comp.at(i);
|
||||||
if( i != 0 )
|
if( i != 0 )
|
||||||
written += print_max( L" ", comp_width - written, 2 );
|
written += print_max( L" ", comp_width - written, 2 );
|
||||||
set_color( get_color(HIGHLIGHT_PAGER_PREFIX),rgb_color_t::normal() );
|
set_color( get_color(HIGHLIGHT_PAGER_PREFIX), bg );
|
||||||
written += print_max( prefix, comp_width - written, comp.empty()?0:1 );
|
written += print_max( prefix, comp_width - written, comp.empty()?0:1 );
|
||||||
set_color( get_color(HIGHLIGHT_PAGER_COMPLETION),rgb_color_t::ignore() );
|
set_color( get_color(HIGHLIGHT_PAGER_COMPLETION), bg);
|
||||||
written += print_max( comp.c_str(), comp_width - written, i!=(c->comp.size()-1) );
|
written += print_max( comp.c_str(), comp_width - written, i!=(c->comp.size()-1) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,7 +445,7 @@ static void completion_print_item( const wchar_t *prefix, comp_t *c, int width )
|
||||||
writech( L' ');
|
writech( L' ');
|
||||||
}
|
}
|
||||||
written += print_max( L"(", 1, 0 );
|
written += print_max( L"(", 1, 0 );
|
||||||
set_color( get_color( HIGHLIGHT_PAGER_DESCRIPTION ), rgb_color_t::ignore() );
|
set_color( get_color( HIGHLIGHT_PAGER_DESCRIPTION ), bg);
|
||||||
written += print_max( c->desc.c_str(), desc_width, 0 );
|
written += print_max( c->desc.c_str(), desc_width, 0 );
|
||||||
written += print_max( L")", 1, 0 );
|
written += print_max( L")", 1, 0 );
|
||||||
}
|
}
|
||||||
|
@ -454,7 +457,8 @@ static void completion_print_item( const wchar_t *prefix, comp_t *c, int width )
|
||||||
writech( L' ');
|
writech( L' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( !primary )
|
||||||
|
set_color( rgb_color_t::normal(), rgb_color_t::normal() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -495,7 +499,7 @@ static void completion_print( int cols,
|
||||||
|
|
||||||
el = lst.at(j*rows + i );
|
el = lst.at(j*rows + i );
|
||||||
|
|
||||||
completion_print_item( prefix, el, width[j] - (is_last?0:2) );
|
completion_print_item( prefix, el, width[j] - (is_last?0:2), i%2 );
|
||||||
|
|
||||||
if( !is_last)
|
if( !is_last)
|
||||||
writestr( L" " );
|
writestr( L" " );
|
||||||
|
|
|
@ -122,6 +122,7 @@ function __fish_config_interactive -d "Initializations that should be performed
|
||||||
set_default fish_pager_color_completion normal
|
set_default fish_pager_color_completion normal
|
||||||
set_default fish_pager_color_description normal
|
set_default fish_pager_color_description normal
|
||||||
set_default fish_pager_color_progress cyan
|
set_default fish_pager_color_progress cyan
|
||||||
|
set_default fish_pater_color_secondary 151515
|
||||||
|
|
||||||
#
|
#
|
||||||
# Directory history colors
|
# Directory history colors
|
||||||
|
|
Loading…
Reference in New Issue
Block a user