mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:37:36 +00:00
LibGUI: Add glyph substitution to TextEditor
This patch adds the member variable m_substitution_code_point to GUI::TextEditor. If non-zero, all gylphs to be drawn will be substituted with the specified code point. This is mainly needed to support a PasswordBox. While the primary use-case is for single-line editors, multi-line editors are also supported. To prevent repeated String construction, a m_substitution_string_data members has been added, which is an OwnPtr<Vector<u32>>. This is used as a UTF-32 string builder. The substitution_code_point_view method uses that Vector to provide a Utf32View of the specified length.
This commit is contained in:
parent
37961bf7cb
commit
de67d86696
2 changed files with 67 additions and 13 deletions
|
@ -176,6 +176,9 @@ public:
|
|||
bool should_autocomplete_automatically() const { return m_autocomplete_timer; }
|
||||
void set_should_autocomplete_automatically(bool);
|
||||
|
||||
u32 substitution_code_point() const { return m_substitution_code_point; }
|
||||
void set_substitution_code_point(u32 code_point);
|
||||
|
||||
bool is_in_drag_select() const { return m_in_drag_select; }
|
||||
|
||||
TextRange* selection() { return &m_selection; };
|
||||
|
@ -274,6 +277,9 @@ private:
|
|||
TextEditor& m_editor;
|
||||
};
|
||||
|
||||
int text_width_for_font(auto const& text_view, Gfx::Font const&) const;
|
||||
Utf32View substitution_code_point_view(size_t length) const;
|
||||
|
||||
Gfx::IntRect line_content_rect(size_t item_index) const;
|
||||
Gfx::IntRect line_widget_rect(size_t line_index) const;
|
||||
void delete_selection();
|
||||
|
@ -321,6 +327,11 @@ private:
|
|||
size_t m_soft_tab_width { 4 };
|
||||
int m_horizontal_content_padding { 3 };
|
||||
TextRange m_selection;
|
||||
|
||||
// NOTE: If non-zero, all glyphs will be substituted with this one.
|
||||
u32 m_substitution_code_point { 0 };
|
||||
mutable OwnPtr<Vector<u32>> m_substitution_string_data; // Used to avoid repeated String construction.
|
||||
|
||||
RefPtr<Menu> m_context_menu;
|
||||
RefPtr<Action> m_undo_action;
|
||||
RefPtr<Action> m_redo_action;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue