Document navigation buttons provide a quick way to jump to the top, middle, or bottom of a document. They appear as a subtle floating overlay in the top-left corner of the editor area.
- Position: Top-left corner of the editor, with 8px margin
- Visibility: Buttons are hidden by default and only appear when the mouse is near the button area (within 20px expanded hover zone)
- Styling: Semi-transparent buttons that become more visible on hover
- Idle: 40% opacity
- Hover: 87% opacity with subtle border
| Button | Icon | Action |
|---|---|---|
| Top | ⤒ | Jump to document start |
| Middle | ◉ | Jump to document center |
| Bottom | ⤓ | Jump to document end |
Buttons automatically adapt to the current theme:
- Dark mode: Dark background with light text
- Light mode: Light background with dark text
When clicking a navigation button in the raw editor:
- Top: Scrolls to line 0, places cursor at position (0, 0)
- Middle: Scrolls to center the middle line of the document, places cursor at that line
- Bottom: Scrolls to show the last line, places cursor at end of document
When clicking a navigation button in rendered mode:
- Top: Scrolls to the top of the rendered content (offset 0)
- Middle: Scrolls to center the middle of the content
- Bottom: Scrolls to the bottom of the content
Note: In rendered mode, cursor position is not tracked as it is in raw mode.
The navigation buttons complement existing keyboard shortcuts:
| Shortcut | Action |
|---|---|
Ctrl+Home |
Jump to document start (same as Top button) |
Ctrl+End |
Jump to document end (same as Bottom button) |
There is currently no keyboard shortcut for jumping to the middle of the document.
The navigation button implementation is located in src/ui/nav_buttons.rs.
/// Renders navigation buttons overlay and returns any requested action.
pub fn render_nav_buttons(ui: &mut Ui, editor_rect: Rect, is_dark_mode: bool) -> NavAction
/// Action requested by navigation button click.
pub enum NavAction {
None, // No button clicked
Top, // Jump to top
Middle, // Jump to middle
Bottom, // Jump to bottom
}-
FerriteEditor (
src/editor/ferrite/editor.rs):- Navigation buttons are rendered at the end of the
ui()method - Actions are handled by calling
view.scroll_to_line()andset_cursor()
- Navigation buttons are rendered at the end of the
-
MarkdownEditor (
src/markdown/editor.rs):- Navigation buttons are rendered after the scroll area in
show_rendered_editor() - Actions store the target scroll offset in egui memory for the next frame
- The stored offset is read and applied before the scroll area is created
- Navigation buttons are rendered after the scroll area in
const BUTTON_SIZE: f32 = 24.0; // Button dimensions
const BUTTON_SPACING: f32 = 2.0; // Vertical spacing between buttons
const MARGIN: f32 = 8.0; // Distance from editor edge
const IDLE_ALPHA: u8 = 100; // Transparency when not hovered
const HOVER_ALPHA: u8 = 220; // Transparency when hovered- Click each button - Verify jumps to correct position
- Test in raw mode - Verify cursor moves with scroll
- Test in rendered mode - Verify scroll without cursor movement
- Test with various file sizes - Ensure works with small and large documents
- Verify buttons don't obstruct content - Buttons should fade when not in use
- Test hover states - Buttons should become more visible on hover
- Test theme compatibility - Verify appearance in both dark and light modes