Editeur Html (Module Scintilla)

Informations pour bien débuter en PureBasic
Avatar de l’utilisateur
microdevweb
Messages : 1798
Inscription : mer. 29/juin/2011 14:11
Localisation : Belgique

Editeur Html (Module Scintilla)

Message par microdevweb »

Mise à jour le : 03/05/2015

Dans le cadre d'un gros projet, j'ai du m'intéresser à Scintilla, la doc n'est pas toujours évidente à comprendre et les exemples sont rare. Après de nombreuses recherches je commence à comprendre le système. J'ai donc commencer le développement d'un module à cette effet (toujours en développement). Actuellement il ne prend en compte que le Html avec colorisation via une feuille de style xml et auto complémentation via xml également
ATTENTION : Scilexer.dll doit être présent dans le répertoire racine du script ou le module est appellé
Dowload ICI https://github.com/jacobslusser/Scintil ... intillaNET

Image

Code module Vers: Beta 2

Tous le pack ICI :arrow: http://microdevweb.com/source/Editor/Editor_Html.zip

Code : Tout sélectionner

;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
;© MicrodevWeb 2015  http://www.microdevweb.com  info@microdevweb.com
; Name : Editor
; Vers : beta 2  date: 2015 05 03
;{ Description : 
;Module pour un éditeur html, avec 
; 1   gestion de colorisation syntatique par feuille de style XML
; 2   autocomplétion des mot clé html par feuille XML
;} END 
; Requiere : None
DeclareModule Editor
      ; ATTENTION : Scilexer.dll doit être présent dans le répertoire racine du script ou le module est appellé
      ; Dowload ICI  https://github.com/jacobslusser/ScintillaNET/tree/master/ScintillaNET
      ; Create --> Crée l'éditeur
      ; X --> position en X de l'éditeur
      ; Y --> position en Y de l'éditeur
      ; Width --> La largeur de l'éditeur
      ; Height --> La hauteur de l'éditeur
      ;style$ --> le chemin complet de la feuille de style (XML)
      ;{ ** Format de la feuille de style **
      ;FrontColor --> La couleur du texte au format hexa ($FFFFFF)
      ;BackColor --> La couleur du fond au format hexa ($FFFFFF)
      ;FontName --> La police utlilisée
      ;FontStyle -->0 pas de style
      ;               -->1 en gras
      ;              -->2 italique
      ;              -->3 gras et italique
      ;FontSize --> Taille de la police
      ;<Eureka>
      ;            <!-- La colonne des numérotation de ligne MarginWidth= largeur de la marge -->
      ;            <RowsNumber FrontColor="" BackColor="" FontName="" FontStyle="" FontSize="" MarginWidth=""/>
      ;            <!-- Les paramètres par défaut CaretFrontColor= la couleur du curseur CaretBackColor=l couleur de fond du curseur
      ;                   TabColor= la couleur de ligne de séparation de tabluature
      ;            <Default FrontColor="" BackColor="" CaretFrontColor="" CaretBackColor="" TabColor="" FontName="" FontStyle="" FontSize="" />   
      ;           <!-- Les lexer de scin tilla -->
      ;           <LexerStyle>  
      ;                 <html>
      ;                       <Default FrontColor="" BackColor="" FontName="" FontStyle="" FontSize=""/>
	;                       <Comment FrontColor="" BackColor="" FontName="" FontStyle="" FontSize=""/>
	;                       <Atribute FrontColor="" BackColor="" FontName="" FontStyle="" FontSize=""/>
	;                       <AtributeUnknown FrontColor="" BackColor="" FontName="" FontStyle="" FontSize=""/>
	;                       <Cdata FrontColor="" BackColor="" FontName="" FontStyle="" FontSize=""/>
	;                       <DoubleString FrontColor="" BackColor=""/>
	;                      <Entity FrontColor="" BackColor="" FontName="" FontStyle="" FontSize=""/>
	;                       <Number FrontColor="" BackColor="" FontName="" FontStyle="" FontSize=""/>
	;                       <Other FrontColor="" BackColor="" FontName="" FontStyle="" FontSize=""/>
	;                      <Question FrontColor="" BackColor="" FontName="" FontStyle="" FontSize=""/>
	;                      <Scritp FrontColor="" BackColor="" FontName="" FontStyle="" FontSize=""/>
	;                      <Tag FrontColor="" BackColor="" FontName="" FontStyle="" FontSize=""/>
	;                     <TagEnd FrontColor="" BackColor="" FontName="" FontStyle="" FontSize=""/>
	;                     <TagUnknown FrontColor="" BackColor="" FontName="" FontStyle="" FontSize=""/>
	;                     <Value FrontColor="" BackColor="" FontName="" FontStyle="" FontSize=""/>
      ;                 </html>
      ;           </LexerStyle>  
      ;</Eureka>
      ;} ** END Format de la feuille de style **
      Declare Create(X,Y,Width,Height,style$)
      ;SetStatusBar --> Active l'affiche dans une StatusBar préalablemnt crée
      ;id --> l'id de la stus bar
      ;id_rows_info --> le numéro (créer avec AddStatusBarField()) exemple: 0 si premier AddStatusBarField()
      ;id_column_info --> Idem
      Declare SetStatusBar(id,id_rows_info,id_column_info)
      ;SetAutoCompleteSeparator --> Change le séparateur de la liste des mots de l'autocomplétion (par défaut 47 /)
      ;separator --> séparateur qui sera utilisé par scintilla au format asci
      Declare SetAutoCompleteSeparator(separator)
      ;SetAutocompleteList --> Ajoute une liste de mot clé pour l'autocomplétion
      ;XmlList$ --> Chemin complet du fichier XML
      ; Type --> type de mot clé  #Key_html;
      ;{ ** Format de la feuille xml
      ;<Eureka>
	;     <AutoComplete>
      ;     	<KeyWord name="" />
      ;     </AutoComplete>
       ;</Eureka>
      ;} ** END Format de la feuille xml
      Declare SetAutocompleteList(XmlList$,Type.i)
      ;SetNbCaratereForAutocomplete --> Détermine le nombre de caractères avant de déclenché l'autocomplétion (par défaut 2 caractères)
      ;nb --> Le nombre de caractères
      Declare SetNbCaratereForAutocomplete(nb)
       Enumeration 1
            #Key_user
            #Key_html
            #Key_php
            #Key_css
            #Key_js
            #Key_jq
      EndEnumeration
EndDeclareModule
Module Editor
      ;-* Constantes / énum ération
      Enumeration Tag 1
            #Tag_html_balise
            #Tag_html_simple
      EndEnumeration
      ;} END Constantes / énumération
      ;-* Structure / List / Map
      Structure AutoComplete
            name$
            nameEnd$
            Tag.i
            Type.i
      EndStructure
      Structure Editor
            myId.i ;--> id du gadget scintilla
            myStyleId.i ;-->id du Xml style
            myStatusBarId.i ;--> id du gadget statusbar
            myRowsInfoId.i ;--> id de la colonne pour l'affichage de la ligne courante
            myColumnInfoId.i ;--> id de la colonne pour l'affichage de la colonne courante
            numberRowsOn.b ;--> Affichage du numéro de ligne
            nbSpaceByTab.b ;--> Nombre d'espace par tabulation
            CurrentPosition.i ;--> La position courante du curseur dans scintilla
            CurrentLine.i ;--> La ligne courante
            CurrentColumn.i ;--> La colonne courante
            AutoCompleteSeparator.i ;--> Le séparateur qui séra utilisé par scintilla pour la séparation de la liste d'autocomplétion
            List myAutoComplete.AutoComplete(); La liste des mots à recherché pour l'autocomplétion
            nbCaratereForAutocomplete.i       ;--> Le nombre de caractère pour déclencher l'autocomplétion
            CurrentWord$
      EndStructure
      Global myEditor.Editor
      ;} END Structure / List / Map
      ;-* Déclarations
      Declare AutoComplete(Type)
      ;} END Déclarations
      ;-* Procédures
      Procedure SetNbCaratereForAutocomplete(nb)
            With myEditor
                  \nbCaratereForAutocomplete=nb      
            EndWith
      EndProcedure
      Procedure SetAutoCompleteSeparator(separator)
            With myEditor
                   \AutoCompleteSeparator=separator     
            EndWith
      EndProcedure
      Procedure SetAutocompleteList(XmlList$,Type.i)
            Protected myXmlList=LoadXML(#PB_Any,XmlList$)
            If myXmlList=0
                  MessageRequester("Eureka","Error the Xml list   "+XmlList$+"   has not be loaded...")
                  ProcedureReturn #False
            EndIf
            If XMLStatus(myXmlList)<>#PB_XML_Success
                  MessageRequester("Eureka","Error, the key word "+XmlList$+" has not xml format")
                  ProcedureReturn #False
            EndIf
             ; Teste le fichier XML
            Protected MainNode=MainXMLNode(myXmlList)
            If (XMLNodeType(MainNode)<>#PB_XML_Normal)
                  MessageRequester("Eureka","Error this XML key word is corrupted")
                  ProcedureReturn #False
            EndIf
            ; Teste l'entete du noeud principale
            If GetXMLNodeName(MainNode)<>"Eureka"
                  MessageRequester("Eureka","Error this XML key word is corrupted")
                  ProcedureReturn #False
            EndIf
            ;Pointe sur l'enfant
            MainNode=ChildXMLNode(MainNode)
            ; Teste l'entete du autocomplete
            If GetXMLNodeName(MainNode)<>"AutoComplete"
                  MessageRequester("Eureka","Error this XML key word is corrupted")
                  ProcedureReturn #False
            EndIf
            ;Pointe sur le premier enfant
            Protected *childNode=ChildXMLNode(MainNode)
            While *childNode<>0
                  AddElement(myEditor\myAutoComplete())
                  myEditor\myAutoComplete()\name$=GetXMLAttribute(*childNode,"name")
                  myEditor\myAutoComplete()\Type=Type
                  ;Détermine si le mot clé est tagé
                  If GetXMLAttribute(*childNode,"Tag")<>""
                        myEditor\myAutoComplete()\Tag=Val(GetXMLAttribute(*childNode,"Tag"))
                  Else
                        myEditor\myAutoComplete()\Tag=0
                  EndIf
                  *ChildNode = NextXMLNode(*ChildNode)
            Wend
      EndProcedure
      Procedure UpdateStatusBar()
            With myEditor
                  If \myStatusBarId=-1 : ProcedureReturn #False :EndIf
                  StatusBarText(\myStatusBarId,\myRowsInfoId,"Ligne : "+Str(\CurrentLine+1))
                  StatusBarText(\myStatusBarId,\myColumnInfoId,"Colonne : "+Str(\CurrentColumn+1))
            EndWith
      EndProcedure
      Procedure Make_form(value$,p1,p2)
            Protected *bufer,txt$,ilen
            ; Cette procédure met en forme les commande suivant les tags
            With myEditor
                  ForEach \myAutoComplete()
                        If \myAutoComplete()\name$=value$
                              Break
                        EndIf
                  Next
                  If \myAutoComplete()\Tag<>0
                        Select \myAutoComplete()\Tag
                              Case #Tag_html_balise,#Tag_html_simple
                                    ;Si il y a le tab devant
                                    ilen=Len(value$)
                                    If ScintillaSendMessage(\myId,#SCI_GETCHARAT,p1-1) <>60
                                          ilen+1
                                          txt$+"<"
                                    EndIf
                                    txt$+value$
                                    If ScintillaSendMessage(\myId,#SCI_GETCHARAT,p2+1) <>62
                                          ilen+1
                                          txt$+">"
                                    EndIf
                                    ScintillaSendMessage(\myId,#SCI_SETSEL,p1,p2)
                                    *bufer=AllocateMemory(ilen) 
                                    PokeS(*bufer,txt$)
                                    ScintillaSendMessage(\myId,#SCI_REPLACESEL,ilen,*bufer)
                                    If \myAutoComplete()\Tag=#Tag_html_balise
                                          ilen=Len(value$)+3
                                          FreeMemory(*bufer)
                                          *bufer=AllocateMemory(ilen)
                                          txt$="</"+value$+">"
                                          PokeS(*bufer,txt$)
                                          ScintillaSendMessage(\myId,#SCI_ADDTEXT,ilen,*bufer)
                                          ScintillaSendMessage(\myId,#SCI_CLEAR)
                                          ScintillaSendMessage(\myId,#SCI_SETANCHOR,ScintillaSendMessage(\myId,#SCI_GETCURRENTPOS)-ilen)
                                          ScintillaSendMessage(\myId,#SCI_SETCURRENTPOS,ScintillaSendMessage(\myId,#SCI_GETCURRENTPOS)-ilen)
                                    EndIf
                        EndSelect
                  EndIf
            EndWith
      EndProcedure
      Procedure ScintillaCallBack(idGadget,*scinotify.SCNotification )         
            Protected Txt$,indent,*Pointer.String,P1,P2
            With myEditor
                  \CurrentPosition=ScintillaSendMessage(\myId, #SCI_GETANCHOR)
                  \CurrentLine=ScintillaSendMessage(\myId,#SCI_LINEFROMPOSITION,\CurrentPosition)
                  \CurrentColumn=ScintillaSendMessage(\myId, #SCI_GETCOLUMN, \CurrentPosition)
                  Select *scinotify\nmhdr\code
                        Case #SCN_AUTOCSELECTION
                              *Pointer=@*scinotify\text
                              ScintillaSendMessage(\myId,#SCI_AUTOCCANCEL) 
                              P1=*scinotify\position
                              P2=P1+Len(*Pointer\s)
                              P2-(Len(*Pointer\s)-Len(\CurrentWord$))-1
                              \CurrentWord$=""
                              Make_form(*Pointer\s,P1,P2)
                  EndSelect
                  Select *scinotify\ch
                        Case 13 ;--> Entrée / Return
                                ;Recupère l'indentation de la ligne précédente
                              indent=ScintillaSendMessage(\myId, #SCI_GETLINEINDENTATION, \CurrentLine-1)
                              ;Si il y a une indentation positionne la ligne suivante
                              If indent>0
                                    ScintillaSendMessage(\myId, #SCI_SETLINEINDENTATION, \CurrentLine, indent)
                                    ScintillaSendMessage(\myId, #SCI_GOTOPOS, \CurrentPosition+indent)
                              EndIf
                              ;Mise à blanc du mot courant pour autocomplet
                              \CurrentWord$=""
                        Case 32 ;--> Space
                              P1=\CurrentPosition-(Len(\CurrentWord$)+1)
                              P2=P1+Len(\CurrentWord$)
                              Make_form(\CurrentWord$,P1,P2)
                              \CurrentWord$=""
                        Case  34 ;-->  "
                              Txt$=Chr(34)
                              ScintillaSendMessage(\myId,#SCI_ADDTEXT,1,@Txt$)
                              ScintillaSendMessage(\myId,#SCI_GOTOPOS,\CurrentPosition)
                        Case 39 ;-->'
                              Txt$=Chr(39)
                              ScintillaSendMessage(\myId,#SCI_ADDTEXT,1,@Txt$)
                              ScintillaSendMessage(\myId,#SCI_GOTOPOS,\CurrentPosition)
                        Case 40 ;-->(
                              Txt$=Chr(41)
                              ScintillaSendMessage(\myId,#SCI_ADDTEXT,1,@Txt$)
                              ScintillaSendMessage(\myId,#SCI_GOTOPOS,\CurrentPosition)
                        Case 60 ;--><
                              Txt$=Chr(62)
                              ScintillaSendMessage(\myId,#SCI_ADDTEXT,1,@Txt$)
                              ScintillaSendMessage(\myId,#SCI_GOTOPOS,\CurrentPosition)
                        Case 91 ;-->[
                              Txt$=Chr(93)
                              ScintillaSendMessage(\myId,#SCI_ADDTEXT,1,@Txt$)
                              ScintillaSendMessage(\myId,#SCI_GOTOPOS,\CurrentPosition)
                        Case 123 ;-->{
                              Txt$=Chr(125)
                              ScintillaSendMessage(\myId,#SCI_ADDTEXT,1,@Txt$)
                              ScintillaSendMessage(\myId,#SCI_GOTOPOS,\CurrentPosition)
                        Case 64 To 90,96 To 122
                              \CurrentWord$+Chr(*scinotify\ch)
                               AutoComplete(#Key_html)
                   EndSelect
                   Select *scinotify\modificationType
                         Case 2064 ; Retour arrière
                               If Len(\CurrentWord$)>0
                                    \CurrentWord$=Left(\CurrentWord$,Len(\CurrentWord$)-1)      
                              EndIf
                   EndSelect
            EndWith
      EndProcedure
      Procedure SetStatusBar(id,id_rows_info,id_column_info)
            With myEditor
                  \myStatusBarId=id
                  \myRowsInfoId=id_rows_info
                  \myColumnInfoId=id_column_info
            EndWith
      EndProcedure
      Procedure AutoComplete(Type)
            Protected WordList$
            With myEditor
                  If Len(\CurrentWord$)<\nbCaratereForAutocomplete:ProcedureReturn :EndIf
                  If ScintillaSendMessage(\myId,#SCI_AUTOCACTIVE)<>0 : ProcedureReturn : EndIf
                  WordList$=""
                  SortStructuredList(\myAutoComplete(),#PB_Sort_Descending,OffsetOf(AutoComplete\name$),TypeOf(AutoComplete\name$))
                  ForEach \myAutoComplete()
                        If \myAutoComplete()\Type=Type
                              If Left(\myAutoComplete()\name$,Len(\CurrentWord$))=\CurrentWord$
                                    If Len(WordList$)>0
                                          WordList$+Chr(\AutoCompleteSeparator)
                                    EndIf
                                    WordList$+\myAutoComplete()\name$
                              EndIf
                        EndIf
                  Next
                  If Len(WordList$)=0:ProcedureReturn :EndIf
                  ScintillaSendMessage(\myId,#SCI_AUTOCGETIGNORECASE)
                  ScintillaSendMessage(\myId,#SCI_AUTOCSETSEPARATOR,47)
                  ScintillaSendMessage(\myId,#SCI_AUTOCSHOW,Len(\CurrentWord$),@WordList$)
            EndWith
      EndProcedure
      Procedure InitMarginNumber(*childNode)
            With myEditor
                  ScintillaSendMessage(\myId,#SCI_SETMARGINTYPEN,0,#SC_MARGIN_NUMBER)
                  ScintillaSendMessage(\myId, #SCI_SETMARGINWIDTHN, 0, Val(GetXMLAttribute(*childNode,"MarginWidth")))
                  ScintillaSendMessage(\myId, #SCI_STYLESETBACK, #STYLE_LINENUMBER, Val(GetXMLAttribute(*childNode,"BackColor")))
                  ScintillaSendMessage(\myId, #SCI_STYLESETFORE, #STYLE_LINENUMBER, Val(GetXMLAttribute(*childNode,"FrontColor")))
            EndWith
      EndProcedure
      Procedure InitDefault(*childNode)
            With myEditor
                  ; Font du gadget
                  ScintillaSendMessage(\myId, #SCI_STYLESETFORE, #STYLE_DEFAULT, Val(GetXMLAttribute(*childNode,"FrontColor")))
                  ScintillaSendMessage(\myId, #SCI_STYLESETBACK, #STYLE_DEFAULT, Val(GetXMLAttribute(*childNode,"BackColor")))
                  ; Propriété des font
                  Protected font$=GetXMLAttribute(*childNode,"FontName")
                  ScintillaSendMessage(\myId, #SCI_STYLESETFONT,#STYLE_DEFAULT,@font$)
                  ScintillaSendMessage(\myId, #SCI_STYLESETSIZE, #STYLE_DEFAULT, Val(GetXMLAttribute(*childNode,"FontSize")))
                  ;Margin Mask Folder
                  ScintillaSendMessage(\myId, #SCI_SETMARGINMASKN, 2, #SC_MASK_FOLDERS)
                  ScintillaSendMessage(\myId, #SCI_SETMARGINWIDTHN, 2, 15)
                   ;Affichage et couleur de la ligne active
                  ScintillaSendMessage(\myId, #SCI_SETCARETLINEVISIBLE, #True)
                  ScintillaSendMessage(\myId, #SCI_SETCARETLINEBACK,Val(GetXMLAttribute(*childNode,"CaretBackColor")) )
                  ScintillaSendMessage(\myId, #SCI_SETCARETFORE,Val(GetXMLAttribute(*childNode,"CaretFrontColor")) )
                  ;Texte par defaut
                  ScintillaSendMessage(\myId, #SCI_STYLESETFORE, #SCE_H_DEFAULT, Val(GetXMLAttribute(*childNode,"FrontColor")))
                  ScintillaSendMessage(\myId, #SCI_STYLESETBACK, #SCE_H_DEFAULT,Val(GetXMLAttribute(*childNode,"BackColor")))
                  ;Les tabulations sont remplacées par des espaces
                  ScintillaSendMessage(\myId, #SCI_SETUSETABS, #False)
                  ;Nombre d'espaces pour une tabulation
                  ScintillaSendMessage(\myId, #SCI_SETINDENT, \nbSpaceByTab)
                   ;Affichage du guide d'indentation et affectation d'une couleur
                  ScintillaSendMessage(\myId, #SCI_SETINDENTATIONGUIDES, #SC_IV_LOOKFORWARD)
                  ScintillaSendMessage(\myId, #SCI_STYLESETFORE, #STYLE_INDENTGUIDE, Val(GetXMLAttribute(*childNode,"TabColor")))
            EndWith
      EndProcedure
      Procedure setStyle(*id,target)
            Protected Font$
            With myEditor
                  ScintillaSendMessage(\myId, #SCI_STYLESETFORE, target, Val(GetXMLAttribute(*id,"FrontColor")))
                  ScintillaSendMessage(\myId, #SCI_STYLESETBACK, target, Val(GetXMLAttribute(*id,"BackColor")))
                  Font$=GetXMLAttribute(*id,"FontName")
                  ScintillaSendMessage(\myId, #SCI_STYLESETFONT, target, @Font$)
                  ScintillaSendMessage(\myId, #SCI_STYLESETSIZE, target, Val(GetXMLAttribute(*id,"FontSize")))
                  Select Val(GetXMLAttribute(*id,"FontStyle"))
                        Case 1
                              ScintillaSendMessage(\myId, #SCI_STYLESETBOLD, target,#True)
                        Case 2
                              ScintillaSendMessage(\myId, #SCI_STYLESETITALIC, target,#True)
                        Case 3
                              ScintillaSendMessage(\myId, #SCI_STYLESETITALIC, target,#True)
                              ScintillaSendMessage(\myId, #SCI_STYLESETBOLD, target,#True)
                  EndSelect
            EndWith
      EndProcedure
      Procedure InitHtml(*childNode)
            ;Chargement du dictionnaire HTML
            ScintillaSendMessage(myEditor\myId, #SCI_SETLEXER, #SCLEX_HTML)
            Protected *myChild=ChildXMLNode(*childNode)
            While *myChild<>0
                  Select GetXMLNodeName(*myChild)
                        Case "default"
                              setStyle(*myChild,#SCE_H_DEFAULT)
                        Case "Comment"
                              setStyle(*myChild,#SCE_H_COMMENT)
                        Case "Attribute"
                              setStyle(*myChild,#SCE_H_ATTRIBUTE)
                        Case "AtributeUnknown"
                              setStyle(*myChild,#SCE_H_ATTRIBUTE)   
                        Case "Cdata"
                              setStyle(*myChild,#SCE_H_CDATA)  
                        Case "DoubleString"
                               ScintillaSendMessage(myEditor\myId, #SCI_STYLESETFORE, #SCE_H_DOUBLESTRING, Val(GetXMLAttribute(*myChild,"FrontColor")))
                               ScintillaSendMessage(myEditor\myId, #SCI_STYLESETBACK, #SCE_H_DOUBLESTRING, Val(GetXMLAttribute(*myChild,"BackColor")))  
                         Case "Entity"
                               setStyle(*myChild,#SCE_H_ENTITY)  
                         Case "Number"
                               setStyle(*myChild,#SCE_H_NUMBER)  
                         Case "Other"
                               setStyle(*myChild,#SCE_H_OTHER)  
                         Case "Question"
                               setStyle(*myChild,#SCE_H_QUESTION)     
                         Case "Scritp"
                               setStyle(*myChild,#SCE_H_SCRIPT)    
                         Case "Tag"
                               setStyle(*myChild,#SCE_H_TAG)    
                         Case "TagEnd"
                               setStyle(*myChild,#SCE_H_TAGEND)   
                         Case "TagUnknown"
                               setStyle(*myChild,#SCE_H_TAGUNKNOWN) 
                         Case "Value"
                               setStyle(*myChild,#SCE_H_VALUE) 
                  EndSelect
                  *myChild=NextXMLNode(*myChild)
            Wend
             ;Texte par defaut
            
      EndProcedure
      Procedure InitLexerStyle(*childNode)
            Protected *myChild=ChildXMLNode(*childNode)
            While *myChild<>0
                  Select GetXMLNodeName(*myChild)
                        Case "html" 
                              InitHtml(*myChild)
                  EndSelect
                  *myChild=NextXMLNode(*myChild)
            Wend
      EndProcedure
      Procedure InitMyScintilla()
            Protected MainNode
            With myEditor
                  ; Teste le fichier XML
                  MainNode=MainXMLNode(\myStyleId)
                  If (XMLNodeType(MainNode)<>#PB_XML_Normal)
                        MessageRequester("Eureka","Error this XML style is corrupted")
                        ProcedureReturn #False
                  EndIf
                  ; Teste l'entete du noeud principale
                  If GetXMLNodeName(MainNode)<>"Eureka"
                        MessageRequester("Eureka","Error this XML style is corrupted")
                        ProcedureReturn #False
                  EndIf
                  ;Pointe sur le premier enfant
                  Protected *childNode=ChildXMLNode(MainNode)
                  While *childNode<>0
                        Select GetXMLNodeName(*childNode)
                              Case "RowsNumber"
                                    InitMarginNumber(*childNode)
                              Case "Default"
                                    InitDefault(*childNode)
                              Case "LexerStyle"
                                    InitLexerStyle(*childNode)
                        EndSelect
                        *ChildNode = NextXMLNode(*ChildNode)
                  Wend
            EndWith
      EndProcedure
      Procedure LoadStyle(style$)
            With myEditor
                   ;Chargement du fichier style
                  \myStyleId=LoadXML(#PB_Any,style$)
                  If \myStyleId=0
                        MessageRequester("Eureka","Error, the style "+style$+"as not ben loaded")
                        ProcedureReturn #False
                  EndIf
                  If XMLStatus(\myStyleId)<>#PB_XML_Success
                        MessageRequester("Eureka","Error, the style "+style$+"as not xml format")
                        ProcedureReturn #False
                  EndIf
            EndWith
            ProcedureReturn #True
      EndProcedure
      Procedure InitValue()
            With myEditor
                  \nbSpaceByTab=4    
                  \AutoCompleteSeparator=47
                  \nbCaratereForAutocomplete=2
            EndWith      
      EndProcedure
      Procedure Create(X,Y,Width,Height,style$)
            InitValue()
            ;Initialisation de scintilla
            If Not InitScintilla("Scilexer.dll")
                  MessageRequester("Eureka","Error, the scintilla engine As Not run")
                  ProcedureReturn #False
            EndIf    
            With myEditor
                  ; Initialisation de scintilla
                  ; Création du gadget scintilla
                  \myId=ScintillaGadget(#PB_Any,X,Y,Width,Height,@ScintillaCallBack())
                  SetActiveGadget(\myId)
                  If LoadStyle(style$)=#False :ProcedureReturn #False :EndIf
                  InitMyScintilla()
                  ProcedureReturn \myId
            EndWith
      EndProcedure  
      ;} END Procédures
EndModule
Dernière modification par microdevweb le dim. 03/mai/2015 13:31, modifié 4 fois.
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Avatar de l’utilisateur
microdevweb
Messages : 1798
Inscription : mer. 29/juin/2011 14:11
Localisation : Belgique

Re: Module Scintilla

Message par microdevweb »

Code Programme de teste:

Code : Tout sélectionner

;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; Application Name : Eureka
; Author: Microdevweb
; File name: Main  Created: 2015 04 29
; Description: Fichier principale de l'application Euréka
;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
EnableExplicit
;-* Include
XIncludeFile "Modules\Editor.pbi"
;} END Include
;-* GLobal variables
Global gExit.b=#False
Global gEvent,gEditorId
;} END GLobal variables
;-* Enumerations
Enumeration Form
      #main_form
EndEnumeration
Enumeration Gadget
      #main_status_bar
EndEnumeration
;} END Enumerations
;-* Procedures
Procedure Open_main_form()
      Protected X=0,Y=0,W=800,H=600
      Protected  myTitle$="Eureka 1.0"
            Protected  Flag=#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered|#PB_Window_Maximize
            OpenWindow(#main_form,X,Y,W,H,myTitle$,Flag)
            W=WindowWidth(#main_form)
            H=WindowHeight(#main_form)
            gEditorId=Editor::Create(0,0,W,H-30,"Themes/Black.xml")
            CreateStatusBar(#main_status_bar,WindowID(#main_form))
            AddStatusBarField(150)
            AddStatusBarField(150)
            Editor::SetStatusBar(#main_status_bar,0,1)
            Editor::SetAutocompleteList("Plugins/html.xml",Editor::#Key_html)
            SetActiveGadget(gEditorId)
            RemoveKeyboardShortcut(#main_form, #PB_Shortcut_Tab)
EndProcedure
;} END Procedures
;-* Initialisation
Open_main_form()
;}END Initialisation
;-* Boucle Evenementielle
Repeat 
      gEvent=WindowEvent()
      Delay(5)
      Select gEvent
            Case #PB_Event_CloseWindow
                  gExit=#True
      EndSelect
Until gExit
End
;} END Boucle Evenementielle
      
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Avatar de l’utilisateur
microdevweb
Messages : 1798
Inscription : mer. 29/juin/2011 14:11
Localisation : Belgique

Re: Module Scintilla

Message par microdevweb »

Code feuille de style Black.xml

Code : Tout sélectionner

<?xml version="1.0"  encoding="utf-8"?>
<!-- Theme Black for use with Eureka editor
Copyright (c) 2015 Microdevweb <http://www.microdevweb.com br/>
-->
<Eureka>
      <RowsNumber FrontColor="$FFFFFF" BackColor="$A9A9A9" FontName="arial" FontStyle="0" FontSize="10" MarginWidth="30"/>
	<Default FrontColor="$00A5FF" BackColor="$696969" CaretFrontColor="$D3D3D3" CaretBackColor="$808080" TabColor="$00FC7C" FontName="Verdana" FontStyle="" FontSize="14" />
	<LexerStyle>
	      <html>
	            <default FrontColor="$DCDCDC" BackColor="$696969" FontName="Verdana" FontStyle="0" FontSize="14"/>
	            <Comment FrontColor="$B3DEF5" BackColor="$696969" FontName="Verdana" FontStyle="2" FontSize="14"/>
	            <Atribute FrontColor="$00FFFF" BackColor="$696969" FontName="Verdana" FontStyle="0" FontSize="14"/>
	            <AtributeUnknown FrontColor="$00FFFF" BackColor="$696969" FontName="Verdana" FontStyle="0" FontSize="14"/>
	            <Cdata FrontColor="$B9DAFF" BackColor="$696969" FontName="Verdana" FontStyle="0" FontSize="14"/>
	            <DoubleString FrontColor="$00FC7C" BackColor="$696969"/>
	            <Entity FrontColor="$B9DAFF" BackColor="$696969" FontName="Verdana" FontStyle="0" FontSize="14"/>
	            <Number FrontColor="$9314FF" BackColor="$696969" FontName="Verdana" FontStyle="1" FontSize="14"/>
	            <Other FrontColor="$B9DAFF" BackColor="$696969" FontName="Verdana" FontStyle="0" FontSize="14"/>
	            <Question FrontColor="$B9DAFF" BackColor="$696969" FontName="Verdana" FontStyle="0" FontSize="14"/>
	            <Scritp FrontColor="$FFFF00" BackColor="$696969" FontName="Verdana" FontStyle="0" FontSize="14"/>
	            <Tag FrontColor="$00A5FF" BackColor="$696969" FontName="Verdana" FontStyle="0" FontSize="14"/>
	            <TagEnd FrontColor="$00A5FF" BackColor="$696969" FontName="Verdana" FontStyle="0" FontSize="14"/>
	            <TagUnknown FrontColor="$00A5FF" BackColor="$696969" FontName="Verdana" FontStyle="0" FontSize="14"/>
	            <Value FrontColor="$B9DAFF" BackColor="$696969" FontName="Verdana" FontStyle="0" FontSize="14"/>
	      </html>
	</LexerStyle>
</Eureka>
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Avatar de l’utilisateur
microdevweb
Messages : 1798
Inscription : mer. 29/juin/2011 14:11
Localisation : Belgique

Re: Module Scintilla

Message par microdevweb »

Code Key word htm.xml

Code : Tout sélectionner

<?xml version="1.0"  encoding="utf-8"?>
<!-- Key word html for use with Eureka editor
Copyright (c) 2015 Microdevweb <http://www.microdevweb.com br/>
-->
<Eureka>
    <AutoComplete>
		<KeyWord name="abbr" Tag="1"/>
		<KeyWord name="acronym" Tag="1"/>
		<KeyWord name="address" Tag="1"/>
		<KeyWord name="a" Tag="1"/>
		<KeyWord name="applet" Tag="1"/>
		<KeyWord name="area" Tag="1"/>
		<KeyWord name="b" Tag="1"/>
		<KeyWord name="base" Tag="1"/>
		<KeyWord name="basefont" Tag="1"/>
		<KeyWord name="bdo" Tag="1"/>
		<KeyWord name="bgsound" Tag="1"/>
		<KeyWord name="big" Tag="1"/>
		<KeyWord name="blink" Tag="1"/>
		<KeyWord name="blockquote" Tag="1"/>
		<KeyWord name="body" Tag="1"/>
		<KeyWord name="br" Tag="1"/>
		<KeyWord name="button" Tag="1"/>
		<KeyWord name="caption" Tag="1"/>
		<KeyWord name="center" Tag="1"/>
		<KeyWord name="cite" Tag="1"/>
		<KeyWord name="code" Tag="1"/>
		<KeyWord name="col" Tag="1"/>
		<KeyWord name="colgroup" Tag="1"/>
		<KeyWord name="commment" Tag="1"/>
		<KeyWord name="dd" Tag="1"/>
		<KeyWord name="dl" Tag="1"/>
		<KeyWord name="del" Tag="1"/>
		<KeyWord name="dfn" Tag="1"/>
		<KeyWord name="dir" Tag="1"/>
		<KeyWord name="div" Tag="1"/>
		<KeyWord name="dl" Tag="1"/>
		<KeyWord name="dt" Tag="1"/>
		<KeyWord name="dd" Tag="1"/>
		<KeyWord name="dt" Tag="1"/>
		<KeyWord name="dl" Tag="1"/>
		<KeyWord name="em" Tag="1"/>
		<KeyWord name="embed" Tag="1"/>
		<KeyWord name="fieldset" Tag="1"/>
		<KeyWord name="font" Tag="1"/>
		<KeyWord name="form" Tag="1"/>
		<KeyWord name="input" Tag="1"/>
		<KeyWord name="textarea" Tag="1"/>
		<KeyWord name="select" Tag="1"/>
		<KeyWord name="option" Tag="1"/>
		<KeyWord name="frame" Tag="1"/>
		<KeyWord name="frameset" Tag="1"/>
		<KeyWord name="frameset" Tag="1"/>
		<KeyWord name="body" Tag="1"/>
		<KeyWord name="frame" Tag="1"/>
		<KeyWord name="h1" Tag="1"/>
		<KeyWord name="h2" Tag="1"/>
		<KeyWord name="h3" Tag="1"/>
		<KeyWord name="h4" Tag="1"/>
		<KeyWord name="h5" Tag="1"/>
		<KeyWord name="h6" Tag="1"/>
		<KeyWord name="head" Tag="1"/>
		<KeyWord name="title" Tag="1"/>
		<KeyWord name="meta" Tag="1"/>
		<KeyWord name="base" Tag="1"/>
		<KeyWord name="hr" Tag="1"/>
		<KeyWord name="html" Tag="1"/>
		<KeyWord name="i" Tag="1"/>
		<KeyWord name="iframe" Tag="1"/>
		<KeyWord name="img" Tag="1"/>
		<KeyWord name="input" Tag="1"/>
		<KeyWord name="ins" Tag="1"/>
		<KeyWord name="isindex" Tag="1"/>
		<KeyWord name="kbd" Tag="1"/>
		<KeyWord name="label" Tag="1"/>
		<KeyWord name="form" Tag="1"/>
		<KeyWord name="layer" Tag="1"/>
		<KeyWord name="legend" Tag="1"/>
		<KeyWord name="li" Tag="1"/>
		<KeyWord name="ul" Tag="1"/>
		<KeyWord name="ol" Tag="1"/>
		<KeyWord name="link" Tag="1"/>
		<KeyWord name="map" Tag="1"/>
		<KeyWord name="marquee" Tag="1"/>
		<KeyWord name="menu" Tag="1"/>
		<KeyWord name="meta" Tag="1"/>
		<KeyWord name="nextid" Tag="1"/>
		<KeyWord name="nobr" Tag="1"/>
		<KeyWord name="wbr" Tag="1"/>
		<KeyWord name="noembed" Tag="1"/>
		<KeyWord name="noframes" Tag="1"/>
		<KeyWord name="noscript" Tag="1"/>
		<KeyWord name="object" Tag="1"/>
		<KeyWord name="ol" Tag="1"/>
		<KeyWord name="li" Tag="1"/>
		<KeyWord name="option" Tag="1"/>
		<KeyWord name="p" Tag="1"/>
		<KeyWord name="param" Tag="1"/>
		<KeyWord name="pre" Tag="1"/>
		<KeyWord name="q" Tag="1"/>
		<KeyWord name="s" Tag="1"/>
		<KeyWord name="samp" Tag="1"/>
		<KeyWord name="script" Tag="1"/>
		<KeyWord name="select" Tag="1"/>
		<KeyWord name="option" Tag="1"/>
		<KeyWord name="form" Tag="1"/>
		<KeyWord name="small" Tag="1"/>
		<KeyWord name="span" Tag="1"/>
		<KeyWord name="strike" Tag="1"/>
		<KeyWord name="strong" Tag="1"/>
		<KeyWord name="style" Tag="1"/>
		<KeyWord name="head" Tag="1"/>
		<KeyWord name="sub" Tag="1"/>
		<KeyWord name="sup" Tag="1"/>
		<KeyWord name="table" Tag="1"/>
		<KeyWord name="tbody" Tag="1"/>
		<KeyWord name="td" Tag="1"/>
		<KeyWord name="tr" Tag="1"/>
		<KeyWord name="textarea" Tag="1"/>
		<KeyWord name="tfoot" Tag="1"/>
		<KeyWord name="th" Tag="1"/>
		<KeyWord name="thead" Tag="1"/>
		<KeyWord name="title" Tag="1"/>
		<KeyWord name="head" Tag="1"/>
		<KeyWord name="tr" Tag="1"/>
		<KeyWord name="table" Tag="1"/>
		<KeyWord name="tt" Tag="1"/>
		<KeyWord name="u" Tag="1"/>
		<KeyWord name="ul" Tag="1"/>
		<KeyWord name="li" Tag="1"/>
		<KeyWord name="var" Tag="1"/>
		<KeyWord name="wbr" Tag="1"/>
		<KeyWord name="nobr" Tag="1"/>
		<KeyWord name="xmp" Tag="1"/>
	</AutoComplete>
</Eureka>
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Avatar de l’utilisateur
microdevweb
Messages : 1798
Inscription : mer. 29/juin/2011 14:11
Localisation : Belgique

Re: Editeur Html (Module Scintilla)

Message par microdevweb »

Version béta 2 Online
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Avatar de l’utilisateur
Ar-S
Messages : 9472
Inscription : dim. 09/oct./2005 16:51
Contact :

Re: Editeur Html (Module Scintilla)

Message par Ar-S »

Pas encore testé mais super boulot. J'ose à peine écrire ce message pour pas polluer le topic mais je voulais saluer ton travail.
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
G-Rom
Messages : 3626
Inscription : dim. 10/janv./2010 5:29

Re: Editeur Html (Module Scintilla)

Message par G-Rom »

@Ar-s tu ne pourrira pas le topic, mieux vaut des compliments que des posts débile. Ça fait du bien au créateur , et cela anime un peu ce forum moribond...

@microdevweb , est ce multi-plateforme ?
Avatar de l’utilisateur
microdevweb
Messages : 1798
Inscription : mer. 29/juin/2011 14:11
Localisation : Belgique

Re: Editeur Html (Module Scintilla)

Message par microdevweb »

Merci Ar-S.. Cela fait tjr plaisir
Non G-rooms, pas actuellement. Mais je ne suis pas certain resté dans cette voie, j'ai du mal avec scintilla et javais commencer à développer mon propre gadget éditeur, mais cela étant un peu stupide de réinventer la roue, j'ai repris scintilla. Mais la, grrrr je ne suis vraiment pas certain de continuer avec.
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Avatar de l’utilisateur
Micoute
Messages : 2522
Inscription : dim. 02/oct./2011 16:17
Localisation : 35520 La Mézière

Re: Editeur Html (Module Scintilla)

Message par Micoute »

Bonjour microdevweb et merci pour le partage, c'est dommage que tu souhaite interrompre, bien que je conçois que ce sois très difficile.
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 5.73 PB 6.00 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
Avatar de l’utilisateur
microdevweb
Messages : 1798
Inscription : mer. 29/juin/2011 14:11
Localisation : Belgique

Re: Editeur Html (Module Scintilla)

Message par microdevweb »

@micoute,
je ne souhaite pas interrompre. Mais je vais plus tôt m'orienter vers un module éditor développé uniquement en PB. Je sais que c'est un peux comme réinventer la roue mais la je serais maître de mon code. J'ai commencé le développement de ce module (qui sera partager sur le forum) pour une compatibilité maximum, ce dernier n’utilisera aucun appi windows, tous sera dessiné dans un canvas (ascenseurs et curseur compris) youpi :o , j'avais faiss un module pour les ascenseurs, je penses pouvoir posté ce module d'ici 2 à 3 jours (sans la colorisation et l'autocomplete qui viendra plus tard). Ma motivation ? Avec scintilla, je bloque un peux. Le fait maison, moins de problème de compréhension et plus de liberté. Surtout que le projet final réside dans un framework Php (genre CakePhp) avec éditeur intégrer, donc il faudra la colorisation et l’auto complétion 5 langages (php, html, css,js,sql) plus l’auto complétion des membres et méthodes des classe (bienvenue à toute personne voulant participer au projet)
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Avatar de l’utilisateur
Micoute
Messages : 2522
Inscription : dim. 02/oct./2011 16:17
Localisation : 35520 La Mézière

Re: Editeur Html (Module Scintilla)

Message par Micoute »

Bonjour microdevweb, je ne pense pas que c'est réinventer la roue que de vouloir rester maître de ses créations, au moins tu n'es pas en territoire inconnu et tu pourras modifier ton code au gré de tes envies. Je ne peux que t'encourager à poursuivre dans cette voie et bravo pour ta ténacité.
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 5.73 PB 6.00 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
Répondre