fidele a mes habitudes, j'ai mis les procedures en fin de listing, on y voi plus clair
je me suis permis l'ajout d'une barre de chargement pour faire patienter le challand
Code : Tout sélectionner
;*************************************
;Projet: SourceWebEditor
;Version: 1.0
;(c): InfoProject - By ARNOULD Julien
;Date de début de Création: 19/01/2007
;Date de Fin de Création:23/01/2007
;*************************************
;*************************************
;Projet: SourceWebEditor
;Version: 1.0
;(c): InfoProject - By ARNOULD Julien
;Date de début de Création: 19/01/2007
;Date de Fin de Création:23/01/2007
;*************************************
Declare OFile(file.s)
Declare SFile(file.s)
Declare SFileM(file.s)
Declare Open_Window_0()
Declare Open_Window_2()
;- Window Constants
;
Enumeration
#Window_0
#Window_2
EndEnumeration
;- MenuBar Constants
;
Enumeration
#MenuBar_0
#progress_0
#ProgressBar_charge
EndEnumeration
Enumeration
#MENU_1
#MENU_2
#MENU_4
#MENU_5
#MENU_6
#MENU_9
#MENU_12
#MENU_13
#MENU_15
#MENU_16
#MENU_18
#MENU_19
#MENU_20
EndEnumeration
;- Gadget Constants
;
Enumeration
#Panel_0
#Editor_0
#Web_0
#Frame3D_0
#ButtonImage_5
#ButtonImage_6
#ButtonImage_7
#ButtonImage_8
#Frame3D_1
#Combo_0
#Button_0
#Button_1
#Image_0
#Text_0
#Text_1
#Text_2
#Text_3
#Hyperlink_0
#Button_2
EndEnumeration
;- StatusBar Constants
;
Enumeration
#StatusBar_0
EndEnumeration
;- Fonts
Global FontID1
FontID1 = LoadFont(1, "Georgia", 8)
Global FontID2
FontID2 = LoadFont(2, "Georgia", 28)
Global FontID3
FontID3 = LoadFont(3, "Courier New", 10)
;- Image Plugins
;- Image Globals
Global Image0
Global Image1
Global Image2
Global Image3
Global Image4
Global Image5
Global Image6
Global Image7
Global Image9
Global Image10
Global Image11
Global Image12
Global Image13
Global Image15
Global Image16
Global Image17
;- Catch Images
; Image0 = CatchImage(0, ?Image0)
; Image1 = CatchImage(1, ?Image1)
; Image2 = CatchImage(2, ?Image2)
; Image3 = CatchImage(3, ?Image3)
; Image4 = CatchImage(4, ?Image4)
; Image5 = CatchImage(5, ?Image5)
; Image6 = CatchImage(6, ?Image6)
; Image7 = CatchImage(7, ?Image7)
; Image9 = CatchImage(9, ?Image9)
; Image10 = CatchImage(10, ?Image10)
; Image11 = CatchImage(11, ?Image11)
; Image12 = CatchImage(12, ?Image12)
; Image13 = CatchImage(13, ?Image13)
; Image15 = CatchImage(15, ?Image15)
; Image16 = CatchImage(16, ?Image16)
; Image17 = CatchImage(17, ?Image17)
;- Images
DataSection
; Image0:
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\precedent.bmp"
; Image1:
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\suivant.bmp"
; Image2:
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\stop.bmp"
; Image3:
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\refrech.bmp"
; Image4:
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\Logo.bmp"
; Image5 :
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\Nouveau.bmp"
; Image6 :
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\Ouvrir.bmp"
; Image7 :
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\Enregistrer.bmp"
; Image9 :
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\Quitter.bmp"
; Image10 :
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\Annuler.bmp"
; Image11 :
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\Couper.bmp"
; Image12 :
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\Copier.bmp"
; Image13 :
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\Coller.bmp"
; Image15 :
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\Apropos.bmp"
; Image16 :
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\Modifications.bmp"
; Image17 :
; IncludeBinary "C:\Documents and Settings\Julien\Mes documents\Sources Logiciel InfoProject\SourceWebEditor\Ressources Graphique\Paint.bmp"
EndDataSection
Open_Window_0()
Repeat ; Début de la boucle d'événement.
Event = WindowEvent() ; Cette ligne attend jusqu'à ce qu'un événement soit reçu de Windows.
WindowID = EventWindow() ; La fenêtre où l'événement est produit, peut être employée dans les procédures Gadget.
EventType = EventType() ; Le type d'événement.
; ;********Début du RESIZE Gadget***********************************
; PureRESIZE_SetGadgetResize(#Editor_0, #True, #True, #True, #True)
; PureRESIZE_SetGadgetResize(#Panel_0, #True, #True, #True, #True)
; PureRESIZE_SetGadgetResize(#Web_0, #True, #True, #True, #True)
; ;********Fin du RESIZE Gadget*************************************
If Event = #PB_Event_Menu
MenuID = EventMenu()
If MenuID = #MENU_1
Debug "GadgetID: #MENU_1"
ClearGadgetItemList(#Editor_0)
ElseIf MenuID = #MENU_2
Debug "GadgetID: #MENU_2"
file$ = OpenFileRequester("Charger un Fichier HTML","","html|*.html",1)
OFile(file$)
MenuID =0
StatusBarText(#StatusBar_0,0," Fichier Ouvert: "+ file$)
ElseIf MenuID = #MENU_4
Debug "GadgetID: #MENU_4"
file$ = SaveFileRequester("Enregistrer un fichier HTML","","html|*.html",1)
SFile(file$)
StatusBarText(#StatusBar_0,0," Fichier Enregistrer: "+ file$)
ElseIf MenuID = #MENU_5
Debug "GadgetID: #MENU_5"
SFileM(file$)
StatusBarText(#StatusBar_0,0," Fichier Modifier: "+ file$)
ElseIf MenuID = #MENU_9
Debug "GadgetID: #MENU_9"
End
ElseIf MenuID = #MENU_12
Debug "GadgetID: #MENU_12"
SendMessage_(GadgetID(#Editor_0),#EM_UNDO,0,0)
ElseIf MenuID = #MENU_13
Debug "GadgetID: #MENU_13"
;Code Couper
Vide$ = ""
SendMessage_(GadgetID(#Editor_0),#EM_GETSEL,@StartSel,@EndSel)
Buffer$ = Space(EndSel-StartSel)
SendMessage_(GadgetID(#Editor_0),#EM_GETSELTEXT,0,@Buffer$)
ClearClipboard()
SetClipboardText(Buffer$)
SendMessage_(GadgetID(#Editor_0),#EM_REPLACESEL,#True,@Vide$)
;Fin de code Couper
ElseIf MenuID = #MENU_15
Debug "GadgetID: #MENU_15"
;Code Copier
SendMessage_(GadgetID(#Editor_0),#EM_GETSEL,@StartSel,@EndSel)
Buffer$ = Space(EndSel-StartSel)
SendMessage_(GadgetID(#Editor_0),#EM_GETSELTEXT,0,@Buffer$)
ClearClipboard()
SetClipboardText(Buffer$)
; Fin de code Copier
ElseIf MenuID = #MENU_16
Debug "GadgetID: #MENU_16"
;Code coller
Buffer$ = GetClipboardText()
SendMessage_(GadgetID(#Editor_0),#EM_REPLACESEL,#True,@Buffer$)
;Fin de code Coller
ElseIf MenuID = #MENU_19
Debug "GadgetID: #MENU_19"
Open_Window_2()
ElseIf MenuID = #MENU_20
Debug "GadgetID: #MENU_20"
EndIf
EndIf
If Event = #PB_Event_Gadget
GadgetID = EventGadget() ; Est-ce un événement Gadget ?
If GadgetID = #Panel_0
SetGadgetState(#Web_0, #PB_Web_Refresh)
ElseIf GadgetID = #Editor_0 ; ici ça colore pendant l'ecriture :D
SetGadgetColor(#Editor_0, #PB_Gadget_BackColor, RGB($FF,$FF,$FF))
NewText.s = GetGadgetText(#Editor_0)
If OldText.s <> NewText.s
SyntaxHighlightingLine(#Editor_0, "a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/,/;/:/!/ /&/é/'/(/-/è/_/ç/à/)/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z", "/", RGB (0, 0, 0), RGB (255, 255, 255), 10, "Courier New" , 0 )
SyntaxHighlightingLine (#Editor_0, "<HTML>|<html>|</HTML>|</html>|<title>|</title>|<TITLE>|</TITLE>|<head>|</head>|<HEAD>|</HEAD>|<body>|</body>|<BODY>|</BODY>|<body|</body|<BODY|</BODY|" , "|" , RGB (0, 0, 204), RGB (255, 255, 255), 10, "Courier New" , 0 )
SyntaxHighlightingLine (#Editor_0, "<script>|<SCRIPT>|</noscript>|</NOSCRIPT>|<script|<SCRIPT|</script>|</SCRIPT>|<noscript>|<NOSCRIPT>" , "|" , RGB (255, 0, 0), RGB (255, 255, 255), 10, "Courier New" , 0)
SyntaxHighlightingLine (#Editor_0, "<!--|-->" , "|" , RGB (255, 0, 0), RGB (255, 255, 255), 10, "Courier New" , 0)
SyntaxHighlightingLine (#Editor_0, "<a>|</a>|<A>|</A>|<b>|</b>|<B>|</B>|<br>|</br>|<BR>|</BR>|<center>|</center>|<CENTER>|</CENTER>|<a|<A" , "|" , RGB (153, 102, 0), RGB (255, 255, 255), 10, "Courier New" , 0)
SyntaxHighlightingLine (#Editor_0, "<div>|</div>|<DIV>|</DIV>|<div|<DIV|<font>|</font>|<FONT>|</FONT>|<h1>|</h1>|<H1>|</H1>|<h2>|</h2>|<H2>|</H2>|<h3>|</h3>|<H3>|</H3>|<h4>|</h4>|<H4>|</H4>|<h5>|</h5>|<H5>|</H5>|<h6>|</h6>|<H6>|</H6>|<hr>|</hr>|<HR>|</HR>" , "|" , RGB (51, 255, 51), RGB (255, 255, 255), 10, "Courier New" , 0)
SyntaxHighlightingLine (#Editor_0, "<img>|</img>|<IMG>|</IMG>|<meta>|<META>|href" , "|" , RGB (255, 153, 0), RGB (255, 255, 255), 10, "Courier New" , 0)
OldText = NewText
EndIf
ElseIf GadgetID = #Web_0
ElseIf GadgetID = #ButtonImage_5
SetGadgetState(#Web_0, #PB_Web_Back)
ElseIf GadgetID = #ButtonImage_6
SetGadgetState(#Web_0, #PB_Web_Forward)
ElseIf GadgetID = #ButtonImage_7
SetGadgetState(#Web_0, #PB_Web_Stop)
ElseIf GadgetID = #ButtonImage_8
SetGadgetState(#Web_0, #PB_Web_Refresh)
ElseIf GadgetID = #Combo_0
ElseIf GadgetID = #Button_1
ElseIf GadgetID = #Image_0
ElseIf GadgetID = #Hyperlink_0
SetGadgetText(#Web_0, GetGadgetText(#Hyperlink_0))
CloseWindow(#Window_2)
ElseIf GadgetID = #Button_2
CloseWindow(#Window_2)
EndIf
EndIf
Delay(2)
Until Event = #PB_Event_CloseWindow ; Fin de la boucle d'événement.
End
;
;-LES PROCEDURES
;****Procedure d'ouverture d'un Fichier**************
Procedure OFile(file.s)
HideGadget(#Editor_0, 1)
d=ReadFile(1, file)
If d
While Eof(1)=0
Text$ = Text$+ReadString(1)+Chr(13)+ Chr(10)
Wend
CloseFile(1)
SetGadgetText(#Web_0, file.s)
SetGadgetText(#Editor_0, Text$)
SetGadgetColor(#Editor_0, #PB_Gadget_BackColor, RGB($FF,$FF,$FF))
; ici ça colore pendant le chargement du fichier :D
If OpenWindow(#progress_0, 376, 189, 302, 81, "Chargement et coloration", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#progress_0))
ProgressBarGadget(#ProgressBar_charge, 30, 30, 250, 20, 0, CountGadgetItems(#Editor_0)-1)
EndIf
EndIf
HideGadget(#Editor_0, 1)
For lili=0 To CountGadgetItems(#Editor_0)-1
SetGadgetState(#ProgressBar_charge, lili)
chaine$=""
chaine$=GetGadgetItemText(#Editor_0, lili, 0) ; recupere chaque ligne de text
SetGadgetItemText(#Editor_0, lili, chaine$, 0)
SyntaxHighlightingLine (#Editor_0, "<HTML>|<html>|</HTML>|</html>|<title>|</title>|<TITLE>|</TITLE>|<head>|</head>|<HEAD>|</HEAD>|<body>|</body>|<BODY>|</BODY>|<body|</body|<BODY|</BODY|" , "|" , RGB (0, 0, 204), RGB (255, 255, 255), 10, "Courier New" , 0 )
SyntaxHighlightingLine (#Editor_0, "<script>|<SCRIPT>|</noscript>|</NOSCRIPT>|<script|<SCRIPT|</script>|</SCRIPT>|<noscript>|<NOSCRIPT>" , "|" , RGB (255, 0, 0), RGB (255, 255, 255), 10, "Courier New" , 0)
SyntaxHighlightingLine (#Editor_0, "<!--|-->" , "|" , RGB (255, 0, 0), RGB (255, 255, 255), 10, "Courier New" , 0)
SyntaxHighlightingLine (#Editor_0, "<a>|</a>|<A>|</A>|<b>|</b>|<B>|</B>|<br>|</br>|<BR>|</BR>|<center>|</center>|<CENTER>|</CENTER>|<a|<A" , "|" , RGB (153, 102, 0), RGB (255, 255, 255), 10, "Courier New" , 0)
SyntaxHighlightingLine (#Editor_0, "<div>|</div>|<DIV>|</DIV>|<div|<DIV|<font>|</font>|<FONT>|</FONT>|<h1>|</h1>|<H1>|</H1>|<h2>|</h2>|<H2>|</H2>|<h3>|</h3>|<H3>|</H3>|<h4>|</h4>|<H4>|</H4>|<h5>|</h5>|<H5>|</H5>|<h6>|</h6>|<H6>|</H6>|<hr>|</hr>|<HR>|</HR>" , "|" , RGB (51, 255, 51), RGB (255, 255, 255), 10, "Courier New" , 0)
SyntaxHighlightingLine (#Editor_0, "<img>|</img>|<IMG>|</IMG>|<meta>|<META>|href" , "|" , RGB (255, 153, 0), RGB (255, 255, 255), 10, "Courier New" , 0)
Next lili
HideGadget(#Editor_0, 0)
CloseWindow(#progress_0)
Else
EndIf
EndProcedure
;****Fin de la Procedure*****************************
;***Procedure D'enregistrement***********************
Procedure SFile(file.s)
If file
If FindString(file.s,".",1)
Else
file.s =file.s + ".html"
EndIf
If CreateFile(0, file.s )
file$ = GetGadgetText(#Editor_0)
WriteData(0, @file$, Len(file$))
CloseFile(0)
Else
MessageRequester("Erreur","Ne peut créer le fichier "+file+"!")
EndIf
EndIf
EndProcedure
;****Fin de Procedure d'enregistrement***************
;***Procedure d'enregistrement des modifications**********
Procedure SFileM(file.s)
If file
If CreateFile(0, file)
file$ = GetGadgetText(#Editor_0)
WriteData(0, @file$, Len(file$))
CloseFile(0)
Else
MessageRequester("Erreur","Ne peut créer le fichier "+file+"!")
EndIf
EndIf
EndProcedure
;****Fin de Procedure d'enregistrement des modification****
Procedure Open_Window_0()
If OpenWindow(#Window_0, 0, 0, 735, 576, "SourceWebEditor Version 1.0.", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_WindowCentered )
Menu = CreateMenu(#MenuBar_0, WindowID(#Window_0))
If Menu
MenuTitle("Fichier")
MenuItem(#MENU_1, " Nouveau")
MenuBar()
MenuItem(#MENU_2, " Ouvrir")
MenuBar()
MenuItem(#MENU_4, " Enregistrer sous")
MenuItem(#MENU_5, " Enregistrer")
MenuBar()
MenuItem(#MENU_9, " Quitter")
MenuTitle("Edition")
MenuItem(#MENU_12, " Annuler")
MenuBar()
MenuItem(#MENU_13, " Couper")
MenuItem(#MENU_15, " Copier")
MenuItem(#MENU_16, " Coller")
MenuTitle("Outils")
MenuItem(#MENU_20, " Coloriser la syntaxe")
MenuTitle("?")
MenuItem(#MENU_19, " A propos de SourceWebEditor")
; SetMenuItemBitmaps_(Menu, #MENU_1, #MF_BYCOMMAND, ImageID(5), ImageID(5))
; SetMenuItemBitmaps_(Menu, #MENU_2, #MF_BYCOMMAND, ImageID(6), ImageID(6))
; SetMenuItemBitmaps_(Menu, #MENU_4, #MF_BYCOMMAND, ImageID(7), ImageID(7))
; SetMenuItemBitmaps_(Menu, #MENU_5, #MF_BYCOMMAND, ImageID(16), ImageID(16))
; SetMenuItemBitmaps_(Menu, #MENU_9, #MF_BYCOMMAND, ImageID(9), ImageID(9))
; SetMenuItemBitmaps_(Menu, #MENU_12, #MF_BYCOMMAND, ImageID(10), ImageID(10))
; SetMenuItemBitmaps_(Menu, #MENU_13, #MF_BYCOMMAND, ImageID(11), ImageID(11))
; SetMenuItemBitmaps_(Menu, #MENU_15, #MF_BYCOMMAND, ImageID(12), ImageID(12))
; SetMenuItemBitmaps_(Menu, #MENU_16, #MF_BYCOMMAND, ImageID(13), ImageID(13))
; SetMenuItemBitmaps_(Menu, #MENU_19, #MF_BYCOMMAND, ImageID(15), ImageID(15))
; SetMenuItemBitmaps_(Menu, #MENU_20, #MF_BYCOMMAND, ImageID(17), ImageID(17))
EndIf
If CreateStatusBar(#StatusBar_0, WindowID(#Window_0))
StatusBarText(#StatusBar_0,0," Aucun Fichier HTML chargé:"+ file$)
EndIf
If CreateGadgetList(WindowID(#Window_0))
;- Panel0
PanelGadget(#Panel_0, 5, 5, 725, 520)
AddGadgetItem(#Panel_0, -1, "Code Source")
EditorGadget(#Editor_0, 8, 8, 705, 480)
SetGadgetFont(#Editor_0, FontID3)
AddGadgetItem(#Panel_0, -1, "Aperçu")
WebGadget(#Web_0, 8, 78, 705, 410, "")
Frame3DGadget(#Frame3D_0, 3, 8, 175, 60, "Outils de Navigation :")
SetGadgetFont(#Frame3D_0, FontID1)
; ButtonImageGadget(#ButtonImage_5, 13, 28, 35, 35, Image0)
; ButtonImageGadget(#ButtonImage_6, 53, 28, 35, 35, Image1)
; ButtonImageGadget(#ButtonImage_7, 93, 28, 35, 35, Image2)
; ButtonImageGadget(#ButtonImage_8, 133, 28, 35, 35, Image3)
CloseGadgetList()
EndIf
EndIf
EndProcedure
Procedure Open_Window_2()
If OpenWindow(#Window_2, 433, 614, 545, 270, "A propos...", #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_WindowCentered )
If CreateGadgetList(WindowID(#Window_2))
ImageGadget(#Image_0, 5, 5, 192, 128, Image4, #PB_Image_Border)
TextGadget(#Text_0, 210, 25, 330, 45, "SourceWebEditor", #PB_Text_Center)
SetGadgetFont(#Text_0, FontID2)
TextGadget(#Text_1, 270, 80, 235, 20, "Version 1.0", #PB_Text_Center)
TextGadget(#Text_2, 15, 145, 520, 75, "SourceWebEditor Version 1.0 est un logiciel gratuit qui peut être distribué librement mais ne peut être vendu ou utilisé dans un but commercial. SourceWebEditor ne présente aucun virus ou logiciel malveillant.")
SetGadgetFont(#Text_2, FontID1)
TextGadget(#Text_3, 330, 230, 205, 15, "(c) 2007 InfoProject. By ARNOULD Julien.")
HyperLinkGadget(#Hyperlink_0, 415, 250, 120, 15, "http://info-project.neuf.fr",#Blue, #PB_HyperLink_Underline)
ButtonGadget(#Button_2, 65, 235, 135, 20, "Ok")
SetGadgetFont(#Button_2, FontID1)
EndIf
EndIf
EndProcedure