Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-text-dev] Extending Text Editors with Rich Text (embedded controls & images)

Hi,

Am 18.04.2016 um 12:11 schrieb rzaghi@xxxxxxxxxxxxx:
I am studying how to create a text editor with the following two characteristics.

Could someone please give me some directions where I can find basic clues/ideas how to do this?

1- In the same view, I would like to keep some parts of the text read-only and some other parts writable.

There are several ways to hook into StyledText to listen to and filter (let happen or prevent) text changes. If memory serves, there is an SWT snippet for StyledText which makes sure that text is limited to a certain length. You can do something similar, but of course you need to track editable and non-editable text ranges. If you want to prevent the user from selecting certain ranges of text at all, you need to modify the StyledText code itself.

Here is a related snippet:

http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet19.java

2- I would like to have some sort of limited "Rich Text" capabilities. For example I want to replace numbers with a drop box of numbers that the user can click and choose from (instead of typing anything or instead of auto-complete). I rather not reinvent the wheel for existing editors though - so I am wondering if this is possible at all? To use existing components and modify them a little so not to create them again just to add this kind of support? Possible? Not possible?

This is possible with StyledText as is. I believe there is a snippet, too:

http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet217.java

Basically, you add any child control to the StyledText widget, and control the positioning and size each control by inserting a text object character with a certain TextStyle. You need to register a PainObjectListener to make the StyledText call your code in order to paint the text object, but what you then do is to position the control according to the information given to the PaintObjectListener.

3- Can we change the way errors look like? Instead of a red underline, to draw a light oval behind the error area?

You would need to keep track of your own TextStyles and paint the text ranges with the help of a PaintListener attached to the StyledText.

Hope this helps, maybe there is sometimes a better way to achieve what you want...

Best regards,
-Stephan


Thanks
Ramin

_______________________________________________
platform-text-dev mailing list
platform-text-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/platform-text-dev




Back to the top