Manual line break on multiline text with \r

Solves #1367
This commit is contained in:
Edward Firmo
2023-12-04 09:30:18 +01:00
parent 961b2c3f4d
commit c1a513610b
2 changed files with 23 additions and 18 deletions

View File

@@ -105,6 +105,7 @@ packages:
- Fix climate page not updating properly - Fix climate page not updating properly
- 4.1.4 patch: - 4.1.4 patch:
- Supports new `weather.get_forecasts` introduced by Home Assistant 2023.12.0 - Supports new `weather.get_forecasts` introduced by Home Assistant 2023.12.0
- Manual line break on multiline text with `\r`
   
## Details of noteworthy changes ## Details of noteworthy changes

View File

@@ -7,7 +7,7 @@
substitutions: substitutions:
##### DON'T CHANGE THIS ##### ##### DON'T CHANGE THIS #####
version: "4.1.3" version: "4.1.4"
############################# #############################
#external_components: #external_components:
@@ -2094,6 +2094,9 @@ script:
int startPos = 0; int startPos = 0;
int endPos = 0; int endPos = 0;
std::string wrappedText = ""; std::string wrappedText = "";
if (text_to_display.find("\\r") != std::string::npos) {
wrappedText = text_to_display;
} else {
while (startPos < text_to_display.length()) { while (startPos < text_to_display.length()) {
while (text_to_display[startPos] == ' ' and startPos < text_to_display.length()) { startPos++; } while (text_to_display[startPos] == ' ' and startPos < text_to_display.length()) { startPos++; }
int endPos = startPos + line_length_limit; int endPos = startPos + line_length_limit;
@@ -2112,6 +2115,7 @@ script:
startPos = endPos + 1; // Skip the space startPos = endPos + 1; // Skip the space
while (text_to_display[startPos] == ' ' and startPos < text_to_display.length()) { startPos++; } while (text_to_display[startPos] == ' ' and startPos < text_to_display.length()) { startPos++; }
} }
}
disp1->set_component_text_printf(component.c_str(), "%s", wrappedText.c_str()); disp1->set_component_text_printf(component.c_str(), "%s", wrappedText.c_str());
- id: display_embedded_temp - id: display_embedded_temp