mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-09 20:43:12 +00:00
* M10.20: plan Unicode text for OCR output in Type3 faces (fonts, edit) OCR output used to flatten every character beyond WinAnsi to a silent `?`. This adds the two pieces that let the OCR layers write the recognized words as they are; the OCR code that uses them follows in M10.21. pdfcraft-fonts - `TextPlan::for_words` maps each word to the standard Helvetica when WinAnsi covers it, else to Type3 fonts drawn from the craft-fonts faces (the Japanese document face first, then the rest of the build input). Characters no face has a glyph for are counted (`missing`), never dropped silently. At most 240 characters per font and 2400 per plan, so one hostile word cannot balloon. - Which face has which character is asked once per (face, character) for a plan, not once per word. - `face_has`, `craft_glyph`, `win_ansi_char`, `fits_win_ansi` are public for it. pdfcraft-edit - `add_type3_fonts` / `stamp_with_fonts` register a plan's fonts on a page under a free `PCOcr`, `PCOcr1`, ... name, build each font once and share the object with later pages. A shared face is registered under a free name on a later page that already has a font of the name it was given first, instead of replacing that page's own font. - The fonts carry real advances and a ToUnicode CMap, so extraction reads the text back. pdfcraft-redact - A test shows a hand-built Type3 text layer (the shape the OCR output writes) is redacted like any other text and the verifier passes. Tests: pdfcraft-fonts 62 passed, pdfcraft-edit 129 passed, pdfcraft-redact 33 passed; clippy -D warnings clean on the three crates. The name-reuse and the redaction tests build their fonts by hand, so they run without the craft-fonts build input; the tests that plan real faces skip without it and were not run in this commit's own check. * M12: give the hostile-XFA open test more room on a loaded machine The test opens a form whose calculate script sets a value 50 000 times, against the one-second budget of an unasked script and a five-second wall-clock bound on the open. Both sit close to what a machine running several suites at once can take, so the test can fail without anything being wrong. It now runs 20 000 iterations (the total is 19999) and allows 30 seconds, which still fails for a script that hangs or is not capped. Test-only; unrelated to the OCR work in this series, so it is a commit of its own. Tests: both hostile_xfa tests in pdfcraft-engine pass. * M10.21: pluggable OCR engines, preprocessing, review sessions and the OCR tools (ocr, engine, create, automation) Scan & OCR gets a second engine, optional raster clean-up, a review step before anything is applied, editable output and a batch mode, headlessly first: the interface for them follows in M10.22. pdfcraft-ocr - A `Recognizer` trait with two engines: the built-in ocrs (moved out of lib.rs) and the installed tesseract program, run as a fenced external process: fixed argv, allow-listed language codes, a private temp directory (mode 0700 on Unix), 120 s timeout, 64 MiB output cap, 50 000-word reading cap. A location from PDFCRAFT_TESSERACT is validated (absolute, existing, executable) and an invalid one fails closed instead of falling back to the PATH. `--list-langs` and `--version` are read from stdout or, for older versions, stderr. - Strategies: PrimaryOnly, ConfidenceWeighted (the second engine joins when the first reading's mean is under 70 or unknown) and a ROVER merge (higher confidence wins per word; against an ocrs word of unknown confidence a tesseract word wins only at 70 or more; capped at 100 M comparisons; a failing partner degrades to the primary with a note). - Preprocessing: opt-in auto-rotate, deskew, denoise and binarize on the RGBA raster, each with an exact inverse so word boxes map back to the scan. The 300 dpi normalization the steps are calibrated for runs only when a step is on: with every step off the render is read as rendered, as before. (Enlarging a 72 dpi render 4x on its own made the models read "due: €250" as "ue: ?250".) `OcrImage` is validated by construction (side and 64 MP area caps, checked before any buffer is allocated, including by the resize). - Confidence bands (High >= 90, Medium 70-89, Low < 70) drive review. pdfcraft-engine, pdfcraft-create - `OcrSettings` gains engine, strategy, the four steps, output mode, region, the skip flags and the low-confidence threshold; Automatic reads confidence weighted unless a strategy is chosen. - A recognition is a session: the document guard refuses a stale result with its reason, pages can be applied one at a time (the guard is taken again after each applied page), and applying is one undoable step. A per-language dictionary (a plain-text file: words added from any document stay on disk after it closes). - Output is searchable (an invisible layer) or a NEW editable document of visible text at the recognized boxes (`create::from_contents`); words beyond WinAnsi use the Type3 faces of M10.20 in both, with the shared plan across pages. - Engine discovery never blocks the interface: results are cached, a stale answer is shown while a background probe retries, and the models search and `--version` are cached. Batch: pages or files that already have text are skipped unless forced, and inputs sharing a file name are found up front. pdfcraft-automation - ocr_recognize (engine, strategy, steps, region, output mode), ocr_words (with a retained review handle), ocr_review_apply, ocr_dictionary, ocr_status and ocr_recognize_files. The editable `out` must be a new file inside --root and is refused for a searchable run (it used to be ignored), two batch inputs of one file name are refused before anything is read, and the batch folder is checked for existing outputs. pdfcraft-ui-egui - Only what the new API needs: the Recognize Text dialog reads with `recognizers(&settings)`. `ocr.correct` is registered with its label in every catalog; the screen itself is M10.22. Tests: pdfcraft-ocr 78 passed; pdfcraft-create passed; pdfcraft-engine and pdfcraft-automation 450 passed and 1 failed (the automation lib 17, automation.rs 157, hostile_args 2 among them); pdfcraft-ui-egui lib + ocr + control tests 391 passed; clippy -D warnings clean on the five crates. The one failure is in a test this commit does not change: recognize_text_makes_a_scanned_page_searchable fails where the models are installed (they read "quick" as "auick" at that render size); the roadmap on main already records it. The real tesseract binary ran in tesseract::tests::recognize_runs_the_installed_binary (tesseract 5.4.0, PATH). * M10.22: OCR Verify screen, the Recognize Text options and the interface catalogs (ui-egui) Scan & OCR ▸ Correct recognized text: a full-window screen where a recognition is reviewed before anything is applied, plus the dialog and batch options for the engines of M10.21. OCR Verify screen - Four panes: the page list, the source page with confidence-coloured word boxes (click to select, drag to draw a region), the recognized text, and a zoom plus word inspector. Corrections commit on Enter (an empty commit removes the word), Remove/Restore, "+ Dictionary" (a per-language file in the preferences folder, so a word added from a document stays on disk after it closes), per-word and per-page Verified, F8 / Shift+F8 walk the low-confidence words, Ctrl+T marks the page reviewed, Ctrl+Tab moves the pane focus, and review edits undo within the panel. - Re-OCR of the whole page or a drawn region. A region re-read moves the review marks of the words it keeps to their new positions and selects the first new word; a whole-page re-read clears that page's marks (and the undo brings them back). The region outline is scaled onto the pane, not mapped through user space again, so it is right on rotated and cropped pages. - Accept / Reject per page or whole. Pages accepted one at a time each apply once (the document guard is taken again after each applied page; an edit made elsewhere in between is still refused with its reason), and Accept in searchable mode is one undoable step. Editable mode writes a NEW `<name>_ocr.pdf` through a save dialog and never the source. A real Cancel keeps the pages already read. - The engine and strategy menus disable a choice that cannot run and say why; the check never waits on a process (a background probe fills a cache), and choosing Automatic moves "Primary only" to Confidence weighted. Recognize Text dialog and batch - Engine, strategy, the four clean-up steps and the skip flags are remembered with the other choices (a saved Automatic without a strategy reads confidence weighted). The batch refuses two inputs of one file name and existing outputs before reading anything, notes low-confidence pages at the settings' threshold, and its toast has a Cancel (the file in flight finishes). Catalogs and attribution - The 90 new interface strings are in all 21 catalogs (the Lithuanian ones were written without native review, and the Bulgarian ones avoid U+045D, which the bundled monospace face lacks). ATTRIBUTION.toml carries the new hashes, a note on the Lithuanian entries and the README screenshot; ATTRIBUTION.md is regenerated. - README: a screenshot of the Verify screen, taken with `cargo xtask screenshots` from a synthetic scan (`shot --ocr-verify on`) built from allowed assets; the page reads it with the real engines. Tests: pdfcraft-ui-egui lib 373 passed (1 ignored: the Windows hinting measurement probe), tests ocr 6, control 46, fonts 9; clippy -D warnings clean on the engine, ui-egui, pdfcraft and xtask packages; `cargo xtask assets` ok. The review state machine has unit tests for every fix above; each was seen failing with its fix reverted. * M10.23: parity entries, roadmap and localization notes for the OCR workflow Records what M10.20-M10.22 ship, and what they do not. parity/acrobat-features.toml - Status changes against main: ocr.rotation-detection and ocr.deskew planned -> shipped (the opt-in steps of M10.21, with their tests); ocr.correct-recognized- text and ocr.ocr-engines planned -> partial. Other Area I entries get their evidence and notes brought up to date. - ocr.correct-recognized-text: the evidence includes the one-page-at-a-time accept and the region re-read tests; the notes say what the headless tools cover (ocr_words with a retained review, ocr_review_apply through the same stale- document guard, ocr_dictionary) and what is still UI-only (suggestions, per-word Verified marks, region re-reads). - ocr.ocr-engines stays partial rather than shipped: part of its evidence is conditional (the real-binary test runs only where tesseract is installed and skips elsewhere, and the process-level tests are Unix-only). It cites the tests that always run (location validation and the fail-closed rule, --list-langs parsing from stdout or stderr, the merge rules, the default strategy) and says which part is not proven everywhere. - `cargo xtask parity`: area I 32.7% -> 44.2% weighted (5 -> 7 shipped, 7 -> 9 partial); overall 52.8% -> 53.0% shipped and 58.2% -> 58.5% weighted. ROADMAP.md - One progress-log entry (2026-10-13, newest first) and the banner line. It says the catalogs are 21 with the Lithuanian additions not natively reviewed, that the end-to-end redaction test of the Type3 layer needs the craft-fonts build input, and that recognize_text_makes_a_scanned_page_searchable still fails where the models are installed, as main's log already records. docs/localization.md, docs/localization-parity.md - The Lithuanian entry count (2,578 -> 2,668) and the counts of the other catalogs that carry entry counts are re-measured with the 90 new entries; the Lithuanian OCR entries are marked as not natively reviewed. Checked: `cargo xtask parity` (numbers above, evidence tests exist) and `cargo xtask assets` pass on this tree. * M10.24: ocr: apply a late result only to the document it was read from The Recognize Text dialog closes on Go, so the document can be edited, or have text redacted, while a long run is still reading. The result was applied without the stale check the tools and the Verify screen use, so words read before a redaction could be written back as invisible text. The run now keeps its guard and applies through the checked path. Accept with the editable output in the Verify screen had the same gap (Exit keeps the review open): it now refuses when the document changed since the review started. Both new tests fail with their guard switched off. * M10.25: ocr: ocr_dictionary takes dictionary file names only Updating sorts, lower-cases and rewrites the file it is given, so pointed at .env or a README it would corrupt it. The tool now accepts only ocr-dictionary-<language>.txt style names, for reading as well as writing. The size-limit test used a file name the rule now refuses first, so it renamed its fixture to keep testing the size limit. The new test fails with the rule switched off. * M10.26: pt-BR: keep (s) on the word counts and say mecanismo for engine Two review fixes from a native speaker: the two word(s) lines had lost their (s), so a count of 1 read as 1 palavras, and engine was translated both as motor and mecanismo. Mecanismo is the Brazilian word for a software engine and two lines already used it, so the other six now match. * M10: fit the rebased OCR workflow to current main's structure * Fix OCR workflow issues from the review Honor the Recognize dialog's editable-output choice: its result opens in the review screen (whose Accept writes the editable document) instead of an invisible layer. Make page acceptance idempotent: a second Accept entire page never appends the OCR layer twice and keeps later corrections. Move page and region re-OCR onto a worker thread with a status line and a cancel that discards the reading. Skip the Tesseract probe for jobs that name their engines. Bound Tesseract's stderr while the child runs, not only after it exits. Surface the editable output's substitution notes in the tools' and the run's results. Also repair the OCR batch tool against the current structure: inputs are held to the read root again, and a batch whose inputs share an output name is refused before the output folder is created, compared the way the default filesystem compares names; and the editable writer test's word stays inside the fixture's pages. * Apply pre-review fixes to the OCR workflow Hold the automation OCR tools to the document's copying permission, as the other text tools are: the recognized text is left out of the results when copying is forbidden, and the paths that carry the words out of the document (the editable output, the review word list) are refused. Mark the ocr_dictionary tool as overwriting its path. Close the searchable layer's graphics state around its invisible text so the rendering mode cannot leak into later content. Read the OCR user dictionary folder from the portable data folder in portable mode, like the recovery store does. Resolve the attribution manifest's leftover conflict markers and regenerate the generated attribution. Describe the review flow, the searchable layer's Type3 fonts and the parity evidence references accurately, and drop an undeclared copy of the recovery module. * OCR: reject readings that exceed the word limit Assisted-by: OpenAI Codex * OCR: new documents go through the page tree builder main added Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * OCR: review notes and lints The editable output refuses a file created during recognition. ocr_words takes skip_text_pages and force_ocr. Automatic OCR checks the engine it will use. The stderr test stays below the kill cap, and a failed --ocr-verify shot exits with an error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * OCR: restore the Verify screenshot attribution, follow the moved constants The merge dropped the screenshot row with the translation rows. The model filename constants live in ocrs.rs now, so the license check reads them there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Attribution: the Verify screenshot entry goes after the header comment Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Attribution: the screenshot row in the table follows the manifest order Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: eliets2 <287273517+eliets2@users.noreply.github.com> Co-authored-by: FredApps <FredApps@users.noreply.github.com> Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
525 lines
30 KiB
Rust
525 lines
30 KiB
Rust
//! The command registry: every user-facing action, by id (architecture §4, "everything is a
|
||
//! command").
|
||
//!
|
||
//! Menus, keyboard shortcuts, the ⌘K palette and automation (CLI `run`, the control channel and
|
||
//! MCP later) all go through this table. A frontend implements *what* each id does. The registry
|
||
//! says what it is called, where it appears, which key runs it, and when it is enabled, so that
|
||
//! every surface agrees.
|
||
//!
|
||
//! View-local keys (zoom, page navigation, find-next) stay with the document view. They act on
|
||
//! view state, not on the document.
|
||
|
||
use crate::{DocId, Session};
|
||
|
||
/// When a command can run.
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||
pub enum Needs {
|
||
/// Always.
|
||
Nothing,
|
||
/// A document is open.
|
||
Document,
|
||
/// The open document's security allows page changes (insert, delete, rotate, extract…).
|
||
Assembly,
|
||
/// The open document's security allows content and metadata changes.
|
||
Modification,
|
||
/// The open document's security allows adding and changing comments.
|
||
Annotate,
|
||
/// The open document's security allows copying text and images out of it.
|
||
Copying,
|
||
/// The open document's security allows printing (low resolution counts).
|
||
Printing,
|
||
/// The document has form fields and its security allows filling them in.
|
||
FillForms,
|
||
/// The document has comments and allows changes.
|
||
HasComments,
|
||
/// The document has form fields and allows changes.
|
||
HasFields,
|
||
/// The document has redaction marks and allows changes.
|
||
HasRedactions,
|
||
/// The document has page marks of this kind and allows changes.
|
||
Marks(crate::MarkKind),
|
||
/// The document's security may be changed (owner, or nothing restricted), or would be
|
||
/// once its permissions password is entered.
|
||
Security,
|
||
/// The document is protected and its security may be removed (perhaps after entering
|
||
/// its permissions password).
|
||
ProtectedSecurity,
|
||
/// The document's restrictions can be lifted with its permissions password.
|
||
Unlock,
|
||
/// There is something to undo.
|
||
Undo,
|
||
/// There is something to redo.
|
||
Redo,
|
||
/// A document is open in two-page view. The engine has no views, so it checks the
|
||
/// document and the frontend checks the view.
|
||
TwoPageView,
|
||
}
|
||
|
||
/// A keyboard shortcut. `command` is ⌘ on macOS and Ctrl elsewhere.
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||
pub struct Shortcut {
|
||
pub command: bool,
|
||
pub shift: bool,
|
||
/// ⌃ on macOS (in addition to ⌘); unused elsewhere.
|
||
pub mac_ctrl: bool,
|
||
/// Key name: a letter, a digit, punctuation such as `,`, or `Delete`.
|
||
pub key: &'static str,
|
||
}
|
||
|
||
impl Shortcut {
|
||
/// ⌘ (Ctrl elsewhere) and `key`.
|
||
pub const fn cmd(key: &'static str) -> Self {
|
||
Self { command: true, shift: false, mac_ctrl: false, key }
|
||
}
|
||
|
||
/// ⇧⌘ (Ctrl+Shift elsewhere) and `key`.
|
||
pub const fn cmd_shift(key: &'static str) -> Self {
|
||
Self { command: true, shift: true, mac_ctrl: false, key }
|
||
}
|
||
|
||
/// The command modifier on its own, for text such as "⌘-scroll" / "Ctrl-scroll".
|
||
pub fn command_name(mac: bool) -> &'static str {
|
||
if mac { "⌘" } else { "Ctrl" }
|
||
}
|
||
|
||
/// How the shortcut is written in menus: `⇧⌘S` on macOS, `Ctrl+Shift+S` elsewhere.
|
||
pub fn label(&self, mac: bool) -> String {
|
||
if mac {
|
||
let mut s = String::new();
|
||
if self.mac_ctrl {
|
||
s.push('⌃');
|
||
}
|
||
if self.shift {
|
||
s.push('⇧');
|
||
}
|
||
if self.command {
|
||
s.push('⌘');
|
||
}
|
||
s.push_str(self.key);
|
||
s
|
||
} else {
|
||
let mut parts = Vec::new();
|
||
if self.command || self.mac_ctrl {
|
||
parts.push("Ctrl");
|
||
}
|
||
if self.shift {
|
||
parts.push("Shift");
|
||
}
|
||
parts.push(self.key);
|
||
parts.join("+")
|
||
}
|
||
}
|
||
|
||
/// Number of modifiers (more specific shortcuts are matched first).
|
||
pub fn modifier_count(&self) -> usize {
|
||
usize::from(self.command) + usize::from(self.shift) + usize::from(self.mac_ctrl)
|
||
}
|
||
}
|
||
|
||
#[derive(Clone, Copy, Debug)]
|
||
pub struct CommandSpec {
|
||
pub id: &'static str,
|
||
pub label: &'static str,
|
||
/// Top-level menu it appears in (`File`, `Edit`, `View`, `Pages`, `Help`), if any.
|
||
pub menu: Option<&'static str>,
|
||
pub shortcut: Option<Shortcut>,
|
||
pub needs: Needs,
|
||
/// The shortcut also works while a text field has focus.
|
||
pub in_text: bool,
|
||
/// Lucide icon name for palettes and toolbars.
|
||
pub icon: &'static str,
|
||
}
|
||
|
||
const fn c(
|
||
id: &'static str,
|
||
label: &'static str,
|
||
menu: Option<&'static str>,
|
||
shortcut: Option<Shortcut>,
|
||
needs: Needs,
|
||
icon: &'static str,
|
||
) -> CommandSpec {
|
||
CommandSpec { id, label, menu, shortcut, needs, in_text: true, icon }
|
||
}
|
||
|
||
/// Like `c`, but the shortcut is left to text fields while one has focus (⌘Z, ⌘A…).
|
||
const fn ct(
|
||
id: &'static str,
|
||
label: &'static str,
|
||
menu: Option<&'static str>,
|
||
shortcut: Option<Shortcut>,
|
||
needs: Needs,
|
||
icon: &'static str,
|
||
) -> CommandSpec {
|
||
CommandSpec { id, label, menu, shortcut, needs, in_text: false, icon }
|
||
}
|
||
|
||
use Needs::*;
|
||
|
||
const FILE: Option<&str> = Some("File");
|
||
const EDIT: Option<&str> = Some("Edit");
|
||
const VIEW: Option<&str> = Some("View");
|
||
const PAGES: Option<&str> = Some("Pages");
|
||
const HELP: Option<&str> = Some("Help");
|
||
|
||
/// Every command, in menu order.
|
||
pub const COMMANDS: &[CommandSpec] = &[
|
||
c("view.select_tool", "Select", None, None, Document, "mouse-pointer-2"),
|
||
c("view.hand_tool", "Hand", None, None, Document, "hand"),
|
||
c("file.open", "Open…", FILE, Some(Shortcut::cmd("O")), Nothing, "folder-open"),
|
||
c("file.open_recent", "Open Recent", FILE, None, Nothing, "clock"),
|
||
// Shown at the foot of File ▸ Open Recent and on Home, not as its own File menu item.
|
||
c("file.clear_recent", "Clear Recent Files", None, None, Nothing, "trash-2"),
|
||
c("file.pin_folder", "Pin folder to Home…", FILE, None, Nothing, "folder-plus"),
|
||
c("create.blank", "New blank PDF", FILE, None, Nothing, "file-plus-2"),
|
||
c("measure.distance", "Measure distance", None, None, Annotate, "ruler"),
|
||
c("measure.perimeter", "Measure perimeter", None, None, Annotate, "ruler"),
|
||
c("measure.area", "Measure area", None, None, Annotate, "ruler"),
|
||
c("measure.scale", "Set measurement scale", None, None, Annotate, "ruler"),
|
||
c("measure.info", "Measurement information", None, None, Document, "ruler"),
|
||
c("measure.snap", "Measurement snapping", None, None, Document, "ruler"),
|
||
c("measure.export", "Export measurements as CSV", None, None, Document, "file-output"),
|
||
c("page.copy", "Copy pages", None, None, Document, "copy"),
|
||
c("page.cut", "Cut pages", None, None, Assembly, "scissors"),
|
||
c("page.paste", "Paste pages", None, None, Assembly, "clipboard-paste"),
|
||
c("create.file", "Create PDF from file…", FILE, None, Nothing, "file-input"),
|
||
c("create.multiple", "Create PDF from multiple files…", FILE, None, Nothing, "files"),
|
||
c("create.multiple_separate", "Create separate PDFs…", FILE, None, Nothing, "files"),
|
||
c("create.images", "Create PDF from images…", FILE, None, Nothing, "image"),
|
||
c("create.clipboard", "Create PDF from clipboard", FILE, None, Nothing, "copy-plus"),
|
||
c("page.combine", "Combine files…", FILE, None, Nothing, "files"),
|
||
c("file.save", "Save", FILE, Some(Shortcut::cmd("S")), Document, "save"),
|
||
c("file.save_as", "Save as…", FILE, Some(Shortcut::cmd_shift("S")), Document, "save"),
|
||
c("file.close", "Close file", FILE, Some(Shortcut::cmd("W")), Document, "x"),
|
||
c("file.close_all", "Close all", FILE, Some(Shortcut::cmd_shift("W")), Document, "x"),
|
||
c("file.revert", "Revert", FILE, None, Undo, "rotate-ccw"),
|
||
c("print.dialog", "Print…", FILE, Some(Shortcut::cmd("P")), Printing, "printer"),
|
||
c("file.properties", "Document properties…", FILE, Some(Shortcut::cmd("D")), Document, "info"),
|
||
c("file.word_count", "Word count…", FILE, None, Copying, "hash"),
|
||
ct("edit.undo", "Undo", EDIT, Some(Shortcut::cmd("Z")), Undo, "undo-2"),
|
||
ct("edit.redo", "Redo", EDIT, Some(Shortcut::cmd_shift("Z")), Redo, "redo-2"),
|
||
c("edit.find", "Find…", EDIT, Some(Shortcut::cmd("F")), Document, "search"),
|
||
c("edit.advanced_search", "Advanced search…", EDIT, Some(Shortcut::cmd_shift("F")), Document, "search"),
|
||
c("view.palette", "Find tools and commands…", VIEW, Some(Shortcut::cmd("K")), Nothing, "search"),
|
||
// Page display: View ▸ Page display and the rail's button list the base layouts as radios and
|
||
// continuous scrolling as a checkbox, so `menu = None` keeps them out of the generated menus.
|
||
// The palette still runs them.
|
||
c("view.layout.single", "Single page", None, None, Document, "file-text"),
|
||
c("view.layout.two_up", "Two-page view", None, None, Document, "columns-2"),
|
||
c("view.continuous", "Continuous scrolling", None, None, Document, "arrow-up-down"),
|
||
c("view.page_gaps", "Show gaps between pages", None, None, Document, "arrow-up-down"),
|
||
c("view.layout.cover", "Show cover page in two-page view", None, None, TwoPageView, "bookmark"),
|
||
// Acrobat's view modes, a page display and a zoom at once (the rail's Page display menu).
|
||
c("view.fit_width_scrolling", "Fit to width scrolling", None, None, Document, "arrow-left-right"),
|
||
c("view.fit_one_page", "Fit one full page", None, None, Document, "maximize-2"),
|
||
// In View ▸ Zoom with the view-local zoom keys, so `menu = None` keeps it out of the generated
|
||
// View menu (where it would show twice). The palette and ⌘3 still run it.
|
||
c("view.fit_visible", "Fit visible", None, Some(Shortcut::cmd("3")), Document, "scan"),
|
||
c("view.marquee_zoom", "Marquee zoom", VIEW, None, Document, "zoom-in"),
|
||
// Acrobat's column select: drag a rectangle and select only the text inside it. Alt/Option-
|
||
// drag with the Select tool does the same; this is the way in where the desktop takes
|
||
// Alt-drag for moving windows (several Linux window managers).
|
||
// Copy events stay with the frontend so focused text inputs and page clipboard routing keep ownership.
|
||
c("edit.copy", "Copy", EDIT, None, Copying, "copy"),
|
||
// Comments travel between documents as XFDF (M14): ⌘C with comments selected copies them,
|
||
// ⌘V pastes the copies onto the current page; the strip's Copy/Paste in the menus too.
|
||
c("comment.copy", "Copy comments", EDIT, None, Document, "copy"),
|
||
c("comment.paste", "Paste comments", EDIT, None, Annotate, "clipboard-paste"),
|
||
c("edit.column_select", "Column select", EDIT, None, Document, "text-select"),
|
||
c("edit.snapshot", "Take a snapshot", EDIT, None, Copying, "camera"),
|
||
c("view.full_screen", "Full screen mode", VIEW, Some(Shortcut::cmd("L")), Document, "maximize"),
|
||
c("view.read_mode", "Read mode", VIEW, Some(Shortcut { command: true, shift: false, mac_ctrl: true, key: "H" }), Document, "book-open"),
|
||
// Browsers' tab keys (#1542): Ctrl+Tab on every platform, ⌃Tab rather than ⌘Tab on macOS,
|
||
// where the system takes ⌘Tab. They follow the tabs' order on screen and wrap around, and
|
||
// also run from Combine files, which has no document open.
|
||
c("view.next_tab", "Next tab", VIEW, Some(Shortcut { command: false, shift: false, mac_ctrl: true, key: "Tab" }), Nothing, "chevron-right"),
|
||
c("view.previous_tab", "Previous tab", VIEW, Some(Shortcut { command: false, shift: true, mac_ctrl: true, key: "Tab" }), Nothing, "chevron-left"),
|
||
// View-local history also appears in the Page navigation section; don't duplicate its menu.
|
||
c("view.previous_view", "Previous view", None, Some(Shortcut::cmd("[")), Document, "chevron-left"),
|
||
c("view.next_view", "Next view", None, Some(Shortcut::cmd("]")), Document, "chevron-right"),
|
||
c("view.focus_page_input", "Go to page…", VIEW, Some(Shortcut::cmd_shift("N")), Document, "text-cursor-input"),
|
||
c(
|
||
"view.side_panel",
|
||
"Show or hide the side panel",
|
||
VIEW,
|
||
Some(Shortcut { command: false, shift: false, mac_ctrl: false, key: "F4" }),
|
||
Nothing,
|
||
"panel-right",
|
||
),
|
||
c(
|
||
"view.tools_pane",
|
||
"Show or hide the Tools panel",
|
||
VIEW,
|
||
Some(Shortcut { command: false, shift: true, mac_ctrl: false, key: "F4" }),
|
||
Nothing,
|
||
"panel-left",
|
||
),
|
||
c("ui.dock.reset", "Reset side panels", VIEW, None, Nothing, "settings"),
|
||
c("view.theme", "Switch light / dark theme", None, None, Nothing, "moon"),
|
||
c("view.theme.system", "Use system setting", None, None, Nothing, "settings"),
|
||
c("view.theme.light", "Light gray", None, None, Nothing, "sun"),
|
||
c("view.theme.dark", "Dark gray", None, None, Nothing, "moon"),
|
||
c("comment.list", "Comments panel", VIEW, None, Document, "message-square-text"),
|
||
c("comment.note", "Add a sticky note", None, None, Annotate, "sticky-note"),
|
||
c("comment.freetext", "Add a text box", None, None, Annotate, "type"),
|
||
c("comment.highlight", "Highlight text", None, None, Annotate, "highlighter"),
|
||
c("comment.underline", "Underline text", None, None, Annotate, "underline"),
|
||
c("comment.strikeout", "Strikethrough text", None, None, Annotate, "strikethrough"),
|
||
c("comment.squiggly", "Squiggly underline text", None, None, Annotate, "spline"),
|
||
c("comment.freehand_highlight", "Freehand-Highlight", None, None, Annotate, "highlighter"),
|
||
c("comment.ink", "Draw freehand", None, None, Annotate, "pencil"),
|
||
c("comment.line", "Draw a line", None, None, Annotate, "minus"),
|
||
c("comment.arrow", "Draw an arrow", None, None, Annotate, "move-right"),
|
||
c("comment.square", "Draw a rectangle", None, None, Annotate, "square"),
|
||
c("comment.circle", "Draw an oval", None, None, Annotate, "circle"),
|
||
c("comment.polygon", "Draw a polygon", None, None, Annotate, "pentagon"),
|
||
c("comment.polyline", "Draw connected lines", None, None, Annotate, "spline"),
|
||
c("comment.cloud", "Draw a cloud", None, None, Annotate, "cloud"),
|
||
c("comment.callout", "Add a callout", None, None, Annotate, "message-square-quote"),
|
||
c("comment.caret", "Insert text", None, None, Annotate, "text-cursor-input"),
|
||
c("comment.replace", "Replace text", None, None, Annotate, "replace"),
|
||
c("comment.attach", "Attach a file", None, None, Annotate, "paperclip"),
|
||
c("comment.eraser", "Erase drawings", None, None, Annotate, "eraser"),
|
||
c("form.fields", "Form fields panel", VIEW, None, Document, "list"),
|
||
c("form.clear", "Clear form", EDIT, None, FillForms, "eraser"),
|
||
c("comment.flatten", "Flatten comments", None, None, HasComments, "layers"),
|
||
c("comment.import", "Import comments…", None, None, Modification, "file-input"),
|
||
c("comment.stamp", "Add a stamp", None, None, Annotate, "stamp"),
|
||
c("comment.export", "Export all comments to data file…", None, None, HasComments, "file-output"),
|
||
c("comment.hide_all", "Hide all comments", None, None, Document, "eye-off"),
|
||
c("comment.summarize", "Summarize comments", None, None, HasComments, "file-text"),
|
||
c("form.import_data", "Import form data…", None, None, HasFields, "file-input"),
|
||
c("form.export_data", "Export form data…", None, None, HasFields, "file-output"),
|
||
c("standards.pdfa", "PDF/A…", None, None, Document, "file-check"),
|
||
c("actions.wizard", "Action Wizard…", None, None, Nothing, "list-checks"),
|
||
c("actions.distribution", "Prepare for distribution…", None, None, Nothing, "send"),
|
||
c("actions.optimize_scans", "Optimize scanned documents…", None, None, Nothing, "scan-text"),
|
||
c("doc.compare", "Compare files…", None, None, Document, "git-compare"),
|
||
c("form.detect", "Detect form fields", None, None, Modification, "scan"),
|
||
c("form.merge_data", "Merge data files into spreadsheet…", None, None, Nothing, "file-spreadsheet"),
|
||
c("form.flatten", "Flatten form fields", None, None, HasFields, "layers"),
|
||
c("form.prepare", "Prepare a form", None, None, Modification, "text-cursor-input"),
|
||
c("form.tab_order.row", "Tab order: by rows", None, None, HasFields, "rows-3"),
|
||
c("form.tab_order.column", "Tab order: by columns", None, None, HasFields, "columns-3"),
|
||
c("form.tab_order.structure", "Tab order: by document structure", None, None, HasFields, "list"),
|
||
c("form.calculation_order", "Calculation order", None, None, Document, "list-ordered"),
|
||
c("edit.text", "Add text", None, None, Modification, "type"),
|
||
c("edit.edit_text", "Edit text & images", None, None, Modification, "text-cursor-input"),
|
||
c("edit.link", "Add or edit links", None, None, Modification, "link-2"),
|
||
c("edit.attach", "Attach a file…", EDIT, None, Modification, "paperclip"),
|
||
c("edit.links_from_urls", "Create links from URLs", None, None, Modification, "link-2"),
|
||
c("edit.remove_links", "Remove all links", None, None, Modification, "trash-2"),
|
||
c("edit.bates", "Add Bates numbering…", None, None, Modification, "hash"),
|
||
c("edit.image", "Add image…", None, None, Modification, "image-plus"),
|
||
c("redact.mark", "Redact text and images", None, None, Modification, "rectangle-horizontal"),
|
||
c("redact.pages", "Redact pages…", None, None, Modification, "file-x"),
|
||
c("redact.search", "Find text and redact…", None, None, Modification, "file-search"),
|
||
c("redact.properties", "Redaction properties…", None, None, Document, "settings-2"),
|
||
c("redact.apply", "Apply redactions…", None, None, HasRedactions, "check"),
|
||
c("redact.clear", "Clear redaction marks", None, None, HasRedactions, "eraser"),
|
||
c("protect.remove_hidden", "Remove hidden information…", None, None, Modification, "eye-off"),
|
||
c("redact.sanitize", "Sanitize document…", None, None, Modification, "sparkles"),
|
||
c("form.field.properties", "Field properties…", None, None, HasFields, "settings-2"),
|
||
c("form.add.text", "Add a text field", None, None, Modification, "text-cursor-input"),
|
||
c("form.add.text_table", "Add text field table", None, None, Modification, "grid-3x3"),
|
||
c("form.add.checkbox", "Add a checkbox", None, None, Modification, "check-circle-2"),
|
||
c("form.add.radio", "Add a radio button", None, None, Modification, "circle"),
|
||
c("form.add.combo", "Add a drop-down list", None, None, Modification, "chevron-down"),
|
||
c("form.add.list", "Add a list box", None, None, Modification, "list"),
|
||
c("form.add.button", "Add a button", None, None, Modification, "square"),
|
||
c("form.add.image", "Add an image field", None, None, Modification, "image"),
|
||
c("form.add.date", "Add a date field", None, None, Modification, "clock-3"),
|
||
c("form.add.signature", "Add a digital signature field", None, None, Modification, "signature"),
|
||
c("sign.digital", "Digitally sign", None, None, Document, "signature"),
|
||
c("sign.certify", "Certify (visible signature)", None, None, Document, "badge-check"),
|
||
c("sign.certify_invisible", "Certify (invisible signature)", None, None, Document, "badge-check"),
|
||
c("sign.validate", "Validate all signatures", None, None, Document, "badge-check"),
|
||
c("sign.panel", "Signatures panel", VIEW, None, Document, "signature"),
|
||
c("sign.fill.text", "Fill & Sign: add text", None, None, Annotate, "type"),
|
||
c("sign.fill.check", "Fill & Sign: checkmark", None, None, Annotate, "check"),
|
||
c("sign.fill.cross", "Fill & Sign: cross", None, None, Annotate, "x"),
|
||
c("sign.fill.dot", "Fill & Sign: dot", None, None, Annotate, "circle-dot"),
|
||
c("sign.fill.line", "Fill & Sign: line", None, None, Annotate, "minus"),
|
||
c("sign.fill.date", "Fill & Sign: date", None, None, Annotate, "clock-3"),
|
||
c("sign.fill.signature", "Fill & Sign: sign", None, None, Annotate, "signature"),
|
||
c("sign.fill.initials", "Fill & Sign: initials", None, None, Annotate, "signature"),
|
||
c("sign.fill.signature.change", "Fill & Sign: change signature", None, None, Nothing, "signature"),
|
||
c("sign.fill.signature.remove", "Fill & Sign: remove saved signature", None, None, Nothing, "x"),
|
||
c("sign.fill.initials.remove", "Fill & Sign: remove saved initials", None, None, Nothing, "x"),
|
||
c("sign.fill.initials.change", "Fill & Sign: change initials", None, None, Nothing, "signature"),
|
||
c("export.image", "Export to image…", FILE, None, Copying, "image"),
|
||
c("optimize.reduce", "Reduce file size…", FILE, None, Document, "file-down"),
|
||
c("optimize.advanced", "Optimize PDF…", FILE, None, Document, "settings-2"),
|
||
c("export.text", "Export to text…", FILE, None, Copying, "type"),
|
||
c("export.docx", "Export to Word…", FILE, None, Copying, "file-text"),
|
||
c("export.pptx", "Export to PowerPoint…", FILE, None, Copying, "presentation"),
|
||
c("export.html", "Export to HTML…", FILE, None, Copying, "file-symlink"),
|
||
c("export.rtf", "Export to RTF…", FILE, None, Copying, "file-text"),
|
||
c("app.preferences", "Preferences…", EDIT, Some(Shortcut::cmd(",")), Nothing, "settings"),
|
||
c("tools.js_console", "JavaScript console…", None, Some(Shortcut::cmd("J")), Document, "square-terminal"),
|
||
c("tools.document_js", "Document JavaScripts…", None, None, Modification, "file-code"),
|
||
c("ocr.recognize", "Recognize text…", None, None, Modification, "scan-text"),
|
||
c("ocr.enhance_camera", "Enhance camera image", None, None, Modification, "camera"),
|
||
c("ocr.enhance", "Enhance scanned file…", None, None, Modification, "sparkles"),
|
||
c("ocr.recognize_batch", "Recognize text in multiple files…", None, None, Nothing, "files"),
|
||
c("ocr.correct", "Correct recognized text…", None, None, Document, "text-select"),
|
||
c("a11y.check", "Check for accessibility…", None, None, Document, "accessibility"),
|
||
c("a11y.find_untagged", "Find untagged content", None, None, Document, "search"),
|
||
c("a11y.autotag", "Automatically tag PDF", None, None, Document, "tag"),
|
||
c("a11y.report", "Open accessibility report", None, None, Document, "file-text"),
|
||
c("a11y.reading_options", "Change reading options…", None, None, Document, "book-open"),
|
||
c("a11y.alt_text", "Add alternate text…", None, None, Modification, "image"),
|
||
c("a11y.autotag_fields", "Tag form fields", None, None, Modification, "tag"),
|
||
c("a11y.tags", "Tags panel", None, None, Document, "tag"),
|
||
c("export.all_images", "Export all images…", FILE, None, Copying, "image"),
|
||
c("edit.header_footer", "Add header & footer…", None, None, Modification, "heading"),
|
||
c("edit.header_footer.update", "Update header & footer…", None, None, Marks(crate::MarkKind::HeaderFooter), "heading"),
|
||
c("edit.header_footer.remove", "Remove header & footer", None, None, Marks(crate::MarkKind::HeaderFooter), "heading"),
|
||
c("edit.watermark", "Add watermark…", None, None, Modification, "stamp"),
|
||
c("edit.watermark.update", "Update watermark…", None, None, Marks(crate::MarkKind::Watermark), "stamp"),
|
||
c("edit.watermark.remove", "Remove watermark", None, None, Marks(crate::MarkKind::Watermark), "stamp"),
|
||
c("edit.background", "Add background…", None, None, Modification, "palette"),
|
||
c("edit.background.update", "Update background…", None, None, Marks(crate::MarkKind::Background), "palette"),
|
||
c("edit.background.remove", "Remove background", None, None, Marks(crate::MarkKind::Background), "palette"),
|
||
c("protect.password", "Protect using password…", FILE, None, Security, "lock"),
|
||
c("protect.remove", "Remove security", FILE, None, ProtectedSecurity, "lock-open"),
|
||
c("protect.unlock", "Enter permissions password…", None, None, Unlock, "lock-open"),
|
||
c("protect.properties", "Security properties…", FILE, None, Document, "shield-check"),
|
||
c("page.organize", "Organize pages", PAGES, None, Document, "layout-grid"),
|
||
c("bookmark.add", "New bookmark", PAGES, Some(Shortcut::cmd("B")), Assembly, "bookmark-plus"),
|
||
c("bookmark.from_structure", "New bookmarks from structure", PAGES, None, Assembly, "list"),
|
||
// Bookmarks from the lines set in chosen text styles, for headings that aren't tagged (#1693).
|
||
c("bookmark.from_text_styles", "New bookmarks from text styles…", PAGES, None, Assembly, "list"),
|
||
c("page.rotate", "Rotate pages clockwise", PAGES, None, Assembly, "rotate-cw"),
|
||
c("page.rotate_ccw", "Rotate pages counterclockwise", PAGES, None, Assembly, "rotate-ccw"),
|
||
c("page.delete", "Delete pages", PAGES, None, Assembly, "trash-2"),
|
||
c("page.insert_blank", "Insert blank page", PAGES, None, Assembly, "file-plus"),
|
||
c("page.rotate_dialog", "Rotate pages…", PAGES, None, Assembly, "rotate-cw"),
|
||
c("page.duplicate", "Duplicate pages", PAGES, None, Assembly, "copy-plus"),
|
||
c("page.reverse", "Reverse pages", PAGES, None, Assembly, "arrow-up-down"),
|
||
c("page.crop", "Crop pages", PAGES, None, Assembly, "crop"),
|
||
c("page.boxes", "Set page boxes…", PAGES, None, Assembly, "square-dashed-mouse-pointer"),
|
||
c("page.insert", "Insert pages from file…", PAGES, None, Assembly, "file-input"),
|
||
c("page.replace", "Replace pages…", PAGES, None, Assembly, "replace"),
|
||
c("page.extract", "Extract pages…", PAGES, None, Assembly, "file-output"),
|
||
c("page.split", "Split document…", PAGES, None, Assembly, "scissors"),
|
||
c("page.number", "Number pages…", PAGES, None, Assembly, "hash"),
|
||
c("page.properties", "Page properties…", PAGES, None, Modification, "info"),
|
||
c("help.shortcuts", "Keyboard shortcuts", HELP, None, Nothing, "circle-help"),
|
||
c("help.discord", "Join the ArtCraft Discord", HELP, None, Nothing, "messages-square"),
|
||
c("help.app_page", "PdfCraft web page", HELP, None, Nothing, "globe"),
|
||
c("help.github", "PdfCraft on GitHub", HELP, None, Nothing, "code-xml"),
|
||
c("help.website", "ArtCraft website", HELP, None, Nothing, "external-link"),
|
||
c("help.check_updates", "Check for updates…", HELP, None, Nothing, "cloud"),
|
||
c("help.about", "About PdfCraft", HELP, None, Nothing, "info"),
|
||
];
|
||
|
||
pub fn command(id: &str) -> Option<&'static CommandSpec> {
|
||
COMMANDS.iter().find(|c| c.id == id)
|
||
}
|
||
|
||
/// Commands that appear in `menu`, in order.
|
||
pub fn menu(menu: &str) -> impl Iterator<Item = &'static CommandSpec> + '_ {
|
||
COMMANDS.iter().filter(move |c| c.menu == Some(menu))
|
||
}
|
||
|
||
/// Whether `spec` can run now, for the document `active` (the focused tab).
|
||
pub fn is_enabled(spec: &CommandSpec, session: &Session, active: Option<DocId>) -> bool {
|
||
let doc = active.and_then(|id| session.get(id));
|
||
match spec.needs {
|
||
Nothing => true,
|
||
Document | TwoPageView => doc.is_some(),
|
||
Assembly => doc.is_some_and(|d| d.allows_assembly()),
|
||
Modification => doc.is_some_and(|d| d.allows_modification()),
|
||
Annotate => doc.is_some_and(|d| d.allows_annotation()),
|
||
Copying => doc.is_some_and(|d| d.allows_copying()),
|
||
Printing => doc.is_some_and(|d| d.allows_printing()),
|
||
FillForms => doc.is_some_and(|d| d.allows_form_filling() && !d.form.is_empty()),
|
||
Marks(k) => doc.is_some_and(|d| d.allows_modification() && d.marks().contains(&k)),
|
||
HasComments => doc.is_some_and(|d| d.allows_modification() && !d.info.annotations.is_empty()),
|
||
HasFields => doc.is_some_and(|d| d.allows_modification() && !d.form.is_empty()),
|
||
HasRedactions => doc.is_some_and(|d| d.allows_modification() && d.redaction_marks() > 0),
|
||
Security => doc.is_some_and(|d| d.allows_security_change() || d.can_unlock()),
|
||
ProtectedSecurity => doc.is_some_and(|d| (d.allows_security_change() || d.can_unlock()) && d.security_summary().is_some()),
|
||
Unlock => doc.is_some_and(|d| d.can_unlock()),
|
||
Undo => doc.is_some_and(|d| d.can_undo().is_some()),
|
||
Redo => doc.is_some_and(|d| d.can_redo().is_some()),
|
||
}
|
||
}
|
||
|
||
/// The edit `spec` names now, with the wording that names it ("Undo {}"), so an interface can say
|
||
/// each part in its own language. `None` for every other command, and when there is nothing to undo.
|
||
pub fn current_edit<'a>(spec: &CommandSpec, session: &'a Session, active: Option<DocId>) -> Option<(&'static str, &'a crate::Label)> {
|
||
let doc = active.and_then(|id| session.get(id))?;
|
||
match spec.id {
|
||
"edit.undo" => doc.undo_label().map(|l| ("Undo {}", l)),
|
||
"edit.redo" => doc.redo_label().map(|l| ("Redo {}", l)),
|
||
_ => None,
|
||
}
|
||
}
|
||
|
||
/// The label to show for `spec` now ("Undo Rotate page" rather than "Undo").
|
||
pub fn current_label(spec: &CommandSpec, session: &Session, active: Option<DocId>) -> String {
|
||
match current_edit(spec, session, active) {
|
||
Some((wording, label)) => wording.replacen("{}", label.as_str(), 1),
|
||
None => spec.label.into(),
|
||
}
|
||
}
|
||
|
||
#[cfg(test)]
|
||
mod tests {
|
||
use super::*;
|
||
|
||
#[test]
|
||
fn ids_and_shortcuts_are_unique() {
|
||
let mut ids = std::collections::HashSet::new();
|
||
let mut keys = std::collections::HashSet::new();
|
||
for c in COMMANDS {
|
||
assert!(ids.insert(c.id), "duplicate id {}", c.id);
|
||
if let Some(s) = c.shortcut {
|
||
assert!(keys.insert(s), "duplicate shortcut {} ({})", s.label(true), c.id);
|
||
}
|
||
}
|
||
}
|
||
|
||
#[test]
|
||
fn every_ready_catalogue_item_is_a_registered_command() {
|
||
for g in crate::catalog::TOOL_GROUPS {
|
||
for s in g.sections {
|
||
for i in s.items {
|
||
if i.availability == crate::catalog::Availability::Ready {
|
||
assert!(command(i.command).is_some(), "catalogue item {} ({}) is Ready but not registered", i.label, i.command);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
#[test]
|
||
fn shortcut_labels_follow_platform_conventions() {
|
||
let s = command("file.save_as").unwrap().shortcut.unwrap();
|
||
assert_eq!(s.label(true), "⇧⌘S");
|
||
assert_eq!(s.label(false), "Ctrl+Shift+S");
|
||
assert_eq!(command("view.read_mode").unwrap().shortcut.unwrap().label(true), "⌃⌘H");
|
||
assert_eq!(Shortcut::cmd("+").label(false), "Ctrl++");
|
||
assert_eq!(Shortcut::cmd_shift("−").label(true), "⇧⌘−");
|
||
assert_eq!(Shortcut::cmd_shift("−").label(false), "Ctrl+Shift+−");
|
||
assert_eq!(Shortcut::command_name(true), "⌘");
|
||
assert_eq!(Shortcut::command_name(false), "Ctrl");
|
||
}
|
||
|
||
#[test]
|
||
fn enablement_follows_the_document_state() {
|
||
let mut s = Session::new();
|
||
let undo = command("edit.undo").unwrap();
|
||
let save = command("file.save").unwrap();
|
||
assert!(!is_enabled(save, &s, None));
|
||
assert!(is_enabled(command("file.open").unwrap(), &s, None));
|
||
let id = s.open("a.pdf", None, std::sync::Arc::new(crate::tests::fixture(2)), None).unwrap();
|
||
assert!(is_enabled(save, &s, Some(id)));
|
||
assert!(!is_enabled(undo, &s, Some(id)));
|
||
s.apply(id, crate::Edit::RotatePages { pages: vec![0], degrees: 90 }).unwrap();
|
||
assert!(is_enabled(undo, &s, Some(id)));
|
||
assert_eq!(current_label(undo, &s, Some(id)), "Undo Rotate page");
|
||
}
|
||
}
|