Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] SWT Styledtext word wrap

Hi, thanks a lot for quick answer.

well:

initially I set the text of Styledtext as " word word word word longword longword longword longword "

I have no \n there.

as soon as I insert it, does Styledtext break this in lines? using \n ?

and protected area is part of text, with different color background, where I do not want the user, to edit this part. I want to adjust the styledtext for translations of texts, where you have only one paragraph at time to edit. other paragraphs, including source language of current paragraph have to be read-only

so you have

some other stuff
-------------
originaltext auf deutsch
--------------
my translation in english
---------------
another stuff


other and another stuff has to be read only

german text is too read only

english translation is editable, no matter, how many lines I have there. then.. if I have 100 words in translation, but I manually do not insert new line, but just type and type... does styledtext enter \n there? if I ask styledtext to extract lines 5-10, where I know that this is "my translation in english" part... will I become \n there? in MS-Word you have a distinction between soft line break and hard line break. soft is wrapped text by word, hard is manually entered paragraph break.

do you now unterstand what I mean?

thanks a lot

Marek

2012/9/5 Stephan Aßmus <superstippi@xxxxxx>
Hi,

Am 05.09.2012 09:33, schrieb Marek Jasovsky:

styledtext component has the ability to wrap a text.

lets say I have following text in the widget:

| protected area.....                       |
|  word word word word longword  |
|  longword X longword longword   |
| protected area.....                       |


the X in second line marks location of cursor.

if I start to type at that location, after few characters, the last word
will be moved to next line..., so the result will be:

| protected area.....                       |
|  word word word word longword  |
|  longword newword longword      |
|  longword                                    |
| protected area.....                       |

where exactly is this handling hidden in code? trouble is, that first
and last line, marked as protected area has to be handled in a different
way, and I need to identify, where unprotected area starts and ends..
both location and line.

thanks a lot in advance for help

Here is some random knowledge that may be useful to you. The actual wrapping is handled by platform native code accessed throw the SWT TextLayout class. StyledText breaks up the text into paragraphs between each new line and uses one TextLayout for each such paragraph. This is what StyledText calls a "line". Yes, a "line" in StyledText terminology can consist of multiple visiual lines when the paragraph is wrapped. So when you use the StyledText "line" related API, you are actually asking it about paragraphs. With this in mind, you can find the location of your protected area. If you explain more what your "proteced area" is, I can probably help more. It is definitely possible to implement non-editable regions of text, if that is what you mean. But if you want for example the selection to always select the non-editable region as a whole, it gets more complicated.

Hope this helps & best regards,
-Stephan


_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top