开发者

Looking for an example of a complex text editor using SWT's StyledText [closed]

Closed. This question does not m开发者_如何转开发eet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 7 years ago.

Improve this question

I need to write a text editor which can merge arbitrary text styles from several sources (in my case: spell checker, style hints like repeated words, links and other markup) using SWT StyledText. I examined the the standard ways to do it:

  1. I could install a modify listener and create the styles for the whole text for each modification. That's pretty slow but accurate.

  2. I could use a LineStyleListener. This means I'll have to redraw the text myself (for example in the case of repeated words because some of them will be outside the current edit range) plus the editor doesn't cache the styles, so this API gets called much more often then one would expect.

  3. I could use a background reconciler like the IDE does. This means the styling lags behind the edits which is bad from a user perspective.

The icing of the cake is that I need hierarchical styles, so I have to reimplement the StyleRange API.

Has anyone seen a better solution? Can someone direct me to some examples which do more than highlight keywords?


I used this example as a starting point for an editor which got fairly advanced. It helped me to understand multi-line styling, and implemenent a reg-ex based styling engine for my editor.

The StyleRange API doesn't really provide a way of doing intersections like merging style 1 which goes from index 1 to index 20 and style 2 ranging from 10 to 14. Something like this.

If this is what you mean with 'hierarchical styles', there's a solution in JFace: org.eclipse.jface.text.TextPresentation

You can add all your styles with mergeStyleRange(.), and use getAllStyleRangeIterator() to get the result. Very useful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