Date: 02-16-2022
Return to Index
created by gbSnippets
'Scintilla can display up to 32 visual enhancements, called indicators, in the text area
'of the control. The indicators are drawn after styling has been completed. Each of the
'32 indicators can in turn be assigned a symbol (called a style), which will be drawn
'over the styled text.
'The following 7 styles are currently available from Scintilla.
' - %INDIC_PLAIN Underline (straight Line)
' - %INDIC_SQUIGGLE Underline (squiggly line)
' - %INDIC_TT Small T shapes
' - %INDIC_DIAGONAL Diagonal hatching
' - %INDIC_STRIKE Strike out
' - %INDIC_HIDDEN No visual effect
' - %INDIC_BOX Rectangle around the text
' - %INDIC_ROUNDBOX Rounded rectangle around the text (can set alpha transparency)
'Even though there are only 7 styles available, the following properties of indicators
'can be set (in addition to selecting the style, or symbol, of the indicator).
' - FG/BG color
' - Transparency
' - Over/under drawing (over by default)
'To use indicators, one of the 32 indicators must be set as current. Then, the current
'indicator my be applied to or removed from a range of characters.
'By convention, indicators 0-7 are reserved for use by lexers, while indicators 8-31
'are reserved for use by the container application.
'By default, indicators 0-2 are set to the following indicator styles:
'- 0 - INDIC_Squiggle
'- 1 - INDIC_TT
'- 2 - INDIC_Plain
'Scintilla also offers are few other capabilities with which to manage indicators:
' - get indicator used at a specific position
' - get the start/end of a range of indicators
'Scintilla originally stored indicator information in the style bytes, a feature
'which will be phased out in favor of the 32 separately stored indicators as
'discussed above.
'Primary Code:
'First, set the style of the indicators you want to use
SendMessage hSci, %SCI_IndicSetStyle, 8, %Indic_Squiggle 'indicator 8 set as squiggle
'Second, make the indicator current
SendMessage hSci, %SCI_SetIndicatorCurrent, 8, 0 'indicator is now #8
'Third, apply the indicator to a range of characters
SendMessage hSci, %SCI_IndicatorFillRange, 3, 3 'startpos=3, length=3, use current indicator
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
#Include "scintilla_gb.inc"
%ID_Sci = 1000 : %ID_BtnA = 1001 : %ID_BtnB = 1002
Global hDlg, hSci, hLib As DWord
Function PBMain() As Long
hLib = LoadLibrary("SCILEXER.DLL")
Dialog New Pixels, 0, "Scintilla Example",300,300,300,150, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %ID_BtnA, "Show Indicators", 10,10,90,20, %WS_Child Or %WS_Visible
Control Add Button, hDlg, %ID_BtnB, "Clear Indicators", 10,40,90,20, %WS_Child Or %WS_Visible
Control Add "Scintilla", hDlg, %ID_Sci, "", 100,10,180,130, %WS_Child Or %WS_Visible
Control Handle hDlg, %ID_Sci To hSci 'get handle to Scintilla window
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local txt As String
txt = "Select Case var$ 'first line" + $CrLf + "End Select 'last line" + Chr$(0)
Select Case CB.Msg
Case %WM_InitDialog
InitializeScintilla
PostMessage hSci, %SCI_SetSel, 0,0 'unselect initially
Case %WM_Command
Select Case CB.Ctl
Case %ID_BtnA : TestA
Case %ID_BtnB : TestB
End Select
Case %WM_Size
Control Set Size hDlg, %ID_Sci, Lo(Word, CB.lParam)-110, Hi(Word, CB.lParam)-20
Case %WM_Destroy
If hLib Then FreeLibrary hLib 'free the Scintilla library
End Select
End Function
Sub InitializeScintilla
Local txt As String, i As Long
For i = 1 to 7
txt = txt + "Line" + Str$(i) + $crlf
Next i
txt = txt + Chr$(0)
SendMessage hSci, %SCI_SetText, 0, StrPTR(txt)
SendMessage hSci, %SCI_SetMarginWidthN, 0, 20
End Sub
Sub TestA
Local i,iStart As Long
'set indicator 8-10 styles
SendMessage hSci, %SCI_IndicSetStyle, 8, %Indic_Plain
SendMessage hSci, %SCI_IndicSetStyle, 9, %Indic_Squiggle
SendMessage hSci, %SCI_IndicSetStyle, 10, %Indic_TT
SendMessage hSci, %SCI_IndicSetStyle, 11, %Indic_Diagonal
SendMessage hSci, %SCI_IndicSetStyle, 12, %Indic_Strike
SendMessage hSci, %SCI_IndicSetStyle, 13, %Indic_Box
SendMessage hSci, %SCI_IndicSetStyle, 14, %Indic_Roundbox
'use each of the indicators
For i = 8 to 14
SendMessage hSci, %SCI_SetIndicatorCurrent, i, 0 'set current indicator
iStart = SendMessage(hSci, %SCI_PositionFromLIne, i-8, 0) 'position of 1st char in line
SendMessage hSci, %SCI_IndicatorFillRange, iStart, 7 'start at pos iStart, for 3 chars
Next i
End Sub
Sub TestB
Local i As Long
For i = 8 to 14
SendMessage hSci, %SCI_SetIndicatorCurrent, i, 0 'set current indicator
SendMessage hSci, %SCI_IndicatorClearRange, 0, 500 'clear all occurences
Next i
End Sub
'gbs_00656
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm