Bloc icon indicating copy to clipboard operation
Bloc copied to clipboard

[Question]- About not recognized Carriage Return (CR) character in BlTextElement

Open ElisabethCabioch opened this issue 1 year ago • 10 comments

Good afternoon,

I am currently trying to convert some text containing some carriage return character : cr into a BLTextElement in order to display it on screen with other BlElements. However, when I display the text, the cr characters are not recognized nor applied, only showing some "error" characters.

My text should be looking like that : image

But it is shown like so: image

In order to display my text , I use the function openInNewSpace. My text is also transformed first as a RopedText so that I can apply some font and size on it and then I transform it as a BlTextElement.

Also, when I look at my BlTextElement, I can clearly see that the cr is present: image

Do you have an idea how I could solve this problem ?

ElisabethCabioch avatar Mar 13 '23 14:03 ElisabethCabioch

Hello Elisabeth, BlTextElement is made to draw text but without any interpretation of its content. You can only have one line. To draw such a multi-line text you can use a label, a text field or a text editor widget. such widgets are available in Toplo and in Brick (but I don't know how to create a multi-line label with Brick).

with Toplo: | lab | lab := ToLabel text: 'Mme XX 28 allée de la mer, 29200 Brest'. lab beMultiLine. lab openInNewSpace.

Please notice that Toplo is currently under development.

plantec avatar Mar 13 '23 15:03 plantec

For those who are not aware what Toplo is, it is a widget framework on top of Bloc (https://github.com/plantec/Toplo)

astares avatar Mar 13 '23 15:03 astares

Hello Alain,

Thank you very much for those explanations. I will try them out.

ElisabethCabioch avatar Mar 13 '23 15:03 ElisabethCabioch

We cannot use Toplo in this project for Text management. We can use Toplo for widgets management but here this is simple text element.

labordep avatar May 23 '23 12:05 labordep

@tinchodias it is possible to display a text with carriage return ? BlRopedText have the CR information, how is it on Alexandrie ?

labordep avatar May 23 '23 12:05 labordep

yes and no. A carriage return is a word processor concept. The CR character is stored in a BlRopedText ok but its interpretation/processing as a carriage return is done at the widget level.

plantec avatar May 23 '23 12:05 plantec

@ElisabethCabioch propose to manage that with more BlElements (one per line) for our project, but it should be good to have a BlTextElement specialized to manage this basic display ?

Else, basically, how to do that without using Toplo ?

labordep avatar May 23 '23 13:05 labordep

I would have a look at BlTextParagraph. It seems broken. I can make a try

plantec avatar May 23 '23 13:05 plantec

bon, it is not so easy. text measuring is needed BlTextParagraph is not functional at all. I will come back on it later.

plantec avatar May 23 '23 20:05 plantec

thanks @plantec

labordep avatar May 23 '23 21:05 labordep