|
1 | | -//! This module provides text editing functionality, by wrapping the functionality of the |
2 | | -//! [`cosmic_text`] crate. |
3 | | -//! |
4 | | -//! The primary entry point into the text editing functionality is the [`TextInputBuffer`] component, |
5 | | -//! which includes a [`cosmic_text::Editor`], and adds the associated "required components" needed |
6 | | -//! to construct functioning text input fields. |
7 | | -//! |
8 | | -//! ## How this works |
9 | | -//! |
10 | | -//! Text editing functionality is included as part of [`TextPlugin`](crate::TextPlugin), |
11 | | -//! and the systems which perform the work are grouped under the [`TextInputSystems`] system set. |
12 | | -//! |
13 | | -//! The [`TextInputBuffer`] comes with the following required components that act as machinery to convert user inputs into text: |
14 | | -//! |
15 | | -//! * [`TextInputValue`] - Contains the current text in the text input buffer. |
16 | | -//! * Automatically synchronized with the buffer by [`apply_text_edits`] after any edits are applied. |
17 | | -//! * [`TextEdits`] - Text input commands queue, used to queue up text edit and navigation actions.\ |
18 | | -//! * Contains a queue of [`TextEdit`] actions that are applied to the buffer. |
19 | | -//! * These are applied by the [`apply_text_edits` system. |
20 | | -//! * [`TextInputTarget`] - Details of the render target the text input will be rendered to, such as size and scale factor. |
21 | | -//! |
22 | | -//! |
23 | | -//! Layouting is done in: |
24 | | -//! |
25 | | -//! * [`update_text_input_layouts`] - Updates the `TextLayoutInfo` for each text input for rendering. |
26 | | -//! * [`update_placeholder_layouts`] - Updates the `TextLayoutInfo` for each [`Placeholder`] for rendering. |
27 | | -//! |
28 | | -//! ## Configuring text input |
29 | | -//! |
30 | | -//! Several components are used to configure the text input, and belong on the [`TextInputBuffer`] entity: |
31 | | -//! |
32 | | -//! * [`TextInputAttributes`] - Common text input properties set by the user, such as font, font size, line height, justification, maximum characters etc. |
33 | | -//! * [`TextInputFilter`] - Optional component that can be added to restrict the text input to certain formats, such as integers, decimals, hexadecimal etc. |
34 | | -//! * [`PasswordMask`] - Optional component that can be added to hide the text input buffer contents by replacing the characters with a mask character. |
35 | | -//! * [`Placeholder`] - Optional component that can be added to display placeholder text when the input buffer is empty. |
36 | | -//! * [`CursorBlink`] - Optional component that controls cursor blinking. |
37 | | -//! |
38 | | -//! ## Copy-paste and clipboard support |
39 | | -//! |
40 | | -//! The clipboard support provided by this module is very basic, and only works within the `bevy` app, |
41 | | -//! storing a simple [`String`]. |
42 | | -//! |
43 | | -//! It can be accessed via the [`Clipboard`] resource. |
44 | 1 |
|
45 | 2 | use bevy_asset::{AssetEvent, Assets, Handle}; |
46 | 3 | use bevy_derive::Deref; |
@@ -96,7 +53,7 @@ pub struct TextInputAttributes { |
96 | 53 | pub const DEFAULT_FONT_SIZE: f32 = 20.; |
97 | 54 | /// Default line height factor (relative to font size) |
98 | 55 | /// |
99 | | -/// `1.2` corresponds to `normal` in https://developer.mozilla.org/en-US/docs/Web/CSS/line-height |
| 56 | +/// `1.2` corresponds to `normal` in `<https://developer.mozilla.org/en-US/docs/Web/CSS/line-height>` |
100 | 57 | pub const DEFAULT_LINE_HEIGHT_FACTOR: f32 = 1.2; |
101 | 58 | /// Default line height |
102 | 59 | pub const DEFAULT_LINE_HEIGHT: f32 = DEFAULT_FONT_SIZE * DEFAULT_LINE_HEIGHT_FACTOR; |
|
0 commit comments