I am currently using a StyledText
widget to display some "excerpt" of the actual code, such as a method definition within a Java file.
My problem is that the line number shown in my StyledText
always start with 1, which is different from the actual line number in the original file. For example, if the original source looks like:
1: package something;
2:
3: public class MyClass {
4: public void foo() {
5: // Do something...
6: }
7: }
then, when the foo()
method is shown in my StyledText
widget, I want to show the line numbers starting from 4, not 1.
Is there a way to achieve this? I read through the javadoc, but could not figure out a good way.
Just change the
LineStyleEvent.bulletIndex
in theLineStyleListener
:Looks like this: