Skip to content

Commit

Permalink
feat: shell integration - current path (#970)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim authored Feb 19, 2025
1 parent 2d2e67c commit 5f9a24a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion corcovado/src/sys/windows/from_raw_arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ mod tests {
#[test]
fn drops() {
struct A<'a>(&'a mut bool);
impl<'a> Drop for A<'a> {
impl Drop for A<'_> {
fn drop(&mut self) {
*self.0 = true;
}
Expand Down
26 changes: 26 additions & 0 deletions frontends/rioterm/src/context/title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,20 @@ pub fn update_title<T: rio_backend::event::EventListener>(
}
}
"absolute_path" => {
{
let terminal = context.terminal.lock();
if let Some(current_directory) = &terminal.current_directory {
if let Ok(dir_str) =
current_directory.clone().into_os_string().into_string()
{
new_template =
new_template.replace(to_replace_str, &dir_str);
matched = true;
continue;
}
};
}

#[cfg(unix)]
{
let path = teletypewriter::foreground_process_path(
Expand Down Expand Up @@ -323,5 +337,17 @@ pub mod test {
update_title("{{ absolute_path || title }}", &context),
String::from("Something")
);

// let's modify current_directory to actually be something
{
let path = std::path::PathBuf::from("/tmp");
let mut term = context.terminal.lock();
term.current_directory = Some(path);
};

assert_eq!(
update_title("{{ absolute_path || title }}", &context),
String::from("/tmp"),
);
}
}
2 changes: 1 addition & 1 deletion rio-backend/src/crosswords/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ where
pub window_id: WindowId,
pub route_id: usize,
title_stack: Vec<String>,
current_directory: Option<std::path::PathBuf>,
pub current_directory: Option<std::path::PathBuf>,
hyperlink_re: regex::Regex,

// The stack for the keyboard modes.
Expand Down
3 changes: 1 addition & 2 deletions rio-window/src/platform_impl/windows/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,7 @@ impl OwnedDisplayHandle {
fn main_thread_id() -> u32 {
static mut MAIN_THREAD_ID: u32 = 0;

/// Function pointer used in CRT initialization section to set the above static field's value.
// Function pointer used in CRT initialization section to set the above static field's value.
// Mark as used so this is not removable.
#[used]
#[allow(non_upper_case_globals)]
Expand Down
2 changes: 1 addition & 1 deletion teletypewriter/src/windows/child.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl ChildExitWatcher {
} else {
let pid = unsafe { NonZeroU32::new(GetProcessId(child_handle)) };
Ok(ChildExitWatcher {
wait_handle: AtomicPtr::from(wait_handle as *mut c_void),
wait_handle: AtomicPtr::from(wait_handle),
event_rx,
child_handle,
pid,
Expand Down

0 comments on commit 5f9a24a

Please sign in to comment.