Skip to content
Merged
Show file tree
Hide file tree
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
26 changes: 21 additions & 5 deletions crates/argus-core/src/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

mod packaged;

use std::path::Path;
use std::{io::ErrorKind, os::windows::fs::OpenOptionsExt, path::Path};

use serde::Serialize;
use windows::Win32::Foundation::{
ERROR_FILE_NOT_FOUND, ERROR_SUCCESS, FILETIME, MAX_PATH, WIN32_ERROR,
};
use windows::Win32::Storage::FileSystem::{DELETE, FILE_FLAG_OPEN_REPARSE_POINT};
use windows::Win32::System::Com::{
CLSCTX_INPROC_SERVER, COINIT_MULTITHREADED, CoCreateInstance, CoInitializeEx, IPersistFile,
STGM_READ,
Expand Down Expand Up @@ -508,6 +509,20 @@ fn remove_file(folder: &Path, name: &str, recycle: bool) -> Result<(), ActionErr
if !path.is_file() {
return Err(ActionError::NotFound);
}
// Check the caller's delete access on the directory entry itself before
// handing it to the Shell. Release the handle before the recycle operation.
if let Err(error) = std::fs::File::options()
.access_mode(DELETE.0)
.custom_flags(FILE_FLAG_OPEN_REPARSE_POINT.0)
.open(&path)
{
crate::diagnostics::file_failure("startup open for deletion", &path, &error);
return Err(match error.kind() {
ErrorKind::PermissionDenied => ActionError::AccessDenied,
ErrorKind::NotFound => ActionError::NotFound,
_ => ActionError::Os(error.to_string()),
});
}
// The paths, each ended by a NUL, and the list by another.
let mut from = wide(&path.to_string_lossy());
from.push(0);
Expand Down Expand Up @@ -727,10 +742,11 @@ mod tests {
.expect("icacls");
assert!(status.success());
}
assert!(matches!(
remove_file(&folder.0, "Locked.lnk", true),
Err(ActionError::AccessDenied)
));
let result = remove_file(&folder.0, "Locked.lnk", true);
assert!(
matches!(result, Err(ActionError::AccessDenied)),
"{result:?}"
);
assert!(folder.0.join("Locked.lnk").exists());
}

Expand Down
4 changes: 2 additions & 2 deletions docs/guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ CSV 使用带 BOM 的 UTF-8 编码,可在 Excel 中打开。名称、描述或

选中应用组时,详情面板显示该组的 CPU 与内存曲线、资源合计、最早启动时间、累计读数之和、按 CPU 排序的成员与文件位置。单击成员可查看单进程详情。结束、优先级和效率模式操作仅作用于选中组。

面板右上角的复制按钮(Ctrl+Shift+C)将面板所列内容复制为文字,按“【进程】”“【资源】”等小节分段,暂无读数的项目不复制;进程页的列表获得焦点时按 Ctrl+C 复制选中项的名称(与名称列显示的一致),面板或其他位置有选中的文字时,两组快捷键都改为复制所选文字。进程的右键菜单中,“复制”子菜单可复制名称、映像名称、PID、映像路径、命令行或详细信息;在某一列上单击右键时,菜单另有“复制“列名””,复制该行在这一列显示的内容,例如在 CPU 列上为“复制“CPU””。
面板右上角的复制按钮(Ctrl+Shift+C)将面板所列内容复制为文字,按“【进程】”“【资源】”等小节分段,暂无读数的项目不复制;进程页的列表获得焦点时按 Ctrl+C 复制选中项的名称(与名称列显示的一致),面板或其他位置有选中的文字时,两组快捷键都改为复制所选文字。进程的右键菜单中,“复制”子菜单可复制名称、映像名称、PID、映像路径、命令行或详细信息;在某一列上单击右键时,菜单另有“复制“列名””,复制该行在这一列显示的内容,例如在 CPU 列上为“复制“CPU””。服务、启动与连接页的列表同样支持:Ctrl+C 复制名称列显示的名称,Ctrl+Shift+C 或右键菜单的“复制详细信息”以“列名: 内容”逐行复制该行显示的各列(空白与暂无读数的列除外),在某一列上单击右键时同样可“复制“列名””。

网络速率默认以字节每秒显示(KB/s、MB/s,与磁盘一致),可以在“设置 → 数据与历史”里改为比特每秒(Kbps、Mbps,与网卡的链路速度、宽带套餐一致),概况带、进程表、详细信息面板和历史页随之切换;性能页的网络视图总是同时显示两种。

