mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-30 19:41:15 -03:00
Link terminal workarounds with comments
It's hard to get rid of these workarounds. Let's at least brand them. Ref: #11819
This commit is contained in:
@@ -185,6 +185,7 @@ if status --is-login
|
||||
#
|
||||
# Put linux consoles in unicode mode.
|
||||
#
|
||||
# TODO(terminal-workaround)
|
||||
if test "$TERM" = linux
|
||||
and string match -qir '\.UTF' -- $LANG
|
||||
and command -sq unicode_start
|
||||
|
||||
@@ -136,6 +136,7 @@ end" >$__fish_config_dir/config.fish
|
||||
# Guidance from the VTE developers is to let them repaint.
|
||||
# Konsole reflows since version 21.04. Konsole added XTVERSION
|
||||
# in v22.03.80~7.
|
||||
# TODO(term-workaround)
|
||||
if string match -rq -- '^(?:VTE\b|Konsole |WezTerm )' (status terminal)
|
||||
or begin
|
||||
set -q KONSOLE_VERSION
|
||||
@@ -162,6 +163,7 @@ end" >$__fish_config_dir/config.fish
|
||||
# # To-do: use a Konsole version where KF6_DEP_VERSION is >= 6.12
|
||||
# and $konsole_version -lt ???
|
||||
# end
|
||||
# TODO(term-workaround)
|
||||
if set -q KONSOLE_VERSION
|
||||
set host ''
|
||||
end
|
||||
|
||||
@@ -52,6 +52,7 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
|
||||
bind --preset $argv alt-b prevd-or-backward-word
|
||||
bind --preset $argv alt-f nextd-or-forward-word
|
||||
|
||||
# TODO(terminal-workaround)
|
||||
set -l alt_right_aliases alt-right \e\[1\;9C # iTerm2 < 3.5.12
|
||||
set -l alt_left_aliases alt-left \e\[1\;9D # iTerm2 < 3.5.12
|
||||
if test (__fish_uname) = Darwin
|
||||
@@ -72,6 +73,7 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
|
||||
|
||||
bind --preset $argv alt-up history-token-search-backward
|
||||
bind --preset $argv alt-down history-token-search-forward
|
||||
# TODO(terminal-workaround)
|
||||
bind --preset $argv \e\[1\;9A history-token-search-backward # iTerm2 < 3.5.12
|
||||
bind --preset $argv \e\[1\;9B history-token-search-forward # iTerm2 < 3.5.12
|
||||
# Bash compatibility
|
||||
|
||||
@@ -69,7 +69,7 @@ function fish_default_key_bindings -d "emacs-like key binds"
|
||||
|
||||
bind --preset $argv ctrl-r history-pager
|
||||
|
||||
# term-specific special bindings
|
||||
# TODO(term-workaround)
|
||||
switch "$TERM"
|
||||
case xterm-256color
|
||||
# Microsoft's conemu uses xterm-256color plus
|
||||
|
||||
@@ -38,6 +38,7 @@ function ls
|
||||
isatty stdout
|
||||
and set -a indicators_opt $__fish_ls_indicators_opt
|
||||
|
||||
# TODO(term-workaround)
|
||||
# Terminal.app doesn't set $COLORTERM or $CLICOLOR,
|
||||
# but the new FreeBSD ls requires either to be set,
|
||||
# before it will enable color.
|
||||
|
||||
@@ -1795,6 +1795,7 @@ pub const fn assert_sync<T: Sync>() {}
|
||||
/// bullet-proof and that's OK.
|
||||
pub fn is_console_session() -> bool {
|
||||
static IS_CONSOLE_SESSION: OnceCell<bool> = OnceCell::new();
|
||||
// TODO(terminal-workaround)
|
||||
*IS_CONSOLE_SESSION.get_or_init(|| {
|
||||
const PATH_MAX: usize = libc::PATH_MAX as usize;
|
||||
let mut tty_name = [0u8; PATH_MAX];
|
||||
|
||||
@@ -175,6 +175,7 @@ pub fn guess_emoji_width(vars: &EnvStack) {
|
||||
.map(|v| v.as_string())
|
||||
.unwrap_or_else(WString::new);
|
||||
|
||||
// TODO(term-workaround)
|
||||
if xtversion().unwrap_or(L!("")).starts_with(L!("iTerm2 ")) {
|
||||
// iTerm2 now defaults to Unicode 9 sizes for anything after macOS 10.12
|
||||
FISH_EMOJI_WIDTH.store(2, Ordering::Relaxed);
|
||||
@@ -397,6 +398,7 @@ fn update_fish_color_support(vars: &EnvStack) {
|
||||
};
|
||||
|
||||
let supports_24bit;
|
||||
#[allow(unused_parens)]
|
||||
if let Some(fish_term24bit) = vars.get(L!("fish_term24bit")).map(|v| v.as_string()) {
|
||||
// $fish_term24bit
|
||||
supports_24bit = crate::wcstringutil::bool_from_string(&fish_term24bit);
|
||||
@@ -409,7 +411,10 @@ fn update_fish_color_support(vars: &EnvStack) {
|
||||
"disabled"
|
||||
}
|
||||
);
|
||||
} else if vars.get(L!("STY")).is_some() {
|
||||
} else if (
|
||||
// TODO(term-workaround)
|
||||
vars.get(L!("STY")).is_some()
|
||||
) {
|
||||
// Screen requires "truecolor on" to enable true-color sequences, so we ignore them
|
||||
// unless force-enabled.
|
||||
supports_24bit = false;
|
||||
@@ -429,10 +434,11 @@ fn update_fish_color_support(vars: &EnvStack) {
|
||||
ct
|
||||
);
|
||||
} else {
|
||||
supports_24bit = !is_xterm_16color
|
||||
&& vars
|
||||
.get_unless_empty(L!("TERM_PROGRAM"))
|
||||
.is_none_or(|term| term.as_list()[0] != "Apple_Terminal");
|
||||
supports_24bit = !is_xterm_16color && {
|
||||
// TODO(term-workaround)
|
||||
vars.get_unless_empty(L!("TERM_PROGRAM"))
|
||||
.is_none_or(|term| term.as_list()[0] != "Apple_Terminal")
|
||||
};
|
||||
FLOG!(
|
||||
term_support,
|
||||
"True-color support",
|
||||
@@ -464,6 +470,7 @@ fn init_terminal(vars: &EnvStack) {
|
||||
IS_DUMB.store(term == "dumb");
|
||||
ONLY_GRAYSCALE.store(term == "ansi-m" || term == "linux-m" || term == "xterm-mono");
|
||||
|
||||
// TODO(term-workaround)
|
||||
if vars.get(MIDNIGHT_COMMANDER_SID).is_some() {
|
||||
screen_set_midnight_commander_hack();
|
||||
}
|
||||
|
||||
@@ -238,10 +238,16 @@ fn redirect_tty_after_sighup() {
|
||||
}
|
||||
|
||||
fn querying_allowed(vars: &dyn Environment) -> bool {
|
||||
future_feature_flags::test(FeatureFlag::query_term) &&
|
||||
!is_dumb() && vars.get(MIDNIGHT_COMMANDER_SID).is_none()
|
||||
// Could use /dev/tty in future.
|
||||
&& isatty(STDOUT_FILENO)
|
||||
future_feature_flags::test(FeatureFlag::query_term)
|
||||
&& !is_dumb()
|
||||
&& {
|
||||
// TODO(term-workaround)
|
||||
vars.get(MIDNIGHT_COMMANDER_SID).is_none()
|
||||
}
|
||||
&& {
|
||||
// Could use /dev/tty in future.
|
||||
isatty(STDOUT_FILENO)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn terminal_init(vars: &dyn Environment, inputfd: RawFd) -> InputEventQueue {
|
||||
@@ -2712,6 +2718,7 @@ fn send_xtgettcap_query(out: &mut impl Output, cap: &'static str) {
|
||||
}
|
||||
|
||||
fn query_capabilities_via_dcs(out: &mut impl Output, vars: &dyn Environment) {
|
||||
// TODO(term-workaround)
|
||||
if vars.get_unless_empty(L!("STY")).is_some()
|
||||
|| vars.get_unless_empty(L!("TERM")).is_some_and(|term| {
|
||||
let term = &term.as_list()[0];
|
||||
|
||||
@@ -365,7 +365,11 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
}
|
||||
|
||||
fn query_kitty_progressive_enhancements(out: &mut impl Output) -> bool {
|
||||
if std::env::var_os("TERM").is_some_and(|term| term.as_os_str().as_bytes() == b"st-256color") {
|
||||
#[allow(unused_parens)]
|
||||
if (
|
||||
// TODO(term-workaround)
|
||||
std::env::var_os("TERM").is_some_and(|term| term.as_os_str().as_bytes() == b"st-256color")
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
out.write_bytes(b"\x1b[?u");
|
||||
|
||||
Reference in New Issue
Block a user