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

add lines and wrap-mode properties to label widget #1278

Merged
merged 3 commits into from
Feb 5, 2025

Conversation

vaporii
Copy link
Contributor

@vaporii vaporii commented Jan 27, 2025

Description

Add the :lines and :wrap-mode properties to the label widget. Used for setting the number of lines to display when wrapping is enabled, and how it should display wrapped text, respectively.

Usage

To set the lines and wrap-mode properties, you could do something like this:

(label
  :text "this is some label text blah blkaghk kwjhndlkaj wbn akj hba jkhawbjakhjhawjkdbh jahbw ajkhbakjawja"
  :wrap true
  :limit-width 15
  :lines 4 ; the number of lines to display
  :wrap-mode "char" ; wraps on characters, ignoring words
)

This will look like the first image in the showcase below.

Showcase

line-wrap-example

Additional Notes

When the label text contains newlines, they aren't interpreted as lines. This fix involves changing the implementation of newlines in labels, or implementing some janky fix elsewhere

Checklist

  • All widgets I've added are correctly documented.
  • I added my changes to CHANGELOG.md, if appropriate.
  • The documentation in the docs/content/main directory has been adjusted to reflect my changes.
  • I used cargo fmt to automatically format all code before committing

Copy link
Contributor

@w-lfchen w-lfchen left a comment

Choose a reason for hiding this comment

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

looks good overall, thank you for your work <3

crates/eww/src/widgets/widget_definitions.rs Show resolved Hide resolved
Copy link
Contributor

@w-lfchen w-lfchen left a comment

Choose a reason for hiding this comment

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

lgtm, thank you again <3

@elkowar elkowar merged commit e7b9568 into elkowar:master Feb 5, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants