team-ljyzipelo

공개

찾기 창, Esc 닫기, 폴더 크기와 빌드별 로그 단계 추가

- Ctrl+F는 보고 있는 폴더 아래 모든 하위 폴더에서 이름으로, Ctrl+Shift+F는 압축파일 전체 경로에서 찾음
- 찾기 결과를 두 번 누르거나 Enter를 누르면 찾기 창을 닫고 그 위치로 이동하며 파일을 선택함
- Esc는 떠 있는 자식 창을 닫고, 자식 창이 없으면 프로그램을 종료함(작업 중에는 종료 확인)
- 폴더 크기를 안에 든 파일 크기의 합으로 표시함
- 배포 빌드는 오류만, 디버그 빌드는 작업 요청과 응답까지 기록하며 ZIPELO_LOG로 바꿀 수 있음
- 빠져 있던 파일 열기 오류 UI 상황(open-blocked, open-failed, open-missing)과 찾기 상황을 추가함

Co-Authored-By: Claude Opus 5.5 <[email protected]>
작성자
LeeJunyoung
작성 시각
커밋
ebed86e29d5c70805d8b85c8b097207488f194a9
부모
8bd3e62
이 시점의 파일 보기

변경된 파일 14개

+1,315-31
수정README.md+7-0
@@ -58,6 +58,13 @@ Ubuntu에서는 [.deb 설치 파일](https://github.com/Team-LJY/zipelo/releases
5858
5959main `3a77cfd`는 Windows 11 Pro build 26300과 Ubuntu 26.04.1 Wayland/X11에서 네 새 기능, 잘못된 암호 재시도와 덮어 설치를 확인했습니다. 실패 시 출력 정리 보강(PR130)은 이후 `cd45eab`로 병합됐으며 해당 수정 후 플랫폼 실기는 재실행하지 않았습니다. 사용자 요청에 따라 v0.2는 로컬 빌드만 허용됐으며 게시하지 않습니다. 구현 범위와 미검증 항목은 [v0.2 릴리스 노트 초안](docs/release-notes-v0.2.md)을 참고하세요.
6060
61추가: ## 개발 중인 main의 사용 편의 기능
62추가:
63추가: - **찾기:** 압축파일을 연 뒤 Ctrl+F를 누르면 지금 보고 있는 폴더 아래의 모든 하위 폴더에서 이름으로 찾고, Ctrl+Shift+F를 누르면 압축파일 전체 경로에서 찾습니다. 찾기 창의 결과를 두 번 누르거나 Enter를 누르면 그 위치로 이동합니다.
64추가: - **Esc:** 찾기 창, 작업 결과 창, 압축 파일 만들기 창 등 자식 창이 떠 있으면 그 창을 닫고, 아무 창도 없으면 프로그램을 종료합니다. 진행 중인 작업 창은 [취소] 버튼을 사용합니다.
65추가: - **폴더 크기:** 목록의 폴더 크기를 0 B가 아닌, 안에 든 모든 파일 크기의 합으로 표시합니다.
66추가: - **로그:** 배포 빌드는 오류만 표준 오류에 남깁니다. 디버그 빌드는 작업 요청과 작업자 응답까지 자세히 남깁니다. 문제를 조사할 때는 `ZIPELO_LOG=debug zipelo`처럼 `ZIPELO_LOG`(off, error, warn, info, debug, trace)로 단계를 바꿀 수 있습니다. 암호는 어느 단계에서도 남기지 않습니다.
67추가:
6168## 개발자용
6269
6370Rust로 개발하며 압축 처리는 별도 작업자 프로세스에서 수행합니다. 로컬 빌드와 시험은 `python3 tests/ci/run_rust.py local`로 실행합니다. 프로젝트 이동 뒤 긴 경로 때문에 시험 실행기가 멈추던 문제는 main에서 해결됐습니다([PR118](https://github.com/Team-LJY/zipelo/pull/118)). 새 실제 경로에서 별칭이나 경로 매핑 없이 전체 local 검증을 통과한 기록이 있습니다.
수정docs/ui-scenario-guide.md+11-1
@@ -44,12 +44,18 @@ cargo +1.99.1 build --locked --manifest-path experiments/rust-ui-memory-app/Carg
4444- empty: 빈 첫 화면. 파일 열기 안내와 툴바 배치를 확인한다.
4545- tar-bz2: TAR.BZ2 목록. 제목표시줄의 파일 이름과 목록을 확인한다.
4646- tar-xz: TAR.XZ 목록. 제목표시줄의 대소문자가 섞인 복합 확장자와 목록을 확인한다.
47삭제: - archive: 파일과 폴더가 있는 압축파일. 이름, 크기, 잠금 아이콘과 상태 줄을 확인한다.
47추가: - archive: 파일과 폴더가 있는 압축파일. 이름, 크기, 잠금 아이콘과 상태 줄을 확인한다. 폴더 크기는 0 B가 아니라 그 안의 모든 파일 크기의 합(사진 폴더 2.5 MB)으로 표시한다.
4848- folder: 사진 폴더 내부. 상위 폴더 이동과 경로 줄을 확인한다.
4949- many-items: 기본 5개 외에 500개 파일을 추가한 목록. 스크롤바와 행 배치를 확인한다.
5050- selection: 파일과 폴더 두 항목 선택. 파란 선택 배경과 선택 수를 확인한다.
5151- marquee: 끌어서 선택 중인 고정 화면. 반투명 파란 면, 테두리와 아래 행의 가독성을 확인한다.
5252- search-empty: 검색 결과 없음. 검색 입력과 빈 결과 안내를 확인한다.
53추가: - find-folder: Ctrl+F 찾기 창. 연 폴더 아래 모든 하위 폴더에서 이름에 "jpg"가 들어간 파일을 찾은 결과입니다. 위쪽 검색어 입력란과 그 아래 세로로 긴 결과 목록, 각 결과의 이름과 상위 경로를 확인합니다. 결과를 두 번 누르거나 Enter를 누르면 찾기 창이 닫히고 그 위치로 이동하며, 파일이면 들어 있는 폴더를 열고 그 파일을 선택합니다.
54추가: - find-all: Ctrl+Shift+F 찾기 창. 압축파일 전체에서 전체 경로에 "사진"이 들어간 폴더와 파일을 찾은 결과입니다. 범위 안내 문구가 "압축파일 전체 경로에서 찾습니다"인지 확인합니다. 찾기 창에서 Ctrl+F와 Ctrl+Shift+F로 범위를 바꿀 수 있습니다.
55추가: - find-empty: 찾기 결과가 없을 때 "찾은 항목이 없습니다" 안내를 확인합니다. Esc를 누르면 찾기 창만 닫힙니다.
56추가: - open-blocked: 압축파일 안 실행 파일을 두 번 눌렀을 때 바로 열지 않는다는 안내를 확인합니다. 풀기 작업은 시작하지 않습니다.
57추가: - open-failed: 파일을 임시 폴더에 푼 뒤 기본 프로그램 실행에 실패한 안내를 확인합니다.
58추가: - open-missing: 열기용으로 푼 결과에서 고른 파일을 찾지 못한 안내를 확인합니다.
5359- password: 암호 입력 창. 입력칸과 보기, 취소, 확인 버튼 배치를 확인한다.
5460- password-retry: 두 번째 암호 입력 요청. 틀린 암호 안내와 입력칸 배치를 확인한다.
5561- archive-loading: 플랫폼과 관계없이 별도 작업 창으로 재현합니다. 최초 생성에서 포커스 정보가 아직 없을 때만 창을 올리며, 다른 앱에 포커스가 있는 상태에서 다시 표시할 때는 올리지 않습니다. 명령줄이나 더블클릭으로 압축파일을 연 직후의 목록 로딩입니다. 목록을 읽는 동안에는 "이 폴더는 비어 있습니다"를 표시하지 않아야 합니다. X11에서는 처음부터 작업 창이 부모 위에 보이고 부모를 클릭해도 유지되는지 확인합니다. 다른 앱으로 전환하면 작업 창이 그 앱 뒤로 내려가야 합니다.
@@ -84,6 +90,10 @@ cargo +1.99.1 build --locked --manifest-path experiments/rust-ui-memory-app/Carg
8490- uninstall-ubuntu-missing: 이전 앱이 없어 복원하지 못한 경우의 터미널 안내 문구를 확인한다.
8591- uninstall-ubuntu-unknown-user: 제거 사용자를 확인하지 못해 설정을 유지하는 안내 문구를 확인한다.
8692
93추가: ## Esc 키
94추가:
95추가: 자식 창(찾기 창, 작업 결과 창, 압축 파일 만들기 창, 미리보기, 암호 입력, 큰 작업 승인, 파일 충돌 선택, 종료 확인 등)이 떠 있으면 Esc는 그 창을 닫거나 취소합니다. 진행 중인 작업 창은 Esc로 닫지 않으며 [취소] 버튼을 사용합니다. 목록에 선택한 항목이 있으면 Esc는 먼저 선택을 해제하고, 입력란에 초점이 있으면 초점만 해제합니다. 아무 자식 창도 없으면 Esc로 프로그램을 종료하며, 작업 중이면 기존 종료 확인 창을 거칩니다. 미리보기 상황은 입력을 받지 않으므로 Esc 동작은 tests/rust-app-ui/explorer_selection.rs와 실제 실행으로 확인합니다.
96추가:
8797--ui-scenario에는 이름 하나만 지정한다. 없는 이름, 누락된 이름, 다른 옵션이나 경로와의 혼합은 사용 가능한 목록을 출력하고 실패로 끝난다. --list-ui-scenarios도 단독으로 사용한다. 기존 파일 연결 실행과 --ui-fixture의 인자 해석은 유지한다.
8898
8999## 검증
수정experiments/rust-archive-worker/src/main.rs+15-3
@@ -1,7 +1,19 @@
11fn main() {
2삭제: std::panic::set_hook(Box::new(|_| {}));
3삭제: if zipelo_archive_worker::runtime::serve(std::io::stdin(), std::io::stdout()).is_err() {
4삭제: eprintln!("작업자 통신 실패");
2추가: // 배포 빌드는 패닉 내용을 남기지 않고, 디버그 빌드는 원인을 자세히 남김.
3추가: if cfg!(debug_assertions) {
4추가: eprintln!("[worker {}] 시작", std::process::id());
5추가: } else {
6추가: std::panic::set_hook(Box::new(|_| {}));
7추가: }
8추가: if let Err(error) = zipelo_archive_worker::runtime::serve(std::io::stdin(), std::io::stdout()) {
9추가: if cfg!(debug_assertions) {
10추가: eprintln!("[worker {}] 작업자 통신 실패: {error:?}", std::process::id());
11추가: } else {
12추가: eprintln!("작업자 통신 실패");
13추가: }
514 std::process::exit(2);
615 }
16추가: if cfg!(debug_assertions) {
17추가: eprintln!("[worker {}] 정상 종료", std::process::id());
18추가: }
719}
추가experiments/rust-ui-memory-app/src/applog.rs+183-0
@@ -0,0 +1,183 @@
1추가: //! 앱 로그. 표준 오류로 한 줄씩 남김.
2추가: //!
3추가: //! 디버그 빌드(debug_assertions)는 모든 단계(trace까지)를 자세히 남기고,
4추가: //! 배포(릴리스) 빌드는 오류만 남겨 로그를 최소화함. 문제를 조사할 때는
5추가: //! ZIPELO_LOG 환경 변수(off, error, warn, info, debug, trace)로 단계를 바꿀 수 있음.
6추가: //! 암호와 파일 내용은 어느 단계에서도 남기지 않음.
7추가:
8추가: use std::sync::OnceLock;
9추가: use std::time::Instant;
10추가:
11추가: #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
12추가: pub enum Level {
13추가: Off = 0,
14추가: Error = 1,
15추가: Warn = 2,
16추가: Info = 3,
17추가: Debug = 4,
18추가: Trace = 5,
19추가: }
20추가:
21추가: impl Level {
22추가: fn label(self) -> &'static str {
23추가: match self {
24추가: Level::Off => "OFF",
25추가: Level::Error => "ERROR",
26추가: Level::Warn => "WARN",
27추가: Level::Info => "INFO",
28추가: Level::Debug => "DEBUG",
29추가: Level::Trace => "TRACE",
30추가: }
31추가: }
32추가:
33추가: /// 빌드 종류에 따른 기본 단계.
34추가: pub const fn default_for_build() -> Self {
35추가: if cfg!(debug_assertions) {
36추가: Level::Trace
37추가: } else {
38추가: Level::Error
39추가: }
40추가: }
41추가:
42추가: pub fn parse(text: &str) -> Option<Self> {
43추가: Some(match text.trim().to_ascii_lowercase().as_str() {
44추가: "off" | "none" | "0" => Level::Off,
45추가: "error" | "1" => Level::Error,
46추가: "warn" | "warning" | "2" => Level::Warn,
47추가: "info" | "3" => Level::Info,
48추가: "debug" | "4" => Level::Debug,
49추가: "trace" | "all" | "5" => Level::Trace,
50추가: _ => return None,
51추가: })
52추가: }
53추가: }
54추가:
55추가: struct State {
56추가: level: Level,
57추가: started: Instant,
58추가: }
59추가:
60추가: fn state() -> &'static State {
61추가: static STATE: OnceLock<State> = OnceLock::new();
62추가: STATE.get_or_init(|| State {
63추가: level: std::env::var("ZIPELO_LOG")
64추가: .ok()
65추가: .and_then(|value| Level::parse(&value))
66추가: .unwrap_or(Level::default_for_build()),
67추가: started: Instant::now(),
68추가: })
69추가: }
70추가:
71추가: /// 현재 로그 단계.
72추가: pub fn level() -> Level {
73추가: state().level
74추가: }
75추가:
76추가: /// 이 단계의 로그를 남기는지. 메시지를 만드는 비용을 아낄 때 씀.
77추가: pub fn enabled(level: Level) -> bool {
78추가: level != Level::Off && level <= state().level
79추가: }
80추가:
81추가: #[doc(hidden)]
82추가: pub fn write(level: Level, target: &str, message: std::fmt::Arguments<'_>) {
83추가: if !enabled(level) {
84추가: return;
85추가: }
86추가: let elapsed = state().started.elapsed();
87추가: let thread = std::thread::current();
88추가: let line = format!(
89추가: "[{:>5}.{:03}s {:<5} {target} {}] {message}\n",
90추가: elapsed.as_secs(),
91추가: elapsed.subsec_millis(),
92추가: level.label(),
93추가: thread.name().unwrap_or("-"),
94추가: );
95추가: // 표준 오류를 쓸 수 없어도(Windows GUI 등) 앱 동작에는 영향을 주지 않음.
96추가: // eprint!는 시험 실행 중에는 시험별로 출력을 모아 실패한 시험만 보여 줌.
97추가: if std::panic::catch_unwind(|| eprint!("{line}")).is_err() {
98추가: // 표준 오류가 닫혀 있어 eprint!가 실패해도 무시함.
99추가: }
100추가: }
101추가:
102추가: #[macro_export]
103추가: macro_rules! log_at {
104추가: ($level:expr, $($arg:tt)+) => {
105추가: if $crate::applog::enabled($level) {
106추가: $crate::applog::write($level, module_path!(), format_args!($($arg)+));
107추가: }
108추가: };
109추가: }
110추가:
111추가: #[macro_export]
112추가: macro_rules! log_error { ($($arg:tt)+) => { $crate::log_at!($crate::applog::Level::Error, $($arg)+) }; }
113추가: #[macro_export]
114추가: macro_rules! log_warn { ($($arg:tt)+) => { $crate::log_at!($crate::applog::Level::Warn, $($arg)+) }; }
115추가: #[macro_export]
116추가: macro_rules! log_info { ($($arg:tt)+) => { $crate::log_at!($crate::applog::Level::Info, $($arg)+) }; }
117추가: #[macro_export]
118추가: macro_rules! log_debug { ($($arg:tt)+) => { $crate::log_at!($crate::applog::Level::Debug, $($arg)+) }; }
119추가: #[macro_export]
120추가: macro_rules! log_trace { ($($arg:tt)+) => { $crate::log_at!($crate::applog::Level::Trace, $($arg)+) }; }
121추가:
122추가: /// Debug 표현을 최대 `max`자까지만 만들어 돌려줌. 큰 값(미리보기 데이터 등)을
123추가: /// 끝까지 문자열로 만들지 않도록 한도에 닿으면 바로 멈춤.
124추가: pub fn brief(value: &impl std::fmt::Debug, max: usize) -> String {
125추가: struct Bounded {
126추가: text: String,
127추가: count: usize,
128추가: max: usize,
129추가: cut: bool,
130추가: }
131추가: impl std::fmt::Write for Bounded {
132추가: fn write_str(&mut self, s: &str) -> std::fmt::Result {
133추가: for c in s.chars() {
134추가: if self.count >= self.max {
135추가: self.cut = true;
136추가: return Err(std::fmt::Error);
137추가: }
138추가: self.text.push(c);
139추가: self.count += 1;
140추가: }
141추가: Ok(())
142추가: }
143추가: }
144추가: let mut out = Bounded {
145추가: text: String::new(),
146추가: count: 0,
147추가: max,
148추가: cut: false,
149추가: };
150추가: let _ = std::fmt::Write::write_fmt(&mut out, format_args!("{value:?}"));
151추가: if out.cut {
152추가: out.text.push('…');
153추가: }
154추가: out.text
155추가: }
156추가:
157추가: #[cfg(test)]
158추가: mod tests {
159추가: use super::*;
160추가:
161추가: #[test]
162추가: fn release_builds_log_errors_only_and_debug_builds_log_everything() {
163추가: let expected = if cfg!(debug_assertions) {
164추가: Level::Trace
165추가: } else {
166추가: Level::Error
167추가: };
168추가: assert_eq!(Level::default_for_build(), expected);
169추가: assert_eq!(Level::parse(" Debug "), Some(Level::Debug));
170추가: assert_eq!(Level::parse("off"), Some(Level::Off));
171추가: assert_eq!(Level::parse("loud"), None);
172추가: assert!(Level::Error < Level::Trace);
173추가: }
174추가:
175추가: #[test]
176추가: fn brief_stops_formatting_large_values() {
177추가: let data = vec![7u8; 100_000];
178추가: let text = brief(&data, 20);
179추가: assert_eq!(text.chars().count(), 21);
180추가: assert!(text.ends_with('…'));
181추가: assert_eq!(brief(&"짧음", 20), "\"짧음\"");
182추가: }
183추가: }
수정experiments/rust-ui-memory-app/src/archive_browser.rs+84-0
@@ -61,6 +61,12 @@ pub fn rows(entries: &[Entry], current: &str, query: &str) -> Vec<Row> {
6161 }
6262 if !directory {
6363 row.bytes = entry.bytes;
64추가: } else if entry.kind == Kind::File {
65추가: // 폴더 크기는 안에 있는 모든 파일 크기의 합으로 표시함.
66추가: let total = row.bytes.unwrap_or(0);
67추가: row.bytes = Some(total.saturating_add(entry.bytes.unwrap_or(0)));
68추가: } else if row.bytes.is_none() {
69추가: row.bytes = Some(0);
6470 }
6571 row.encrypted |= entry.encrypted;
6672 }
@@ -114,3 +120,81 @@ pub fn remove_selection(entries: &[Entry], selected: &mut BTreeSet<u32>, removed
114120 .collect::<BTreeSet<_>>();
115121 selected.retain(|id| !removed.contains(id) && !ancestors.contains(id));
116122}
123추가:
124추가: /// 찾기 창의 결과 한 줄.
125추가: #[derive(Clone, Debug, Eq, PartialEq)]
126추가: pub struct Found {
127추가: /// 압축파일 안 전체 경로 (앞뒤 '/' 없음).
128추가: pub path: String,
129추가: pub name: String,
130추가: pub directory: bool,
131추가: }
132추가:
133추가: /// 찾기 결과를 너무 많이 그리지 않도록 정한 최대 개수.
134추가: pub const FIND_LIMIT: usize = 5000;
135추가:
136추가: /// 압축파일 안에서 검색어가 들어간 파일과 폴더를 찾음. 대소문자는 구분하지 않음.
137추가: ///
138추가: /// - `whole_path`가 false면(Ctrl+F) `base` 폴더 아래의 모든 하위 폴더를 찾아 내려가며
139추가: /// 이름에 검색어가 들어간 항목을 찾음.
140추가: /// - `whole_path`가 true면(Ctrl+Shift+F) 압축파일 전체에서 전체 경로에 검색어가 들어간
141추가: /// 항목을 찾음. 이때 `base`는 쓰지 않음.
142추가: ///
143추가: /// 압축파일에 따로 적혀 있지 않은 상위 폴더도 결과에 포함함. 결과는 경로 순서이며
144추가: /// `limit`개를 넘으면 잘라 내고 두 번째 값으로 true를 돌려줌.
145추가: pub fn find(
146추가: entries: &[Entry],
147추가: base: &str,
148추가: query: &str,
149추가: whole_path: bool,
150추가: limit: usize,
151추가: ) -> (Vec<Found>, bool) {
152추가: let query = query.trim().to_lowercase();
153추가: if query.is_empty() {
154추가: return (Vec::new(), false);
155추가: }
156추가: let base = base.trim_matches('/');
157추가: let prefix = if whole_path || base.is_empty() {
158추가: String::new()
159추가: } else {
160추가: format!("{base}/")
161추가: };
162추가: let mut paths = BTreeMap::<String, bool>::new();
163추가: for entry in entries {
164추가: if !matches!(entry.kind, Kind::File | Kind::Directory) {
165추가: continue;
166추가: }
167추가: let Some(path) = normalized(&entry.name) else {
168추가: continue;
169추가: };
170추가: if !path.starts_with(&prefix) {
171추가: continue;
172추가: }
173추가: // 상위 폴더는 압축파일에 따로 없어도 폴더로 넣음.
174추가: let mut end = prefix.len();
175추가: while let Some(slash) = path[end..].find('/') {
176추가: end += slash;
177추가: paths.insert(path[..end].to_owned(), true);
178추가: end += 1;
179추가: }
180추가: let directory = entry.kind == Kind::Directory;
181추가: *paths.entry(path).or_insert(directory) |= directory;
182추가: }
183추가: let mut found = Vec::new();
184추가: for (path, directory) in paths {
185추가: let name = path.rsplit('/').next().unwrap_or(&path);
186추가: let haystack = if whole_path { path.as_str() } else { name };
187추가: if !haystack.to_lowercase().contains(&query) {
188추가: continue;
189추가: }
190추가: if found.len() == limit {
191추가: return (found, true);
192추가: }
193추가: found.push(Found {
194추가: name: name.to_owned(),
195추가: path,
196추가: directory,
197추가: });
198추가: }
199추가: (found, false)
200추가: }
수정experiments/rust-ui-memory-app/src/archive_process.rs+13-3
@@ -486,8 +486,10 @@ impl ProcessFactory {
486486impl ui::Factory for ProcessFactory {
487487 fn connect(&mut self, job_id: u64) -> Result<Box<dyn ui::Connection>, String> {
488488 if !self.worker.is_absolute() || job_id == 0 {
489추가: crate::log_error!("작업자 경로 또는 작업 ID가 올바르지 않음: job={job_id}");
489490 return Err("작업자 경로 또는 작업 ID가 올바르지 않습니다".into());
490491 }
492추가: crate::log_debug!("작업 {job_id} 작업자 실행: {}", self.worker.display());
491493 let (send, requests) = mpsc::sync_channel::<Frame>(8);
492494 let (events, receive) = mpsc::sync_channel(64);
493495 let (ready, started) = mpsc::sync_channel(1);
@@ -515,7 +517,8 @@ impl ui::Factory for ProcessFactory {
515517 }
516518 let child = match command.spawn() {
517519 Ok(child) => child,
518삭제: Err(_) => {
520추가: Err(error) => {
521추가: crate::log_error!("작업자를 실행하지 못함: {error}");
519522 let _ = ready.send(Err(
520523 "작업자를 실행하지 못했습니다. 앱과 작업자를 함께 설치하세요"
521524 .to_string(),
@@ -830,9 +833,16 @@ fn supervise(
830833 notify(&tx, ui::HostEvent::StderrEof);
831834 break;
832835 }
833삭제: Ok(_) => {}
836추가: Ok(count) => {
837추가: // 작업자가 표준 오류에 남긴 내용은 디버그 로그로만 옮김.
838추가: crate::log_debug!(
839추가: "작업자 표준 오류: {}",
840추가: String::from_utf8_lossy(&bytes[..count]).trim_end()
841추가: );
842추가: }
834843 Err(error) if error.kind() == io::ErrorKind::Interrupted => {}
835삭제: Err(_) => {
844추가: Err(error) => {
845추가: crate::log_error!("작업자 오류 파이프 읽기 실패: {error}");
836846 fault(&tx, &abort, "작업자 오류 파이프를 읽지 못했습니다");
837847 break;
838848 }
수정experiments/rust-ui-memory-app/src/archive_screen.rs+605-19
@@ -111,17 +111,13 @@ impl WorkWindow {
111111 decorations: bool,
112112 native_dialog_open: bool,
113113 ) -> egui::ViewportBuilder {
114삭제: let (parent, parent_focused, now) = ctx.input(|i| {
115삭제: (
116삭제: i.viewport().outer_rect,
117삭제: i.viewport().focused,
118삭제: i.time,
119삭제: )
120삭제: });
114추가: let (parent, parent_focused, now) =
115추가: ctx.input(|i| (i.viewport().outer_rect, i.viewport().focused, i.time));
121116 let (child, child_focused) = ctx.input(|i| {
122삭제: i.raw.viewports.get(&id).map_or((None, None), |v| {
123삭제: (v.outer_rect, v.focused)
124삭제: })
117추가: i.raw
118추가: .viewports
119추가: .get(&id)
120추가: .map_or((None, None), |v| (v.outer_rect, v.focused))
125121 });
126122 let initial_focus_unknown =
127123 !self.created && parent_focused.is_none() && child_focused.is_none();
@@ -208,6 +204,34 @@ struct OpenRequest {
208204 automatic: bool,
209205}
210206
207추가: /// 찾기 창(Ctrl+F, Ctrl+Shift+F) 크기. 검색어 입력란 아래로 결과 목록이 길게 이어지는
208추가: /// 작은 세로 창임.
209추가: const FIND_WIDTH: f32 = 360.0;
210추가: const FIND_HEIGHT: f32 = 560.0;
211추가: /// 찾기 결과 한 줄(이름과 상위 경로 두 줄)의 높이.
212추가: const FIND_ROW: f32 = 48.0;
213추가:
214추가: /// 찾기 창 상태.
215추가: #[derive(Default)]
216추가: struct FindState {
217추가: open: bool,
218추가: /// true면 압축파일 전체의 전체 경로에서 찾음(Ctrl+Shift+F).
219추가: /// false면 연 폴더 아래의 하위 폴더를 따라 이름에서 찾음(Ctrl+F).
220추가: whole_path: bool,
221추가: /// Ctrl+F를 누른 때 보고 있던 폴더.
222추가: base: String,
223추가: query: String,
224추가: results: Vec<browser::Found>,
225추가: truncated: bool,
226추가: /// 결과를 마지막으로 계산한 조건. 바뀐 경우에만 다시 찾음.
227추가: key: Option<(String, bool, String, usize)>,
228추가: cursor: Option<usize>,
229추가: focus_query: bool,
230추가: scroll_to_cursor: bool,
231추가: offset: f32,
232추가: win: WorkWindow,
233추가: }
234추가:
211235/// 파일 목록의 오른쪽 클릭 메뉴에서 고른 동작.
212236enum MenuAction {
213237 NewFolder,
@@ -287,6 +311,14 @@ pub struct ArchiveApp {
287311 open_roots: Vec<(PathBuf, present::OpenRoot)>,
288312 open_count: u64,
289313 opener: Opener,
314추가: find: FindState,
315추가: /// 이번 화면에서 목록 선택 해제 등 다른 곳이 Esc를 이미 처리했는지.
316추가: escape_handled: bool,
317추가: /// 찾기 결과로 이동한 뒤 다음 화면에서 목록에 키보드 초점을 줌.
318추가: focus_list: bool,
319추가: /// 지난 화면 끝에 입력란(전체, 목록 위 검색란)에 초점이 있었는지.
320추가: /// egui는 Esc를 누른 화면이 시작될 때 초점을 먼저 해제하므로 지난 값을 씀.
321추가: text_focus_before: (bool, bool),
290322 #[cfg(all(feature = "ui-fixture", debug_assertions))]
291323 scenario_marquee: Option<egui::Rect>,
292324 #[cfg(all(feature = "ui-fixture", debug_assertions))]
@@ -359,6 +391,10 @@ impl ArchiveApp {
359391 open_roots: Vec::new(),
360392 open_count: 0,
361393 opener: Box::new(present::open_with_default),
394추가: find: FindState::default(),
395추가: escape_handled: false,
396추가: focus_list: false,
397추가: text_focus_before: (false, false),
362398 #[cfg(all(feature = "ui-fixture", debug_assertions))]
363399 scenario_marquee: None,
364400 #[cfg(all(feature = "ui-fixture", debug_assertions))]
@@ -511,10 +547,125 @@ impl ArchiveApp {
511547
512548 pub fn browse_folder(&mut self, folder: &str) {
513549 self.folder = folder.trim_matches('/').to_owned();
550추가: crate::log_trace!("폴더 이동: /{}", self.folder);
514551 self.search.clear();
515552 self.clear_list_selection();
516553 }
517554
555추가: /// 찾기 창이 열려 있는지.
556추가: pub fn find_open(&self) -> bool {
557추가: self.find.open
558추가: }
559추가:
560추가: /// 찾기 창의 검색어. 시험과 UI 상황 미리보기에서 씀.
561추가: pub fn set_find_query(&mut self, query: &str) {
562추가: self.find.query = query.to_owned();
563추가: }
564추가:
565추가: /// 찾기 창의 현재 결과.
566추가: pub fn find_results(&mut self) -> &[browser::Found] {
567추가: self.refresh_find();
568추가: &self.find.results
569추가: }
570추가:
571추가: /// 찾기 창을 엶. `whole_path`가 false면(Ctrl+F) 지금 보고 있는 폴더 아래에서
572추가: /// 이름으로 찾고, true면(Ctrl+Shift+F) 압축파일 전체 경로에서 찾음.
573추가: /// 이미 열려 있으면 찾는 범위만 바꾸고 검색어는 유지함.
574추가: pub fn open_find(&mut self, whole_path: bool) -> bool {
575추가: if self.model.archive.is_none() || self.model.list_id.is_none() || self.model.busy() {
576추가: return false;
577추가: }
578추가: if !self.find.open {
579추가: self.find.win = WorkWindow::default();
580추가: }
581추가: self.find.open = true;
582추가: self.find.whole_path = whole_path;
583추가: self.find.base = if whole_path {
584추가: String::new()
585추가: } else {
586추가: self.folder.clone()
587추가: };
588추가: self.find.key = None;
589추가: self.find.cursor = None;
590추가: self.find.focus_query = true;
591추가: crate::log_debug!(
592추가: "찾기 창 열기: {}",
593추가: if whole_path {
594추가: "전체 경로".to_owned()
595추가: } else {
596추가: format!("/{} 아래", self.find.base)
597추가: }
598추가: );
599추가: true
600추가: }
601추가:
602추가: pub fn close_find(&mut self) {
603추가: if self.find.open {
604추가: crate::log_debug!("찾기 창 닫기");
605추가: }
606추가: self.find.open = false;
607추가: self.find.win = WorkWindow::default();
608추가: self.find.results.clear();
609추가: self.find.key = None;
610추가: self.find.cursor = None;
611추가: }
612추가:
613추가: fn refresh_find(&mut self) {
614추가: let key = (
615추가: self.find.query.clone(),
616추가: self.find.whole_path,
617추가: self.find.base.clone(),
618추가: self.model.entries.len(),
619추가: );
620추가: if self.find.key.as_ref() == Some(&key) {
621추가: return;
622추가: }
623추가: let (results, truncated) = browser::find(
624추가: &self.model.entries,
625추가: &self.find.base,
626추가: &self.find.query,
627추가: self.find.whole_path,
628추가: browser::FIND_LIMIT,
629추가: );
630추가: crate::log_trace!(
631추가: "찾기 '{}': {}개{}",
632추가: self.find.query,
633추가: results.len(),
634추가: if truncated { " (일부만 표시)" } else { "" }
635추가: );
636추가: self.find.results = results;
637추가: self.find.truncated = truncated;
638추가: self.find.cursor = self
639추가: .find
640추가: .cursor
641추가: .filter(|index| *index < self.find.results.len());
642추가: self.find.key = Some(key);
643추가: }
644추가:
645추가: /// 찾기 결과로 이동함. 찾기 창을 닫고, 폴더면 그 폴더를 열고
646추가: /// 파일이면 들어 있는 폴더를 연 뒤 그 파일을 선택함.
647추가: pub fn go_to_found(&mut self, found: &browser::Found) {
648추가: crate::log_debug!("찾기 결과로 이동: /{}", found.path);
649추가: self.close_find();
650추가: if found.directory {
651추가: self.browse_folder(&found.path);
652추가: } else {
653추가: let parent = found
654추가: .path
655추가: .rsplit_once('/')
656추가: .map_or("", |(parent, _)| parent)
657추가: .to_owned();
658추가: self.browse_folder(&parent);
659추가: let rows = browser::rows(&self.model.entries, &self.folder, "");
660추가: if let Some(index) = rows.iter().position(|row| row.name == found.name) {
661추가: self.select_row(&rows, index, false, false);
662추가: // 선택한 행이 목록 위쪽에 보이도록 스크롤함.
663추가: self.list_offset = (index as f32 * LIST_ROW - 2.0 * LIST_ROW).max(0.0);
664추가: }
665추가: }
666추가: self.focus_list = true;
667추가: }
668추가:
518669 pub fn show_create(&mut self, encrypted: bool) {
519670 if !self.model.busy() {
520671 self.create = true;
@@ -640,8 +791,10 @@ impl ArchiveApp {
640791 self.folder.clear();
641792 self.search.clear();
642793 self.clear_list_selection();
794추가: self.close_find();
643795 self.targets = None;
644796 self.directories.clear();
797추가: crate::log_debug!("압축파일 열기: {}", archive.display());
645798 self.start(Start::List { archive });
646799 }
647800
@@ -1145,6 +1298,27 @@ impl ArchiveApp {
11451298 self.clear_password();
11461299 }
11471300 self.password_challenge = challenge;
1301추가: // Esc 처리에 쓰려고 그리기 전에 입력란 초점과 열린 자식 창을 기억함.
1302추가: self.escape_handled = false;
1303추가: let (text_focused, main_search_focused) = self.text_focus_before;
1304추가: let child_open = self.child_window_open();
1305추가: if self.model.archive.is_some()
1306추가: && !self.main_modal_open()
1307추가: && !self.preview_open
1308추가: && self.model.close == Close::Open
1309추가: {
1310추가: // 더 구체적인 Ctrl+Shift+F를 먼저 확인함.
1311추가: if ctx.input_mut(|i| {
1312추가: i.consume_key(
1313추가: egui::Modifiers::COMMAND | egui::Modifiers::SHIFT,
1314추가: egui::Key::F,
1315추가: )
1316추가: }) {
1317추가: self.open_find(true);
1318추가: } else if ctx.input_mut(|i| i.consume_key(egui::Modifiers::COMMAND, egui::Key::F)) {
1319추가: self.open_find(false);
1320추가: }
1321추가: }
11481322 let dropped = ctx.input(|i| {
11491323 i.raw
11501324 .dropped_files
@@ -1319,6 +1493,7 @@ impl ArchiveApp {
13191493 self.work_window(&ctx);
13201494 self.limit_result_dialog(&ctx);
13211495 self.create_window(&ctx);
1496추가: self.find_window(&ctx);
13221497 if self.model.challenge.is_some() {
13231498 self.password_dialog(&ctx, new_challenge);
13241499 }
@@ -1328,6 +1503,11 @@ impl ArchiveApp {
13281503 }
13291504 self.close_dialog(&ctx);
13301505 self.picker_notice(&ctx);
1506추가: self.handle_escape(&ctx, text_focused, main_search_focused, child_open);
1507추가: self.text_focus_before = (
1508추가: ctx.text_edit_focused(),
1509추가: ctx.memory(|m| m.has_focus(egui::Id::unique("archive-search"))),
1510추가: );
13311511 if !preview_was_open
13321512 && !self.preview_open
13331513 && !self.model.busy()
@@ -1343,6 +1523,386 @@ impl ArchiveApp {
13431523 }
13441524 }
13451525
1526추가: /// 메인 창 위에 자식 창(모달, 작업 창, 만들기 창, 찾기 창 등)이 떠 있는지.
1527추가: fn child_window_open(&self) -> bool {
1528추가: self.find.open
1529추가: || self.preview_open
1530추가: || self.create
1531추가: || self.picker.is_some()
1532추가: || self.model.challenge.is_some()
1533추가: || self.model.resource.is_some()
1534추가: || self.model.conflict.is_some()
1535추가: || self.model.close != Close::Open
1536추가: || self.work_visible()
1537추가: }
1538추가:
1539추가: /// 다른 곳에서 처리하지 않은 Esc를 처리함. 자식 창이 떠 있으면 그 창을 닫고,
1540추가: /// 아무 창도 없으면 프로그램을 종료함(작업 중이면 기존 종료 확인을 거침).
1541추가: /// 암호 입력, 미리보기 등 모달은 Esc를 직접 받아 닫으므로 여기까지 오지 않음.
1542추가: fn handle_escape(
1543추가: &mut self,
1544추가: ctx: &egui::Context,
1545추가: text_focused: bool,
1546추가: main_search_focused: bool,
1547추가: child_open: bool,
1548추가: ) {
1549추가: if self.escape_handled
1550추가: || self.picker.is_some()
1551추가: || !ctx.input(|i| i.key_pressed(egui::Key::Escape))
1552추가: {
1553추가: return;
1554추가: }
1555추가: let consume = |ctx: &egui::Context| {
1556추가: ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape))
1557추가: };
1558추가: if child_open {
1559추가: if self.find.open && !main_search_focused {
1560추가: consume(ctx);
1561추가: crate::log_debug!("Esc: 찾기 창 닫기");
1562추가: self.close_find();
1563추가: } else if matches!(self.model.close, Close::Confirm | Close::Waiting) {
1564추가: consume(ctx);
1565추가: crate::log_debug!("Esc: 종료 확인 취소");
1566추가: self.model.keep_open();
1567추가: } else if self.create && !self.model.busy() {
1568추가: consume(ctx);
1569추가: crate::log_debug!("Esc: 만들기 창 닫기");
1570추가: self.close_create();
1571추가: } else if !self.model.busy() && self.work_visible() {
1572추가: consume(ctx);
1573추가: crate::log_debug!("Esc: 작업 결과 창 닫기");
1574추가: self.dismissed = true;
1575추가: self.ui_error = None;
1576추가: self.model.input_error = None;
1577추가: }
1578추가: // 진행 중인 작업 창은 Esc로 닫지 않음. 취소는 [취소] 버튼으로 함.
1579추가: return;
1580추가: }
1581추가: if text_focused {
1582추가: // 입력란에서 누른 Esc는 입력란 초점만 해제함.
1583추가: return;
1584추가: }
1585추가: consume(ctx);
1586추가: crate::log_info!("Esc: 프로그램 종료 요청");
1587추가: ctx.send_viewport_cmd_to(egui::ViewportId::ROOT, egui::ViewportCommand::Close);
1588추가: }
1589추가:
1590추가: /// 찾기 창. 진행·결과 창처럼 부모 창을 따라가는 별도 창으로 띄우고,
1591추가: /// 별도 창을 만들 수 없는 환경(시험 등)에서는 메인 창 안의 창으로 띄움.
1592추가: fn find_window(&mut self, ctx: &egui::Context) {
1593추가: if !self.find.open {
1594추가: return;
1595추가: }
1596추가: if self.model.archive.is_none() || self.model.list_id.is_none() {
1597추가: self.close_find();
1598추가: return;
1599추가: }
1600추가: if self.main_modal_open() || self.preview_open {
1601추가: // 암호 입력 등 모달을 가리지 않게 잠시 숨김.
1602추가: self.find.win.open = false;
1603추가: return;
1604추가: }
1605추가: let title = if self.find.whole_path {
1606추가: "전체 경로에서 찾기"
1607추가: } else {
1608추가: "찾기"
1609추가: };
1610추가: let mut chosen = None;
1611추가: let mut close = false;
1612추가: if ctx.embed_viewports() || self.work_in_parent {
1613추가: egui::Window::new(title)
1614추가: .id(egui::Id::unique("archive-find-in-parent"))
1615추가: .title_bar(false)
1616추가: .default_pos(ctx.content_rect().right_top() + egui::vec2(-FIND_WIDTH - 24.0, 24.0))
1617추가: .default_width(FIND_WIDTH)
1618추가: .min_width(FIND_WIDTH)
1619추가: .max_width(FIND_WIDTH)
1620추가: .collapsible(false)
1621추가: .resizable(false)
1622추가: .fade_in(false)
1623추가: .fade_out(false)
1624추가: .frame(
1625추가: egui::Frame::new()
1626추가: .fill(theme::PANEL)
1627추가: .stroke(egui::Stroke::new(1.0, theme::BORDER))
1628추가: .inner_margin(egui::Margin::ZERO)
1629추가: .corner_radius(0),
1630추가: )
1631추가: .show(ctx, |ui| {
1632추가: let spacing = ui.spacing().item_spacing.y;
1633추가: ui.spacing_mut().item_spacing.y = 0.0;
1634추가: close = window_frame::in_parent_title(ui, "find-in-parent", title, true);
1635추가: egui::Frame::new()
1636추가: .inner_margin(egui::Margin::same(theme::PAD))
1637추가: .show(ui, |ui| {
1638추가: ui.spacing_mut().item_spacing.y = spacing;
1639추가: ui.set_width(FIND_WIDTH - 2.0 * theme::PAD as f32);
1640추가: let list_height = (ctx.content_rect().height() - 260.0)
1641추가: .clamp(120.0, FIND_HEIGHT - 200.0);
1642추가: chosen = self.find_contents(ui, list_height, false);
1643추가: });
1644추가: });
1645추가: } else {
1646추가: let id = egui::ViewportId::from_hash_of("archive-find");
1647추가: let window_title = format!("{title} — Zipelo");
1648추가: let custom_frame = self.custom_frame;
1649추가: let builder = self.find.win.builder(
1650추가: ctx,
1651추가: id,
1652추가: egui::vec2(FIND_WIDTH, FIND_HEIGHT),
1653추가: &window_title,
1654추가: !custom_frame,
1655추가: self.picker.is_some(),
1656추가: );
1657추가: ctx.show_viewport_immediate(id, builder, |ui, class| {
1658추가: if ui.ctx().input(|i| i.viewport().close_requested()) {
1659추가: close = true;
1660추가: }
1661추가: if ui
1662추가: .ctx()
1663추가: .input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape))
1664추가: {
1665추가: crate::log_debug!("Esc: 찾기 창 닫기");
1666추가: close = true;
1667추가: }
1668추가: // 찾기 창 안에서도 단축키로 찾는 범위를 바꿀 수 있음.
1669추가: if ui.ctx().input_mut(|i| {
1670추가: i.consume_key(
1671추가: egui::Modifiers::COMMAND | egui::Modifiers::SHIFT,
1672추가: egui::Key::F,
1673추가: )
1674추가: }) {
1675추가: self.find.whole_path = true;
1676추가: self.find.base.clear();
1677추가: self.find.focus_query = true;
1678추가: } else if ui
1679추가: .ctx()
1680추가: .input_mut(|i| i.consume_key(egui::Modifiers::COMMAND, egui::Key::F))
1681추가: {
1682추가: self.find.whole_path = false;
1683추가: self.find.base = self.folder.clone();
1684추가: self.find.focus_query = true;
1685추가: }
1686추가: if class == egui::ViewportClass::EmbeddedWindow {
1687추가: ui.set_width(FIND_WIDTH);
1688추가: chosen = self.find_contents(ui, FIND_HEIGHT - 200.0, false);
1689추가: return;
1690추가: }
1691추가: if custom_frame {
1692추가: window_frame::title_bar(
1693추가: ui,
1694추가: "find",
1695추가: &window_title,
1696추가: window_frame::Buttons {
1697추가: minimize: false,
1698추가: maximize: false,
1699추가: },
1700추가: );
1701추가: window_frame::edges(ui.ctx(), false);
1702추가: }
1703추가: egui::CentralPanel::default()
1704추가: .frame(
1705추가: theme::panel(theme::PANEL)
1706추가: .corner_radius(0)
1707추가: .inner_margin(egui::Margin::same(theme::PAD)),
1708추가: )
1709추가: .show(ui, |ui| {
1710추가: chosen = self.find_contents(ui, 0.0, true);
1711추가: });
1712추가: });
1713추가: }
1714추가: if let Some(found) = chosen {
1715추가: self.go_to_found(&found);
1716추가: } else if close {
1717추가: self.close_find();
1718추가: }
1719추가: }
1720추가:
1721추가: /// 찾기 창 내용: 위쪽 검색어 입력란과 그 아래 세로로 긴 결과 목록.
1722추가: /// `list_height`가 0이면 남은 높이를 모두 목록에 씀. `own_keyboard`가 true면
1723추가: /// 창 전체가 찾기 창이므로 입력란에 초점이 없어도 화살표와 Enter를 받음.
1724추가: /// 결과를 골랐으면(더블클릭 또는 Enter) 그 결과를 돌려줌.
1725추가: fn find_contents(
1726추가: &mut self,
1727추가: ui: &mut egui::Ui,
1728추가: list_height: f32,
1729추가: own_keyboard: bool,
1730추가: ) -> Option<browser::Found> {
1731추가: self.refresh_find();
1732추가: let scope = if self.find.whole_path {
1733추가: "압축파일 전체 경로에서 찾습니다".to_owned()
1734추가: } else {
1735추가: format!("/{} 아래 모든 폴더에서 이름으로 찾습니다", self.find.base)
1736추가: };
1737추가: let width = ui.available_width();
1738추가: ui.add(egui::Label::new(RichText::new(&scope).color(theme::MUTED)).truncate())
1739추가: .on_hover_text(&scope);
1740추가: ui.add_space(theme::SPACE / 2.0);
1741추가: let query_id = egui::Id::unique("archive-find-query");
1742추가: let edit = ui.add(
1743추가: egui::TextEdit::singleline(&mut self.find.query)
1744추가: .id(query_id)
1745추가: .char_limit(512)
1746추가: .desired_width(width)
1747추가: .hint_text(if self.find.whole_path {
1748추가: "찾을 경로 입력"
1749추가: } else {
1750추가: "찾을 이름 입력"
1751추가: }),
1752추가: );
1753추가: theme::focus(&edit);
1754추가: if std::mem::take(&mut self.find.focus_query) {
1755추가: edit.request_focus();
1756추가: }
1757추가: if edit.changed() {
1758추가: self.refresh_find();
1759추가: self.find.cursor = (!self.find.results.is_empty()).then_some(0);
1760추가: self.find.offset = 0.0;
1761추가: self.find.scroll_to_cursor = true;
1762추가: }
1763추가: let keyboard = own_keyboard || edit.has_focus() || edit.lost_focus();
1764추가: let count = self.find.results.len();
1765추가: let mut chosen = None;
1766추가: if keyboard && count > 0 {
1767추가: let (down, up, enter) = ui.input(|i| {
1768추가: (
1769추가: i.key_pressed(egui::Key::ArrowDown),
1770추가: i.key_pressed(egui::Key::ArrowUp),
1771추가: i.key_pressed(egui::Key::Enter),
1772추가: )
1773추가: });
1774추가: if down || up {
1775추가: let index = match self.find.cursor {
1776추가: None => 0,
1777추가: Some(index) if down => (index + 1).min(count - 1),
1778추가: Some(index) => index.saturating_sub(1),
1779추가: };
1780추가: self.find.cursor = Some(index);
1781추가: self.find.scroll_to_cursor = true;
1782추가: }
1783추가: if enter {
1784추가: chosen = Some(self.find.cursor.unwrap_or(0));
1785추가: }
1786추가: }
1787추가: ui.add_space(theme::SPACE / 2.0);
1788추가: let status = if self.find.query.trim().is_empty() {
1789추가: "검색어를 입력하세요".to_owned()
1790추가: } else if count == 0 {
1791추가: "찾은 항목이 없습니다".to_owned()
1792추가: } else if self.find.truncated {
1793추가: format!("처음 {count}개만 표시합니다. 검색어를 더 구체적으로 입력하세요")
1794추가: } else {
1795추가: format!("{count}개 찾음 · 두 번 누르거나 Enter로 이동")
1796추가: };
1797추가: ui.add(
1798추가: egui::Label::new(
1799추가: RichText::new(status)
1800추가: .size(theme::FONT_SMALL)
1801추가: .color(theme::MUTED),
1802추가: )
1803추가: .truncate(),
1804추가: );
1805추가: ui.add_space(theme::SPACE / 2.0);
1806추가: let height = if list_height > 0.0 {
1807추가: list_height
1808추가: } else {
1809추가: ui.available_height().max(FIND_ROW)
1810추가: };
1811추가: let (frame_rect, _) =
1812추가: ui.allocate_exact_size(egui::vec2(width, height), egui::Sense::hover());
1813추가: theme::boxed_field(ui, frame_rect);
1814추가: let mut list_ui = ui.new_child(
1815추가: egui::UiBuilder::new()
1816추가: .max_rect(frame_rect.shrink(1.0))
1817추가: .layout(Layout::top_down(Align::Min)),
1818추가: );
1819추가: let viewport_height = frame_rect.height() - 2.0;
1820추가: if self.find.scroll_to_cursor
1821추가: && let Some(index) = self.find.cursor
1822추가: {
1823추가: let top = index as f32 * FIND_ROW;
1824추가: if top < self.find.offset {
1825추가: self.find.offset = top;
1826추가: } else if top + FIND_ROW > self.find.offset + viewport_height {
1827추가: self.find.offset = top + FIND_ROW - viewport_height;
1828추가: }
1829추가: }
1830추가: let mut area = egui::ScrollArea::vertical()
1831추가: .id_salt("archive-find-results")
1832추가: .auto_shrink([false, false]);
1833추가: if std::mem::take(&mut self.find.scroll_to_cursor) {
1834추가: area = area.vertical_scroll_offset(self.find.offset);
1835추가: }
1836추가: let output = area.show_rows(&mut list_ui, FIND_ROW, count, |ui, range| {
1837추가: ui.spacing_mut().item_spacing.y = 0.0;
1838추가: let row_width = ui.available_width();
1839추가: for index in range {
1840추가: let found = &self.find.results[index];
1841추가: let (rect, response) =
1842추가: ui.allocate_exact_size(egui::vec2(row_width, FIND_ROW), egui::Sense::click());
1843추가: theme::pointer(&response);
1844추가: let parent = format!(
1845추가: "/{}",
1846추가: found.path.rsplit_once('/').map_or("", |(parent, _)| parent)
1847추가: );
1848추가: response.widget_info(|| {
1849추가: egui::WidgetInfo::selected(
1850추가: egui::Role::ListBoxOption,
1851추가: true,
1852추가: self.find.cursor == Some(index),
1853추가: &found.path,
1854추가: )
1855추가: });
1856추가: theme::row_background(
1857추가: ui,
1858추가: rect,
1859추가: self.find.cursor == Some(index),
1860추가: response.hovered(),
1861추가: );
1862추가: ui.scope_builder(
1863추가: egui::UiBuilder::new()
1864추가: .max_rect(rect.shrink2(egui::vec2(10.0, 4.0)))
1865추가: .layout(Layout::left_to_right(Align::Center)),
1866추가: |ui| {
1867추가: ui.style_mut().interaction.selectable_labels = false;
1868추가: theme::icon(
1869추가: ui,
1870추가: if found.directory {
1871추가: Icon::Folder
1872추가: } else {
1873추가: Icon::File
1874추가: },
1875추가: 20.0,
1876추가: );
1877추가: ui.add_space(6.0);
1878추가: let text_width = ui.available_width();
1879추가: ui.vertical(|ui| {
1880추가: ui.spacing_mut().item_spacing.y = 0.0;
1881추가: theme::bounded_text_hover(ui, &found.name, &found.path, text_width);
1882추가: ui.add_sized(
1883추가: egui::vec2(text_width, 18.0),
1884추가: egui::Label::new(
1885추가: RichText::new(&parent)
1886추가: .size(theme::FONT_SMALL)
1887추가: .color(theme::MUTED),
1888추가: )
1889추가: .truncate(),
1890추가: );
1891추가: });
1892추가: },
1893추가: );
1894추가: if response.clicked() {
1895추가: self.find.cursor = Some(index);
1896추가: }
1897추가: if response.double_clicked() {
1898추가: chosen = Some(index);
1899추가: }
1900추가: }
1901추가: });
1902추가: self.find.offset = output.state.offset().y;
1903추가: chosen.and_then(|index| self.find.results.get(index).cloned())
1904추가: }
1905추가:
13461906 // 선택 창이 열려 있는 동안 다른 조작을 막고, 응답을 받도록 화면을 계속 갱신함.
13471907 fn picker_notice(&mut self, ctx: &egui::Context) {
13481908 if self.picker.is_none() {
@@ -1537,6 +2097,9 @@ impl ArchiveApp {
15372097 );
15382098 background
15392099 .widget_info(|| egui::WidgetInfo::labeled(egui::Role::ListBox, active, "파일 목록"));
2100추가: if active && std::mem::take(&mut self.focus_list) {
2101추가: background.request_focus();
2102추가: }
15402103 if background.has_focus() {
15412104 ui.ctx().memory_mut(|memory| {
15422105 memory.set_focus_lock_filter(
@@ -1705,7 +2268,10 @@ impl ArchiveApp {
17052268 }
17062269 if active {
17072270 response.context_menu(|ui| {
1708삭제: if ui.button("압축 파일명으로 새 폴더를 만들어 압축 풀기").clicked() {
2271추가: if ui
2272추가: .button("압축 파일명으로 새 폴더를 만들어 압축 풀기")
2273추가: .clicked()
2274추가: {
17092275 menu_action = Some(MenuAction::NewFolder);
17102276 }
17112277 if ui.button("특정 폴더에 압축 풀기").clicked() {
@@ -1725,13 +2291,9 @@ impl ArchiveApp {
17252291 row.directory,
17262292 &name,
17272293 &row.name,
1728삭제: if row.directory {
1729삭제: "0 B".into()
1730삭제: } else {
1731삭제: row.bytes
1732삭제: .map(present::bytes_text)
1733삭제: .unwrap_or_else(|| "—".into())
1734삭제: },
2294추가: row.bytes
2295추가: .map(present::bytes_text)
2296추가: .unwrap_or_else(|| "—".into()),
17352297 name_width,
17362298 );
17372299 if active
@@ -1802,10 +2364,14 @@ impl ArchiveApp {
18022364 }
18032365 let modifiers = ui.input(|i| i.modifiers);
18042366 let ctrl = modifiers.ctrl || modifiers.command;
1805삭제: if ui.input(|i| i.key_pressed(egui::Key::Escape)) {
2367추가: // 선택이 있으면 Esc는 선택만 해제함. 선택이 없으면 창 닫기로 넘김.
2368추가: if (!self.model.selected.is_empty() || self.marquee.is_some())
2369추가: && ui.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape))
2370추가: {
18062371 self.model.selected.clear();
18072372 self.marquee = None;
18082373 background.request_focus();
2374추가: self.escape_handled = true;
18092375 }
18102376 if ctrl && ui.input(|i| i.key_pressed(egui::Key::A)) {
18112377 self.model.selected = rows
@@ -2262,6 +2828,17 @@ impl ArchiveApp {
22622828 self.picker.is_some(),
22632829 );
22642830 let height = ctx.show_viewport_immediate(id, builder, |ui, class| {
2831추가: // 끝난 작업의 결과 창은 Esc로 닫음. 진행 중에는 [취소] 버튼을 씀.
2832추가: if !self.model.busy()
2833추가: && ui
2834추가: .ctx()
2835추가: .input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape))
2836추가: {
2837추가: crate::log_debug!("Esc: 작업 결과 창 닫기");
2838추가: self.dismissed = true;
2839추가: self.ui_error = None;
2840추가: self.model.input_error = None;
2841추가: }
22652842 if ui.ctx().input(|i| i.viewport().close_requested()) {
22662843 if self.model.busy() {
22672844 ui.ctx()
@@ -3039,10 +3616,19 @@ impl ArchiveApp {
30393616 self.create_win
30403617 .builder(ctx, id, size, title, !custom_frame, self.picker.is_some());
30413618 let mut close = false;
3619추가: let picker_open = self.picker.is_some();
30423620 let height = ctx.show_viewport_immediate(id, builder, |ui, class| {
30433621 if ui.ctx().input(|i| i.viewport().close_requested()) {
30443622 close = true;
30453623 }
3624추가: if !picker_open
3625추가: && ui
3626추가: .ctx()
3627추가: .input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape))
3628추가: {
3629추가: crate::log_debug!("Esc: 만들기 창 닫기");
3630추가: close = true;
3631추가: }
30463632 if class == egui::ViewportClass::EmbeddedWindow {
30473633 ui.set_width(CREATE_WIDTH);
30483634 close |= self.create_area(ui);
수정experiments/rust-ui-memory-app/src/archive_ui.rs+83-5
@@ -607,8 +607,13 @@ impl Model {
607607 expanded: bool,
608608 ) -> bool {
609609 if self.busy() || self.close != Close::Open {
610추가: crate::log_debug!("작업을 시작하지 않음: 다른 작업 중이거나 닫는 중");
610611 return false;
611612 }
613추가: crate::log_debug!(
614추가: "작업 시작 요청 (확대 한도: {expanded}): {}",
615추가: crate::applog::brief(&start, 600)
616추가: );
612617 let selectable: BTreeSet<_> = self
613618 .entries
614619 .iter()
@@ -800,6 +805,7 @@ impl Model {
800805 return false;
801806 }
802807 };
808추가: crate::log_debug!("암호 전달 (요청 {challenge_id}, 내용은 기록하지 않음)");
803809 if self
804810 .send(Command::Password {
805811 challenge_id,
@@ -844,6 +850,32 @@ impl Model {
844850 return None;
845851 }
846852 let seq = run.outgoing;
853추가: if crate::applog::enabled(crate::applog::Level::Trace) {
854추가: // 암호는 내용 없이 요청 번호만 남김.
855추가: let text = match &command {
856추가: Command::Start(start) => format!("Start {}", crate::applog::brief(start, 400)),
857추가: Command::StartExpanded(start) => {
858추가: format!("StartExpanded {}", crate::applog::brief(start, 400))
859추가: }
860추가: Command::ResourceReply {
861추가: challenge_id,
862추가: allow,
863추가: ..
864추가: } => format!("ResourceReply challenge={challenge_id} allow={allow}"),
865추가: Command::Password { challenge_id, .. } => {
866추가: format!("Password challenge={challenge_id}")
867추가: }
868추가: Command::ConflictReply {
869추가: challenge_id,
870추가: choice,
871추가: apply_to_remaining,
872추가: } => format!(
873추가: "ConflictReply challenge={challenge_id} choice={choice:?} apply={apply_to_remaining}"
874추가: ),
875추가: Command::Cancel => "Cancel".into(),
876추가: };
877추가: crate::log_trace!("작업 {} #{seq} 송신: {text}", run.id);
878추가: }
847879 let Some(next) = seq.checked_add(1) else {
848880 self.error = Some("요청 순서 한도 초과".into());
849881 return None;
@@ -864,6 +896,7 @@ impl Model {
864896 }
865897 }
866898 pub fn cancel(&mut self) {
899추가: crate::log_debug!("작업 취소 요청");
867900 self.preview = None;
868901 if let Some(run) = self.running.as_mut()
869902 && matches!(run.start, Start::Preview { .. })
@@ -944,6 +977,20 @@ impl Model {
944977 let mut run = self.running.take().unwrap();
945978 self.confirmed =
946979 self.terminal.is_some() && run.exit == Some(true) && self.error.is_none();
980추가: match (&self.terminal, &self.error) {
981추가: (_, Some(error)) => crate::log_error!("작업 {} 실패: {error}", run.id),
982추가: (Some(terminal), None) if terminal.error.is_some() => crate::log_warn!(
983추가: "작업 {} 끝남: {}",
984추가: run.id,
985추가: crate::applog::brief(terminal, 400)
986추가: ),
987추가: (Some(terminal), None) => crate::log_info!(
988추가: "작업 {} 끝남: {}",
989추가: run.id,
990추가: crate::applog::brief(terminal, 400)
991추가: ),
992추가: (None, None) => crate::log_warn!("작업 {} 종료 결과 없음", run.id),
993추가: }
947994 if !self.confirmed {
948995 self.error.get_or_insert(
949996 "작업자 종료 결과를 확인할 수 없습니다. 출력 상태를 확인하세요".into(),
@@ -1030,16 +1077,47 @@ impl Model {
10301077 fn receive(&mut self, host: HostEvent) {
10311078 let run = self.running.as_mut().unwrap();
10321079 match host {
1033삭제: HostEvent::Fault(message) => self.error = Some(message),
1034삭제: HostEvent::CleanupComplete => run.transport_closed = true,
1035삭제: HostEvent::StdoutEof => run.stdout_eof = true,
1036삭제: HostEvent::StderrEof => run.stderr_eof = true,
1037삭제: HostEvent::Exited { success } => run.exit = Some(success),
1080추가: HostEvent::Fault(message) => {
1081추가: crate::log_error!("작업자 통신 오류: {message}");
1082추가: self.error = Some(message)
1083추가: }
1084추가: HostEvent::CleanupComplete => {
1085추가: crate::log_trace!("작업 {} 통신 정리 완료", run.id);
1086추가: run.transport_closed = true
1087추가: }
1088추가: HostEvent::StdoutEof => {
1089추가: crate::log_trace!("작업 {} 표준 출력 끝", run.id);
1090추가: run.stdout_eof = true
1091추가: }
1092추가: HostEvent::StderrEof => {
1093추가: crate::log_trace!("작업 {} 표준 오류 끝", run.id);
1094추가: run.stderr_eof = true
1095추가: }
1096추가: HostEvent::Exited { success } => {
1097추가: if success {
1098추가: crate::log_debug!("작업 {} 작업자 종료 (성공)", run.id);
1099추가: } else {
1100추가: crate::log_warn!("작업 {} 작업자 종료 (실패)", run.id);
1101추가: }
1102추가: run.exit = Some(success)
1103추가: }
10381104 HostEvent::Frame {
10391105 job_id,
10401106 sequence,
10411107 event,
10421108 } => {
1109추가: if crate::applog::enabled(crate::applog::Level::Trace) {
1110추가: match &event {
1111추가: Event::PreviewChunk { offset, data, .. } => crate::log_trace!(
1112추가: "작업 {job_id} #{sequence} 미리보기 조각 offset={offset} len={}",
1113추가: data.len()
1114추가: ),
1115추가: event => crate::log_trace!(
1116추가: "작업 {job_id} #{sequence} 수신: {}",
1117추가: crate::applog::brief(event, 400)
1118추가: ),
1119추가: }
1120추가: }
10431121 if job_id != run.id
10441122 || sequence != run.incoming
10451123 || self.terminal.is_some()
수정experiments/rust-ui-memory-app/src/desktop.rs+13-0
@@ -15,7 +15,16 @@ mod renderer;
1515mod system_font;
1616use eframe::egui;
1717fn main() -> eframe::Result {
18추가: zipelo_ui_memory_app::log_info!(
19추가: "Zipelo {} 시작 (로그 단계 {:?}, ZIPELO_LOG로 변경 가능)",
20추가: env!("CARGO_PKG_VERSION"),
21추가: zipelo_ui_memory_app::applog::level()
22추가: );
1823 let result = run();
24추가: match &result {
25추가: Ok(()) => zipelo_ui_memory_app::log_info!("Zipelo 정상 종료"),
26추가: Err(error) => zipelo_ui_memory_app::log_error!("Zipelo 시작 또는 실행 실패: {error}"),
27추가: }
1928 #[cfg(all(
2029 target_os = "windows",
2130 not(all(feature = "ui-fixture", debug_assertions))
@@ -84,6 +93,10 @@ fn run() -> eframe::Result {
8493 )
8594 .map_err(|e| eframe::Error::AppCreation(Box::new(std::io::Error::other(e))))?;
8695 let custom_frame = zipelo_ui_memory_app::window_frame::custom_frame_needed();
96추가: zipelo_ui_memory_app::log_debug!(
97추가: "실행 인자 해석: 시험 모드={fixture}, 시작 파일={:?}, 직접 그린 창 테두리={custom_frame}",
98추가: startup
99추가: );
87100 // 운영체제 한글 글꼴은 Pretendard에 없는 글자를 위한 대체 글꼴로만 씀.
88101 let fallback = system_font::load()
89102 .ok()
수정experiments/rust-ui-memory-app/src/lib.rs+2-0
@@ -3,6 +3,8 @@
33#[cfg(all(feature = "ui-fixture", debug_assertions))]
44extern crate self as zipelo_ui_memory_app;
55
6추가: pub mod applog;
7추가:
68pub mod archive_ui;
79
810#[cfg(feature = "ui")]
추가tests/rust-app-ui/find_escape.rs+249-0
@@ -0,0 +1,249 @@
1추가: // 찾기 창(Ctrl+F, Ctrl+Shift+F), 폴더 크기와 Esc 동작 시험.
2추가: // presentation.rs의 widgets 모듈 안에 explorer_selection.rs 다음으로 포함됨.
3추가:
4추가: fn find_ctrl(shift: bool) -> egui::Modifiers {
5추가: // Linux와 Windows의 실제 입력처럼 ctrl과 command를 함께 켬.
6추가: egui::Modifiers {
7추가: ctrl: true,
8추가: command: true,
9추가: shift,
10추가: ..egui::Modifiers::NONE
11추가: }
12추가: }
13추가:
14추가: fn press(s: &mut Explorer, key: egui::Key, modifiers: egui::Modifiers) -> Vec<egui::FullOutput> {
15추가: let mut outputs = Vec::new();
16추가: for pressed in [true, false] {
17추가: outputs.push(s.frame(
18추가: modifiers,
19추가: vec![egui::Event::Key {
20추가: key,
21추가: physical_key: None,
22추가: pressed,
23추가: repeat: false,
24추가: modifiers,
25추가: }],
26추가: ));
27추가: }
28추가: outputs
29추가: }
30추가:
31추가: fn close_requested(outputs: &[egui::FullOutput]) -> bool {
32추가: outputs.iter().any(|output| {
33추가: output
34추가: .viewport_output
35추가: .get(&egui::ViewportId::ROOT)
36추가: .is_some_and(|viewport| {
37추가: viewport
38추가: .commands
39추가: .iter()
40추가: .any(|command| *command == egui::ViewportCommand::Close)
41추가: })
42추가: })
43추가: }
44추가:
45추가: fn find_entries() -> Vec<Entry> {
46추가: [
47추가: (0, "docs/child.txt", Kind::File, Some(7)),
48추가: (1, "docs/deep/report.TXT", Kind::File, Some(1000)),
49추가: (2, "alpha.txt", Kind::File, Some(3)),
50추가: (3, "docs", Kind::Directory, Some(0)),
51추가: (4, "music/child-song.mp3", Kind::File, None),
52추가: ]
53추가: .map(|(id, name, kind, bytes)| Entry {
54추가: id,
55추가: name: name.into(),
56추가: kind,
57추가: bytes,
58추가: packed: None,
59추가: encrypted: false,
60추가: })
61추가: .into()
62추가: }
63추가:
64추가: #[test]
65추가: fn folder_rows_show_the_sum_of_contained_file_sizes() {
66추가: use zipelo_ui_memory_app::archive_browser::rows;
67추가: let entries = find_entries();
68추가: let root = rows(&entries, "", "");
69추가: let size = |name: &str| root.iter().find(|row| row.name == name).unwrap().bytes;
70추가: // 명시된 폴더와 하위 폴더의 파일을 모두 더함.
71추가: assert_eq!(size("docs"), Some(1007));
72추가: // 압축파일에 따로 없는 폴더도 크기를 알 수 없는 파일은 0으로 보고 더함.
73추가: assert_eq!(size("music"), Some(0));
74추가: assert_eq!(size("alpha.txt"), Some(3));
75추가: let docs = rows(&entries, "docs", "");
76추가: assert_eq!(
77추가: docs.iter().find(|row| row.name == "deep").unwrap().bytes,
78추가: Some(1000)
79추가: );
80추가: // 빈 폴더는 0 B.
81추가: let empty = [Entry {
82추가: id: 0,
83추가: name: "empty/".into(),
84추가: kind: Kind::Directory,
85추가: bytes: None,
86추가: packed: None,
87추가: encrypted: false,
88추가: }];
89추가: assert_eq!(rows(&empty, "", "")[0].bytes, Some(0));
90추가: }
91추가:
92추가: #[test]
93추가: fn find_searches_subfolders_by_name_or_whole_archive_by_path() {
94추가: use zipelo_ui_memory_app::archive_browser::find;
95추가: let entries = find_entries();
96추가: let paths = |base: &str, query: &str, whole: bool| {
97추가: find(&entries, base, query, whole, 100)
98추가: .0
99추가: .into_iter()
100추가: .map(|found| (found.path, found.directory))
101추가: .collect::<Vec<_>>()
102추가: };
103추가: // Ctrl+F: 연 폴더 아래 모든 하위 폴더에서 이름으로 찾음. 대소문자는 구분하지 않음.
104추가: assert_eq!(
105추가: paths("", "child", false),
106추가: [
107추가: ("docs/child.txt".into(), false),
108추가: ("music/child-song.mp3".into(), false)
109추가: ]
110추가: );
111추가: assert_eq!(paths("docs", "child", false), [("docs/child.txt".into(), false)]);
112추가: assert_eq!(
113추가: paths("docs", "txt", false),
114추가: [
115추가: ("docs/child.txt".into(), false),
116추가: ("docs/deep/report.TXT".into(), false)
117추가: ]
118추가: );
119추가: // 압축파일에 따로 없는 하위 폴더도 찾음. 연 폴더 자신은 결과에 넣지 않음.
120추가: assert_eq!(paths("docs", "deep", false), [("docs/deep".into(), true)]);
121추가: assert_eq!(paths("docs", "docs", false), []);
122추가: // 이름만 보므로 상위 폴더 이름으로는 찾지 않음.
123추가: assert_eq!(paths("", "deep", false), [("docs/deep".into(), true)]);
124추가: // Ctrl+Shift+F: 연 폴더와 관계없이 전체 경로에서 찾음.
125추가: assert_eq!(
126추가: paths("music", "deep", true),
127추가: [
128추가: ("docs/deep".into(), true),
129추가: ("docs/deep/report.TXT".into(), false)
130추가: ]
131추가: );
132추가: assert_eq!(paths("", " ", true), []);
133추가: let (limited, truncated) = find(&entries, "", "t", true, 2);
134추가: assert_eq!(limited.len(), 2);
135추가: assert!(truncated);
136추가: }
137추가:
138추가: #[test]
139추가: fn ctrl_f_finds_below_current_folder_and_enter_moves_to_the_file() {
140추가: let scratch = Folder::new();
141추가: let mut s = Explorer::new(&scratch);
142추가: s.app.model.entries = find_entries();
143추가: s.frame(egui::Modifiers::NONE, vec![]);
144추가: press(&mut s, egui::Key::F, find_ctrl(false));
145추가: assert!(s.app.find_open());
146추가: let labels = layout_text(&s.frame(egui::Modifiers::NONE, vec![]));
147추가: assert!(
148추가: labels
149추가: .iter()
150추가: .any(|(text, _, _)| text == "/ 아래 모든 폴더에서 이름으로 찾습니다"),
151추가: "{labels:?}"
152추가: );
153추가: // 입력란에 초점이 있으므로 그대로 입력함.
154추가: s.frame(egui::Modifiers::NONE, vec![egui::Event::Text("report".into())]);
155추가: s.frame(egui::Modifiers::NONE, vec![]);
156추가: assert_eq!(s.app.find_results().len(), 1);
157추가: press(&mut s, egui::Key::Enter, egui::Modifiers::NONE);
158추가: s.frame(egui::Modifiers::NONE, vec![]);
159추가: assert!(!s.app.find_open());
160추가: // 파일이 든 폴더를 열고 그 파일을 선택함.
161추가: s.selected(&[1]);
162추가: let labels = layout_text(&s.frame(egui::Modifiers::NONE, vec![]));
163추가: assert!(labels.iter().any(|(text, _, _)| text == "/docs/deep"), "{labels:?}");
164추가: }
165추가:
166추가: #[test]
167추가: fn ctrl_shift_f_searches_whole_paths_and_double_click_opens_folder() {
168추가: let scratch = Folder::new();
169추가: let mut s = Explorer::new(&scratch);
170추가: s.app.model.entries = find_entries();
171추가: s.app.browse_folder("music");
172추가: s.frame(egui::Modifiers::NONE, vec![]);
173추가: press(&mut s, egui::Key::F, find_ctrl(true));
174추가: assert!(s.app.find_open());
175추가: s.app.set_find_query("deep");
176추가: let labels = layout_text(&s.frame(egui::Modifiers::NONE, vec![]));
177추가: assert!(
178추가: labels
179추가: .iter()
180추가: .any(|(text, _, _)| text == "압축파일 전체 경로에서 찾습니다"),
181추가: "{labels:?}"
182추가: );
183추가: // 첫 "deep"은 검색어 입력란이므로 마지막(결과 행)을 고름.
184추가: let row = labels
185추가: .iter()
186추가: .rev()
187추가: .find(|(text, _, _)| text == "deep")
188추가: .map(|(_, rect, _)| rect.center())
189추가: .expect("찾은 폴더 행");
190추가: s.time += 1.0;
191추가: for _ in 0..2 {
192추가: s.pointer(row, true, egui::Modifiers::NONE);
193추가: s.pointer(row, false, egui::Modifiers::NONE);
194추가: }
195추가: let after = layout_text(&s.frame(egui::Modifiers::NONE, vec![]));
196추가: assert!(!s.app.find_open(), "{row:?} {after:?}");
197추가: let labels = layout_text(&s.frame(egui::Modifiers::NONE, vec![]));
198추가: assert!(labels.iter().any(|(text, _, _)| text == "/docs/deep"), "{labels:?}");
199추가: assert!(labels.iter().any(|(text, _, _)| text == "report.TXT"), "{labels:?}");
200추가: }
201추가:
202추가: #[test]
203추가: fn escape_closes_child_windows_first_and_then_quits() {
204추가: let scratch = Folder::new();
205추가: let mut s = Explorer::new(&scratch);
206추가: // 찾기 창이 떠 있으면 찾기 창만 닫음.
207추가: press(&mut s, egui::Key::F, find_ctrl(false));
208추가: assert!(s.app.find_open());
209추가: let outputs = press(&mut s, egui::Key::Escape, egui::Modifiers::NONE);
210추가: assert!(!s.app.find_open());
211추가: assert!(!close_requested(&outputs));
212추가: // 선택한 항목이 있으면 먼저 선택만 해제함.
213추가: s.click("alpha.txt", egui::Modifiers::NONE);
214추가: s.selected(&[1]);
215추가: let outputs = press(&mut s, egui::Key::Escape, egui::Modifiers::NONE);
216추가: s.selected(&[]);
217추가: assert!(!close_requested(&outputs));
218추가: // 만들기 창이 떠 있으면 그 창을 닫음.
219추가: s.app.show_create(false);
220추가: s.frame(egui::Modifiers::NONE, vec![]);
221추가: let shown = |s: &mut Explorer| {
222추가: layout_text(&s.frame(egui::Modifiers::NONE, vec![]))
223추가: .iter()
224추가: .any(|(text, _, _)| text == "ZIP 만들기")
225추가: };
226추가: assert!(
227추가: shown(&mut s),
228추가: "{:?}",
229추가: layout_text(&s.frame(egui::Modifiers::NONE, vec![]))
230추가: );
231추가: let outputs = press(&mut s, egui::Key::Escape, egui::Modifiers::NONE);
232추가: assert!(!close_requested(&outputs));
233추가: assert!(!shown(&mut s));
234추가: // 아무 자식 창도 없으면 프로그램을 종료함.
235추가: let outputs = press(&mut s, egui::Key::Escape, egui::Modifiers::NONE);
236추가: assert!(close_requested(&outputs));
237추가: }
238추가:
239추가: #[test]
240추가: fn escape_in_the_search_box_only_leaves_the_text_field() {
241추가: let scratch = Folder::new();
242추가: let mut s = Explorer::new(&scratch);
243추가: s.ctx
244추가: .memory_mut(|m| m.request_focus(egui::Id::unique("archive-search")));
245추가: s.frame(egui::Modifiers::NONE, vec![]);
246추가: assert!(s.ctx.text_edit_focused());
247추가: let outputs = press(&mut s, egui::Key::Escape, egui::Modifiers::NONE);
248추가: assert!(!close_requested(&outputs));
249추가: }
수정tests/rust-app-ui/presentation.rs+1-0
@@ -1050,6 +1050,7 @@ mod widgets {
10501050 include!("toolbar.rs");
10511051 include!("long_layout.rs");
10521052 include!("explorer_selection.rs");
1053추가: include!("find_escape.rs");
10531054 include!("window_frame.rs");
10541055 include!("work_window.rs");
10551056 include!("create_window.rs");
수정tests/rust-app-ui/scenario_tests.rs+25-0
@@ -190,6 +190,12 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() {
190190 "password-create" => "암호 확인",
191191 "folder" => "바다.jpg",
192192 "search-empty" => "일치하는 항목이 없습니다",
193추가: "find-folder" => "풍경.jpg",
194추가: "find-all" => "압축파일 전체 경로에서 찾습니다",
195추가: "find-empty" => "찾은 항목이 없습니다",
196추가: "open-blocked" => "안전을 위해 바로 열 수 없습니다",
197추가: "open-failed" => "파일을 열 프로그램을 실행하지 못했습니다",
198추가: "open-missing" => "풀린 파일을 찾지 못해 열지 못했습니다",
193199 "password" | "password-retry" => "암호",
194200 "extract-complete" => "압축을 풀었습니다",
195201 "extract-cancelled" => "작업을 취소했습니다",
@@ -201,6 +207,25 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() {
201207 _ => "읽어주세요.txt",
202208 };
203209 assert!(labels.contains(expected), "{}: {labels}", scenario.name);
210추가: if scenario.name == "archive" {
211추가: // 폴더 크기는 안에 든 파일 크기의 합(1,287,952 B × 2)으로 표시함.
212추가: assert!(labels.contains("2.5 MB"), "{labels}");
213추가: assert!(!labels.contains("0 B"), "{labels}");
214추가: }
215추가: if scenario.name.starts_with("find-") {
216추가: assert!(app.find_open(), "{}", scenario.name);
217추가: let paths: Vec<_> = app
218추가: .find_results()
219추가: .iter()
220추가: .map(|found| found.path.clone())
221추가: .collect();
222추가: let expected: &[&str] = match scenario.name {
223추가: "find-folder" => &["사진/바다.jpg", "사진/풍경.jpg"],
224추가: "find-all" => &["사진", "사진/바다.jpg", "사진/풍경.jpg"],
225추가: _ => &[],
226추가: };
227추가: assert_eq!(paths, expected, "{}", scenario.name);
228추가: }
204229 if scenario.name == "extract-complete-cleanup-failed" {
205230 use zipelo_ui_memory_app::archive_ui::{
206231 Cleanup, Disposition, Outcome, Publication,
수정tests/rust-app-ui/scenarios.rs+24-0
@@ -76,6 +76,12 @@ catalog! {
7676 "selection" => "여러 파일과 폴더 선택",
7777 "marquee" => "반투명 사각형으로 끌어서 선택 중",
7878 "search-empty" => "검색 결과 없음",
79추가: "find-folder" => "Ctrl+F로 연 폴더 아래 이름 찾기 창",
80추가: "find-all" => "Ctrl+Shift+F로 연 전체 경로 찾기 창",
81추가: "find-empty" => "찾기 창의 결과 없음 안내",
82추가: "open-blocked" => "실행 파일을 바로 열지 않는다는 안내",
83추가: "open-failed" => "기본 프로그램 실행 실패 안내",
84추가: "open-missing" => "풀린 파일을 찾지 못해 열지 못한 안내",
7985 "password" => "압축 해제 암호 입력",
8086 "password-retry" => "암호가 틀린 뒤 다시 입력",
8187 "extract-progress" => "압축 해제 진행률 62%",
@@ -546,6 +552,24 @@ impl Scenario {
546552 app.search = "없는 파일".into();
547553 return app;
548554 }
555추가: "find-folder" | "find-all" | "find-empty" => {
556추가: app.open_find(self.name == "find-all");
557추가: app.set_find_query(match self.name {
558추가: "find-folder" => "jpg",
559추가: "find-all" => "사진",
560추가: _ => "없는 이름",
561추가: });
562추가: return app;
563추가: }
564추가: "open-blocked" | "open-failed" | "open-missing" => {
565추가: app.dismissed = false;
566추가: app.ui_error = Some(match self.name {
567추가: "open-blocked" => present::open_blocked_text("설치 프로그램.exe"),
568추가: "open-failed" => "파일을 열 프로그램을 실행하지 못했습니다".into(),
569추가: _ => present::OPEN_MISSING.into(),
570추가: });
571추가: return app;
572추가: }
549573 "selection" | "marquee" => {
550574 app.model
551575 .selected