Expand Down Expand Up @@ -314,7 +314,7 @@ Windows 触摸屏支持点按按钮、选择列表项,以及双击展开或折
| 选择 | ↑ ↓ |
| 折叠 / 展开 | ← →;分组标题上也可按 Enter 或空格 |
| 打开详细信息 | Enter |
| 复制名称 / 详细信息 | 进程页 Ctrl+C / Ctrl+Shift+C;有选中的文字时复制所选文字 |
| 复制名称 / 详细信息 | 进程、服务、启动与连接页 Ctrl+C / Ctrl+Shift+C;有选中的文字时复制所选文字 |
| 横向滚动列表 | Shift+滚轮(指针位于列表上) |
| 结束进程 | 进程页 Alt+E;列表获得焦点时也可按 Delete(Shift+Delete 跳过确认) |
| 显示 / 隐藏窗口(全局) | Ctrl+Alt+Esc,可在设置中更改 |
Expand Down
4 changes: 2 additions & 2 deletions locales/de-DE/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
"ends": "Wählen Sie das erste / letzte Element aus",
"expand": "Prozesse: Reduzieren/Erweitern einer Gruppe oder Kategorie oder Auswählen eines übergeordneten/untergeordneten Elements",
"details": "Prozesse: Details öffnen",
"copyName": "Prozesse: Namen der Auswahl kopieren",
"copyDetails": "Prozesse: Details der Auswahl kopieren",
"copyName": "Namen der Auswahl kopieren",
"copyDetails": "Details der Auswahl kopieren",
"endTable": "Prozesse: Auswahl beenden, mit Bestätigung",
"endDirect": "Prozesse: Auswahl ohne Bestätigung beenden",
"clear": "Auswahl löschen; löschen Sie zuerst die Prozesssuche, falls eine aktiv ist.",
Expand Down
4 changes: 2 additions & 2 deletions locales/en-US/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
"ends": "Select the first / last item",
"expand": "Processes: collapse / expand a group or category, or select a parent / child",
"details": "Processes: open details",
"copyName": "Processes: copy the name of the selection",
"copyDetails": "Processes: copy the details of the selection",
"copyName": "Copy the name of the selection",
"copyDetails": "Copy the details of the selection",
"endTable": "Processes: end the selection, with confirmation",
"endDirect": "Processes: end the selection without confirmation",
"clear": "Clear selection; clear the process search first if one is active.",
Expand Down
4 changes: 2 additions & 2 deletions locales/es-ES/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
"ends": "Seleccione el primer/último elemento",
"expand": "Procesos: contraer/expandir un grupo o categoría, o seleccionar un padre/hijo",
"details": "Procesos: abrir detalles",
"copyName": "Procesos: copiar el nombre de la selección",
"copyDetails": "Procesos: copiar los detalles de la selección",
"copyName": "Copiar el nombre de la selección",
"copyDetails": "Copiar los detalles de la selección",
"endTable": "Procesos: finalizar la selección, con confirmación",
"endDirect": "Procesos: finalizar la selección sin confirmación",
"clear": "Borrar selección; borre primero la búsqueda de procesos si hay alguna activa.",
Expand Down
4 changes: 2 additions & 2 deletions locales/fr-FR/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
"ends": "Sélectionnez le premier/dernier élément",
"expand": "Processus : réduire/développer un groupe ou une catégorie, ou sélectionner un parent/enfant",
"details": "Processus : ouvrir les détails",
"copyName": "Processus : copier le nom de la sélection",
"copyDetails": "Processus : copier les détails de la sélection",
"copyName": "Copier le nom de la sélection",
"copyDetails": "Copier les détails de la sélection",
"endTable": "Processus : terminer la sélection, avec confirmation",
"endDirect": "Processus : terminer la sélection sans confirmation",
"clear": "Effacer la sélection ; effacez d’abord la recherche de processus si elle est active.",
Expand Down
4 changes: 2 additions & 2 deletions locales/ja-JP/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
"ends": "最初/最後の項目を選択",
"expand": "プロセス:グループまたはカテゴリを折りたたむ/展開する、または親/子を選択する",
"details": "プロセス:詳細を開く",
"copyName": "プロセス:選択項目の名前をコピー",
"copyDetails": "プロセス:選択項目の詳細をコピー",
"copyName": "選択項目の名前をコピー",
"copyDetails": "選択項目の詳細をコピー",
"endTable": "プロセス一覧:確認後に選択項目を終了",
"endDirect": "プロセス一覧:確認を省略して選択項目を終了",
"clear": "選択をクリアします。プロセス検索がアクティブな場合は、最初にそれをクリアします。",
Expand Down
4 changes: 2 additions & 2 deletions locales/ru-RU/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
"ends": "Выбор первого/последнего элемента",
"expand": "Процессы: свернуть/развернуть группу или категорию или выбрать родительский/дочерний элемент",
"details": "Процессы: открыть сведения",
"copyName": "Процессы: копировать имя выбранного элемента",
"copyDetails": "Процессы: копировать сведения о выбранном элементе",
"copyName": "Копировать имя выбранного элемента",
"copyDetails": "Копировать сведения о выбранном элементе",
"endTable": "Процессы: завершить выбранные элементы с подтверждением",
"endDirect": "Процессы: завершить выбранные элементы без подтверждения",
"clear": "Снять выделение; если активен поиск процессов, сначала очистить его.",
Expand Down
4 changes: 2 additions & 2 deletions locales/zh-CN/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
"ends": "选择第一项 / 最后一项",
"expand": "进程列表:折叠 / 展开进程组或分组,或选择父项 / 子项",
"details": "进程列表:打开详细信息",
"copyName": "进程列表:复制选中项的名称",
"copyDetails": "进程列表:复制选中项的详细信息",
"copyName": "复制选中项的名称",
"copyDetails": "复制选中项的详细信息",
"endTable": "进程列表:结束选中项,操作前确认",
"endDirect": "进程列表:直接结束选中项,跳过确认",
"clear": "取消选择;进程列表有搜索条件时先清空搜索。",
Expand Down
4 changes: 2 additions & 2 deletions locales/zh-TW/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
"ends": "選取第一項 / 最後一項",
"expand": "處理程序清單:摺疊 / 展開處理程序群組或分組,或選取父項 / 子項",
"details": "處理程序清單:開啟詳細資料",
"copyName": "處理程序清單:複製選取項目的名稱",
"copyDetails": "處理程序清單:複製選取項目的詳細資料",
"copyName": "複製選取項目的名稱",
"copyDetails": "複製選取項目的詳細資料",
"endTable": "處理程序清單:結束選取項目,操作前確認",
"endDirect": "處理程序清單:直接結束選取項目,略過確認",
"clear": "取消選取;處理程序清單有搜尋條件時先清除搜尋。",
Expand Down
7 changes: 7 additions & 0 deletions src-gpui/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,13 @@ pub fn history_move(
Ok(settings_view(&app))
}

