Code: Alles auswählen
;##################################################################
;#
;#
;#
;##################################################################
Procedure SetStyle(id,style,fore,back,bold=-1,italic=-1,size=0,font.s="")
ScintillaSendMessage(id,#SCI_STYLESETFORE, style, fore)
ScintillaSendMessage(id,#SCI_STYLESETBACK, style, back)
If italic > -1
ScintillaSendMessage(id,#SCI_STYLESETITALIC, style, italic)
EndIf
If bold > -1
ScintillaSendMessage(id,#SCI_STYLESETBOLD, style, bold)
EndIf
If size > 0
ScintillaSendMessage(id,#SCI_STYLESETSIZE, style, size)
EndIf
If font
ScintillaSendMessage(id,#SCI_STYLESETFONT, style, @font)
EndIf
EndProcedure
;##################################################################
;#
;#
;#
;##################################################################
ProcedureDLL ScintillaCallBack(Gadget, *scinotify.SCNotification)
Protected line = ScintillaSendMessage(Gadget,#SCI_LINEFROMPOSITION,*scinotify\position)
If *scinotify\margin = 1
ScintillaSendMessage(Gadget,#SCI_TOGGLEFOLD, line, 0)
EndIf
EndProcedure
;##################################################################
;#
;#
;#
;##################################################################
Procedure NewSciGadget(id,x,y,cx,cy,cb=0)
Protected Gadget , keyword.s
Static Init
If Not Init
InitScintilla("scilexer")
EndIf
Gadget = ScintillaGadget(id,x,y,cx,cy,cb)
If id <> #PB_Any
Gadget = id
EndIf
; lexer default
ScintillaSendMessage(Gadget,#SCI_SETLEXER,#SCLEX_VB)
ScintillaSendMessage(Gadget,#SCI_SETSTYLEBITS, 5)
SetStyle(Gadget,#STYLE_DEFAULT, #Black, #White,#PB_Default,#PB_Default,10, "courier new")
ScintillaSendMessage(Gadget,#SCI_STYLECLEARALL)
; keyyword
keyword = "addressof alias and as attribute base begin binary boolean byref byte byval call case compare "
keyword + "const currency date decimal declare defbool defbyte defint deflng defcur defsng defdbl defdec "
keyword + "defdate defstr defobj defvar dim do double each else elseif empty end enum eqv erase error "
keyword + "event exit explicit false for friend function get gosub goto if imp implements in input integer "
keyword + "is len let lib like load lock long loop lset me mid midb mod new next not nothing null object "
keyword + "on option optional or paramarray preserve print private property public raiseevent randomize "
keyword + "redim rem resume return rset seek select set single static step stop string sub then time to "
keyword + "true type typeof unload until variant wend while with withevents xor"
ScintillaSendMessage(Gadget,#SCI_SETKEYWORDS,0,@keyword)
SetStyle(Gadget,#SCE_B_KEYWORD , #Blue , #White,#True)
ScintillaSendMessage(Gadget,#SCI_SETKEYWORDS,1,@"option explicit")
SetStyle(Gadget,#SCE_B_KEYWORD2 , #red , #White,#True)
ScintillaSendMessage(Gadget,#SCI_SETKEYWORDS,2,@"blub")
SetStyle(Gadget,#SCE_B_KEYWORD3 , $FFFFFF , $C0C0C0)
SetStyle(Gadget,#SCE_B_NUMBER , #red , #White)
SetStyle(Gadget,#SCE_B_COMMENT , $C0C0C0 , #White)
;line number
ScintillaSendMessage(Gadget,#SCI_SETMARGINWIDTHN, 0, 30)
; folding
ScintillaSendMessage(Gadget,#SCI_SETPROPERTY, @"fold", @"1")
ScintillaSendMessage(Gadget,#SCI_SETMARGINTYPEN, 1, #SC_MARGIN_SYMBOL)
ScintillaSendMessage(Gadget,#SCI_SETMARGINMASKN, 1, #SC_MASK_FOLDERS)
ScintillaSendMessage(Gadget,#SCI_SETMARGINWIDTHN, 1, 20)
ScintillaSendMessage(Gadget,#SCI_SETMARGINSENSITIVEN, 1, 1)
ScintillaSendMessage(Gadget,#SCI_MARKERDEFINE, #SC_MARKNUM_FOLDEROPEN , #SC_MARK_MINUS)
ScintillaSendMessage(Gadget,#SCI_MARKERDEFINE, #SC_MARKNUM_FOLDER , #SC_MARK_PLUS)
ScintillaSendMessage(Gadget,#SCI_MARKERDEFINE, #SC_MARKNUM_FOLDERSUB , #SC_MARK_EMPTY)
ScintillaSendMessage(Gadget,#SCI_MARKERDEFINE, #SC_MARKNUM_FOLDERTAIL , #SC_MARK_EMPTY)
ScintillaSendMessage(Gadget,#SCI_MARKERDEFINE, #SC_MARKNUM_FOLDEREND , #SC_MARK_EMPTY)
ScintillaSendMessage(Gadget,#SCI_MARKERDEFINE, #SC_MARKNUM_FOLDEROPENMID , #SC_MARK_EMPTY)
ScintillaSendMessage(Gadget,#SCI_MARKERDEFINE, #SC_MARKNUM_FOLDERMIDTAIL , #SC_MARK_EMPTY)
EndProcedure
;##################################################################
;#
;#
;#
;##################################################################
Procedure main()
Protected hWnd
hWnd = OpenWindow(0,#PB_Ignore,#PB_Ignore,640,480,"leer",#WS_OVERLAPPEDWINDOW)
SmartWindowRefresh(0,1)
CreateGadgetList(hWnd)
NewSciGadget(0,0,0,640,480,@ScintillaCallBack())
text.s = "Function test()" + #lf$
text.s + " ' blub" + #lf$
text.s + " Dim blub as Integer " + #lf$
text.s + "End Function " + #lf$
SetGadgetText(0,text+#lf$+text)
Repeat
event = WaitWindowEvent()
If event = #PB_Event_SizeWindow
ResizeGadget(0,#PB_Ignore,#PB_Ignore,WindowWidth(0),WindowHeight(0))
EndIf
Until event = #PB_Event_CloseWindow
EndProcedure:main()