Help with indicator logic

89 views
Skip to first unread message

Yury Dubinsky

unread,
Jul 18, 2016, 1:12:12 PM7/18/16
to scite-interest

Hello, Neil,

Could you, please, assist to understand few moments related to Indicators?

Basically I have 4 questions.

Question 1.  Indicators are mentioned on “Using Lua With Scite” page.  (http://lua-users.org/wiki/UsingLuaWithScite).

There are 2 examples how to use it. One example is  based on three command sequence:

  editor:StartStyling(pos,INDICS_MASK)

  editor:SetStyling(len,INDIC0_MASK + ind)

  editor:SetStyling(2,31)

(“ind” value could be:

  0 green squiggly line

  1 light blue line of small T shapes

  2 light red line)

However,  when I try using these commands usually I don’t see any effect. Sometimes, the text between pos and pos+len is highlighted in gray. I assume it could relate to some property value.

There is another example on this page:

“Indicators with version 1.70 and maybe previous. And you can use it like this :

   editor:StartStyling(editor.SelectionStart,INDICS_MASK)

  editor:SetStyling(string.len(editor:GetSelText()),flag)”

But, it also doesn’t work for me.

Does SciTe still support above methods? What is wrong here?

Question 2. I found another  method in  “Scite Mark Word” macro.

(http://lua-users.org/wiki/SciteMarkWord ).

The author used the following commands.

   scite.SendEditor(SCI_INDICSETSTYLE, 0, INDIC_ROUNDBOX)

   scite.SendEditor(SCI_INDICSETFORE, 0, 255)

   scite.SendEditor(SCI_INDICATORFILLRANGE, a, b)

However, it looks like SCI_INDICSETSTYLE and SCI_INDICSETFORE don’t have any effect.

When SCI_INDICATORFILLRANGE is applied the specified  text  is underlined.

Does scite still support  SCI_INDICSETSTYLE and SCI_INDICSETFORE?


Question 3. I realized that indicators applied using  SCI_INDICATORFILLRANGE.are  controlled  by SCI_SETINDICATORCURRENT.  The command is scite.SendEditor(SCI_SETINDICATORCURRENT, n) . Default value of n(when scite starts) is 9. ( scite.SendEditor(SCI_GETINDICATORCURRENT) returns current value).  Then I found the following:
If n=0,  text is coloured in green.
If n=1,  text is coloured in blue.
If n=2,  text is coloured in red.
If n is between 3 and 13.  text is underlined. I didn’t test values greater than n=13.
I also found some differences in the following indicator behavior.
If N=9 (the default value) tab switch removes indicators.
If N is between 0 and 7, tab switch  doesn't remove indicators, but language switch  via Language menu removes indicators.
If N=8 or N is between 10 and 13, neither tab switch  nor language switch  remove indicators.
So, I would like to confirm if it is a supported or unsupported behavior.


Question 4 is not directly related to indicators as I believe. When I was testing indicators  on Windows I noticed some weird phenomenon. Once  when SCI_SETINDICATORCURRENT was set to  9 the text was highlighted in yellow and not underlined.  I believe it was some kind of glitch. The strange thing was that when I opened  another scite windows and set  SCI_SETINDICATORCURRENT to 9 the text was still highlighted in yellow. Then I closed all windows except the first and open again new windows. The text was still highlighted in yellow. And only after I closed all windows the indicator behavior was restored and in newly opened windows the text was again underlined.  I even don’t try to interpret the nature of this glitch. My question is different.  I understand that each scite window is an independent Windows process. How was it possible that a glitch that  happened in one process could be spread across other independent Windows processes?

Thank you,
 Yury

Neil Hodgson

unread,
Aug 16, 2016, 11:07:10 PM8/16/16
to scite-i...@googlegroups.com
Yury Dubinsky:

> Question 1. Indicators are mentioned on “Using Lua With Scite” page. (http://lua-users.org/wiki/UsingLuaWithScite).
> There are 2 examples how to use it. One example is based on three command sequence:
> editor:StartStyling(pos,INDICS_MASK)
> editor:SetStyling(len,INDIC0_MASK + ind) …
> However, when I try using these commands usually I don’t see any effect. Sometimes, the text between pos and pos+len is highlighted in gray.

This is an old and dead API. From the Scintilla documentation:

Originally, Scintilla used a different technique for indicators but this has been removed and the APIs perform no action. While both techniques were supported, the term "modern indicators" was used for the newer implementation.

http://www.scintilla.org/ScintillaDoc.html#Indicators

> Question 2. I found another method in “Scite Mark Word” macro.
> (http://lua-users.org/wiki/SciteMarkWord ).
> The author used the following commands.
> scite.SendEditor(SCI_INDICSETSTYLE, 0, INDIC_ROUNDBOX)
> scite.SendEditor(SCI_INDICSETFORE, 0, 255)
> scite.SendEditor(SCI_INDICATORFILLRANGE, a, b)

Indicators 0…7 are allocated to lexers, 32…35 to IMEs, and 8…31 to applications. SciTE currently uses 8…10 and may use more in the future so start at 20 or allocate backwards from 31.

> Once when SCI_SETINDICATORCURRENT was set to 9 the text was highlighted in yellow and not underlined. I believe it was some kind of glitch

Indicator 9 is used for SciTE’s highlight.current.word feature.

Here is a recent indicator script that works in SciTE although it was written to demonstrate multiple colours with one indicator which is probably not what you want.

function RainbowTags()
-- Simplistic marking of nested tags with cyclic set of colours
-- Does not cope with all HTML including '>' in attributes or scripts.
local rainbow = { 0x10000A0, 0x100A0A0, 0x100A000, 0x1A0A000, 0x1A00000, 0x1A000A0 }
local indic = 20
editor.IndicStyle[indic] = INDIC_FULLBOX
editor.IndicFore[indic] = 0x0000A0
editor.IndicAlpha[indic] = 90
editor.IndicOutlineAlpha[indic] = 90
editor.IndicFlags[indic] = SC_INDICFLAG_VALUEFORE
editor.IndicatorCurrent = indic
local level = 120 -- Start positive to avoid modulo negative
local i = 0
while i < editor.Length do
local ich = editor.CharAt[i]
if ich < 0 then
ich = ich + 256
end
local ch = string.char(ich)
if ch == '<' then
local tag = ch
local start = i
i = i + 1
while i < editor.Length do
local ich = editor.CharAt[i]
if ich < 0 then
ich = ich + 256
end
local ch = string.char(ich)
tag = tag .. ch
if ch == '>' then
if tag:sub(2,2) == "/" then -- end tag
--print("End tag", tag)
editor.IndicatorValue = rainbow[level+1]
editor:IndicatorFillRange(start, #tag)
level = (level - 1) % #rainbow
elseif tag:sub(2,4) == "!--" then -- comment
-- Should continue to "-->"
--print("Comment", #tag, tag[2], tag:sub(#tag-1,#tag-1), tag)
editor.IndicatorValue = rainbow[level+1]
editor:IndicatorFillRange(start, #tag)
elseif tag:sub(#tag-1,#tag-1) == "/" then -- neutral tag
--print("Neutral tag", #tag, tag[2], tag:sub(#tag-1,#tag-1), tag)
editor.IndicatorValue = rainbow[level+1]
editor:IndicatorFillRange(start, #tag)
else -- start tag
--print("Start tag", #tag, tag[2], tag:sub(2,2), tag)
level = (level + 1) % #rainbow
editor.IndicatorValue = rainbow[level+1]
editor:IndicatorFillRange(start, #tag)
end
break
end
i = i + 1
end
else
i = i + 1
end
end
end

Produces http://scintilla.org/RainbowTags.png

Neil

Reply all
Reply to author
Forward
0 new messages