Harmonize temporary Midnight Commander workarounds a bit

(cherry picked from commit 86a0a348ee)
This commit is contained in:
Johannes Altmanninger
2025-10-03 18:12:15 +02:00
parent 84dbdf4e2a
commit 77a038541a
3 changed files with 8 additions and 6 deletions

View File

@@ -452,6 +452,8 @@ fn update_fish_color_support(vars: &EnvStack) {
crate::terminal::set_color_support(color_support);
}
pub const MIDNIGHT_COMMANDER_SID: &wstr = L!("MC_SID");
// Initialize the terminal subsystem
fn init_terminal(vars: &EnvStack) {
let term = vars.get(L!("TERM"));
@@ -464,7 +466,7 @@ fn init_terminal(vars: &EnvStack) {
IS_DUMB.store(term == "dumb");
ONLY_GRAYSCALE.store(term == "ansi-m" || term == "linux-m" || term == "xterm-mono");
if vars.get(L!("MC_SID")).is_some() {
if vars.get(MIDNIGHT_COMMANDER_SID).is_some() {
screen_set_midnight_commander_hack();
}

View File

@@ -66,6 +66,7 @@
use crate::env::EnvStack;
use crate::env::{EnvMode, Environment, Statuses};
use crate::env_dispatch::guess_emoji_width;
use crate::env_dispatch::MIDNIGHT_COMMANDER_SID;
use crate::exec::exec_subshell;
use crate::expand::expand_one;
use crate::expand::{expand_string, expand_tilde, ExpandFlags, ExpandResultCode};
@@ -260,9 +261,9 @@ fn redirect_tty_after_sighup() {
}
}
fn querying_allowed() -> bool {
fn querying_allowed(vars: &dyn Environment) -> bool {
future_feature_flags::test(FeatureFlag::query_term) &&
!is_dumb() && std::env::var_os("MC_TMPDIR").is_none()
!is_dumb() && vars.get(MIDNIGHT_COMMANDER_SID).is_none()
// Could use /dev/tty in future.
&& isatty(STDOUT_FILENO)
}
@@ -281,7 +282,7 @@ pub fn terminal_init(vars: &dyn Environment, inputfd: RawFd) -> InputEventQueue
initialize_tty_protocols();
});
if !querying_allowed() {
if !querying_allowed(vars) {
return input_queue;
}
@@ -1644,7 +1645,7 @@ pub fn combine_command_and_autosuggestion(
impl<'a> Reader<'a> {
pub fn request_cursor_position(&mut self, out: &mut Outputter, q: CursorPositionQuery) {
if !querying_allowed() {
if !querying_allowed(self.vars()) {
return;
}
let mut query = self.blocking_query();

View File

@@ -61,7 +61,6 @@ def makeenv(script_path: Path, home: Path) -> Dict[str, str]:
"XDG_DATA_DIRS",
"LANGUAGE",
"MC_SID",
"MC_TMPDIR",
"COLORTERM",
"KONSOLE_VERSION",
"STY",