Write OSC 7 escaped codes on a the tui backend

pull/485/head
Arijit Basu 2 years ago committed by Arijit Basu
parent 47f7d51e46
commit d35a4c58cb

@ -27,7 +27,6 @@ use std::collections::HashMap;
use std::collections::VecDeque;
use std::env;
use std::fs;
use std::io::Write;
use std::path::PathBuf;
use tui_input::{Input, InputRequest};
@ -35,14 +34,6 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const TEMPLATE_TABLE_ROW: &str = "TEMPLATE_TABLE_ROW";
pub const UNSUPPORTED_STR: &str = "???";
fn set_current_dir(path: &str, hostname: &str) -> std::io::Result<()> {
env::set_current_dir(path).map(|r| {
print!("\x1b]7;file://{}{}\x1b\\", hostname, path);
std::io::stdout().flush().ok();
r
})
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct Task {
pub msg: MsgIn,
@ -293,7 +284,7 @@ impl App {
let hostname = gethostname().to_string_lossy().to_string();
let pwd = pwd.to_string_lossy().to_string();
set_current_dir(&pwd, &hostname)?;
env::set_current_dir(&pwd)?;
let input = InputBuffer {
buffer: Default::default(),
@ -756,15 +747,13 @@ impl App {
dir = PathBuf::from(self.pwd.clone()).join(dir);
}
let dir = dir.to_string_lossy().to_string();
match set_current_dir(&dir, &self.hostname) {
match env::set_current_dir(&dir) {
Ok(()) => {
let pwd = self.pwd.clone();
let focus =
self.focused_node().map(|n| n.relative_path.clone());
self = self.add_last_focus(pwd, focus)?;
self.pwd = dir;
self.pwd = dir.to_string_lossy().to_string();
if save_history {
self.history = self.history.push(format!("{}/", self.pwd));
}

@ -358,8 +358,6 @@ impl Runner {
Refresh => {
// $PWD watcher
tx_pwd_watcher.send(app.pwd.clone())?;
// UI
terminal.draw(|f| ui::draw(f, &app, &lua))?;
// Fifo
let focus = app.focused_node();
if focus != last_focus.as_ref() {
@ -371,7 +369,19 @@ impl Runner {
)?;
};
last_focus = focus.cloned();
// OSC 7: Change CWD
terminal.backend_mut().write(
format!(
"\x1b]7;file://{}{}\x1b\\",
&app.hostname, &app.pwd
)
.as_bytes(),
)?;
}
// UI
terminal.draw(|f| ui::draw(f, &app, &lua))?;
}
EnableMouse => {

Loading…
Cancel
Save