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