Skip to content

Commit 0fae175

Browse files
feigeCodeclaude
andcommitted
input: gutter markers, range decorations, and inline widgets
Editors can now show feature-owned markers in a reserved gutter lane, geometric Fill/Frame decorations over UTF-8 ranges, and non-document inline widgets at an offset. All three follow text edits and are exposed through InputBaseState setters plus an Editor builder for the marker renderer; markers report clicks through InputEvent::GutterMarkerMouseDown. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 32030ed commit 0fae175

11 files changed

Lines changed: 848 additions & 24 deletions

File tree

‎crates/base/src/input/base/element.rs‎

Lines changed: 395 additions & 4 deletions
Large diffs are not rendered by default.

‎crates/base/src/input/base/kind.rs‎

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@
2121
//! reachable.
2222
2323
use std::cell::RefCell;
24+
use std::collections::HashMap;
2425
use std::rc::Rc;
2526

26-
use gpui::{Div, Entity, Stateful, Window};
27+
use gpui::{Bounds, Div, Entity, Pixels, SharedString, Stateful, Window};
2728
use ropey::Rope;
2829

29-
use super::decorations::DecorationCollections;
30+
use super::decorations::{DecorationCollections, EditorAnnotations};
3031
use super::lsp::{ContextMenuContent, HoverDefinition, InlineCompletion};
3132
use crate::input::{
32-
HighlightStyleResolver, InputEdit, InputHighlighter, SyntaxContext, TextDecoration,
33+
GutterMarker, HighlightStyleResolver, InlineWidget, InputEdit, InputHighlighter,
34+
RangeDecoration, SyntaxContext, TextDecoration,
3335
};
3436
use crate::input::{HoverPopoverState, Lsp};
3537
use gpui::Task;
@@ -115,6 +117,36 @@ pub trait InputExtras: Default + 'static {
115117
fn context_menu_capabilities(&self) -> (bool, bool) {
116118
(false, false)
117119
}
120+
121+
/// Feature-owned gutter markers anchored to logical rows.
122+
fn gutter_markers(&self) -> &[GutterMarker] {
123+
&[]
124+
}
125+
126+
/// Whether the gutter marker lane has ever been used and stays reserved.
127+
fn gutter_lane_reserved(&self) -> bool {
128+
false
129+
}
130+
131+
/// The application-owned presentation for gutter markers, if any.
132+
fn gutter_marker_renderer(&self) -> Option<crate::input::GutterMarkerRenderer> {
133+
None
134+
}
135+
136+
/// Last-paint bounds per gutter marker, keyed by marker id.
137+
fn gutter_marker_bounds(&self) -> Option<Rc<RefCell<HashMap<SharedString, Bounds<Pixels>>>>> {
138+
None
139+
}
140+
141+
/// Geometric range decorations to paint.
142+
fn range_decorations(&self) -> &[RangeDecoration] {
143+
&[]
144+
}
145+
146+
/// Non-document inline widgets to paint at their offsets.
147+
fn inline_widgets(&self) -> &[InlineWidget] {
148+
&[]
149+
}
118150
}
119151

120152
/// A mode with nothing extra to render.
@@ -341,6 +373,7 @@ pub struct EditorExtras {
341373
pub(crate) hover_popover: Option<HoverPopoverState>,
342374
pub(crate) hover_definition: HoverDefinition,
343375
pub(crate) context_menu_task: Task<anyhow::Result<()>>,
376+
pub(crate) annotations: EditorAnnotations,
344377
}
345378

346379
impl Default for EditorExtras {
@@ -353,6 +386,7 @@ impl Default for EditorExtras {
353386
hover_popover: None,
354387
hover_definition: HoverDefinition::default(),
355388
context_menu_task: Task::ready(Ok(())),
389+
annotations: EditorAnnotations::default(),
356390
}
357391
}
358392
}

‎crates/base/src/input/base/state.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,16 @@ actions!(
121121
#[derive(Clone)]
122122
pub enum InputEvent {
123123
Change,
124-
PressEnter { secondary: bool, shift: bool },
124+
PressEnter {
125+
secondary: bool,
126+
shift: bool,
127+
},
125128
Focus,
126129
Blur,
130+
GutterMarkerMouseDown {
131+
marker_id: SharedString,
132+
logical_row: usize,
133+
},
127134
}
128135

129136
pub(super) const CONTEXT: &str = "Input";

0 commit comments

Comments
 (0)