Add editor text zoom slider
A Zoom slider (with Reset) above the editor scales the monospace font from -50% to +200%, defaulting to 0%. The editor keeps infinite desired width inside a vertical-only scroll area, so text wraps to the pane at any zoom with no horizontal scrolling. The zoom level persists in config. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -64,7 +64,9 @@ Terminal=false
|
||||
After that, the **⟳ Sync (git)** button commits all changes, `pull --rebase`s,
|
||||
and pushes.
|
||||
3. Create files with **+ New**, edit on the right, `Ctrl+S` (or the Save button)
|
||||
to write to disk. Drag the `⠿` handles to reorder.
|
||||
to write to disk. Drag the `⠿` handles to reorder. Use the **Zoom** slider
|
||||
above the editor to scale the editor text (0% = default; **Reset** returns to
|
||||
it). Text always wraps to the pane width, so there is no horizontal scrolling.
|
||||
4. Set the **Chapter title** for the open file if you want to override the
|
||||
auto-derived one (the field shows the automatic title as a hint). Leaving it
|
||||
blank falls back to a `# Title:` line in the header, and if there is none, to
|
||||
|
||||
+33
@@ -664,6 +664,27 @@ impl App {
|
||||
self.dirty = true; // ensure save runs
|
||||
self.save_current();
|
||||
}
|
||||
ui.separator();
|
||||
ui.label("Zoom:");
|
||||
if ui
|
||||
.add(
|
||||
egui::Slider::new(&mut self.config.editor_zoom, -50.0..=200.0)
|
||||
.suffix("%")
|
||||
.step_by(5.0),
|
||||
)
|
||||
.on_hover_text("Editor text size (0% = default)")
|
||||
.changed()
|
||||
{
|
||||
self.config.save();
|
||||
}
|
||||
if ui
|
||||
.button("Reset")
|
||||
.on_hover_text("Reset zoom to 0%")
|
||||
.clicked()
|
||||
{
|
||||
self.config.editor_zoom = 0.0;
|
||||
self.config.save();
|
||||
}
|
||||
});
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Chapter title:");
|
||||
@@ -716,6 +737,17 @@ impl App {
|
||||
}
|
||||
|
||||
fn editor(&mut self, ui: &mut egui::Ui) {
|
||||
// Base monospace size scaled by the zoom percentage. `desired_width` stays
|
||||
// infinite and the scroll area is vertical-only, so text wraps to the pane
|
||||
// width at any zoom (no horizontal scrolling).
|
||||
let base = ui
|
||||
.style()
|
||||
.text_styles
|
||||
.get(&egui::TextStyle::Monospace)
|
||||
.map(|f| f.size)
|
||||
.unwrap_or(12.0);
|
||||
let size = (base * (1.0 + self.config.editor_zoom / 100.0)).max(4.0);
|
||||
|
||||
egui::ScrollArea::vertical()
|
||||
.id_salt("editor")
|
||||
.auto_shrink([false, false])
|
||||
@@ -723,6 +755,7 @@ impl App {
|
||||
let resp = ui.add(
|
||||
egui::TextEdit::multiline(&mut self.buffer)
|
||||
.code_editor()
|
||||
.font(egui::FontId::monospace(size))
|
||||
.desired_width(f32::INFINITY)
|
||||
.desired_rows(30),
|
||||
);
|
||||
|
||||
@@ -20,6 +20,10 @@ pub struct Config {
|
||||
/// zeros to the width of the largest chapter number (e.g. "03." of 12).
|
||||
#[serde(default)]
|
||||
pub zero_pad_index: bool,
|
||||
/// Editor text zoom as a percentage offset from the base size (0 = default,
|
||||
/// +100 = double, -50 = half).
|
||||
#[serde(default)]
|
||||
pub editor_zoom: f32,
|
||||
}
|
||||
|
||||
/// Default header/body separator, matching the manuscript drafting convention.
|
||||
@@ -37,6 +41,7 @@ impl Default for Config {
|
||||
show_preview: false,
|
||||
draft_marker: default_marker(),
|
||||
zero_pad_index: false,
|
||||
editor_zoom: 0.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user