Invisible characters
Display markers for spaces, line breaks, and paragraph ends.
Try it
Section titled “Try it”Click after “Two words” and press Space to add a space marker. Press Enter to see a new paragraph end.
Install
Section titled “Install”cargo add gpdoc-plugin-invisible-charactersExample
Section titled “Example”use gpdoc::{EditorConfig, PluginViewExt};use gpdoc_plugin_invisible_characters::{character_markers, invisible_characters, paint_marker};use gpdoc_plugin_paragraph::paragraph;
let config = EditorConfig::builder() .plugin(paragraph()) .plugin(invisible_characters(true).with_view(|| character_markers(paint_marker))) .build() .expect("configure editor");The document plugin stores visibility for each editor. Pass true to show markers when the editor opens, or false to start with them hidden. The view paints the markers over the document.
Run toggleInvisibleCharacters to switch visibility. Use showInvisibleCharacters or hideInvisibleCharacters to set it explicitly. These commands preserve the document’s text.
Compose character markers
Section titled “Compose character markers”Anatomy
Section titled “Anatomy”invisible_characters(true).with_view(...) Starts with the markers visible└── character_markers(...) Calls your painter for each visible marker ├── marker.kind Space, LineBreak, or ParagraphEnd └── marker.bounds Where to paint the glyphShow only paragraph ends
Section titled “Show only paragraph ends”Pass paragraph_end to character_markers in the example. Use the marker kind to choose which glyphs reach the default painter.
use gpdoc::DecorationFrame;use gpdoc_plugin_invisible_characters::{CharacterMarker, MarkerKind};use gpui::{App, Window};
fn paragraph_end(marker: CharacterMarker, frame: &DecorationFrame<'_>, window: &mut Window, cx: &mut App) { if marker.kind == MarkerKind::ParagraphEnd { paint_marker(marker, frame, window, cx); }}Type two words separated by a space and press Enter. A ¶ appears at the end of each paragraph.