Code: Alles auswählen
#mein_style1 = 1
#mein_style2 = 2
#mein_style3 = 3
Procedure sci_cb(hWnd,id,*scin.SCNOTIFICATION,lParam)
Protected endstyle = ScintillaSendMessage(id,#SCI_GETENDSTYLED,0,0)
Protected line = ScintillaSendMessage(id,#SCI_LINEFROMPOSITION,endstyle,0)
Protected start_pos = ScintillaSendMessage(id,#SCI_POSITIONFROMLINE,line,0)
Protected end_pos = *scin\position
Protected first_char = 0
While start_pos < end_pos
first_char = ScintillaSendMessage(id,#SCI_GETCHARAT,start_pos,0)
ScintillaSendMessage(id,#SCI_STARTSTYLING,start_pos,31)
Select first_char
Case '+','*','-','/'
ScintillaSendMessage(id,#SCI_SETSTYLING,1,#mein_style1)
Case '(',')'
ScintillaSendMessage(id,#SCI_SETSTYLING,1,#mein_style2)
Case '0' To '9'
ScintillaSendMessage(id,#SCI_SETSTYLING,1,#mein_style3)
Default
ScintillaSendMessage(id,#SCI_SETSTYLING,1,#STYLE_DEFAULT)
EndSelect
start_pos + 1
Wend
EndProcedure
InitScintilla("scilexer.dll")
hWnd = OpenWindow(0,#PB_Ignore,#PB_Ignore,320,240,"leer")
CreateGadgetList(hWnd)
ScintillaGadget(0,0,0,320,240,0,@sci_cb())
ScintillaSendMessage(0,#SCI_STYLESETFORE,#STYLE_DEFAULT, #Black)
ScintillaSendMessage(0,#SCI_STYLESETBACK,#STYLE_DEFAULT, #White)
ScintillaSendMessage(0,#SCI_STYLECLEARALL,0,0)
ScintillaSendMessage(0,#SCI_STYLESETFORE,#mein_style1,$0000FF)
ScintillaSendMessage(0,#SCI_STYLESETFORE,#mein_style2,$FF0000)
ScintillaSendMessage(0,#SCI_STYLESETBACK,#mein_style2,$C0C0C0)
ScintillaSendMessage(0,#SCI_STYLESETFORE,#mein_style3,$00FF00)
SetGadgetText(0,"a = 1+1*(1/1)-1")
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
der Dokumentation von Scintilla weiter.