I’ve spend tonight doing some experiments with combining the org.eclipse.text-Support and JavaFXs new TextFlow which allows to one to render complex texts. The result of this 3 hours is astonishing! I have a working SourceViewer (please note it is ONLY a viewer without editing support!).
I’ve recorded a small video so that you can see it in action:
The scrolling performance is great but you’ll notice that the initial rendering of big files (> 10.000 lines) takes some time. So while this is Ok for a prototype time has to be spend on the performance for a real world app (I also hope there are optimization possibilities in JavaFX itself), adding editing needs logic to only modify parts of the TextFlow model but I hope I can find some time to give it a try.

February 14, 2013 





Nice Tom! The initial time you see is not rendering time (as rendering is limited by clipping, which I’m assuming the scrollview provides). The time is in analyzing the text and generating the glyphs. If you ever implement editing this will be a major problem too as the TextFlow will re-analyze the entire text every key stroke. The design we used in Orion (and Eclipse) is to have a text model object (and an annotation model for the styles) for backing store and only to set the visible text in the TextFlow. One way to do that is to use one TextFlow per line of text. That makes you view virtual, so it doesn’t matter how huge you document is, the performance will be the same.
Very nice. What kind of JavaFX control is behind the SourceViewer?
In this case it was a simple TextFlow – later iterations who add editing support the underlying control is a ListView
A requirement for a prototypw was the styling on character level. I haven’t found a control to do this easily (html control was annoying for this). So I used a TextField for each character and synchronized them so it looks like a single TextField (only for short texts). I ask myself how you solved the source viewer with ListView. What’s inside the ListView?
Look at the source? Like i stated I’ve added editing support in later iterations (see http://tomsondev.bestsolution.at/2013/02/20/from-styledtextviewer-to-a-styledtexteditor-with-javafx8/) the source is in my github-repo
I’m using the TextFlow class which is only available in JFX8 but in 2.x one could replace it with a HBox.