mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 00:41:15 -03:00
Don't send kitty kbd protocol probe until ECHO is disabled
With tmux 3.0 (from 2019) inside SSH, the CSI 5n response is echoed. I guess with all other terminals we were just lucky. Move it to right after where we disable ECHO I guess. In general, asynchronous requests create a lot of potential for error, we should try to get away from them.
This commit is contained in:
@@ -9,19 +9,19 @@
|
|||||||
|
|
||||||
use std::{ops::ControlFlow, os::unix::prelude::OsStrExt};
|
use std::{ops::ControlFlow, os::unix::prelude::OsStrExt};
|
||||||
|
|
||||||
use libc::{STDIN_FILENO, TCSANOW, VEOF, VINTR};
|
use libc::{STDIN_FILENO, STDOUT_FILENO, TCSANOW, VEOF, VINTR};
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use fish::future::IsSomeAnd;
|
use fish::future::IsSomeAnd;
|
||||||
use fish::{
|
use fish::{
|
||||||
builtins::shared::BUILTIN_ERR_UNKNOWN,
|
builtins::shared::BUILTIN_ERR_UNKNOWN,
|
||||||
common::{shell_modes, str2wcstring, PROGRAM_NAME},
|
common::{shell_modes, str2wcstring, write_loop, PROGRAM_NAME},
|
||||||
env::env_init,
|
env::env_init,
|
||||||
eprintf, fprintf,
|
eprintf, fprintf,
|
||||||
input::input_terminfo_get_name,
|
input::input_terminfo_get_name,
|
||||||
input_common::{
|
input_common::{
|
||||||
terminal_protocol_hacks, terminal_protocols_enable_ifn, CharEvent, InputEventQueue,
|
terminal_protocol_hacks, terminal_protocols_enable_ifn, CharEvent, InputEventQueue,
|
||||||
InputEventQueuer,
|
InputEventQueuer, KITTY_PROGRESSIVE_ENHANCEMENTS_QUERY,
|
||||||
},
|
},
|
||||||
key::{char_to_symbol, Key},
|
key::{char_to_symbol, Key},
|
||||||
panic::panic_handler,
|
panic::panic_handler,
|
||||||
@@ -137,6 +137,7 @@ fn setup_and_process_keys(continuous_mode: bool, verbose: bool) -> i32 {
|
|||||||
unsafe { libc::tcsetattr(STDIN_FILENO, TCSANOW, &*shell_modes()) };
|
unsafe { libc::tcsetattr(STDIN_FILENO, TCSANOW, &*shell_modes()) };
|
||||||
|
|
||||||
terminal_protocol_hacks();
|
terminal_protocol_hacks();
|
||||||
|
let _ = write_loop(&STDOUT_FILENO, KITTY_PROGRESSIVE_ENHANCEMENTS_QUERY);
|
||||||
|
|
||||||
if continuous_mode {
|
if continuous_mode {
|
||||||
eprintf!("\n");
|
eprintf!("\n");
|
||||||
|
|||||||
@@ -451,6 +451,8 @@ macro_rules! kitty_progressive_enhancements {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const KITTY_PROGRESSIVE_ENHANCEMENTS_QUERY: &[u8] = b"\x1b[?u\x1b[5n";
|
||||||
|
|
||||||
static IS_TMUX: RelaxedAtomicBool = RelaxedAtomicBool::new(false);
|
static IS_TMUX: RelaxedAtomicBool = RelaxedAtomicBool::new(false);
|
||||||
pub static IN_MIDNIGHT_COMMANDER_PRE_CSI_U: RelaxedAtomicBool = RelaxedAtomicBool::new(false);
|
pub static IN_MIDNIGHT_COMMANDER_PRE_CSI_U: RelaxedAtomicBool = RelaxedAtomicBool::new(false);
|
||||||
static IN_ITERM_PRE_CSI_U: RelaxedAtomicBool = RelaxedAtomicBool::new(false);
|
static IN_ITERM_PRE_CSI_U: RelaxedAtomicBool = RelaxedAtomicBool::new(false);
|
||||||
@@ -468,8 +470,6 @@ pub fn terminal_protocol_hacks() {
|
|||||||
version < (3, 5, 6)
|
version < (3, 5, 6)
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
// Request kitty progressive enhancement value and primary device attribute.
|
|
||||||
let _ = write_loop(&STDOUT_FILENO, b"\x1b[?u\x1b[5n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_version(version: &wstr) -> Option<(i64, i64, i64)> {
|
fn parse_version(version: &wstr) -> Option<(i64, i64, i64)> {
|
||||||
|
|||||||
@@ -82,6 +82,7 @@
|
|||||||
use crate::input_common::InputEventQueuer;
|
use crate::input_common::InputEventQueuer;
|
||||||
use crate::input_common::WaitingForCursorPosition;
|
use crate::input_common::WaitingForCursorPosition;
|
||||||
use crate::input_common::IN_MIDNIGHT_COMMANDER_PRE_CSI_U;
|
use crate::input_common::IN_MIDNIGHT_COMMANDER_PRE_CSI_U;
|
||||||
|
use crate::input_common::KITTY_PROGRESSIVE_ENHANCEMENTS_QUERY;
|
||||||
use crate::input_common::{
|
use crate::input_common::{
|
||||||
terminal_protocol_hacks, terminal_protocols_enable_ifn, CharEvent, CharInputStyle, InputData,
|
terminal_protocol_hacks, terminal_protocols_enable_ifn, CharEvent, CharInputStyle, InputData,
|
||||||
ReadlineCmd,
|
ReadlineCmd,
|
||||||
@@ -2083,6 +2084,13 @@ fn readline(&mut self, nchars: Option<NonZeroUsize>) -> Option<WString> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static queried: RelaxedAtomicBool = RelaxedAtomicBool::new(false);
|
||||||
|
if !queried.load() {
|
||||||
|
queried.store(true);
|
||||||
|
// Query for kitty keyboard protocol support.
|
||||||
|
let _ = write_loop(&STDOUT_FILENO, KITTY_PROGRESSIVE_ENHANCEMENTS_QUERY);
|
||||||
|
}
|
||||||
|
|
||||||
// HACK: Don't abandon line for the first prompt, because
|
// HACK: Don't abandon line for the first prompt, because
|
||||||
// if we're started with the terminal it might not have settled,
|
// if we're started with the terminal it might not have settled,
|
||||||
// so the width is quite likely to be in flight.
|
// so the width is quite likely to be in flight.
|
||||||
|
|||||||
Reference in New Issue
Block a user