Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text handling refactor #337

Open
PoignardAzur opened this issue Apr 9, 2024 · 0 comments
Open

Text handling refactor #337

PoignardAzur opened this issue Apr 9, 2024 · 0 comments
Labels
architecture (imported from Masonry) masonry Issues relating to the Masonry widget layer

Comments

@PoignardAzur
Copy link
Contributor

PoignardAzur commented Apr 9, 2024

Text handling needs in-depth refactoring. As we proceed with the port to Winit, a lot of text-related code is being removed. This issue catalogues what will need to be added back. It might be split into multiple issues later.

debug_widget_text

Every Widget had a feature to display its ID when a flag was set. Will probably be superseeded by the devtools inspector.

Create "text_helpers" module

We should create a "text_helpers" module based on druid's text module. The new modules shouldn't define widgets, only utility methods for text rendering and editing.

Here are some likely submodules:

  • backspace
  • cursor_movement
  • text_action
  • pointer_to_cursor

Write Text widget that's editable and selectable

This Text widget should be fully featured and eventually replace the Label widget.

These features will need to be implemented:

  • Displaying cursor.
  • Displaying selection areas.
  • Handling double/triple-click selection.
  • Handling IME events.
  • Handling arrow keys and modifiers.
  • Handling Home, End, etc.

We should also create a follow-up issue for MacOS text-edition keybindings (see this zulip discussion).

Add rich text support

It's not clear yet how we want to proceed. We're starting to consider integration with Taffy, where inline layout is just a part of the broader layout algorithm. This has benefits in terms of being able to embed non-text stuff in your inline layouts (especially non-emoji icons).

Ideally, rich text should be editable: this is especially useful for apps like Discord where the text-input area offers a preview of markdown effects that will be applied to the message being typed.

Add links

We need to re-implement link handling.

Clicking a link should trigger a LinkClicked(String) action at first. We can consider more involved designs later.

Handle very large strings

Druid and current-Masonry use the TextStorage and EditableText traits to abstract over various string-holding types. This has the advantage that it could in theory extend to ropes and other types that can efficiently process text.

This is useful, because we don't want an app to slow to a crawl as soon as the user pastes a 20MB string into a text input box.

However, these traits make the druid code much harder to read and maintain. And in practice most consumers end up using Arc<str> or String, negating the theoretical benefits. We should find a more lightweight solution to the above problem.

Re-add examples

Once text editing is implemented, we should add the textbox and to_do_list examples back.

@PoignardAzur PoignardAzur added the architecture (imported from Masonry) label Apr 9, 2024
@PoignardAzur PoignardAzur added the masonry Issues relating to the Masonry widget layer label Apr 19, 2024
@DJMcNab DJMcNab transferred this issue from linebender/masonry Jun 5, 2024
github-merge-queue bot pushed a commit that referenced this issue Jul 18, 2024
This was imported in #241

See also [#masonry > text vs
text2](https://xi.zulipchat.com/#narrow/stream/317477-masonry/topic/text.20vs.20text2)

We do want to sort out text properly, see #337, so I'm keeping the
reference code around.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architecture (imported from Masonry) masonry Issues relating to the Masonry widget layer
Projects
None yet
Development

No branches or pull requests

1 participant