Introduce custom fold placeholders (#12214)
This pull request replaces the static `⋯` character we used to insert when folding a range with a custom render function that return an `AnyElement`. We plan to use this in the assistant, but for now this should be behavior-preserving. Release Notes: - N/A --------- Co-authored-by: Nathan <nathan@zed.dev> Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
parent
e0cfba43aa
commit
57d570c281
19 changed files with 774 additions and 437 deletions
|
@ -143,7 +143,7 @@ impl StyledText {
|
|||
}
|
||||
}
|
||||
|
||||
/// todo!()
|
||||
/// Get the layout for this element. This can be used to map indices to pixels and vice versa.
|
||||
pub fn layout(&self) -> &TextLayout {
|
||||
&self.layout
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ impl IntoElement for StyledText {
|
|||
}
|
||||
}
|
||||
|
||||
/// todo!()
|
||||
/// The Layout for TextElement. This can be used to map indices to pixels and vice versa.
|
||||
#[derive(Default, Clone)]
|
||||
pub struct TextLayout(Arc<Mutex<Option<TextLayoutInner>>>);
|
||||
|
||||
|
@ -358,7 +358,7 @@ impl TextLayout {
|
|||
}
|
||||
}
|
||||
|
||||
/// todo!()
|
||||
/// Get the byte index into the input of the pixel position.
|
||||
pub fn index_for_position(&self, mut position: Point<Pixels>) -> Result<usize, usize> {
|
||||
let element_state = self.lock();
|
||||
let element_state = element_state
|
||||
|
@ -392,7 +392,7 @@ impl TextLayout {
|
|||
Err(line_start_ix.saturating_sub(1))
|
||||
}
|
||||
|
||||
/// todo!()
|
||||
/// Get the pixel position for the given byte index.
|
||||
pub fn position_for_index(&self, index: usize) -> Option<Point<Pixels>> {
|
||||
let element_state = self.lock();
|
||||
let element_state = element_state
|
||||
|
@ -423,17 +423,17 @@ impl TextLayout {
|
|||
None
|
||||
}
|
||||
|
||||
/// todo!()
|
||||
/// The bounds of this layout.
|
||||
pub fn bounds(&self) -> Bounds<Pixels> {
|
||||
self.0.lock().as_ref().unwrap().bounds.unwrap()
|
||||
}
|
||||
|
||||
/// todo!()
|
||||
/// The line height for this layout.
|
||||
pub fn line_height(&self) -> Pixels {
|
||||
self.0.lock().as_ref().unwrap().line_height
|
||||
}
|
||||
|
||||
/// todo!()
|
||||
/// The text for this layout.
|
||||
pub fn text(&self) -> String {
|
||||
self.0
|
||||
.lock()
|
||||
|
|
|
@ -302,7 +302,7 @@ impl WrappedLineLayout {
|
|||
}
|
||||
}
|
||||
|
||||
/// todo!()
|
||||
/// Returns the pixel position for the given byte index.
|
||||
pub fn position_for_index(&self, index: usize, line_height: Pixels) -> Option<Point<Pixels>> {
|
||||
let mut line_start_ix = 0;
|
||||
let mut line_end_indices = self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue