Indicator features to change text colour and allow more colours

159 views
Skip to first unread message

Neil Hodgson

unread,
Feb 12, 2015, 1:23:41 AM2/12/15
to Scintilla mailing list
   To allow applications to display more information on top of document text, 3 new indicator API elements have been implemented.

(1) INDIC_FULLBOX indicator style. This has already been committed since it is very simple. Its just like INDIC_STRAIGHTBOX but it covers the full area of the character instead of leaving a pixel clear at the top. This means that this indicator on adjacent lines may merge together. I prefer INDIC_STRAIGHTBOX but INDIC_FULLBOX can set a simple background colour over the whole height (with the alpha values set to 0xFF) which can emulate other applications.

(2) INDIC_TEXTFORE indicator style allows the foreground colour of text to be changed. For example, you may want to display spelling mistakes by making the text red instead of using an underline. Using this indicator is more expensive than other indicators as it affects low level text display. Some effort is made to avoid costs here and more could be done if it turns out this is heavily used.

(3) SC_INDICATORATTRIBUTE_FOREFROMVALUE indicator attribute. Indicators have always had an integer value for each run but this has previously been treated as a boolean with all non-zero values displaying the indicator in its fore colour. With the SC_INDICATORATTRIBUTE_FOREFROMVALUE attribute (which could have a shorter name) the value is used for the colour as a standard RGB integer as used everywhere in Scintilla. Thus one indicator may have a wide variety of colours. This can be used, for example, to display braces with cyclic colours to help decipher nested expressions like this image:

Rainbow.lua
Override4.patch
PastedGraphic-1.tiff

Neil Hodgson

unread,
Feb 12, 2015, 1:26:44 AM2/12/15
to scintilla...@googlegroups.com
   It appears my mailer did a very poor job on that message so here is the text again in order without images or attachments.

   Another use is to similarly show the nesting level of HTML tags as in http://scintilla.org/RainbowTags.png .

   Neither INDIC_TEXTFORE or SC_INDICATORATTRIBUTE_FOREFROMVALUE have yet been committed. The current implementation patch is attached to this message.

   An issue with INDIC_TEXTFORE is that it splits up character runs which may cause a different image to when the text is displayed in longer runs. Combining characters, ligatures and kerned pairs may display badly. In http://scintilla.org/CombiningSeparated.png the text consists of 4 characters: N <COMBINING TILDE> n <COMBINING TILDE> . When each character is displayed separately, the graphics library doesn’t know that it needs to move the first tilde up to go over the N. This can also occur with current Scintilla if a lexer assigns different styles to the characters.

   Another minor issue with SC_INDICATORATTRIBUTE_FOREFROMVALUE is that the value 0 means don’t display and colour 0 is black, so pure black will be invisible. A workaround is to use a very dark grey like 0x010101. Its possible this could be avoided by something like oring in 0x1000000 to all colours. There may be other attributes that could be stored in the high byte of the value.

   Attached are also the SciTE Lua scripts used for the images above. These scripts are very simple and can’t handle braces inside strings or some uses of ‘<‘and ‘>' in HTML. To use these scripts, SciTE must be updated with scite/scripts/RegenerateSource.py after applying the Scintilla patch.

   Neil

Neil Hodgson

unread,
Feb 15, 2015, 7:56:58 AM2/15/15
to scintilla...@googlegroups.com
   The new indicator features have now been committed.

   Neil

Reply all
Reply to author
Forward
0 new messages