Merge branch 'port/deckcraft/red/app-r7-1' into port/deckcraft/area/app

This commit is contained in:
Dylan M. Taylor committed 2026-11-28 00:45:34 +00:00
commit 0e152c076e
1 file changed
+23 -17
+23 -17
View File
@@ -2,7 +2,7 @@ use std::ops::Range;
use craft::behavior::{MotionMode, kurbo::Point};
use craft::text::ui::editor::{
CaretAffinity, CaretLine, CaretStop, ClickRuns, EditKind, EditorComposition, EditorEnd, HostLine, HostRun, TextEditor, TextEditorHost,
CaretAffinity, CaretLine, CaretStop, ClickRuns, EditKind, EditorComposition, EditorEnd, HostLine, HostRun, TabKeys, TextEditor, TextEditorHost,
TextEditorOutput, TextReplacement, TextSelection,
};
use craft::ui::canvas::CanvasSpace;
@@ -293,22 +293,8 @@ impl TextEditorHost for EngineTextHost<'_> {
props.vert.unwrap_or(TextDir::Horizontal) != TextDir::Horizontal
}
/// Tab in a cell goes to the next cell, at a paragraph start or over a range it changes the list level; Shift+Tab
/// elsewhere types a tab as Tab does.
fn tab(&mut self, selection: TextSelection, back: bool) -> Option<TextSelection> {
self.select(selection);
match self.session.text_tab(back) {
Ok(true) => self.adopt_selection(),
Ok(false) if back => {
let replaced = self.replace(selection.range(), "\t", EditKind::Typed)?;
Some(replaced.selection)
}
Ok(false) => None,
Err(error) => {
self.error = Some(error.to_string());
Some(selection)
}
}
fn tab_keys(&mut self) -> Option<&mut dyn TabKeys> {
Some(self)
}
fn caret_stop(&mut self, offset: usize, stop: CaretStop, forward: bool) -> Option<usize> {
@@ -347,6 +333,26 @@ impl TextEditorHost for EngineTextHost<'_> {
}
}
impl TabKeys for EngineTextHost<'_> {
/// Tab in a cell goes to the next cell, at a paragraph start or over a range it changes the list level; Shift+Tab
/// elsewhere types a tab as Tab does.
fn tab(&mut self, selection: TextSelection, back: bool) -> Option<TextSelection> {
self.select(selection);
match self.session.text_tab(back) {
Ok(true) => self.adopt_selection(),
Ok(false) if back => {
let replaced = self.replace(selection.range(), "\t", EditKind::Typed)?;
Some(replaced.selection)
}
Ok(false) => None,
Err(error) => {
self.error = Some(error.to_string());
Some(selection)
}
}
}
}
fn layout_affinity(affinity: CaretAffinity) -> Affinity {
if affinity == CaretAffinity::Upstream { Affinity::Upstream } else { Affinity::Downstream }
}