mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Update pager colors, tweak pager.cpp
Adds a color reset thing, to ensure fish tries to use hard colors during testing. Also, work on a discrepancy (not introduced by my changes, afaik) when with some combinations of color settings, and usage of --bold, caused super flakey color paninting in the pager. Downwards movements that trigger scrolling vs. upwards movement in the pager would only apply bold to selections when moving upwards. The bold state of the command completions in the pager was flipping flops on and off, depending on if there is a description on the preceding line. Implement a lame fix by reseting the color to normal and applying a different style on the rightmost ')' which seems to be what was influencing it. Makes fish use terminfo for coloring the newline glich char.
This commit is contained in:
parent
af95813514
commit
90e535f66f
4 changed files with 61 additions and 44 deletions
|
@ -1,8 +1,6 @@
|
|||
# Main file for fish command completions. This file contains various
|
||||
# common helper functions for the command completions. All actual
|
||||
# completions are located in the completions subdirectory.
|
||||
#
|
||||
|
||||
#
|
||||
# Set default field separators
|
||||
#
|
||||
|
@ -15,6 +13,8 @@ function __fish_default_command_not_found_handler
|
|||
echo "fish: Unknown command '$argv'" >&2
|
||||
end
|
||||
|
||||
set -g version $FISH_VERSION
|
||||
|
||||
if status --is-interactive
|
||||
# The user has seemingly explicitly launched an old fish with too-new scripts installed.
|
||||
if not contains "string" (builtin -n)
|
||||
|
|
|
@ -22,16 +22,28 @@ function __fish_config_interactive -d "Initializations that should be performed
|
|||
set userdatadir $XDG_DATA_HOME
|
||||
end
|
||||
|
||||
if not set -q fish_greeting
|
||||
set -l line1 (printf (_ 'Welcome to fish, the friendly interactive shell' ))
|
||||
if not set -q __fish_init_2_3_0
|
||||
set -l line2 \n(printf (_ 'Type %shelp%s for instructions on how to use fish %s') (set_color green) (set_color normal))
|
||||
else
|
||||
set -l line2 ''
|
||||
end
|
||||
set -U fish_greeting $line1$line2
|
||||
end
|
||||
|
||||
#
|
||||
# If we are starting up for the first time, set various defaults
|
||||
#
|
||||
if not set -q __fish_init_1_50_0
|
||||
if not set -q fish_greeting
|
||||
set -l line1 (printf (_ 'Welcome to fish, the friendly interactive shell') )
|
||||
set -l line2 (printf (_ 'Type %shelp%s for instructions on how to use fish') (set_color green) (set_color normal))
|
||||
set -U fish_greeting $line1\n$line2
|
||||
#
|
||||
if not set -q __fish_init_2_39_8 # bump this to 2_4_0 when rolling release if anything changes after 9/10/2016
|
||||
set -g colors_backup "$HOME/fish_previous_colors-(date).txt"
|
||||
|
||||
echo Backing up uvars to:\n (set_color --underline)$colors_backup(set_color normal)
|
||||
set -U >>$colors_backup
|
||||
for option in (set -Un | string match "fish*color_*")
|
||||
set -eU $option
|
||||
end
|
||||
set -U __fish_init_1_50_0
|
||||
echo \"Normalized\" colors on upgrade.
|
||||
|
||||
# Regular syntax highlighting colors
|
||||
set -q fish_color_normal
|
||||
|
@ -41,7 +53,7 @@ function __fish_config_interactive -d "Initializations that should be performed
|
|||
set -q fish_color_param
|
||||
or set -U fish_color_param cyan
|
||||
set -q fish_color_redirection
|
||||
or set -U fish_color_redirection normal
|
||||
or set -U fish_color_redirection brblue
|
||||
set -q fish_color_comment
|
||||
or set -U fish_color_comment red
|
||||
set -q fish_color_error
|
||||
|
@ -49,13 +61,13 @@ function __fish_config_interactive -d "Initializations that should be performed
|
|||
set -q fish_color_escape
|
||||
or set -U fish_color_escape bryellow
|
||||
set -q fish_color_operator
|
||||
or set -U fish_color_operator cyan
|
||||
or set -U fish_color_operator bryellow
|
||||
set -q fish_color_end
|
||||
or set -U fish_color_end green
|
||||
or set -U fish_color_end brmagenta
|
||||
set -q fish_color_quote
|
||||
or set -U fish_color_quote yellow
|
||||
set -q fish_color_autosuggestion
|
||||
or set -U fish_color_autosuggestion 222 brblack
|
||||
or set -U fish_color_autosuggestion 555 brblack
|
||||
set -q fish_color_user
|
||||
or set -U fish_color_user brgreen
|
||||
|
||||
|
@ -71,31 +83,34 @@ function __fish_config_interactive -d "Initializations that should be performed
|
|||
|
||||
# Background color for matching quotes and parenthesis
|
||||
set -q fish_color_match
|
||||
or set -U fish_color_match brwhite
|
||||
or set -U fish_color_match --background=blue
|
||||
|
||||
# Background color for search matches
|
||||
set -q fish_color_search_match
|
||||
or set -U fish_color_search_match --background=magenta
|
||||
or set -U fish_color_search_match bryellow --background=brgrey
|
||||
|
||||
# Background color for selections
|
||||
set -q fish_color_selection
|
||||
or set -U fish_color_selection --background=magenta
|
||||
or set -U fish_color_selection white --bold --background=brgrey
|
||||
|
||||
# Pager colors
|
||||
set -q fish_pager_color_prefix
|
||||
or set -U fish_pager_color_prefix brcyan
|
||||
set -q fish_pager_color_completion
|
||||
or set -U fish_pager_color_completion normal
|
||||
or set -U fish_pager_color_prefix white --bold --underline
|
||||
#set -q fish_pager_color_completion
|
||||
#or set -U fish_pager_color_completion
|
||||
set -q fish_pager_color_description
|
||||
or set -U fish_pager_color_description brblack
|
||||
or set -U fish_pager_color_description B3A06D yellow
|
||||
set -q fish_pager_color_progress
|
||||
or set -U fish_pager_color_progress cyan
|
||||
or set -U fish_pager_color_progress brwhite --background=cyan
|
||||
|
||||
#
|
||||
# Directory history colors
|
||||
#
|
||||
set -q fish_color_history_current
|
||||
or set -U fish_color_history_current cyan
|
||||
or set -U fish_color_history_current --bold
|
||||
|
||||
|
||||
set -U __fish_init_2_39_8
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -210,15 +225,14 @@ function __fish_config_interactive -d "Initializations that should be performed
|
|||
commandline -f repaint
|
||||
end
|
||||
|
||||
|
||||
# Notify vte-based terminals when $PWD changes (issue #906)
|
||||
# Notify terminals when $PWD changes (issue #906)
|
||||
if test "$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = "Apple_Terminal"
|
||||
function __update_vte_cwd --on-variable PWD --description 'Notify VTE of change to $PWD'
|
||||
function __update_cwd_osc --on-variable PWD --description 'Notify VTE of change to $PWD'
|
||||
status --is-command-substitution
|
||||
and return
|
||||
printf '\033]7;file://%s%s\a' (hostname) (pwd | __fish_urlencode)
|
||||
printf \e\]7\;file://\%s\%s\a (hostname) (pwd | __fish_urlencode)
|
||||
end
|
||||
__update_vte_cwd # Run once because we might have already inherited a PWD from an old tab
|
||||
__update_cwd_osc # Run once because we might have already inherited a PWD from an old tab
|
||||
end
|
||||
|
||||
### Command-not-found handlers
|
||||
|
|
|
@ -130,9 +130,10 @@ line_t pager_t::completion_print_item(const wcstring &prefix, const comp_t *c, s
|
|||
{
|
||||
written += print_max(L" ", packed_color, 1, false, &line_data);
|
||||
}
|
||||
print_max(L"(", packed_color, 1, false, &line_data);
|
||||
// hack - this just works around the issue
|
||||
print_max(L"(", highlight_spec_pager_completion | highlight_make_background(bg_color), 1, false, &line_data);
|
||||
print_max(c->desc, packed_color, desc_width, false, &line_data);
|
||||
print_max(L")", packed_color, 1, false, &line_data);
|
||||
print_max(L")", highlight_spec_pager_completion | highlight_make_background(bg_color), 1, false, &line_data);
|
||||
} else {
|
||||
while (written < width) {
|
||||
written += print_max(L" ", 0, 1, false, &line_data);
|
||||
|
|
|
@ -205,8 +205,8 @@ size_t escape_code_length(const wchar_t *code) {
|
|||
bool found = false;
|
||||
|
||||
if (cur_term != NULL) {
|
||||
// Detect these terminfo color escapes with parameter value 0..7, all of which don't move
|
||||
// the cursor.
|
||||
// Detect these terminfo color escapes with parameter value 0..16, all of which don't move
|
||||
// the cursor.
|
||||
char *const esc[] = {
|
||||
set_a_foreground, set_a_background, set_foreground, set_background,
|
||||
};
|
||||
|
@ -232,12 +232,15 @@ size_t escape_code_length(const wchar_t *code) {
|
|||
enter_superscript_mode, exit_superscript_mode, enter_blink_mode,
|
||||
enter_italics_mode, exit_italics_mode, enter_reverse_mode,
|
||||
enter_shadow_mode, exit_shadow_mode, enter_standout_mode,
|
||||
exit_standout_mode, enter_secure_mode};
|
||||
exit_standout_mode, enter_secure_mode, enter_dim_mode,
|
||||
enter_blink_mode, enter_protected_mode, enter_alt_charset_mode,
|
||||
exit_alt_charset_mode};
|
||||
|
||||
for (size_t p = 0; p < sizeof esc2 / sizeof *esc2 && !found; p++) {
|
||||
if (!esc2[p]) continue;
|
||||
// Test both padded and unpadded version, just to be safe. Most versions of tparm don't
|
||||
// actually seem to do anything these days.
|
||||
|
||||
size_t len = maxi(try_sequence(tparm(esc2[p]), code), try_sequence(esc2[p], code));
|
||||
if (len) {
|
||||
resulting_length = len;
|
||||
|
@ -601,9 +604,8 @@ static bool perform_any_impending_soft_wrap(screen_t *scr, int x, int y) {
|
|||
/// Make sure we don't soft wrap.
|
||||
static void invalidate_soft_wrap(screen_t *scr) { scr->soft_wrap_location = INVALID_LOCATION; }
|
||||
|
||||
// Various code for testing term behavior.
|
||||
|
||||
#if 0
|
||||
/// Various code for testing term behavior.
|
||||
static bool test_stuff(screen_t *scr)
|
||||
{
|
||||
data_buffer_t output;
|
||||
|
@ -1186,18 +1188,18 @@ void s_reset(screen_t *s, screen_reset_mode_t mode) {
|
|||
// omitted_newline_char in common.cpp.
|
||||
int non_space_width = fish_wcwidth(omitted_newline_char);
|
||||
if (screen_width >= non_space_width) {
|
||||
bool has_256_colors = output_get_color_support() & color_support_term256;
|
||||
if (has_256_colors) {
|
||||
// Draw the string in term256 gray.
|
||||
abandon_line_string.append(L"\x1b[38;5;245m");
|
||||
} else {
|
||||
// Draw in "bright black" (gray).
|
||||
abandon_line_string.append(
|
||||
L"\x1b[0m" // bright
|
||||
L"\x1b[30;1m"); // black
|
||||
if (enter_dim_mode) {
|
||||
// Use dim if they have it, so the color will be based on their actual normal color and the background of the termianl.
|
||||
abandon_line_string.append(str2wcstring(tparm(enter_dim_mode)));
|
||||
}
|
||||
else if (set_a_foreground && max_colors >= 8) {
|
||||
// Draw the string in gray.
|
||||
abandon_line_string.append(str2wcstring(tparm(set_a_foreground, 8)));
|
||||
}
|
||||
|
||||
abandon_line_string.push_back(omitted_newline_char);
|
||||
abandon_line_string.append(L"\x1b[0m"); // normal text ANSI escape sequence
|
||||
if (exit_attribute_mode)
|
||||
abandon_line_string.append(str2wcstring(tparm(exit_attribute_mode))); // normal text ANSI escape sequence
|
||||
abandon_line_string.append(screen_width - non_space_width, L' ');
|
||||
}
|
||||
abandon_line_string.push_back(L'\r');
|
||||
|
|
Loading…
Reference in a new issue