IT. WORKS.
HOLY MOLY IT WORKS
okay so the editor was bad. like really bad. it was a stack of separate blocks where you’d click one, it’d turn into a little text box, and moving between them felt like filling out a tax form. so i did the normal reasonable thing and threw the whole thing out lol
the new editor is built on cosmic-text (the text engine from the COSMIC desktop people, they’re epic).
penumbra-ui doesn’t use the old block-based EditorSession anymore. instead there’s a new rich_editor.rs, about 900 lines cryign emoji, that does everything itself. it shapes the text, draws it into an RGBA pixel buffer, and passes that to slint as an image. slint basically just shows a picture of text and forwards me the keys and clicks. the caret is a separate blinking rectangle drawn on top, because a caret baked into the image would only blink when the whole thing re-rendered, which is cursed
so slint shows a rendered picture of my text editor. is that unhinged? maybe. does it let me have one continuous document with real selection, drag select, double click to select a word, and scrolling? yes :3
is that worth it?
DEFINITELY
markdown too
the markdown round-trips. it parses the note into the penumbra-markdown AST, turns it into styled text runs, and when you edit it turns the buffer back into blocks and inlines and writes markdown. bold stays **bold** and inline code stays inline code. there are 6 round-trip tests so i don’t silently eat someone’s notes
speaking of eating notes, there’s a comment in there that says text with no style attached gets emitted as plain text “so no characters are dropped (this was pain to find)”. yeah. letters you typed at the end of a line were just vanishing on save. fun times
slint and UI
oh and i’m now vendoring my own fork of slint as a git submodule, and the workspace points every slint crate at vendor/slint.
also some UI polish while i was there: a little highlight line on the top bar and the new note button, a “A universe for your notes” subtitle, an accent bar on the left of the selected card, card previews capped so they don’t overflow, and the zoom readout got some breathing room
LOL the editor is a fixed 760x440 surface right now, headings just render as bold text, and other block types are pretty bare. but it finally FEELS like typing in a text editor and not like clicking through form fields, and that’s the important part
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.