editor/editor.rs
1//! The editing surface.
2//!
3//! The document is the single source of truth. There is no `TextField` per
4//! block: a selection is a pair of `Cursor`s into one `Doc`, which is what
5//! makes Enter split, Backspace merge and Tab indent into list operations
6//! rather than negotiations between separate widgets each owning a string.
7//!
8//! Everything about *what* an edit does lives in `markdown` — `edit` and
9//! `select` — and is tested there without a window. This crate owns only what
10//! needs one: a focus handle, key bindings, the platform input handler, and
11//! turning a click into a position.
12
13use gpui::{
14 App, Context, CursorStyle, ElementInputHandler, EventEmitter, FocusHandle, Focusable,
15 KeyContext, MouseButton, Render, Styled as _, Task, Window, canvas, div, prelude::*,
16};
17use markdown::{
18 Annotation, AppExt as _, Block, BlockKind, BlockLayouts, Cursor, Doc, Form, Mark, Part,
19 Selection, Splice, Text, edit, edit::shortcut,
20};
21use std::{ops::Range, time::Duration};
22use theme::Theme;
23
24use crate::{
25 anchor::{Anchor, AnchorId, Delta},
26 history::{EditKind, History},
27 link::{self, Choice},
28 slash::Slash,
29 text_size,
30};
31
32mod anchors;
33mod blocks;
34mod caret;
35mod clipboard;
36pub(crate) mod image;
37mod input;
38pub mod keys;
39pub(crate) mod menu;
40mod mode;
41mod pointer;
42mod render;
43mod table;
44mod typing;
45
46pub use keys::init;
47use keys::{
48 Backspace, Copy, Cut, DecreaseTextSize, Delete, DeleteToHome, DeleteWordLeft, DeleteWordRight,
49 Dismiss, DocumentEnd, DocumentStart, Down, DuplicateBlock, End, Home, IncreaseTextSize, Indent,
50 InsertParagraph, KillLine, Left, MoveBlockDown, MoveBlockUp, Outdent, Paste, Redo, RemoveBlock,
51 ResetTextSize, Right, SelectAll, SelectDocumentEnd, SelectDocumentStart, SelectDown, SelectEnd,
52 SelectHome, SelectLeft, SelectRight, SelectUp, SelectWordLeft, SelectWordRight, SoftBreak,
53 SplitBlock, ToggleBold, ToggleCode, ToggleHighlight, ToggleItalic, ToggleStrike, Undo, Up,
54 WordLeft, WordRight,
55};
56
57pub const CONTEXT: &str = "BezelEditor";
58
59/// The custom mark [`ToggleHighlight`] toggles. It does nothing until the app
60/// registers a mark under this name with [`markdown::AppExt::set_marks`].
61pub const HIGHLIGHT_MARK: &str = "highlight";
62
63/// [`CONTEXT`], which every binding in [`keys`] is scoped to, plus the mark
64/// that keeps `tab` for [`Editor::indent`].
65fn key_context() -> KeyContext {
66 let mut context = KeyContext::default();
67 context.add(CONTEXT);
68 context.add(ui::focus::CLAIMS_TAB);
69 context
70}
71
72/// What the editor tells its host about.
73///
74/// An app holding comment threads has to hear that the document moved, or its
75/// side of the pairing goes stale against anchors that did not. Split the way
76/// [`ui::input::FieldEvent`] is, so a listener takes only the half it needs.
77#[derive(Clone, Copy, Debug, PartialEq)]
78pub enum EditorEvent {
79 /// The document is different, and the anchors have been mapped through it.
80 Changed,
81 /// A click landed on an anchor's range.
82 AnchorActivated(AnchorId),
83 /// The editor switched between the document and its source, which a host
84 /// lighting its own toggle has no other way to hear about — the switch can
85 /// come from an undo as well as from the button.
86 ModeChanged(Mode),
87}
88
89/// Which form the document is being edited in.
90///
91/// The trigger is the app's: a button, a menu row, a chord of its own. What is
92/// here is the switch it calls, because the caret, the undo history and the
93/// focus have to survive it, and only the editor owns all three.
94#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
95pub enum Mode {
96 /// The document as it reads.
97 #[default]
98 Blocks,
99 /// The markdown a save would write, in one editable text.
100 Source,
101}
102
103/// Which of the editor's own affordances are on.
104///
105/// All of them unless an app says otherwise: a document with nothing
106/// discoverable on it is the wrong default for a library. Turning one off is
107/// for an app that puts its own in the same place — a bar with its own block
108/// menu does not want the gutter handle's as well — rather than for trimming.
109#[derive(Clone, Copy, Debug, PartialEq, Eq)]
110pub struct Chrome {
111 /// The gutter handle, the menu it opens, and dragging a block by it.
112 pub handle: bool,
113 /// The `/` menu at an empty block.
114 pub slash: bool,
115 /// A fence's language label, and the picker it opens.
116 pub language: bool,
117 /// The menu a pasted URL drops — leave it, or make a card, a chip or the
118 /// picture it points at.
119 pub paste: bool,
120}
121
122impl Default for Chrome {
123 fn default() -> Self {
124 Self {
125 handle: true,
126 slash: true,
127 language: true,
128 paste: true,
129 }
130 }
131}
132
133/// What a toolbar reads to light itself, in one call.
134///
135/// Every field is a question a bar asks on every frame, and each was a separate
136/// reach into the document before: which marks are lit, what the block is
137/// called, whether cmd-E would fence, and whether any of it applies at all.
138/// Taken together so a bar cannot answer half of them from one frame and half
139/// from the next.
140#[derive(Clone, Debug, PartialEq, Eq)]
141pub struct Formatting {
142 /// Which form the document is in. In [`Mode::Source`] the markup is already
143 /// spelled out, so [`Self::marks`] is empty and a bar has nothing to light.
144 pub mode: Mode,
145 /// The marks the selection carries throughout — and at a collapsed caret,
146 /// the ones the next character typed would carry, cmd-B before typing
147 /// included.
148 pub marks: Vec<Mark>,
149 /// What the caret's block is called in [`turns`], or `None` for a block the
150 /// menu does not offer.
151 pub block: Option<gpui::SharedString>,
152 /// Whether [`Mark::Code`] here makes a fence out of the selection rather
153 /// than an inline span — the one chord whose meaning changes with what is
154 /// selected, and the one a bar cannot work out for itself.
155 pub fenceable: bool,
156}
157
158/// Every block a block can be turned into, and what each is called — the
159/// vocabulary the slash menu and the block menu both offer, for an app building
160/// a menu of its own. Pair with [`Editor::set_block`], which is what both of
161/// bezel's own menus call.
162pub fn turns() -> Vec<(gpui::SharedString, BlockKind)> {
163 crate::slash::items()
164}
165
166/// Shown on the focused block while it is empty — the only discoverable place
167/// to say that `/` does anything.
168const PLACEHOLDER: &str = "Type / for commands";
169
170/// What tab inserts in the source, where there are no blocks to indent. Two
171/// spaces, which is what markdown's own nesting is written in.
172const INDENT: &str = " ";
173
174/// Half the caret's blink period — `ui::TextField`'s, which is the 500ms on,
175/// 500ms off macOS itself uses.
176const BLINK: Duration = Duration::from_millis(500);
177
178/// The handle's box. Wide enough to be hit without crowding the margin; how
179/// far left of the text it sits is [`Layout::text_inset`](crate::Layout).
180const HANDLE_SIZE: f32 = 18.0;
181
182/// How far a drag on an image's edge handle can shrink it — matches
183/// `markdown::render`'s `TABLE_MIN_COLUMN_WIDTH`, the same floor for the
184/// other block content a drag can resize.
185const MIN_IMAGE_WIDTH: f32 = 96.0;
186
187/// Whether a selection is prose covering more than one line — two blocks, or
188/// one line break inside a single block.
189///
190/// What a chord means about a selection is the editor's to decide; a [`Doc`]
191/// has no opinion about it. A selection reaching into a table or a fence is not
192/// prose and keeps the inline behaviour, because half a table has no lines to
193/// make a fence out of.
194fn fenceable(doc: &Doc, selection: Selection) -> bool {
195 let spans = doc.spans(selection);
196 let covered = |at: &Cursor, range: &Range<usize>| {
197 doc.blocks[at.block]
198 .text_at(at.part)
199 .and_then(|text| text.text.get(range.clone()))
200 };
201 spans.iter().all(|(at, _)| at.part == Part::Body)
202 && (spans.len() > 1
203 || spans
204 .iter()
205 .any(|(at, range)| covered(at, range).is_some_and(|text| text.contains('\n'))))
206}
207
208/// Give an empty document a block to hold a caret, and say whether one was
209/// needed.
210///
211/// A [`Doc`] with no blocks is a legitimate document — it is what `parse("")`
212/// returns — but it is not something that can be edited: nothing paints, so
213/// there is no caret and no placeholder, and neither a click nor a hit test
214/// has a target to find. An empty file would sit inert until something typed
215/// a block into existence, which is the one thing you cannot do with no caret.
216fn ensure_block(doc: &mut Doc) -> bool {
217 if !doc.blocks.is_empty() {
218 return false;
219 }
220 doc.blocks
221 .push(Block::new(BlockKind::Paragraph(Text::default())));
222 true
223}
224
225fn line_home(at: Cursor, doc: &Doc) -> Cursor {
226 let Some(text) = doc
227 .blocks
228 .get(at.block)
229 .and_then(|block| block.text_at(at.part))
230 else {
231 return at.home();
232 };
233 Cursor {
234 offset: ui::input::line_start(&text.text, at.offset.min(text.text.len())),
235 ..at
236 }
237}
238
239fn line_end(at: Cursor, doc: &Doc) -> Cursor {
240 let Some(text) = doc
241 .blocks
242 .get(at.block)
243 .and_then(|block| block.text_at(at.part))
244 else {
245 return at.end(doc);
246 };
247 Cursor {
248 offset: ui::input::line_end(&text.text, at.offset.min(text.text.len())),
249 ..at
250 }
251}
252
253/// The document a source view is edited as: one fence holding the markdown.
254///
255/// A fence rather than a paragraph because a fence is the block whose caret
256/// already behaves like a plain text editor's — Enter is a newline, nothing
257/// typed into it is markup, and its lines are laid out one per source line.
258fn source_doc(source: &str) -> Doc {
259 Doc {
260 blocks: vec![Block::new(BlockKind::Code {
261 language: Some(markdown::source::LANGUAGES[0].to_string()),
262 code: Text::plain(source),
263 })],
264 }
265}
266
267/// One of the two floating menus a block drops — the block it belongs to and
268/// where it hangs. A `Popup` rather than an `Option` for the exit phase, and
269/// for the press note: the card's `on_mouse_down_out` fires on the *press*, so
270/// without one a trigger's click on the *release* reopens what it just shut.
271pub(crate) type MenuPopup = ui::popover::Popup<(usize, gpui::Point<gpui::Pixels>)>;
272
273/// The row, column, or cell whose table menu is open.
274#[derive(Clone, Copy, PartialEq, Eq)]
275pub(crate) enum TableTarget {
276 Row(usize),
277 Column(usize),
278 Cell { row: usize, column: usize },
279}
280
281/// A table's row or column, as [`markdown::Part::Cell`] numbers them.
282#[derive(Clone, Copy, Debug, PartialEq, Eq)]
283pub(crate) enum Line {
284 Row(usize),
285 Column(usize),
286}
287
288pub struct Editor {
289 doc: Doc,
290 /// The dialect this document is read and written in — the app's own marks,
291 /// taken once at construction. One editor, one spelling: a document that
292 /// changed dialect between a read and a write would rewrite itself.
293 marks: markdown::Marks,
294 /// Which of the editor's own affordances paint. The app's, so one document
295 /// can carry the lot and another none of it.
296 chrome: Chrome,
297 /// Which form the document is in. In [`Mode::Source`] `doc` is one fenced
298 /// block holding the markdown, so every operation below that is about
299 /// *blocks* asks [`Editor::blocks`] first.
300 mode: Mode,
301 /// Collapsed for an ordinary caret, so there is one position here rather
302 /// than a caret and a range that can disagree.
303 selection: Selection,
304 focus_handle: FocusHandle,
305 /// The IME composition range within the caret's text, underlined while it
306 /// is being composed.
307 marked: Option<Range<usize>>,
308 /// Where each text landed last frame, so a click can be turned into a
309 /// caret. Only paint knows this, so the renderer fills it.
310 layouts: BlockLayouts,
311 history: History,
312 /// Which half of the blink the caret is in. Flipped by [`Self::start_blink`].
313 caret_on: bool,
314 /// The blink, alive only while the document holds focus.
315 blink: Option<Task<()>>,
316 /// Comment ranges, mapped through every edit and snapshotted with the
317 /// document. Here rather than in the app because an undo restores a whole
318 /// document and leaves no delta an app could map its own copy through.
319 anchors: Vec<Anchor>,
320 /// Marks the next typed character will carry — cmd-B at a collapsed caret,
321 /// which otherwise has no range to apply to and so would do nothing.
322 /// Cleared by any motion, because they belong to a spot and not to a mood.
323 stored: Vec<Mark>,
324 /// The open slash menu, if `/` started one.
325 slash: Option<Slash>,
326 /// The open paste menu, if a URL landed in a block of its own.
327 pasted: Option<link::Paste>,
328 /// The open prompt, if an image is waiting to be told where to look.
329 url_prompt: Option<image::Prompt>,
330 /// The block a file being dragged over the document would land after.
331 dropping: Option<usize>,
332 /// The block the pointer is over, which is the only one showing a handle.
333 hovered: Option<usize>,
334 /// The table cell the pointer is over, whose row and column show handles.
335 hovered_cell: Option<(usize, Part)>,
336 /// A table row's or column's menu: the table, the line and where it hangs.
337 table_drag: Option<table::TableDrag>,
338 table_dragged: bool,
339 table_menu: ui::popover::Popup<(usize, TableTarget, gpui::Point<gpui::Pixels>)>,
340 /// A block being dragged by its handle, and where it would land.
341 lifted: Option<(usize, usize)>,
342 /// An image being dragged wider or narrower by its edge handle, and the
343 /// width it holds now — `None` being the natural one, exactly as the
344 /// document spells it. The document only learns the final width on
345 /// release, the same reason `lifted` waits for the drop; carrying the
346 /// document's own value here is what makes a press that never moved
347 /// read back as no change at all.
348 resizing: Option<(usize, Option<u32>)>,
349 /// The block menu the handle opened, and where to anchor it.
350 block_menu: MenuPopup,
351 /// The language menu a fence's header opened, and the block it belongs to.
352 language_menu: MenuPopup,
353 /// Set by a floating layer's press — the gutter handle, the URL prompt —
354 /// so the editor's own press does not undo what that press just did.
355 press_claimed: bool,
356 /// Where the editor's own box starts, so a position recorded in window
357 /// coordinates can be placed inside it, and how far it reaches — which is
358 /// how wide a resized image is allowed to be. Its own box rather than the
359 /// picture's: a picture already narrowed would otherwise be its own
360 /// ceiling, and no drag could ever widen it again.
361 origin: gpui::Point<gpui::Pixels>,
362 width: gpui::Pixels,
363 /// The press being dragged out: what it selects by, and what it selected.
364 dragging: Option<(ui::input::Granularity, Range<Cursor>)>,
365 /// Whether the pointer is over painted text, which is the only place the
366 /// editor claims an I-beam.
367 over_text: bool,
368 /// The host's scroll box, when it gave one, and whether the caret still
369 /// owes it a reveal.
370 scroll: Option<gpui::ScrollHandle>,
371 reveal: bool,
372 /// Where the gutter handle was placed this frame, so the frame after can
373 /// tell whether the block moved out from under it.
374 handle_at: Option<gpui::Point<gpui::Pixels>>,
375 /// The column and row held across consecutive vertical moves.
376 goal: Option<VerticalGoal>,
377 /// The size the app set this document in, in points, or `None` to follow
378 /// the app's own text size. Absolute rather than a factor over the ladder,
379 /// so moving the interface size leaves a document set to 16pt at 16pt.
380 ///
381 /// What the chords move is the shared adjustment on top of this; the base
382 /// itself is the app's alone.
383 text_size: Option<f32>,
384 /// The directory relative image paths resolve against.
385 base: Option<std::path::PathBuf>,
386 image_overlay: Option<markdown::ImageOverlay>,
387 image_overlay_corner: markdown::ImageOverlayCorner,
388}
389
390#[derive(Clone, Copy)]
391struct VerticalGoal {
392 x: gpui::Pixels,
393 /// Relative to the caret's painted position so scrolling cannot change the row.
394 row_from_caret: gpui::Pixels,
395}
396
397impl Editor {
398 pub fn new(source: &str, cx: &mut Context<Self>) -> Self {
399 let marks = cx.marks();
400 let mut doc = markdown::parse_with(source, &marks);
401 ensure_block(&mut doc);
402 Self {
403 marks,
404 // Clamped, not defaulted: a document opening on a fence or a table
405 // has no body at block zero, and a caret claiming one resolves
406 // against nothing until something moves it.
407 selection: Selection::at(Cursor::default().clamp(&doc)),
408 doc,
409 chrome: Chrome::default(),
410 mode: Mode::default(),
411 focus_handle: cx.focus_handle(),
412 marked: None,
413 layouts: BlockLayouts::default(),
414 history: History::default(),
415 caret_on: true,
416 blink: None,
417 anchors: Vec::new(),
418 stored: Vec::new(),
419 slash: None,
420 pasted: None,
421 url_prompt: None,
422 dropping: None,
423 hovered: None,
424 hovered_cell: None,
425 table_menu: Default::default(),
426 table_drag: None,
427 table_dragged: false,
428 lifted: None,
429 resizing: None,
430 block_menu: MenuPopup::default(),
431 language_menu: MenuPopup::default(),
432 press_claimed: false,
433 origin: gpui::Point::default(),
434 width: gpui::Pixels::ZERO,
435 dragging: None,
436 over_text: false,
437 scroll: None,
438 reveal: false,
439 goal: None,
440 handle_at: None,
441 text_size: None,
442 base: None,
443 image_overlay: None,
444 image_overlay_corner: markdown::ImageOverlayCorner::default(),
445 }
446 }
447
448 /// How many undo steps to keep. App-wide configuration would be a gpui
449 /// global alongside [`init`], not a `Theme` field — the theme is rebuilt on
450 /// every light/dark switch, which would quietly reset anything behavioural
451 /// parked in it.
452 pub fn with_undo_limit(mut self, limit: usize) -> Self {
453 self.history = History::with_limit(limit);
454 self
455 }
456
457 /// Read and write this document with marks of its own, rather than the ones
458 /// [`markdown::AppExt::set_marks`] installed. For an app whose editors do not all
459 /// speak the same dialect.
460 pub fn with_marks(mut self, marks: markdown::Marks) -> Self {
461 let source = self.source();
462 self.marks = marks;
463 self.doc = markdown::parse_with(&source, &self.marks);
464 ensure_block(&mut self.doc);
465 self.selection = self.selection.clamp(&self.doc);
466 self
467 }
468
469 /// Which of the editor's own affordances to paint. See [`Chrome`].
470 pub fn with_chrome(mut self, chrome: Chrome) -> Self {
471 self.chrome = chrome;
472 self
473 }
474
475 /// Adds an app-provided hover control to pictures in rich mode.
476 pub fn with_image_overlay(mut self, overlay: markdown::ImageOverlay) -> Self {
477 self.image_overlay = Some(overlay);
478 self
479 }
480
481 /// Replaces or removes the picture hover control.
482 pub fn set_image_overlay(
483 &mut self,
484 overlay: Option<markdown::ImageOverlay>,
485 cx: &mut Context<Self>,
486 ) {
487 self.image_overlay = overlay;
488 cx.notify();
489 }
490
491 /// Positions picture hover controls; bottom-right by default.
492 pub fn with_image_overlay_corner(mut self, corner: markdown::ImageOverlayCorner) -> Self {
493 self.image_overlay_corner = corner;
494 self
495 }
496
497 /// Repositions the picture hover control.
498 pub fn set_image_overlay_corner(
499 &mut self,
500 corner: markdown::ImageOverlayCorner,
501 cx: &mut Context<Self>,
502 ) {
503 self.image_overlay_corner = corner;
504 cx.notify();
505 }
506
507 /// What is painting now, for an app whose own bar mirrors it.
508 pub fn chrome(&self) -> Chrome {
509 self.chrome
510 }
511
512 /// Open in [`Mode::Source`] rather than on the document — an app whose
513 /// editor is a markdown file first. Nothing is recorded: this is where the
514 /// document starts, not a switch to step back over.
515 pub fn with_mode(mut self, mode: Mode) -> Self {
516 if mode != self.mode {
517 self.switch(mode);
518 }
519 self
520 }
521
522 /// Open the document at a size of its own, in points — the app's settings
523 /// field for prose. Unset, it is set at the app's own text size.
524 ///
525 /// The base, not the current size: `cmd-+` moves a shared adjustment over
526 /// this, and `cmd-0` clears that adjustment to come back here.
527 pub fn with_text_size(mut self, points: f32) -> Self {
528 self.text_size = Some(points);
529 self
530 }
531
532 /// Update the configured base size without changing the temporary zoom.
533 pub fn set_text_size(&mut self, points: f32, cx: &mut Context<Self>) {
534 if self.text_size != Some(points) {
535 self.text_size = Some(points);
536 cx.notify();
537 }
538 }
539
540 /// The base the app set, if any. Add
541 /// [`crate::AppExt::editor_text_size_adjustment`](crate::AppExt::editor_text_size_adjustment) for what is on
542 /// screen.
543 pub fn text_size(&self) -> Option<f32> {
544 self.text_size
545 }
546
547 /// Resolve relative image paths against `dir` — the document's own folder,
548 /// for a document that keeps its pictures beside it. The stored URL stays
549 /// as written.
550 pub fn with_base(mut self, dir: impl Into<std::path::PathBuf>) -> Self {
551 self.base = Some(dir.into());
552 self
553 }
554
555 /// Change or clear the directory relative image paths resolve against.
556 pub fn set_base(&mut self, dir: Option<std::path::PathBuf>, cx: &mut Context<Self>) {
557 if self.base != dir {
558 self.base = dir;
559 cx.notify();
560 }
561 }
562
563 /// The directory relative image paths resolve against, if one is set.
564 pub fn base(&self) -> Option<&std::path::Path> {
565 self.base.as_deref()
566 }
567
568 /// The box the document scrolls in, so typing off the bottom follows the
569 /// caret down.
570 ///
571 /// The host's rather than the editor's: a document goes in whatever pane
572 /// the app gives it, and the gutter handle, the drop indicator and the
573 /// menus are all placed absolutely against this editor's own origin — put
574 /// the scroll box here and every one of them would be offset twice.
575 pub fn with_scroll(mut self, handle: gpui::ScrollHandle) -> Self {
576 self.scroll = Some(handle);
577 self
578 }
579
580 pub fn doc(&self) -> &Doc {
581 &self.doc
582 }
583
584 pub fn selection(&self) -> Selection {
585 self.selection
586 }
587
588 /// Put the selection somewhere — what a thread in a sidebar does when it is
589 /// clicked, and what a caret restored with a document needs.
590 ///
591 /// Clamped, because the caller's range came from somewhere the document may
592 /// have moved on from.
593 pub fn select(&mut self, selection: Selection, cx: &mut Context<Self>) {
594 self.selection = selection.clamp(&self.doc);
595 self.history.interrupt();
596 self.reveal = true;
597 self.caret_moved();
598 cx.notify();
599 }
600
601 /// Where the selection sits on screen, in window coordinates, so a host can
602 /// float a toolbar at it.
603 ///
604 /// The head's row only — a selection spanning ten blocks wants its bubble
605 /// where the pointer left off, not centred over the whole span. `None` when
606 /// nothing is selected or the caret has not painted yet.
607 /// Where everything landed last frame — blocks, pictures, a fence's
608 /// language label, and the row rects of any range.
609 ///
610 /// Handed out whole rather than a method per question: an app placing
611 /// chrome of its own asks the geometry, and which question it needs is not
612 /// this crate's to guess. See [`markdown::BlockLayouts`].
613 pub fn layouts(&self) -> &BlockLayouts {
614 &self.layouts
615 }
616
617 pub fn selection_bounds(&self) -> Option<gpui::Bounds<gpui::Pixels>> {
618 // The head alone. A bar centred over the whole selection wants
619 // `layouts().rects(selection)`, which is every painted row of it.
620 if self.selection.is_collapsed() {
621 return None;
622 }
623 let (point, line_height) = self.layouts.position(self.selection.head)?;
624 Some(gpui::Bounds::new(
625 point,
626 gpui::size(gpui::px(0.0), line_height),
627 ))
628 }
629}
630
631impl EventEmitter<EditorEvent> for Editor {}
632
633impl Focusable for Editor {
634 fn focus_handle(&self, _: &App) -> FocusHandle {
635 self.focus_handle.clone()
636 }
637}