pub fn history_reset_dir(
app: crate::native_runtime::Host,
move_records: bool,
) -> Result<SettingsView, String> {
history_move(app, String::new(), move_records)
}

pub fn history_open_dir(dir: State<'_, HistoryDir>) -> Result<(), String> {
open_folder(&dir.read()).map_err(|_| tr!("history.error.open"))
}
Expand Down
63 changes: 32 additions & 31 deletions src-gpui/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ fn argument<T: serde::de::DeserializeOwned>(args: &Value, key: &str) -> Result<T
serde_json::from_value(args.get(key).cloned().unwrap_or(Value::Null))
.map_err(|_| serde_json::json!(argus_core::tr!("app.invalidRequest")))
}
fn history_settings(result: Result<crate::settings::SettingsView, String>) -> Result<Value, Value> {
serde_json::to_value(result.map_err(Value::String)?)
.map_err(|_| Value::String(argus_core::tr!("app.invalidRequest")))
}
pub fn invoke(host: &Host, name: &str, args: Value) -> Result<Value, Value> {
match name {
"desktop_shell" => Ok(serde_json::to_value(crate::commands::desktop_shell())
Expand Down Expand Up @@ -301,15 +297,13 @@ pub fn invoke(host: &Host, name: &str, args: Value) -> Result<Value, Value> {
argument::<Vec<String>>(&args, "keys")?,
))
.expect("serializable command response")),
"history_events" => serde_json::to_value(
crate::commands::history_events(
host.state(),
argument::<i64>(&args, "from")?,
argument::<i64>(&args, "to")?,
)
.map_err(Value::String)?,
"history_events" => crate::commands::history_events(
host.state(),
argument::<i64>(&args, "from")?,
argument::<i64>(&args, "to")?,
)
.map_err(|_| Value::String(argus_core::tr!("app.invalidRequest"))),
.map(|value| serde_json::to_value(value).expect("serializable command response"))
.map_err(|error| serde_json::to_value(error).unwrap_or(serde_json::Value::Null)),
"history_channels" => Ok(serde_json::to_value(crate::commands::history_channels(
host.state(),
argument::<i64>(&args, "from")?,
Expand Down Expand Up @@ -347,29 +341,36 @@ pub fn invoke(host: &Host, name: &str, args: Value) -> Result<Value, Value> {
)
.map(|value| serde_json::to_value(value).expect("serializable command response"))
.map_err(|error| serde_json::to_value(error).unwrap_or(serde_json::Value::Null)),
"history_move" => history_settings(crate::commands::history_move(
"set_history_enabled" => crate::commands::set_history_enabled(
host.clone(),
argument(&args, "dir")?,
argument(&args, "moveRecords")?,
)),
"history_reset_dir" => history_settings(crate::commands::history_move(
host.state(),
host.state(),
argument::<bool>(&args, "enabled")?,
)
.map(|value| serde_json::to_value(value).expect("serializable command response"))
.map_err(|error| serde_json::to_value(error).unwrap_or(serde_json::Value::Null)),
"set_history_options" => crate::commands::set_history_options(
host.clone(),
String::new(),
argument(&args, "moveRecords")?,
)),
"history_open_dir" => crate::commands::history_open_dir(host.state())
.map(|()| Value::Null)
.map_err(Value::String),
"set_history_options" => history_settings(crate::commands::set_history_options(
argument::<crate::settings::HistoryOptionsPatch>(&args, "options")?,
)
.map(|value| serde_json::to_value(value).expect("serializable command response"))
.map_err(|error| serde_json::to_value(error).unwrap_or(serde_json::Value::Null)),
"history_move" => crate::commands::history_move(
host.clone(),
argument(&args, "options")?,
)),
"set_history_enabled" => history_settings(crate::commands::set_history_enabled(
argument::<String>(&args, "dir")?,
argument::<bool>(&args, "moveRecords")?,
)
.map(|value| serde_json::to_value(value).expect("serializable command response"))
.map_err(|error| serde_json::to_value(error).unwrap_or(serde_json::Value::Null)),
"history_reset_dir" => crate::commands::history_reset_dir(
host.clone(),
host.state(),
host.state(),
argument(&args, "enabled")?,
)),
argument::<bool>(&args, "moveRecords")?,
)
.map(|value| serde_json::to_value(value).expect("serializable command response"))
.map_err(|error| serde_json::to_value(error).unwrap_or(serde_json::Value::Null)),
"history_open_dir" => crate::commands::history_open_dir(host.state())
.map(|value| serde_json::to_value(value).expect("serializable command response"))
.map_err(|error| serde_json::to_value(error).unwrap_or(serde_json::Value::Null)),
"set_kernel_sensors" => crate::commands::set_kernel_sensors(
host.clone(),
host.state(),
Expand Down
1 change: 1 addition & 0 deletions src-gpui/src/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod icon_motion;
mod inline;
mod layout;
mod leaks;
mod list_copy;
mod lists;
mod menus;
mod model;
Expand Down
13 changes: 10 additions & 3 deletions src-gpui/src/frontend/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1199,9 +1199,11 @@ impl Desktop {
cx.stop_propagation();
return;
}
// Ctrl+C copies the selected process's name and Ctrl+Shift+C its
// Ctrl+C copies the selected row's name and Ctrl+Shift+C its
// details, unless text is selected: the window copies that instead.
if self.page == "processes"
// A process's details are the details pane's, another list's the
// columns it shows (`list_copy`).
if list_copy::LISTS.contains(&self.page.as_str())
&& key == "c"
&& m.control
&& !m.alt
Expand All @@ -1212,8 +1214,13 @@ impl Desktop {
.and_then(|index| self.rows.get(index))
.filter(|row| row.section.is_none())
{
let action = if m.shift {
let action = if m.shift && self.page == "processes" {
Action::CopyDetails(row.key.clone())
} else if m.shift {
let Some(details) = self.cells_text(row, cx) else {
return;
};
Action::CopyAs(details, label("actions.copyWhat.details"))
} else {
Action::Copy(row.title.clone(), "actions.copyWhat.name")
};
Expand Down
Loading