Skip to content

maerkdown: the style row shows which toggles are armed - #21

Open
nicolas-maman wants to merge 1 commit into
mainfrom
feat/maerkdown-toolbar-state
Open

maerkdown: the style row shows which toggles are armed#21
nicolas-maman wants to merge 1 commit into
mainfrom
feat/maerkdown-toolbar-state

Conversation

@nicolas-maman

Copy link
Copy Markdown
Contributor

Ctrl+B armed bold, but nothing on screen said so. pend was only visible in the debug caret line, so pressing B or Ctrl+B gave no feedback until you typed the next word.

The eight style buttons now carry an accent while armed and the theme's plate colour while idle, seeded once at startup so the row does not jump from native to plated on the first edit.

Why it re-reads rather than latches

pend stays the single source of truth. sync_toolbar re-reads it from publish, which every edit already funnels through. A button that latched on click would stay lit after commit_word clears pend, i.e. lit over a word that is no longer being styled. Re-reading also means the Ctrl+B/I/U shortcuts light the row for free, since they go through the same toggle_flag.

Why colour and not a label marker

I tried the label first ([B] when armed) and backed it out. widget_id_of matches widget text exactly, so the spec suite addresses these buttons as "B", "U", "Mark", "Sup", "Sub". A label that changed with state would make them unaddressable mid-run, and would read oddly to a screen reader too. Colour leaves the labels alone.

Idle colour follows is_dark_mode(), so the plate suits either desktop theme.

Testing

Driven end to end through the UI driver on macOS:

  • idle at startup: all eight plated, none accented
  • click B: B accents to #3d77c6, the other seven stay on the idle plate
  • type a word and press space: B returns to the idle plate as pend clears, which is the case a latching implementation would get wrong
  • buttons still resolve by exact label, so the spec's lookups keep working

Builds clean with no new warnings (13 W1001 before and after, all pre-existing). test_mdown passes.

One caveat: I could not run spec_maerkdown locally, it fails to compile against my aeocha checkout with 'expect_http_post_ok' is not exported from module 'aeocha'. That failure reproduces identically on unmodified main, so it is a stale local checkout rather than anything in this branch, but it does mean the spec has not been run against this change here. Worth a CI look.

Ed gains nine fields (eight handles plus the theme flag), so its allocation goes 104 to 176 bytes.

Ctrl+B (or the B button) armed bold, but nothing on screen said so:
`pend` was only visible in the debug caret line, so a toggle gave no
feedback until the next word was typed.

The eight style buttons now carry an accent while armed and the theme's
plate colour while idle, seeded once at startup so the row does not jump
from native to plated on the first edit.

`pend` stays the single source of truth. sync_toolbar re-reads it from
publish, which every edit already funnels through, rather than latching
on click. That matters because commit_word clears pend after XORing it
into the word, so a latched button would stay lit over a word that is no
longer being styled.

Colour rather than a label marker deliberately: the labels are how the
UI driver and screen readers address these buttons (widget_id_of matches
text exactly), so a label that changed with state would make them
unaddressable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant