When using color tags (simple like [red] or more complex like [red:-:b] in a Modal, the line breaks stop working.
Demo code (based on modal demo code):
package main
import (
"code.rocketnine.space/tslocum/cview"
)
func main() {
app := cview.NewApplication()
app.EnableMouse(true)
modal := cview.NewModal()
//modal.SetText("Do you want to\n\n quit the application?")
//modal.SetText("[red:-:-]Do you[blue:-:-] want to\n\n quit the application?")
modal.SetText("[red:-:-]Do you[-:-:-] want to\n\n quit the application?")
modal.AddButtons([]string{"Quit", "Cancel"})
modal.SetDoneFunc(func(buttonIndex int, buttonLabel string) {
if buttonLabel == "Quit" {
app.Stop()
}
})
app.SetRoot(modal, false)
if err := app.Run(); err != nil {
panic(err)
}
}
In this code, uncomment the first SetText and comment the 2nd and 3rd one => The line breaks will work.
In the other 2 example, it doesn't, but the colors work.
(btw, thanks a lot for the other fix and the feature request, both tested today and they work as expected :)).
When using color tags (simple like `[red]` or more complex like `[red:-:b]` in a Modal, the line breaks stop working.
Demo code (based on modal demo code):
```
package main
import (
"code.rocketnine.space/tslocum/cview"
)
func main() {
app := cview.NewApplication()
app.EnableMouse(true)
modal := cview.NewModal()
//modal.SetText("Do you want to\n\n quit the application?")
//modal.SetText("[red:-:-]Do you[blue:-:-] want to\n\n quit the application?")
modal.SetText("[red:-:-]Do you[-:-:-] want to\n\n quit the application?")
modal.AddButtons([]string{"Quit", "Cancel"})
modal.SetDoneFunc(func(buttonIndex int, buttonLabel string) {
if buttonLabel == "Quit" {
app.Stop()
}
})
app.SetRoot(modal, false)
if err := app.Run(); err != nil {
panic(err)
}
}
```
In this code, uncomment the first SetText and comment the 2nd and 3rd one => The line breaks will work.
In the other 2 example, it doesn't, but the colors work.
Tested on the latest commit 605d0123c1
(btw, thanks a lot for the other fix and the feature request, both tested today and they work as expected :)).
Thanks for reporting this. WordWrap is returning strings containing a newline character (when each line should be a separate string). This is the root cause for the issue above.
Thanks for reporting this. `WordWrap` is returning strings containing a newline character (when each line should be a separate string). This is the root cause for the issue above.
Would this also be the cause of modal needing 2 "\n" to actually display a line break?
package main
import (
"code.rocketnine.space/tslocum/cview"
)
func main() {
app := cview.NewApplication()
app.EnableMouse(true)
modal := cview.NewModal()
modal.SetText("Do you want to quit\n the application?")
//modal.SetText("Do you want to quit\n\n the application?")
modal.AddButtons([]string{"Quit", "Cancel"})
modal.SetDoneFunc(func(buttonIndex int, buttonLabel string) {
if buttonLabel == "Quit" {
app.Stop()
}
})
app.SetRoot(modal, false)
if err := app.Run(); err != nil {
panic(err)
}
}
In this case, having just one "\n" don't break the line. By adding 2 "\n" like in the commented line, then I see a line break in the modal.
Based on your comment, I'm thinking this may be related. But if that's not the case, happy to remove this comment and create a dedicated issue for this.
Would this also be the cause of modal needing 2 "\n" to actually display a line break?
```
package main
import (
"code.rocketnine.space/tslocum/cview"
)
func main() {
app := cview.NewApplication()
app.EnableMouse(true)
modal := cview.NewModal()
modal.SetText("Do you want to quit\n the application?")
//modal.SetText("Do you want to quit\n\n the application?")
modal.AddButtons([]string{"Quit", "Cancel"})
modal.SetDoneFunc(func(buttonIndex int, buttonLabel string) {
if buttonLabel == "Quit" {
app.Stop()
}
})
app.SetRoot(modal, false)
if err := app.Run(); err != nil {
panic(err)
}
}
```
In this case, having just one "\n" don't break the line. By adding 2 "\n" like in the commented line, then I see a line break in the modal.
Based on your comment, I'm thinking this may be related. But if that's not the case, happy to remove this comment and create a dedicated issue for this.
Thanks. I've looked into this a bit, and shared what I've found here: https://code.rocketnine.space/tslocum/cview/issues/27#issuecomment-3976.
Closing in favor of #27.
When using color tags (simple like
[red]
or more complex like[red:-:b]
in a Modal, the line breaks stop working.Demo code (based on modal demo code):
In this code, uncomment the first SetText and comment the 2nd and 3rd one => The line breaks will work.
In the other 2 example, it doesn't, but the colors work.
Tested on the latest commit
605d0123c1
(btw, thanks a lot for the other fix and the feature request, both tested today and they work as expected :)).
Modal.SetText don't respect line breaks when using color tagsto WordWrap does not split on newlines 12 months agoThanks for reporting this.
WordWrap
is returning strings containing a newline character (when each line should be a separate string). This is the root cause for the issue above.Would this also be the cause of modal needing 2 "\n" to actually display a line break?
In this case, having just one "\n" don't break the line. By adding 2 "\n" like in the commented line, then I see a line break in the modal.
Based on your comment, I'm thinking this may be related. But if that's not the case, happy to remove this comment and create a dedicated issue for this.
Thanks. I've looked into this a bit, and shared what I've found here: #27.
Closing in favor of #27.