Skip to content

Commit 5ea06cb

Browse files
committed
CI
1 parent 7f2a1ce commit 5ea06cb

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

crates/bevy_text/src/input.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::time::Duration;
1+
use core::time::Duration;
22

33
use crate::buffer_dimensions;
44
use crate::load_font_to_fontdb;
@@ -251,7 +251,7 @@ impl Default for TextInputAttributes {
251251
}
252252
}
253253

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
255255
/// against the filter, and if it fails, the `TextEdit` is rolled back.
256256
#[derive(Component)]
257257
pub enum TextInputFilter {
@@ -712,12 +712,12 @@ impl<'b> Iterator for ScrollingLayoutRunIter<'b> {
712712
let glyph_height = layout_line.max_ascent + layout_line.max_descent;
713713
let centering_offset = (line_height - glyph_height) / 2.0;
714714
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;
721721
}
722722
self.line_top += line_height;
723723
if line_bottom < 0.0 {
@@ -803,14 +803,14 @@ pub fn update_text_input_layouts(
803803
));
804804
}
805805
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);
814814
}
815815

816816
run.glyphs
@@ -933,7 +933,7 @@ pub enum InvalidTextEditError {
933933
}
934934

935935
/// Apply a text input action to a text input
936-
fn apply_text_edit(
936+
pub fn apply_text_edit(
937937
mut editor: BorrowedWithFontSystem<'_, Editor<'static>>,
938938
maybe_filter: Option<&TextInputFilter>,
939939
max_chars: Option<usize>,
@@ -1053,7 +1053,7 @@ fn apply_text_edit(
10531053
let cursor = editor.cursor();
10541054
editor.set_selection(Selection::Normal(cursor));
10551055
editor.action(Action::Motion(Motion::End));
1056-
editor.insert_string(&text, None);
1056+
editor.insert_string(text, None);
10571057
}
10581058
TextEdit::Submit => {}
10591059
}

examples/2d/text_input_2d.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use bevy::{
99
},
1010
input::keyboard::{Key, KeyboardInput},
1111
prelude::*,
12+
render::{sync_world::TemporaryRenderEntity, Extract, RenderApp},
1213
sprite::Anchor,
1314
sprite_render::{
1415
ExtractedSlice, ExtractedSlices, ExtractedSprite, ExtractedSpriteKind, ExtractedSprites,
@@ -20,7 +21,6 @@ use bevy::{
2021
},
2122
window::PrimaryWindow,
2223
};
23-
use bevy_render::{sync_world::TemporaryRenderEntity, Extract, RenderApp};
2424

2525
#[derive(Component)]
2626
struct TextInputSize(Vec2);

release-content/release-notes/bevy_text_input_module.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pull_requests: [20366]
77
A long-standing feature request from our users is support for text input. Whether the user is creating a new character, logging in with a username and password, or creating a new save file, it's vitally important for them to be able to enter a string of text. Unfortunately, writing a robust and feature-rich text input widget is not easy, especially one that supports all of the expected capabilities (such as range selection, and scrolling). This effort is made much easier now that Bevy has incorporated the cosmic crate for text handling.
88

99
Features:
10+
1011
* Placeholder text for empty inputs
1112
* Password mode.
1213
* Filters applied at edit.

0 commit comments

Comments
 (0)