Skip to content

gpui: Implement inline box text layout - #26307

Closed
MatinAniss wants to merge 4 commits into
zed-industries:mainfrom
MatinAniss:inline-text
Closed

gpui: Implement inline box text layout#26307
MatinAniss wants to merge 4 commits into
zed-industries:mainfrom
MatinAniss:inline-text

Conversation

@MatinAniss

@MatinAniss MatinAniss commented Mar 7, 2025

Copy link
Copy Markdown
Contributor

This is an implementation of inline boxes in text layouts, this allows you to have spaces at certain points of your text layout where you can have "inline elements" in these spaces that flow with your text layout.

The gpui text system should look into moving to Parley in the future, which already supports text layouting features such as inline text boxes. Moving to Parley would require some much larger changes but will be better in the long run.

Closes #10916

Current State:

  • The text line still needs to adjust its line height if a inline box height exceeds it, but this isn't a must need.
text-inline.mp4

Release Notes:

  • N/A

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Mar 7, 2025
@MatinAniss
MatinAniss marked this pull request as ready for review March 9, 2025 00:25
.text_color(gpui::white())
.child(
div().border_1().border_color(gpui::red()).child(
InlineText::new()

@huacnlee huacnlee Mar 10, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use span, Span::new, like the before div.

And the next add_text, add_element.

I think we can try to have a better API like this if it's possible:

div().id("paragraph")
  .child(span("This is an inline element ->"))
  .child(span().w_4().bg(gpui::red()))
  .child(span("text"))

Or at least we can:

div().id("paragraph")
  .child(
    InlineText::new()
      .child("This is an inline element ->")
      .child(div().w_4().bg(gpui::red()))
      .child("text")
  )

@mikayla-maki mikayla-maki self-assigned this Mar 14, 2025
@mikayla-maki

Copy link
Copy Markdown
Member

This is a good idea, and one we really want to have in Zed. However, I'm not convinced on the API yet, I'd think this would be a display mode on the div, right?

I've let this one languish, so I'm going to close it for now.

@MatinAniss

MatinAniss commented Apr 10, 2025

Copy link
Copy Markdown
Contributor Author

Agreed, I wasn't too confident on my implementation and It would be better to utilise Parley instead but that requires some larger changes that I haven't had the time to look into deeply.

@MatinAniss
MatinAniss deleted the inline-text branch June 3, 2025 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GPUI] Support inline box text layout

3 participants