|
1 |
| -use std::time::Duration; |
| 1 | +use core::time::Duration; |
2 | 2 |
|
3 | 3 | use crate::buffer_dimensions;
|
4 | 4 | use crate::load_font_to_fontdb;
|
@@ -251,7 +251,7 @@ impl Default for TextInputAttributes {
|
251 | 251 | }
|
252 | 252 | }
|
253 | 253 |
|
254 |
| -/// If a text input entity has a `TextInputFilter` component, after each [TextEdit] is applied, the [TextInputBuffer]’s text is checked |
| 254 | +/// If a text input entity has a `TextInputFilter` component, after each [`TextEdit`] is applied, the [`TextInputBuffer`]’s text is checked |
255 | 255 | /// against the filter, and if it fails, the `TextEdit` is rolled back.
|
256 | 256 | #[derive(Component)]
|
257 | 257 | pub enum TextInputFilter {
|
@@ -712,12 +712,12 @@ impl<'b> Iterator for ScrollingLayoutRunIter<'b> {
|
712 | 712 | let glyph_height = layout_line.max_ascent + layout_line.max_descent;
|
713 | 713 | let centering_offset = (line_height - glyph_height) / 2.0;
|
714 | 714 | let line_bottom = line_top + centering_offset + layout_line.max_ascent;
|
715 |
| - if let Some(height) = self.buffer.size().1 { |
716 |
| - if height + line_height < line_bottom { |
717 |
| - // The line is below the target bound's bottom edge. |
718 |
| - // No more lines are visible, return `None` to end the iteration. |
719 |
| - return None; |
720 |
| - } |
| 715 | + if let Some(height) = self.buffer.size().1 |
| 716 | + && height + line_height < line_bottom |
| 717 | + { |
| 718 | + // The line is below the target bound's bottom edge. |
| 719 | + // No more lines are visible, return `None` to end the iteration. |
| 720 | + return None; |
721 | 721 | }
|
722 | 722 | self.line_top += line_height;
|
723 | 723 | if line_bottom < 0.0 {
|
@@ -803,14 +803,14 @@ pub fn update_text_input_layouts(
|
803 | 803 | ));
|
804 | 804 | }
|
805 | 805 | let result = ScrollingLayoutRunIter::new(buffer).try_for_each(|run| {
|
806 |
| - if let Some(selection) = selection { |
807 |
| - if let Some((x0, w)) = run.highlight(selection.0, selection.1) { |
808 |
| - let y0 = run.line_top; |
809 |
| - let y1 = y0 + run.line_height; |
810 |
| - let x1 = x0 + w; |
811 |
| - let r = Rect::new(x0, y0, x1, y1); |
812 |
| - layout_info.selection_rects.push(r); |
813 |
| - } |
| 806 | + if let Some(selection) = selection |
| 807 | + && let Some((x0, w)) = run.highlight(selection.0, selection.1) |
| 808 | + { |
| 809 | + let y0 = run.line_top; |
| 810 | + let y1 = y0 + run.line_height; |
| 811 | + let x1 = x0 + w; |
| 812 | + let r = Rect::new(x0, y0, x1, y1); |
| 813 | + layout_info.selection_rects.push(r); |
814 | 814 | }
|
815 | 815 |
|
816 | 816 | run.glyphs
|
@@ -933,7 +933,7 @@ pub enum InvalidTextEditError {
|
933 | 933 | }
|
934 | 934 |
|
935 | 935 | /// Apply a text input action to a text input
|
936 |
| -fn apply_text_edit( |
| 936 | +pub fn apply_text_edit( |
937 | 937 | mut editor: BorrowedWithFontSystem<'_, Editor<'static>>,
|
938 | 938 | maybe_filter: Option<&TextInputFilter>,
|
939 | 939 | max_chars: Option<usize>,
|
@@ -1053,7 +1053,7 @@ fn apply_text_edit(
|
1053 | 1053 | let cursor = editor.cursor();
|
1054 | 1054 | editor.set_selection(Selection::Normal(cursor));
|
1055 | 1055 | editor.action(Action::Motion(Motion::End));
|
1056 |
| - editor.insert_string(&text, None); |
| 1056 | + editor.insert_string(text, None); |
1057 | 1057 | }
|
1058 | 1058 | TextEdit::Submit => {}
|
1059 | 1059 | }
|
|
0 commit comments