Commit Graph

20 Commits

Author SHA1 Message Date
landon e5eadc08c1 Add Mistral plot-beat generation (Tools menu)
New Tools ▸ "Generate plot beats (Mistral)…" command: pick a novel
proposal markdown file (characters + loose plot summary) and have the
Mistral chat API lay it out as plot beats in the classic three-act
structure. The result opens in a floating window where it can be edited,
saved as a new "<proposal> — beats.md" workspace file, or copied.

- src/mistral.rs: pure-Rust ureq/rustls POST to /v1/chat/completions
  (self-contained; no C bindings). System prompt fixes the three-act
  markdown shape; friendly API-error surfacing. Unit tests for content
  parsing, empty/blank responses, error-message extraction, and the
  missing-key guard.
- config: mistral_api_key / mistral_model / mistral_base_url with
  effective-value helpers and defaults (mistral-large-latest,
  https://api.mistral.ai).
- app: background generation + poll (editor stays responsive), a
  Settings ▸ Mistral… window (key/model/base URL), and the results
  window with save/copy.
- Docs: README "Plot beats (Mistral)" section and help cheatsheet note.

Verified: cargo build --release clean, 56 tests pass (+6 Mistral),
ldd still only libc/libgcc/libm. Clippy: no new warnings in the added
code (the two extra vs. the old 3-warning baseline are toolchain-surfaced
in pre-existing app.rs code).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XDfaEsTgcn61n3wgP62DFF
2026-08-20 14:39:08 -05:00
landon 5bc2acad25 Add header field-name autocomplete above the draft marker
Typing a header line above the draft marker (`#`/`##`/… + the start of a
field name) now shows an autocomplete popup: Tab/Enter or click to insert
"Field: ", Up/Down to choose, Esc to dismiss (and stay dismissed until the
partial changes). It never triggers in the prose below the marker.

Suggestions combine a built-in list (Title, Slug, POV, Word Count Target,
Characters, Setting, Conflict, …) with field names learned from every
file's header, refreshed on open and merged on save, so custom fields
autocomplete too.

Implementation: the editor gets a stable id so completions can drive its
cursor/focus; nav keys are consumed before the TextEdit sees them, and the
popup is recomputed from the caret each frame. Pure helpers
(header_completion_context, field_matches, header_field_names) are unit
tested; 50 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N9kRuP7JvXoUGdNNeg5ZSs
2026-08-14 07:30:48 -05:00
landon 894a0746e3 Add a per-file word-count-target bar in the file list
Each file row now shows a compact progress bar beside its name when the
file sets a Word Count Target, alongside the existing detailed bar in the
status bar for the active file. Same colour scheme (amber under / green in
range / blue over) and a hover tooltip with the exact words / target.

The per-file slug/POV cache is generalised to a FileMeta (slug, POV, goal,
prose word count), filled on open and refreshed on save; the selected
file's row reads live from the buffer so its bar tracks as you type.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N9kRuP7JvXoUGdNNeg5ZSs
2026-08-14 06:55:09 -05:00
landon c926b6696f Include the POV field in the file-list hover tooltip
Header parsing now also lifts a `POV:` line (any heading level). The
file-list tooltip combines it with the slug — "POV: <name>" then the
slug synopsis — cached per file alongside the slug (HoverInfo) and read
live from the buffer for the selected file. Adds a POV parse test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N9kRuP7JvXoUGdNNeg5ZSs
2026-08-14 06:49:53 -05:00
landon 9c4498a680 Show each file's slug as a file-list hover tooltip
Hovering a file in the left pane now shows its `# Slug:` line as a
tooltip — a one-line synopsis per chapter. Slugs are cached per file
(name -> slug), filled when the workspace opens (snapshot_slugs) and
refreshed on save; the selected file is parsed live from the buffer so
unsaved slug edits show immediately. The cache is kept consistent on
rename and delete.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N9kRuP7JvXoUGdNNeg5ZSs
2026-08-14 06:46:44 -05:00
landon 9d2207ba96 Parse per-file Word Count Target header and show progress
Header parsing now recognises a `Word Count Target:` line at any heading
level (## included) in addition to `# Title:`/`# Slug:`, and accepts one
or more leading `#`. The value parses a single number or a range —
"1500 - 2000", "1500-2000", "1,500 to 2,000" — into a min/max WordGoal
(stripped from the exported document like the other header lines).

When a target is set, the status bar shows a progress bar of the file's
prose word count (the body below the draft marker) against it: amber
under the target, green in range, blue over. Aliases "Word Count Goal:"
and "Word Count:" also work.

Adds preprocess tests for the range forms, ## heading level, alias, and
absence; 44 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N9kRuP7JvXoUGdNNeg5ZSs
2026-08-14 06:39:22 -05:00
landon 19dddf30c7 Add offline live spell checking (Hunspell via spellbook)
Spelling is now checked live as you type, fully offline, using the
pure-Rust `spellbook` crate to read Hunspell .aff/.dic dictionaries (no C
libhunspell — the binary stays self-contained; ldd unchanged).

- Canadian (en-CA, default) and British (en-GB) English dictionaries are
  compiled in; more languages are auto-discovered from system Hunspell
  folders and ~/.config/md-manuscript/dictionaries/. A "Spelling" row in
  the top bar toggles live checking and picks the dictionary.
- Misspellings are underlined in red; right-clicking a word opens a menu
  of suggested corrections. A results-panel and one-click fixes work too.
- Checks run on a background thread, debounced ~400ms after the last edit.
  Prose is extracted with pulldown-cmark so code spans, code blocks and
  link targets are skipped; ALL-CAPS initialisms are ignored.
- LanguageTool still layers on top: when its results are fresh they own
  the underlines (spelling + grammar); once you edit, the offline checker
  resumes. The editor underlines, issues panel and fix-apply logic are
  now shared between the two sources.

Bundled dictionaries are SCOWL-derived under a permissive license (kept
in dictionaries/<lang>/license). Adds spell-check unit tests (tokenizer,
code-block skipping, offset mapping, en-CA/en-GB spelling); 40 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N9kRuP7JvXoUGdNNeg5ZSs
2026-08-14 06:25:08 -05:00
landon 691d1a0515 Add a find/replace bar to the editor
Ctrl+F opens a find bar above the editor (Ctrl+H focuses the replace
field; Edit ▸ Find / Replace… opens it too). Matches are shaded in the
editor with the active one highlighted more strongly; Enter/Shift+Enter
and ▼/▲ step through them with wraparound and scroll-to-view. An "Aa"
toggle controls case sensitivity. Replace swaps the current match and
advances; Replace all swaps every match in one pass. Esc closes the bar.

Search/replace logic lives in pure, unit-tested functions (find_matches,
replace_all) with non-overlapping matching and correct multibyte offset
mapping for case-insensitive search. Highlighting reuses the editor's
layout-job builder alongside the grammar underlines.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N9kRuP7JvXoUGdNNeg5ZSs
2026-08-14 06:02:46 -05:00
landon ae8de32f04 Add markdown formatting hotkeys to the editor
Ctrl/Cmd+B/I/E wrap the selection in bold / italic / inline-code markers,
Ctrl/Cmd+Shift+X in strikethrough, and Ctrl/Cmd+K as a link (with the url
placeholder selected). Pressing the same key on already-wrapped text
removes the markers. Applied to the live selection via the TextEdit
cursor range, with the caret/selection restored around the edit.

Documented in the built-in cheatsheet and the README.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-04 07:59:19 -05:00
landon 503ef4f24a Add a Help menu with a built-in Markdown cheatsheet
Mirrors the logrs cheatsheet: a scrollable reference window covering the
markdown md-manuscript renders on export, plus the manuscript-specific
conventions (# Title:/# Slug: metadata, the draft-marker header, and
comments). Opened from Help ▸ Markdown cheatsheet in the menu bar.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-29 10:49:13 -05:00
landon b31ac0c6c8 Offer to adopt an enclosing git repository when opening a subfolder
When a workspace folder isn't a git repo itself but sits inside one, ask
the user to confirm before using the parent repository for Sync, rather
than silently operating on whichever repo git walks up to find.

- gitsync: add repo_root() via `git rev-parse --show-toplevel`
- app: detect_repo() distinguishes repo-root / parent-repo / no-repo;
  a confirmation dialog adopts or declines the parent repo; git_init
  tracks repo_root and clears any pending prompt
- Sync button hover names the enclosing repo when one is adopted

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-28 11:58:47 -05:00
landon 496bbfd298 Improve readability: brighter left-pane text and an editor contrast slider
The left file pane now boosts its widget text colours (toward white in dark
mode, black in light mode) so file names stay legible against the panel
background; the change is scoped to that panel only.

Add a "Contrast" slider beside Zoom that interpolates the editor text colour
from the theme default toward maximum contrast, persisted as
editor_text_contrast in the config. build_editor_job takes the computed colour
so underlined grammar/spelling runs match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-27 11:55:25 -05:00
landon 5ecbf3ffbb Add LanguageTool grammar/spell checking with a settings dialog
Check the current file against a LanguageTool server (typically a local
instance) from a background thread. Issues are underlined in the editor
(red spelling, blue grammar) and listed in a bottom panel with one-click
fixes that re-align the remaining matches.

A menu bar (File / View / Settings) exposes a LanguageTool settings
dialog with discrete scheme / host / port / token / language fields, an
endpoint preview, and a Test connection button. Config stores the parts
and assembles the base URL. The token is sent as a bearer header.

Uses ureq with a statically-linked rustls backend, so both http and
https endpoints work with no new runtime library dependencies.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-27 08:33:00 -05:00
landon 2b401b9a3b 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>
2026-07-26 15:21:27 -05:00
landon f05ee655c3 Add zero-pad option for numbered chapter titles
A "Zero-pad #" checkbox pads chapter titles that default to their
position number with leading zeros to a uniform width (the digit count
of the largest chapter number, e.g. 03. of 12). Padding never applies to
"# Title:" headers or manual overrides. The setting persists in config.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-26 14:59:13 -05:00
landon 6680c001bf Page-break between chapters and numeric title fallback
Every chapter after the first now starts on a new page via a
Chapter_20_Break heading style (fo:break-before="page"); the first
chapter keeps the plain heading so there is no blank leading page.

Chapter titles now resolve as: manual override > "# Title:" header >
the chapter's 1-based position in the left pane (e.g. "3."). The old
"# heading" / filename fallbacks are replaced by this numbering, and the
same logic drives the chapter-title hint.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-26 14:51:21 -05:00
landon 7271e5e2ef Add native file dialogs for workspace and export paths
A 📂 button beside each path field opens a native picker: a folder
chooser for the workspace and an .odt save dialog for the export (which
appends the extension if omitted). Uses rfd with the XDG Desktop Portal
backend, so there is no GTK build dependency and no new shared library
at runtime.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-26 14:17:24 -05:00
landon 7008463ebf Add current-file word counter to the status bar
Shows a live word count for the open file plus the net words added or
removed since this session started. Per-file baselines are snapshotted
when the workspace opens (session_start_counts) and follow renames.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-26 13:49:27 -05:00
landon 507e0ab724 Strip comments and header metadata on ODT export
Each file is now cleaned before conversion: HTML comments are removed
and everything above the configurable Draft marker (default
"### Rough Draft:") is dropped. A "# Title:" line becomes the chapter
heading and a "# Slug:" line becomes an italic caption beneath it.

- new preprocess module (strip_comments + header parse) with tests
- Chapter gains a slug rendered via a Chapter_20_Caption style, italic
  at both paragraph-style and character-run level
- draft_marker config setting + top-bar field
- export title priority: override > # Title: > first # heading > filename

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-25 19:01:45 -05:00
landon f473b63ee3 Initial commit: md-manuscript editor
Rust/egui desktop app: draggable markdown file list, editor, git sync,
per-file chapter titles, and native ODT export. Includes README and
Debian 12 (Surface) install guide.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-25 15:17:42 -05:00