Community
Participate
Working Groups
The inlined annotation support draw line content annotations by using GlyphMetrics#width which are set with StyledText#setStyleRange for a given offset when annotation is drawn (see InlinedAnnotationDrawingStrategy). The offset used contains a character (character after the GlyphMetrics) which is replaced by GlyphMetrics, in other words the character disapear. To fix this problem the draw of inlined annotation: * draw the content of the inlined annotation * redraw the character which is replaced by GlyphMetrics This redraw is not perfect because it doesn't take care of some background color like selection, line cusrsor, etc You can see the trouble with a simple snippet: * the StyledText contains "abc" * the insert of GlyphMetrics after the character "a" (offset of "b" character replace "b" and "b" is not visible. Here the snippet: ----------------------------------------------------------------- StyledText text = new StyledText(shell, SWT.BORDER | SWT.V_SCROLL); text.setText("abc"); // insert a blank space after "a" by replacing "b" character GlyphMetrics metrics = new GlyphMetrics(0, 0, 100); StyleRange style = new StyleRange(); style.start = 1; style.length = 1; style.metrics = metrics; text.setStyleRange(style); ----------------------------------------------------------------- The StyledText will contain ("b" is hidden by GlyphMetrics): ----------------------------------------------------------------- a c ----------------------------------------------------------------- My idea to fix this problem (and manage line content annotation with clean mean without redrawing the character "b") is that GlyphMetrics should provide a new field "insert" ----------------------------------------------------------------- /** * true if metrics should be inserted in the given offset and false othewise. */ public boolean insert; ----------------------------------------------------------------- Here the same snippet with "metrics.insert = true;" ----------------------------------------------------------------- StyledText text = new StyledText(shell, SWT.BORDER | SWT.V_SCROLL); text.setText("abc"); // insert a blank space after "a" and before "b" ("b" is visible) GlyphMetrics metrics = new GlyphMetrics(0, 0, 100); metrics.insert = true; StyleRange style = new StyleRange(); style.start = 1; style.length = 1; style.metrics = metrics; text.setStyleRange(style); ----------------------------------------------------------------- To provide this feature, the TextLayout of each OS must be changed. As I have only Windows OS, I have supported that for windows. I will create a gerrit patch with this snippet and support of GlyphMetrics#insert only for windows. If you like this idea, I hope that they will have people which will update too TextLayout for other OS. @Mickael, do you like this idea? If yes, do you think there is any chance that we will find people who will implement GlyphMetrics#insert for other OS? IMHO I think we should have this feature to provide a better draw of inlined line content annotation (without redrawing the character will support selection, line cursor, etc)
Bug title/content similar to bug 531769(which additionally as a gerrit.) *** This bug has been marked as a duplicate of bug 531769 ***
Oooops sorry @Niraj with my mistake.