Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion plugins/rust-explorer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ const MENU_ZIP: u32 = 0x9001;
const MENU_EXTRACT: u32 = 0x9002;
const MENU_PIN: u32 = 0x9003;
const MENU_RENAME: u32 = 0x9004;
const MENU_CMD: u32 = 0x9005;

/// True while the window shows the inside of a .zip: read-only, its rows are no files on disk.
fn in_zip() -> bool { zipx::split_zip(&cur_dir()).is_some() }
Expand Down Expand Up @@ -474,10 +475,19 @@ fn zip_menu(h: HWND, paths: &[PathBuf]) {
}
}

/// Opens a command prompt in `dir`.
fn open_cmd(dir: &Path) {
let comspec = env::var_os("COMSPEC").unwrap_or_else(|| "cmd.exe".into());
let _ = std::process::Command::new(comspec).current_dir(dir).spawn();
}

/// The shell menu for the selection, with our "Compress to ZIP" / "Extract here" on top.
fn item_menu(h: HWND, dir: &Path, paths: &[PathBuf]) {
if zipx::split_zip(dir).is_some() { return zip_menu(h, paths); }
let mut extra = vec![(MENU_ZIP, t!("Сжать в ZIP", "Compress to ZIP", ja: "ZIP に圧縮", pt: "Compactar em ZIP", zh: "压缩为 ZIP"))];
let mut extra = vec![
(MENU_CMD, t!("Открыть командную строку здесь", "Open cmd here", ja: "ここでコマンド プロンプトを開く", pt: "Abrir cmd aqui", zh: "在此处打开命令提示符")),
(MENU_ZIP, t!("Сжать в ZIP", "Compress to ZIP", ja: "ZIP に圧縮", pt: "Compactar em ZIP", zh: "压缩为 ZIP")),
];
if paths.iter().all(|p| p.is_file() && jobs::is_archive(p)) {
extra.insert(0, (MENU_EXTRACT, t!("Извлечь сюда", "Extract here", ja: "ここに展開", pt: "Extrair aqui", zh: "解压到此处")));
}
Expand All @@ -486,6 +496,7 @@ fn item_menu(h: HWND, dir: &Path, paths: &[PathBuf]) {
if let [p] = paths { if p.is_dir() { extra.push((MENU_PIN, if ui::pins().contains(p) { t!("Открепить от быстрого доступа", "Unpin from Quick access", ja: "クイック アクセスからピン留めを解除", pt: "Desafixar do Acesso rápido", zh: "从快速访问取消固定") } else { t!("Закрепить в быстром доступе", "Pin to Quick access", ja: "クイック アクセスにピン留め", pt: "Fixar no Acesso rápido", zh: "固定到快速访问") })); } }
let picked = sh::show(h, paths, if jobs::busy() { &[] } else { &extra }).ok().flatten();
match picked {
Some(MENU_CMD) => open_cmd(match paths { [p] if p.is_dir() => p.as_path(), _ => dir }),
Some(MENU_PIN) => ui::toggle_pin(&paths[0]),
Some(MENU_RENAME) => unsafe {
let (list, ..) = selected();
Expand Down Expand Up @@ -586,6 +597,7 @@ unsafe fn bg_menu(h: HWND) {
menu::item(m, 1, "\u{E8F4}", t!("Новая папка", "New folder", ja: "新しいフォルダー", pt: "Nova pasta", zh: "新建文件夹"), false);
menu::item(m, 2, "\u{E8A5}", t!("Новый текстовый файл", "New text file", ja: "新しいテキスト ドキュメント", pt: "Novo arquivo de texto", zh: "新建文本文件"), false);
menu::item(m, 3, "\u{E77F}", t!("Вставить", "Paste", ja: "貼り付け", pt: "Colar", zh: "粘贴"), false);
menu::item(m, 17, "\u{E756}", t!("Открыть командную строку здесь", "Open cmd here", ja: "ここでコマンド プロンプトを開く", pt: "Abrir cmd aqui", zh: "在此处打开命令提示符"), false);
menu::sep(m);
if !desk() {
let sort = CreatePopupMenu();
Expand Down Expand Up @@ -633,6 +645,7 @@ unsafe fn bg_menu(h: HWND) {
match id {
7 => set_icons_hidden(!icons_hidden()),
16 => { SHOW_HIDDEN.fetch_xor(true, Relaxed); } // the reload below lists them
17 => open_cmd(&dir),
20..=23 => SORT_COL.store(id as usize - 20, Relaxed), // the reload below sorts again
30 | 31 => SORT_ASC.store(id == 30, Relaxed),
13 => {
Expand Down
Loading