Skip to content

fontlabapp.core.edit_guards

edit_guards

Public queue disclosure and refusal guards for scripts that write to the current font.

What: queue disclosure for ordinary writers, and four checks that raise ValueError before any native write.

  • require_selection_window(package_id): the active panel is a Font window of the bound font (FontLab issue 8528: selection writers crash while a Glyph window is active).
  • require_no_editors(): no Glyph editor is open, also an inactive one (the Unicode save-cache gap of the duplicate-Unicode writer).
  • require_settled(): FontLab has no queued native glyph updates (FontLab issue 8537: queued cache updates become semantic edits later).
  • require_history_scope(glyphs, creates=...): no Glyph window is the active canvas, or every owner glyph is in that canvas and no glyph is new (FontLab issue 8573: from a Glyph window, the Undo step covers only the glyphs that the canvas shows). fontlabapp.core.history.glyphs.commit, fontlabapp.glyphs.creation.create_glyphs and the eight App writers that call notifyChangesApplied directly call it.

How: the selection and editor guards delegate to the reviewed private implementation (scripting._require_selection_window, duplicate_unicodes_capture.require_no_editors); require_settled reads the native queue once; require_history_scope reads the text blocks of the active canvas once. The implementations load only when a guard runs, so this module imports only the standard library and FontLab's 5-second cold import stays fast.

Why: scripts must not import private App names. Use these guards through fly.ap.core.edit_guards. fontlabapp.core.history.glyphs.commit discloses the queue by default; settled=True explicitly opts into refusing it. Never normalise unrelated dates. Offline tests do not prove native behaviour.

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
CANVAS_SCAN_SECONDS attribute
CANVAS_TEXT attribute
EDITOR_SCAN_SECONDS attribute
append_note function (text: str, result: Mapping[str, Any]) -> str Append the stored pre-write note once, using the standard separator.
canvas_glyphs function (native: Any=None, *, deadline: float | None=None) -> frozenset[tuple[int, str]] | None Return the glyphs that the active Glyph window shows, or <code>None</code>.
disclose function (result: Any, target: dict[str, Any] | None=None) -> None Copy a commit's disclosure to a caller's result, or print it for CLI use.
pending_note function (ids: Sequence[int]) -> str Explain queued ids and their date caveat, or return empty text.
pending_updates function (native: Any=None) -> tuple[int, ...] Read the native queue once before a write; never clear or deliver it.
require_history_scope function (glyphs: Sequence[Any], *, creates: bool=False, native: Any=None) -> None Refuse a write that FontLab would undo only in part (FontLab issue 8573).
require_no_editors function (*, qt: Any=None, deadline: float | None=None, action: str='removing Unicode assignments') -> None Refuse a write while any Glyph editor is open, also an inactive one.
require_selection_window function (package_id: int) -> None Refuse a write unless a Font window of the bound font is active.
require_settled function (native: Any=None) -> None Refuse a write while FontLab has queued native glyph updates.