Given the following code:
if (a == b)
if (b == c)
....
endIf
endif
I'd like to perform the following:
- Display the corresponding condition expression next to each EndIf line. Additionally, check if the if clause's starting line is visible (in the TextView's viewable area) and skip if it is.
- The text generated above is clickable, i.e., can handle click/mouse events.
- If possible, display a small icon next to the condition expression, i.e., the one generated in the first step.
I understand this can be achieved with the VisualLineElementGenerator/InlineObjectElement classes and have a crude setup working. I use the Generator class to add a label control that's uses the same font parameters of the code editor.
.
While using a control has the implicit benefit of supporting events, it's rather unsightly. For starters, the selection layer is rendered underneath the label control. Secondly, the text rendering isn't consistent with the editor's. Also, it doesn't align correctly with the editor's text.
Is there a better way to pull this off?
PS: How do I determine if a particular line (given its line number) is visible in the textview (inside a ConstructElement() call and otherwise)?