Retrieving value with SCI_GETINDICATORVALUE

43 views
Skip to first unread message

cfran...@gmail.com

unread,
Apr 8, 2018, 6:25:08 PM4/8/18
to scintilla-interest
Hello, another understanding question

am I right to assume that retrieving a value with SCI_GETINDICATORVALUE is only possible if called either directly
after SCI_SETINDICATORVALUE or SCI_INDICATORFILLRANGE but not anymore if called
after setting either the same or different indicator by calling
SCI_SETINDICATORCURRENT?

Once
SCI_SETINDICATORCURRENT is called again one should use
SCI_INDICATORVALUEAT to get the value, correct?

In case it isn't clear what I tried to explain, this lua script demonstrates it, the output would be

before IndicatorFillRange:42
after IndicatorFillRange:42
after setting indicator_1 again:1
IndicatorValueAt:42
IndicatorValueAt after different indicator was set:42
done

Was expecting, that after setting indicator_1 again IndicValue would receive 42 instead of default 1.


Thank you
Claudia

--First line for indicator 1
--Second line with indicator 2
--Strike three

function set_indicator_attributes(indicator_number,
                                  alpha
,
                                 
--fore,
                                  outline_alpha
,
                                  indicator_style
,
                                  under
)
   
    editor
.IndicAlpha[indicator_number] = alpha
   
--editor.IndicSetFore[indicator_number] = fore
    editor
.IndicOutlineAlpha[indicator_number] = outline_alpha
    editor
.IndicStyle[indicator_number] = indicator_style
    editor
.IndicUnder[indicator_number] = under
end

Indicator_1 = 8
Indicator_2 = 9
Indicator_3 = 10

set_indicator_attributes
(Indicator_1, 55, 255, INDIC_CONTAINER,true)
set_indicator_attributes
(Indicator_2, 55, 255, INDIC_DASH, true)
set_indicator_attributes
(Indicator_3, 55, 255, INDIC_STRIKE, true)

editor
.IndicatorCurrent = Indicator_1
editor
.IndicatorValue = 42
print('before IndicatorFillRange:' .. editor.IndicatorValue)
editor
:IndicatorFillRange(editor:PositionFromLine(0), editor.LineEndPosition[0]-editor:PositionFromLine(0))
print('after IndicatorFillRange:' .. editor.IndicatorValue)

editor
.IndicatorCurrent = Indicator_1
print('after setting indicator_1 again:' .. editor.IndicatorValue)
print('IndicatorValueAt:' .. editor:IndicatorValueAt(Indicator_1, editor:PositionFromLine(0)))

editor
.IndicatorCurrent = Indicator_2
editor
:IndicatorFillRange(editor:PositionFromLine(1), editor.LineEndPosition[1]-editor:PositionFromLine(1))

editor
.IndicatorCurrent = Indicator_3
editor
:IndicatorFillRange(editor:PositionFromLine(2), editor.LineEndPosition[2]-editor:PositionFromLine(2))

print('IndicatorValueAt after different indicator was set:' .. editor:IndicatorValueAt(Indicator_1, editor:PositionFromLine(0)))

print("done")




Neil Hodgson

unread,
Apr 9, 2018, 6:11:46 PM4/9/18
to Scintilla mailing list
Hi Claudia,

> am I right to assume that retrieving a value with SCI_GETINDICATORVALUE is only possible if called either directly
> after SCI_SETINDICATORVALUE or SCI_INDICATORFILLRANGE but not anymore if called
> after setting either the same or different indicator by calling SCI_SETINDICATORCURRENT?

SCI_SETINDICATORCURRENT also sets the current value to 1 to avoid using an unexpected value on a different indicator. Most applications rarely use any value other than 1.

> Once SCI_SETINDICATORCURRENT is called again one should use SCI_INDICATORVALUEAT to get the value, correct?

SCI_INDICATORVALUEAT is to find the value at a particular location. SCI_GETINDICATORVALUE is the counterpart to SCI_SETINDICATORVALUE.

SCI_INDICATORVALUEAT is only used when your application is storing more than just a binary on/off in indicators. Perhaps you have a checker pass that highlights all spelling and grammar errors in one visual way but uses the indicator value 1 for spelling errors and 2 for grammar errors so that the context menu code can work out which options to show without rerunning the checker.

Your code should know what effect it wants to produce when creating indicator ranges and not need to call any read APIs. Call SCI_SETINDICATORCURRENT and then SCI_SETINDICATORVALUE if you are using a value other than 1.

Neil

cfran...@gmail.com

unread,
Apr 10, 2018, 8:33:42 AM4/10/18
to scintilla-interest
Hi Neil,

thank you for your responds, I guess I understand now.
SCI_GETINDICATORVALUE is only able to retrieve the current value from the currently set indicator.
if calling SCI_SETINDICATORCURRENT again, even with same indicator number, then it is,
from logical point of view, a new/different indicator as the one which was used previously and with its own current value.
So I either need to store the values in my own list or using SCI_INDICATORVALUEAT to retrieve
the value at a certain position.

Thanks again
Claudia
Reply all
Reply to author
Forward
0 new messages