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,

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




Back to the top