Skip to content
gpdoc
Playground

Invisible characters

Display markers for spaces, line breaks, and paragraph ends.

Click after “Two words” and press Space to add a space marker. Press Enter to see a new paragraph end.

Terminal window
cargo add gpdoc-plugin-invisible-characters
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.

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 glyph

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.

invisible-characters/src/lib.rs