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

btw...

advanced editor features, contained in eclipse java editor, like line numbers, breakpoint/error markers, etc... these are contained in JFace-classes, aren't they? they are then extension of StyledText, right?
these classes must then know also model and structure of edited text, so that e.g. code completion and code-assist can work. right?

thanks
marek

2012/9/5 Marek Jasovsky <jasovsky.marek@xxxxxxxxx>
thanks for help. for beginning, I will try the easier way, but so far, you have already helped me a lot. 

Selectionlistener might not be necessary in the first versions, however to delete whole word, should not be difficult, if the underlying model of the text contains all informations.

will let you know, if I managed to do it :)

have a nice day and thanks for help

Marek


2012/9/5 Stephan Aßmus <superstippi@xxxxxx>
Am 05.09.2012 10:56, schrieb Marek Jasovsky:

thanks for great news. bit confusing, but otherwise undestandable.

so, what's then most quickest way, to make one Line (let's stick with
styledtext terminology) non editable?
catch events and in case, where I am in a line, which is not editable, I
just don't allow that event? or now?

Yes, that is what I do.


btw, it can happen, that I will need such behavior also on line-level.,
means, if I have text like:

this is my [t1: translation] of <ref>name of book</ref> from <ctrl> texts...

<ctrl> should be handled as one unit... I only can delete whole piece
(if allowed...), same with [t1: ... ]

all this are tags, I have to have in the text, and they then have effect
on what I can/must do with the text

This is where it gets complicated and you may not be able to achieve this without overwriting internal StyledText behavior. For example to delete the whole tag word is probably easy, but to get the selection behavior intuitive requires "filtering" the selection start and end positions for "valid" positions. For various reaons I've made my own copy of the org.eclipse.swt.custom package with the classes I needed to mess with. Implementing filtering valid selection offsets is only one of many changes, so I don't know if it may be possible with the stock StyledText code.

One other possibility is to embed "paint objects" into the text. To see how this works, study one of the snippets that show embedding images into StyledText that wrap with the text. These are treated as one character as far as the selection behavior is concerned. It should be easy to modify the snippet such that instead of images, you embed words that you draw yourself in the PaintObjectListener (if memory serves) that you register with the StyledText control. But note that this stuff cannot wrap itself. So if your tag is for example "<ref id="someLongId">" then you can only make this wrap in one piece, since you specify the GlyphMetrics for only one "char" and it must be the bounding box of the entire string. If it's not clear what I mean, it will probably become clear when you look at how the snippet reserves the room for the image within the text.

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