Real text in the preview, system title bar, toolbar, Discord presence

The preview draws real glyphs on a worker thread, within the GPU's
texture limit. The window uses the system title bar; the top right holds
up to 8 icons chosen in Settings, then the menu logo. Adds a shell
picker, taskbar actions and Discord presence, and drops the Caelestia
and KDE colour choices in favour of Desktop.

Word wrap no longer moves the view. The terminal starts at its final
size and the morph never resizes the shell.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-06 17:41:56 -06:00
commit c9905567a6

View file

@ -48,6 +48,7 @@ fn tour() {
let mut h: H = Harness::builder().with_size(vec2(1400.0, 900.0)).wgpu().build_eframe(move |cc| App::new(cc, vec![file.clone()]));
h.ctx.set_missing_glyph_policy(eframe::epaint::text::MissingGlyphPolicy::Tofu);
settle(&mut h, 40);
assert!(h.state().panes[0].mini.ready(*h.state().docs.keys().next().unwrap()), "preview is up within a moment of opening");
assert_eq!(h.state().docs.len(), 1, "file opened");
assert_eq!(h.state().cur_doc().unwrap().language, "Rust");
shot(&mut h, &out, "01-editor");
@ -61,20 +62,20 @@ fn tour() {
settle(&mut h, 3);
// grab the preview, drag, and catch it while popped out
let rail = pos2(1340.0, 300.0);
let rail = pos2(1330.0, 300.0);
mv(&mut h, rail);
press(&mut h, rail, true);
settle(&mut h, 6);
shot(&mut h, &out, "02-preview-popping");
for i in 0..24 {
mv(&mut h, pos2(1340.0, 300.0 + i as f32 * 12.0));
mv(&mut h, pos2(1330.0, 300.0 + i as f32 * 12.0));
std::thread::sleep(std::time::Duration::from_millis(16));
}
settle(&mut h, 24);
assert!(h.state().panes[0].dragging_mini, "rail is being dragged");
assert!(h.state().panes[0].tabs[0].scroll.x > 100.0, "dragging scrolled the file");
shot(&mut h, &out, "03-preview-lens");
press(&mut h, pos2(1340.0, 588.0), false);
press(&mut h, pos2(1330.0, 588.0), false);
settle(&mut h, 40);
assert!(!h.state().panes[0].dragging_mini);
shot(&mut h, &out, "04-preview-released");
@ -116,6 +117,17 @@ fn tour() {
cmd(&mut h, Cmd::Settings);
settle(&mut h, 20);
shot(&mut h, &out, "11-settings");
h.state_mut().settings_tab = 3;
h.state_mut().shell_open = true;
settle(&mut h, 30);
shot(&mut h, &out, "11b-shells");
h.state_mut().settings_tab = 4;
settle(&mut h, 30);
shot(&mut h, &out, "11c-toolbar");
h.state_mut().settings_tab = 5;
settle(&mut h, 30);
shot(&mut h, &out, "11d-discord");
h.state_mut().settings_tab = 0;
cmd(&mut h, Cmd::Settings);
cmd(&mut h, Cmd::ToggleDark);
@ -198,3 +210,62 @@ fn keyboard_paths() {
assert!(!h.state().term_open, "F4 hides it even with the terminal focused");
std::fs::remove_dir_all(dir).ok();
}
/// Reopening the terminal must not make the shell print its prompt again.
#[test]
fn reopening_terminal_keeps_one_prompt() {
let dir = std::env::temp_dir().join(format!("damson-prompt-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
std::env::set_var("XDG_CONFIG_HOME", dir.join("config"));
let mut h: H = Harness::builder().with_size(vec2(1200.0, 800.0)).wgpu().build_eframe(|cc| App::new(cc, vec![]));
settle(&mut h, 6);
// the login shell here; bash doesn't show the problem
h.state_mut().s.shell = "/usr/bin/fish".into();
let used = |h: &H| h.state().terms[0].screen_text().iter().filter(|r| !r.trim().is_empty()).count();
key(&mut h, egui::Key::F4, Modifiers::NONE);
// let the shell finish starting, then toggle as a person would
for _ in 0..60 { settle(&mut h, 2) }
// real use has output above the prompt, and the morph squeezes the card to a few rows
for i in 0..3 {
h.state().terms[0].write(format!("echo line{i}\r"));
for _ in 0..12 { settle(&mut h, 2) }
}
let first = used(&h);
assert!(first >= 1, "shell printed a prompt");
eprintln!("before: {:#?}", h.state().terms[0].screen_text().iter().filter(|r| !r.trim().is_empty()).map(|r| r.trim_end().to_string()).collect::<Vec<_>>());
for _ in 0..3 {
key(&mut h, egui::Key::F4, Modifiers::NONE);
settle(&mut h, 40);
key(&mut h, egui::Key::F4, Modifiers::NONE);
settle(&mut h, 40);
}
for _ in 0..30 { settle(&mut h, 2) }
eprintln!("after: {:#?}", h.state().terms[0].screen_text().iter().filter(|r| !r.trim().is_empty()).map(|r| r.trim_end().to_string()).collect::<Vec<_>>());
assert_eq!(h.state().terms[0].resizes, 0, "opening and closing never resizes the shell");
assert_eq!(used(&h), first, "screen grew: {:#?}", h.state().terms[0].screen_text().iter().filter(|r| !r.trim().is_empty()).collect::<Vec<_>>());
std::fs::remove_dir_all(dir).ok();
}
/// Toggling wrap with the cursor far away must not move the view, and toggling back returns.
#[test]
fn word_wrap_keeps_your_place() {
let dir = std::env::temp_dir().join(format!("damson-wrap-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
std::env::set_var("XDG_CONFIG_HOME", dir.join("config"));
let file = dir.join("t.txt");
std::fs::write(&file, format!("{}\n", "a fairly long line of plain text that will wrap when the wrap is on and the width is narrow ".repeat(2)).repeat(400)).unwrap();
let f = file.to_string_lossy().into_owned();
let mut h: H = Harness::builder().with_size(vec2(1000.0, 700.0)).wgpu().build_eframe(move |cc| App::new(cc, vec![f.clone()]));
settle(&mut h, 10);
let lh = (h.state().s.font_size * 1.55).round();
h.state_mut().panes[0].tabs[0].scroll.snap(lh * 200.0);
settle(&mut h, 6);
let line_at_top = |h: &H| { let t = &h.state().panes[0].tabs[0]; t.rows.row((t.scroll.x / lh) as usize).0 };
assert_eq!(line_at_top(&h), 200);
cmd(&mut h, Cmd::ToggleWrap);
assert_eq!(line_at_top(&h), 200, "wrap on stays at the same line");
cmd(&mut h, Cmd::ToggleWrap);
assert_eq!(line_at_top(&h), 200, "wrap off is back at the same line");
assert!((h.state().panes[0].tabs[0].scroll.x - lh * 200.0).abs() < lh, "and the same position");
std::fs::remove_dir_all(dir).ok();
}