8000 Escape characters in texts, eg. `label` · Issue #40 · clydebarrow/esphome · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Escape characters in texts, eg. label #40

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

Closed
nagyrobi opened this issue Jan 16, 2024 · 2 comments
Closed

Escape characters in texts, eg. label #40

nagyrobi opened this issue Jan 16, 2024 · 2 comments

Comments

@nagyrobi
Copy link
nagyrobi commented Jan 16, 2024

label supports multiline texts: https://docs.lvgl.io/8.3/widgets/core/label.html#newline
\n should start a new line. Currently:

        - label:
            align: center
            id: lbl_id
            y: 30
            recolor: true
            text: 'Write a #ff0000 red# word\nand a #0000ff blue# one'

produces:
kép
looks like \n is interpreted textually, not being escaped.

Other escape sequences like \u, \U should be supported on long term...

Also LVGL supports formatting with printf which is also ESPHome-friendly: https://docs.lvgl.io/8.3/widgets/core/label.html#set-text this could be usable when updating labels from lambdas.

Maybe some configurable options would be needed? Like escape_chars: true and use_printf: true?

@clydebarrow
Copy link
Owner

For escape sequences like newline to be translated, enclose the string in double quotes:

"Write a #ff0000 red# word\nand a #0000ff blue# one"

@nagyrobi
Copy link
Author
nagyrobi commented Feb 3, 2024

😬 can't believe I missed that, sorry.

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

No branches or pull requests

2 participants
0