J'ai lu dans les forums que la nouvelle version de PB avait de nouvelles fonctionnalités relative à scintilla. par contre je n'ai pas vu de code montrant son utilisation concrète
Avez-vous des exemples ?
Merci d'avance à la comunauté

@
JF
Code : Tout sélectionner
;http://www.purebasic.fr/german/viewtopic.php?t=13234, merci ts-soft.
;Pour récupérer l'aide de scintilla au format chm , merci kai.
;http://www.kaispage.de/content/download/Scintilla.chm
EnableExplicit
If InitScintilla("scintilla.dll") = #False
MessageRequester("Erreur","Scintilla.DLL n'a pas pu être chargé",0)
End
EndIf
Enumeration; Gadgets
#SciID
EndEnumeration
Procedure ScintillaCallBack(EditorGadget.l, *scinotify.SCNotification)
If *scinotify\nmhdr\code = #SCN_STYLENEEDED
ScintillaSendMessage(EditorGadget, #SCI_LINEFROMPOSITION, ScintillaSendMessage(EditorGadget, #SCI_GETENDSTYLED))
EndIf
EndProcedure
Procedure CreatePBSource()
Protected WFlags.l = #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SystemMenu | #PB_Window_SizeGadget
Protected temp.s
If OpenWindow(1, #PB_Ignore, 0, 640, 480, "Tests avec Scintilla", WFlags)
CreateGadgetList(WindowID(1))
ScintillaGadget(#SciID, 20, 20, 600, 440, @ScintillaCallBack())
ScintillaSendMessage(#SciID, #SCI_STYLESETBACK, #STYLE_DEFAULT, $BEFCFD) ; Couleur de fond
temp = "Lucida BlackLetter"
ScintillaSendMessage(#SciID, #SCI_STYLESETFONT, #STYLE_DEFAULT, @temp) ; Police
ScintillaSendMessage(#SciID, #SCI_STYLESETSIZE, #STYLE_DEFAULT, 24) ; Taille police
ScintillaSendMessage(#SciID, #SCI_STYLECLEARALL)
ScintillaSendMessage(#SciID, #SCI_STYLESETFORE, 0, $FF0000) ;Couleur du texte
ScintillaSendMessage(#SciID, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER)
ScintillaSendMessage(#SciID, #SCI_SETMARGINWIDTHN, 0, 40) ; Largeur Marge
ScintillaSendMessage(#SciID, #SCI_STYLESETBACK, #STYLE_LINENUMBER, #Gray) ;Couleur de la marge
ScintillaSendMessage(#SciID, #SCI_STYLESETFORE, #STYLE_LINENUMBER, #Yellow) ;Couleur Texte de la marge
ProcedureReturn 1
EndIf
ProcedureReturn 0
EndProcedure
If CreatePBSource()
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow : Break
EndSelect
ForEver
EndIf
Code : Tout sélectionner
; SendMessage_(hScintilla,#SCI_StyleSetFore,#STYLE_DEFAULT,RGB(250,250,250)) ; couleur de la police
; SendMessage_(hScintilla,#SCI_STYLESETBACK,#STYLE_DEFAULT,RGB(40,40,80)) ; couleur du fond
; SendMessage_(hScintilla,#SCI_STYLECLEARALL,0,0);
; SendMessage_(hScintilla,#SCI_StyleSetFore,1,RGB(0,250,0)); définti une liste de couleur comme en rtf
; SendMessage_(hScintilla,#SCI_StyleSetFore,2,RGB(0,250,250));
; SendMessage_(hScintilla,#SCI_StyleSetFore,3,RGB(250,250,0));
; SendMessage_(hScintilla,#SCI_StyleSetFore,4,RGB(250,100,0));
; SendMessage_(hScintilla,#SCI_STYLESETBACK,#STYLE_LINENUMBER,RGB(80,80,160)) ; fond
; SendMessage_(hScintilla,#SCI_StyleSetFore,#STYLE_LINENUMBER,RGB(250,250,250)); écriture
; SendMessage_(hScintilla,#SCI_SETMARGINWIDTHN,0,30); Affiche les numero des lignes
; SendMessage_(hScintilla,#SCI_SETSELBACK,#True,RGB(0,100,150)); Détermine la couleur de fond de la sélection
; SendMessage_(hScintilla,#SCI_SETSELFORE,#False,0); La couleur du texte sélectionné est inchangée
; SendMessage_(hScintilla,#SCI_SETCARETFORE,RGB(250,200,100),0); Couleur du curseur
; SendMessage_(hScintilla,#SCI_SETCARETWIDTH,2,0); Largeur du curseur
; SendMessage_(hScintilla,#SCI_SETINDENTATIONGUIDES,#True,0) ; Affiche le guide d'indentation
; SendMessage_(hScintilla,#SCI_SETINDENT,8,0) ; Détermine la longueur de la tabulation
; SendMessage_(hScintilla,#SCI_INSERTTEXT,-1,Texte$) ; insère le texte à la fin !
; For t=1 To 6
; SendMessage_(hScintilla,#SCI_SETLINEINDENTATION,t,8) ; indente le texte de 8 espaces
; Next
; SendMessage_(hScintilla,#SCI_SETLINEINDENTATION,2,16)
; SendMessage_(hScintilla,#SCI_SETLINEINDENTATION,4,16)
; SendMessage_(hScintilla,#SCI_SETLINEINDENTATION,6,16)
;
; SendMessage_(hScintilla,#SCI_STARTSTYLING,9,$FF);x=début de la coloration y=??
; SendMessage_(hScintilla,#SCI_SETSTYLING,8,1) ;x=nombre de caractère y : numéro de couleur dans le dico
; SendMessage_(hScintilla,#SCI_STARTSTYLING,29,$FF)
; SendMessage_(hScintilla,#SCI_SETSTYLING,7,2)
; SendMessage_(hScintilla,#SCI_STARTSTYLING,40,$FF)
; SendMessage_(hScintilla,#SCI_SETSTYLING,213,4)
; SendMessage_(hScintilla,#SCI_STARTSTYLING,266,$FF)
; SendMessage_(hScintilla,#SCI_SETSTYLING,7,4)
;
; SendMessage_(hScintilla,#SCI_SETMARGINSENSITIVEN,1,#True); active le folding
; SendMessage_(hScintilla,#SCI_SETMARGINMASKN,1,~#SC_MASK_FOLDERS);masque la couleur différente du folding
; SendMessage_(hScintilla,#SCI_MARKERDEFINE,0,#SC_MARK_ARROW) ; définit la fleche pour le droite (replié)
; SendMessage_(hScintilla,#SCI_MARKERDEFINE,1,#SC_MARK_ARROWDOWN) ; définti la fleche pour le bas (déplié)
;
; SendMessage_(hScintilla,#SCI_SETFOLDFLAGS,8,1)
; SendMessage_(hScintilla,#SCI_SETFOLDLEVEL,0,#SC_FOLDLEVELHEADERFLAG)
; SendMessage_(hScintilla,#SCI_MARKERADD,0,0) ; ajoute le petit triangle : y0 triangle pointé vers la gauche 1vers le bas
; SendMessage_(hScintilla,#SCI_HIDELINES,1,6); Cacher des lignes : ligne de départ, ombre de lignes
; SendMessage_(hScintilla,#SCI_SETFOLDEXPANDED,1,1); x ? y fait une ligne endessous du folder
DeclareDLL ScintillaCallBack(Gadget, *scinotify.SCNotification)
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#Editor_0
#Button_0
#Button_1
#Button_2
#Button_3
EndEnumeration
If InitScintilla("D:\purebasic4\Compilers\Scintilla.dll")=0 ; on charge la dll
MessageRequester("erreur","trouve pas la dll scintilla", #PB_MessageRequester_Ok )
End
EndIf
Procedure Open_Window_0()
If OpenWindow(#Window_0, 357, 1, 499, 670, "New window ( 0 )", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
ScintillaGadget(#Editor_0, 20, 70, 460, 570, @ScintillaCallBack())
ButtonGadget(#Button_0, 20, 20, 90, 30, "coul fond")
ButtonGadget(#Button_1, 150, 20, 90, 30, "numero")
ButtonGadget(#Button_2, 280, 20, 90, 30, "coul curs")
ButtonGadget(#Button_3, 400, 20, 80, 30, "indent ligne 1")
EndIf
EndIf
EndProcedure
Open_Window_0()
ScintillaSendMessage(#Editor_0, #SCI_STYLESETFORE, 0, $FF0000) ; couleur du text
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadget() ; Is it a gadget event?
EventType = EventType() ; The event type
;You can place code here, and use the result as parameters for the procedures
If Event = #PB_Event_Gadget
If GadgetID = #Editor_0
ElseIf GadgetID = #Button_0 ;on envoi un message de colorisation pour voir
ScintillaSendMessage(#Editor_0, #SCI_STYLESETBACK,#STYLE_DEFAULT,RGB(40,40,80)) ; couleur du fond
ElseIf GadgetID = #Button_1
ScintillaSendMessage(#Editor_0, #SCI_SETMARGINWIDTHN,0,30) ; active les numero de ligne !!!
ElseIf GadgetID = #Button_2
ScintillaSendMessage(#Editor_0,#SCI_SETCARETWIDTH,5); Largeur du curseur
ScintillaSendMessage(#Editor_0, #SCI_SETCARETFORE,RGB(250,0,0)); couleur du curseur
ElseIf GadgetID = #Button_3
ScintillaSendMessage(#Editor_0,#SCI_SETLINEINDENTATION,1,8) ; indente le texte de la ligne 1 de 8 espaces)
EndIf
EndIf
Until Event = #PB_Event_CloseWindow ; End of the event loop
End
;
ProcedureDLL ScintillaCallBack(Gadget, *scinotify.SCNotification)
;
; The ProcedureDLL declaration is important for the callback to work correctly on MacOSX,
; on all other OS it has no effect.
;
EndProcedure
c'est la même dll !! elle a ete renommé pour Purebasicflaith a écrit :Comme Jeff j'avais besoin d'un exemple, ça tombe bien, donc merci à vous deux.
juste une chose, Comtois, tu utilises "scintilla.dll" et toi Dobro "SciLexer.dll", quel est al différence ?
d'avance merci
Code : Tout sélectionner
; SendMessage_(hScintilla,#SCI_StyleSetFore,#STYLE_DEFAULT,RGB(250,250,250)) ; couleur de la police
C'est presque la même chose.Dobro a écrit :c'est la même dll !! elle a ete renommé pour Purebasic en "SciLexer.dll"
Code : Tout sélectionner
;
; Use Existing Lexer With Scintilla
;
; Here an example for VB
; ! Important : use SciLexer from SciTe download !
;
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
; default lexer --> set to VB
ScintillaSendMessage(Gadget,#SCI_SETLEXER,#SCLEX_VB)
ScintillaSendMessage(Gadget,#SCI_SETSTYLEBITS, 5)
;{ Available lexers
; #SCLEX_CONTAINER = 0
; #SCLEX_NULL = 1
; #SCLEX_PYTHON = 2
; #SCLEX_CPP = 3
; #SCLEX_HTML = 4
; #SCLEX_XML = 5
; #SCLEX_PERL = 6
; #SCLEX_SQL = 7
; #SCLEX_VB = 8
; #SCLEX_PROPERTIES = 9
; #SCLEX_ERRORLIST = 10
; #SCLEX_MAKEFILE = 11
; #SCLEX_BATCH = 12
; #SCLEX_XCODE = 13
; #SCLEX_LATEX = 14
; #SCLEX_LUA = 15
; #SCLEX_DIFF = 16
; #SCLEX_CONF = 17
; #SCLEX_PASCAL = 18
; #SCLEX_AVE = 19
; #SCLEX_ADA = 20
; #SCLEX_LISP = 21
; #SCLEX_RUBY = 22
; #SCLEX_EIFFEL = 23
; #SCLEX_EIFFELKW = 24
; #SCLEX_TCL = 25
; #SCLEX_NNCRONTAB = 26
; #SCLEX_BULLANT = 27
; #SCLEX_VBSCRIPT = 28
; #SCLEX_BAAN = 31
; #SCLEX_MATLAB = 32
; #SCLEX_SCRIPTOL = 33
; #SCLEX_ASM = 34
; #SCLEX_CPPNOCASE = 35
; #SCLEX_FORTRAN = 36
; #SCLEX_F77 = 37
; #SCLEX_CSS = 38
; #SCLEX_POV = 39
; #SCLEX_LOUT = 40
; #SCLEX_ESCRIPT = 41
; #SCLEX_PS = 42
; #SCLEX_NSIS = 43
; #SCLEX_MMIXAL = 44
; #SCLEX_CLW = 45
; #SCLEX_CLWNOCASE = 46
; #SCLEX_LOT = 47
; #SCLEX_YAML = 48
; #SCLEX_TEX = 49
; #SCLEX_METAPOST = 50
; #SCLEX_POWERBASIC = 51
; #SCLEX_FORTH = 52
; #SCLEX_ERLANG = 53
; #SCLEX_OCTAVE = 54
; #SCLEX_MSSQL = 55
; #SCLEX_VERILOG = 56
; #SCLEX_KIX = 57
; #SCLEX_GUI4CLI = 58
; #SCLEX_SPECMAN = 59
; #SCLEX_AU3 = 60
; #SCLEX_APDL = 61
; #SCLEX_BASH = 62
; #SCLEX_ASN1 = 63
; #SCLEX_VHDL = 64
; #SCLEX_CAML = 65
; #SCLEX_BLITZBASIC = 66
; #SCLEX_PUREBASIC = 67
; #SCLEX_HASKELL = 68
; #SCLEX_PHPSCRIPT = 69
; #SCLEX_TADS3 = 70
; #SCLEX_REBOL = 71
; #SCLEX_SMALLTALK = 72
; #SCLEX_FLAGSHIP = 73
; #SCLEX_CSOUND = 74
; #SCLEX_FREEBASIC = 75
;}
;
SetStyle(Gadget,#STYLE_DEFAULT, #Black, #White,#PB_Default,#PB_Default,10, "courier new")
ScintillaSendMessage(Gadget,#SCI_STYLECLEARALL)
;
; keywords
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,@"glloq")
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())
; Test code
text.s = "Function test()" + #lf$
text.s + " ' glloq" + #lf$
text.s + " Dim glloq as Integer " + #lf$
text.s + "End Function " + #lf$
SetGadgetText(0,text+#lf$+text)
; Events
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()
Code : Tout sélectionner
key.s="goto print next"
Code : Tout sélectionner
ScintillaSendMessage(#Editor_0,#SCI_SETKEYWORDS,0,@key.s) ; on envoi l'adresse des mots clef pour coloration
Code : Tout sélectionner
SetStyle(#Editor_0,#SCE_B_KEYWORD , #Red , #White,#True) ; en principe active la coloration !!!!!!
Code : Tout sélectionner
; SendMessage_(hScintilla,#SCI_StyleSetFore,#STYLE_DEFAULT,RGB(250,250,250)) ; couleur de la police
; SendMessage_(hScintilla,#SCI_STYLESETBACK,#STYLE_DEFAULT,RGB(40,40,80)) ; couleur du fond
; SendMessage_(hScintilla,#SCI_STYLECLEARALL,0,0);
; SendMessage_(hScintilla,#SCI_StyleSetFore,1,RGB(0,250,0)); définti une liste de couleur comme en rtf
; SendMessage_(hScintilla,#SCI_StyleSetFore,2,RGB(0,250,250));
; SendMessage_(hScintilla,#SCI_StyleSetFore,3,RGB(250,250,0));
; SendMessage_(hScintilla,#SCI_StyleSetFore,4,RGB(250,100,0));
; SendMessage_(hScintilla,#SCI_STYLESETBACK,#STYLE_LINENUMBER,RGB(80,80,160)) ; fond
; SendMessage_(hScintilla,#SCI_StyleSetFore,#STYLE_LINENUMBER,RGB(250,250,250)); écriture
; SendMessage_(hScintilla,#SCI_SETMARGINWIDTHN,0,30); Affiche les numero des lignes
; SendMessage_(hScintilla,#SCI_SETSELBACK,#True,RGB(0,100,150)); Détermine la couleur de fond de la sélection
; SendMessage_(hScintilla,#SCI_SETSELFORE,#False,0); La couleur du texte sélectionné est inchangée
; SendMessage_(hScintilla,#SCI_SETCARETFORE,RGB(250,200,100),0); Couleur du curseur
; SendMessage_(hScintilla,#SCI_SETCARETWIDTH,2,0); Largeur du curseur
; SendMessage_(hScintilla,#SCI_SETINDENTATIONGUIDES,#True,0) ; Affiche le guide d'indentation
; SendMessage_(hScintilla,#SCI_SETINDENT,8,0) ; Détermine la longueur de la tabulation
; SendMessage_(hScintilla,#SCI_INSERTTEXT,-1,Texte$) ; insère le texte à la fin !
; For t=1 To 6
; SendMessage_(hScintilla,#SCI_SETLINEINDENTATION,t,8) ; indente le texte de 8 espaces
; Next
; SendMessage_(hScintilla,#SCI_SETLINEINDENTATION,2,16)
; SendMessage_(hScintilla,#SCI_SETLINEINDENTATION,4,16)
; SendMessage_(hScintilla,#SCI_SETLINEINDENTATION,6,16)
;
; SendMessage_(hScintilla,#SCI_STARTSTYLING,9,$FF);x=début de la coloration y=??
; SendMessage_(hScintilla,#SCI_SETSTYLING,8,1) ;x=nombre de caractère y : numéro de couleur dans le dico
; SendMessage_(hScintilla,#SCI_STARTSTYLING,29,$FF)
; SendMessage_(hScintilla,#SCI_SETSTYLING,7,2)
; SendMessage_(hScintilla,#SCI_STARTSTYLING,40,$FF)
; SendMessage_(hScintilla,#SCI_SETSTYLING,213,4)
; SendMessage_(hScintilla,#SCI_STARTSTYLING,266,$FF)
; SendMessage_(hScintilla,#SCI_SETSTYLING,7,4)
;
; SendMessage_(hScintilla,#SCI_SETMARGINSENSITIVEN,1,#True); active le folding
; SendMessage_(hScintilla,#SCI_SETMARGINMASKN,1,~#SC_MASK_FOLDERS);masque la couleur différente du folding
; SendMessage_(hScintilla,#SCI_MARKERDEFINE,0,#SC_MARK_ARROW) ; définit la fleche pour le droite (replié)
; SendMessage_(hScintilla,#SCI_MARKERDEFINE,1,#SC_MARK_ARROWDOWN) ; définti la fleche pour le bas (déplié)
;
; SendMessage_(hScintilla,#SCI_SETFOLDFLAGS,8,1)
; SendMessage_(hScintilla,#SCI_SETFOLDLEVEL,0,#SC_FOLDLEVELHEADERFLAG)
; SendMessage_(hScintilla,#SCI_MARKERADD,0,0) ; ajoute le petit triangle : y0 triangle pointé vers la gauche 1vers le bas
; SendMessage_(hScintilla,#SCI_HIDELINES,1,6); Cacher des lignes : ligne de départ, ombre de lignes
; SendMessage_(hScintilla,#SCI_SETFOLDEXPANDED,1,1); x ? y fait une ligne endessous du folder
;ScintillaSendMessage(Gadget,#SCI_SETKEYWORDS,0,@keyword)
;SetStyle(Gadget,#SCE_B_KEYWORD , #Blue , #White,#True)
DeclareDLL ScintillaCallBack(Gadget, *scinotify.SCNotification)
Declare SetStyle(id,style,fore,back,bold=-1,italic=-1,Size=0,font.s="")
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#Editor_0
#Button_0
#Button_1
#Button_2
#Button_3
EndEnumeration
If InitScintilla("D:\purebasic4\japbe4\SciLexer.dll")=0 ; on charge la dll
MessageRequester("erreur","trouve pas la dll scintilla", #PB_MessageRequester_Ok )
End
EndIf
Procedure Open_Window_0()
If OpenWindow(#Window_0, 357, 1, 499, 670, "New window ( 0 )", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
SmartWindowRefresh(0,1)
If CreateGadgetList(WindowID(#Window_0))
ScintillaGadget(#Editor_0, 20, 70, 460, 570, @ScintillaCallBack())
ButtonGadget(#Button_0, 20, 20, 90, 30, "coul fond")
ButtonGadget(#Button_1, 150, 20, 90, 30, "numero")
ButtonGadget(#Button_2, 280, 20, 90, 30, "coul curs")
ButtonGadget(#Button_3, 400, 20, 80, 30, "indent ligne 1")
EndIf
EndIf
EndProcedure
Open_Window_0()
; ScintillaSendMessage(#Editor_0,#SCI_SETLEXER,#SCLEX_VB)
; ScintillaSendMessage(#Editor_0,#SCI_SETSTYLEBITS, 5)
key.s="goto print for next " ; on defini les mots clef a colorer en rouge
ScintillaSendMessage(#Editor_0,#SCI_SETKEYWORDS,0,@key.s) ; on envoi l'adresse des mots clef pour coloration
SetStyle(#Editor_0,#SCE_B_KEYWORD , #Red , #White,#True) ; en principe active la coloration !!!!!! <------------------------- hum !!
; ScintillaSendMessage(#Editor_0, #SCI_STYLESETFORE, 0, $0) ; couleur du text
; ScintillaSendMessage(#Editor_0, #SCI_STYLESETBACK,#STYLE_DEFAULT,RGB(255,255,150)) ; couleur du fond
SetStyle(#Editor_0,#STYLE_DEFAULT, #Black, #White,#PB_Default,#PB_Default,10, "courier new")
ScintillaSendMessage(#Editor_0,#SCI_STYLECLEARALL) ; on efface tout
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadget() ; Is it a gadget event?
EventType = EventType() ; The event type
;You can place code here, and use the result as parameters for the procedures
If Event = #PB_Event_Gadget
If GadgetID = #Editor_0
ElseIf GadgetID = #Button_0 ;on envoi un message de colorisation pour voir
ScintillaSendMessage(#Editor_0, #SCI_STYLESETBACK,#STYLE_DEFAULT,RGB(40,40,80)) ; couleur du fond
ElseIf GadgetID = #Button_1
ScintillaSendMessage(#Editor_0, #SCI_SETMARGINWIDTHN,0,30) ; active les numero de ligne !!!
ElseIf GadgetID = #Button_2
ScintillaSendMessage(#Editor_0,#SCI_SETCARETWIDTH,3); Largeur du curseur
ScintillaSendMessage(#Editor_0, #SCI_SETCARETFORE,RGB(250,0,0)); couleur du curseur
ElseIf GadgetID = #Button_3
ScintillaSendMessage(#Editor_0,#SCI_SETLINEINDENTATION,1,8) ; indente le texte de la ligne 1 de 8 espaces)
EndIf
EndIf
Until Event = #PB_Event_CloseWindow ; End of the event loop
End
;
ProcedureDLL ScintillaCallBack(Gadget, *scinotify.SCNotification)
;
; The ProcedureDLL declaration is important for the callback to work correctly on MacOSX,
; on all other OS it has no effect.
EndProcedure
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