1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
| ; PureBasic Visual Designer v3.95 build 1485 (PB4Code)
;- Window Constants
;
Enumeration
#Window_0
#Window_1
EndEnumeration
;- MenuBar Constants
;
Enumeration
#Menu
EndEnumeration
Enumeration
#File
EndEnumeration
Enumeration
#New
#Open
#Save
#SaveAs
#Run
#RunSave
#Borders
#AGrafVisual
#Standart
#Help
#About
#LoadOem
#SaveOem
EndEnumeration
Global CurrentFileName$
Prototype ProtoCharToOem(*mem1$, *mem2$)
;- Gadget Constants
;
Enumeration
#Scintilla
#Image_9
#Image_10
#Image_11
#Image_12
#Image_13
#Image_14
#Image_15
#Image_16
#Editor_0
EndEnumeration
Global Image0
Global Image1
Global Image2
Global Image3
Global Image4
Global Image5
Global Image6
Global Image7
;- 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)
;- Images
DataSection
Image0:
IncludeBinary "img\Left.bmp"
Image1:
IncludeBinary "img\Top.bmp"
Image2:
IncludeBinary "img\TopLeft.bmp"
Image3:
IncludeBinary "img\BottomLeft.bmp"
Image4:
IncludeBinary "img\bottom.bmp"
Image5:
IncludeBinary "img\BottomRight.bmp"
Image6:
IncludeBinary "img\Right.bmp"
Image7:
IncludeBinary "img\topRight.bmp"
EndDataSection
Procedure OpenAssistantWindow()
If OpenWindow(#Window_1, 220, 0, 340, 121, "Assistant bordures", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
ImageGadget(#Image_9, 10, 42, 32, 32, Image0)
ImageGadget(#Image_10, 42, 10, 32, 32, Image1)
ImageGadget(#Image_11, 10, 10, 32, 32, Image2)
ImageGadget(#Image_12, 10, 74, 32, 32, Image3)
ImageGadget(#Image_13, 42, 74, 32, 32, Image4)
ImageGadget(#Image_14, 74, 74, 32, 32, Image5)
ImageGadget(#Image_15, 74, 42, 32, 32, Image6)
ImageGadget(#Image_16, 74, 10, 32, 32, Image7)
EditorGadget(#Editor_0, 120, 10, 210, 100)
EndIf
EndProcedure
Procedure LoadWin32Funct()
If OpenLibrary(0, "User32.dll")
Global CharToOem.ProtoCharToOem = GetFunction(0, "CharToOemA")
Global OemToChar.ProtoCharToOem = GetFunction(0, "OemToCharA")
Else
Debug "Unable to load api Function"
EndIf
EndProcedure
Procedure.s GetScintillaText(id)
iLenght=ScintillaSendMessage(id, #SCI_GETTEXTLENGTH)
*ptrBuffer=AllocateMemory(iLenght+1)
ScintillaSendMessage(id, #SCI_GETTEXT, iLenght+1, *ptrBuffer)
code$=PeekS(*ptrBuffer, iLenght+1)
FreeMemory(*ptrBuffer)
ProcedureReturn code$
EndProcedure
Procedure SetAStyle(style,foreground,background=$ffffff,size=0,face$="")
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, style, foreground)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETBACK, style, background)
If size <> 0
ScintillaSendMessage(#Scintilla, #SCI_STYLESETSIZE, style, size)
EndIf
If face$ <> ""
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFONT, style, @face$)
EndIf
EndProcedure
Procedure OpenHomeWindow()
If OpenWindow(#Window_0, 220, 0, 600, 300, "BatMan - [ Nouveau Fichier ]", #PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_Maximize | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateMenu(#Menu, WindowID(#Window_0))
MenuTitle("Fichier")
MenuItem(#New, "Nouveau CTRL+N")
MenuItem(#Open, "Ouvrir CTRL+O")
MenuItem(#Save, "Enregister CTRL+S")
MenuItem(#SaveAs, "Enregister sous")
MenuTitle("Executer")
MenuItem(#Run,"Lancer CTRL+R")
MenuItem(#RunSave,"Sauver et Lancer")
MenuTitle("Options")
MenuItem(#LoadOem, "Ouvrir les fichier en Oem")
MenuItem(#SaveOem, "Enregister les fichier en Oem")
MenuTitle("Assistants")
MenuItem(#Borders, "Créateurs de bordures")
MenuItem(#AGrafVisual, "Editeur visuel d'interfaces")
MenuItem(#Standart, "Debut de batch standard")
MenuTitle("Aide")
MenuItem(#Help, "Aide")
MenuItem(#About, "A propos")
EndIf
ScintillaGadget(#Scintilla, 10, 10, 580, 260, @CallBackProc)
ScintillaSendMessage(#Scintilla, #SCI_SETTABWIDTH, 4)
ScintillaSendMessage(#Scintilla, #SCI_SETSTYLEBITS, 5)
ScintillaSendMessage(#Scintilla, #SCI_STYLECLEARALL)
ScintillaSendMessage(#Scintilla, #SCI_SETLEXER, #SCLEX_BATCH)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #STYLE_BRACELIGHT, RGB(255,0,0))
SetAStyle(#STYLE_DEFAULT, RGB(0,0,0), RGB(255,255,255), 12, "Courrier New")
SetAStyle(#STYLE_LINENUMBER, RGB(0,0,0), RGB(200,200,200), 10, "Courrier New")
ScintillaSendMessage(#Scintilla, #STYLE_LINENUMBER, #SCI_STYLESETFORE, RGB(255,255,255))
ScintillaSendMessage(#Scintilla, #SCI_SETCARETFORE, RGB(0,0,0))
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_BAT_DEFAULT, RGB(0,0,0))
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_BAT_COMMAND, RGB(0,0,255))
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_BAT_COMMENT, RGB(0,255,0))
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_BAT_LABEL, RGB(255,0,0))
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_BAT_HIDE, RGB(255,0,0))
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_BAT_IDENTIFIER, RGB(255,127,31))
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_BAT_OPERATOR, RGB(255,0,0))
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_BAT_WORD, RGB(128,128,128))
ScintillaSendMessage(#Scintilla, #SCI_CANREDO)
ScintillaSendMessage(#Scintilla, #SCI_CANUNDO)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, ScintillaSendMessage(#Scintilla, #SCI_TEXTWIDTH, #STYLE_LINENUMBER, @"9999"))
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER)
EndIf
EndProcedure
ProcedureDLL CallBackProc(Gadget, *scinotify.SCNotification)
;La touche Entrée est utilisée
If *scinotify\ch=13
;Mise en place dans la nouvelle ligne de l'indentation de la ligne précédente
ScintillaSendMessage(Gadget, #SCI_SETLINEINDENTATION, SciLIne+1, SciIndent)
;Positionnement du curseur d'edition sur la nouvelle ligne
;Si pas d'indentation alors on ajoute 2 (ça fait bricolage mais je n'ai pas trouvé mieux)
If SciIndent=0
SciPos=SciPos+2
EndIf
;Positionnement du curseur
ScintillaSendMessage(Gadget, #SCI_GOTOPOS, SciPos+SciIndent)
EndIf
;Determination de la position à l'intérieur de la chaine scintilla
SciPos = ScintillaSendMessage(Gadget, #SCI_GETANCHOR)
;Determination de la ligne en cours
SciLine = ScintillaSendMessage(Gadget, #SCI_LINEFROMPOSITION, SciPos)
;Determination de la colonne en cours
SciCol = ScintillaSendMessage(Gadget, #SCI_GETCOLUMN, SciPos)
;Determination de l'indentation
SciIndent = ScintillaSendMessage(Gadget, #SCI_GETLINEINDENTATION, SciLine)
EndProcedure
; ============================= fonction du coeur de BatMan =====================================================
Procedure Load(fileName$)
If ReadFile(#File, fileName$)
iLenght=Lof(#File)
*ptrBuffer=AllocateMemory(iLenght)
If *ptrBuffer
ReadData(#File, *ptrBuffer, iLenght)
If GetMenuItemState(#Menu, #LoadOem)
OemToChar(*ptrBuffer, *ptrBuffer)
EndIf
ScintillaSendMessage(#Scintilla, #SCI_SETTEXT, 0, *ptrBuffer)
FreeMemory(*ptrBuffer)
EndIf
CloseFile(#File)
SetWindowTitle(#Window_0, "BatMan - "+fileName$)
CurrentFileName$=fileName$
EndIf
EndProcedure
Procedure Open()
fileName$=OpenFileRequester("Ouvrir un fichier", GetCurrentDirectory(), "Fichiers Batch (*.bat,*.cmd)|*.bat;*.cmd", 0)
Load(fileName$)
EndProcedure
Procedure Save()
If CreateFile(#File, CurrentFileName$)
code$=GetScintillaText(#Scintilla)
If GetMenuItemState(#Menu, #SaveOem)
CharToOem(@code$, @code$)
EndIf
WriteString(#File, code$)
CloseFile(#File)
EndIf
EndProcedure
Procedure SaveAs()
fileName$=SaveFileRequester("Enregister sous", GetCurrentDirectory(), "Fichiers Batch (*.bat,*.cmd)|*.bat;*.cmd", 0)
If CreateFile(#File, fileName$)
code$=GetScintillaText(#Scintilla)
If GetMenuItemState(#Menu, #SaveOem)
CharToOem(@code$, @code$)
EndIf
WriteString(#File, code$)
CloseFile(#File)
CurrentFileName$=fileName$
EndIf
EndProcedure
Procedure SetStandardBegin()
code$="@ECHO OFF"+Chr(13)+"SETLOCAL ENABLEDELAYEDEXPANSION"+Chr(13)+":: Placez votre code ici"
ScintillaSendMessage(#Scintilla, #SCI_SETTEXT, 0, @code$)
EndProcedure
Procedure AddBorder(string$)
If (GetMenuItemState(#Menu, #SaveOem))
OemToChar(@string$, @string$)
EndIf
iNb=CountGadgetItems(#Editor_0)
code$=GetGadgetItemText(#Editor_0, iNb)
SetGadgetItemText(#Editor_0, iNb, code$+string$)
EndProcedure
Procedure AddEcho()
iNb=CountGadgetItems(#Editor_0)
Debug iNb
code$=GetGadgetItemText(#Editor_0, iNb-1)
Debug code$
If code$ = ""
SetGadgetItemText(#Editor_0, iNb-1, "ECHO ")
EndIf
EndProcedure
CurrentFileName$=""
Debug InitScintilla("SciLexer.dll")
LoadWin32Funct()
OpenHomeWindow()
Repeat ; Start of the event loop
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 WindowID = #Window_1 And Event = #PB_Event_CloseWindow
CloseWindow(#Window_1)
EndIf
If Event = #PB_Event_SizeWindow
;ResizeGadget(#Scintilla, 10, 10, WindowWidth(#Window_0)-20, WindowHeight(#Window_0)-40)
EndIf
If Event = #PB_Event_Menu
MenuID = EventMenu()
Select (MenuID)
Case #New :
If CurrentFileName$ <> ""
If MessageRequester("Etes vous sur ?", "Voulez vous fermer le fichier"+CurrentFileName$+" ?", #PB_MessageRequester_YesNo)=#PB_MessageRequester_No
Continue
EndIf
EndIf
SetWindowTitle(#Window_0, "BatMan - [ Nouveau Fichier ]")
ScintillaSendMessage(#Scintilla, #SCI_SETTEXT, 0, @"");
Case #Open :
If CurrentFileName$ <> ""
If MessageRequester("Etes vous sur ?", "Voulez vous fermer le fichier "+CurrentFileName$+" ?", #PB_MessageRequester_YesNo)=#PB_MessageRequester_No
Continue
EndIf
EndIf
Open()
Case #Save :
If CurrentFileName$ <> ""
Save()
Continue
EndIf
SaveAs()
Case #SaveAs :
If CurrentFileName$ <> ""
If MessageRequester("Etes vous sur ?", "Voulez vous fermer le fichier "+CurrentFileName$+" ?", #PB_MessageRequester_YesNo)=#PB_MessageRequester_No
Continue
EndIf
EndIf
SaveAs()
Case #Run :
If CurrentFileName$ = ""
SaveAs()
EndIf
If CurrentFileName$ <> ""
RunProgram(CurrentFileName$)
EndIf
Case #RunSave :
If CurrentFileName$ = ""
SaveAs()
EndIf
If CurrentFileName$ <> ""
Save()
RunProgram(CurrentFileName$)
EndIf
Case #Borders :
OpenAssistantWindow()
Case #AGrafVisual :
RunProgram("AGrafVEdit.exe")
Case #Standart :
SetStandardBegin()
Case #Help :
Case #About :
Case #LoadOem :
If GetMenuItemState(#Menu, #LoadOem)
SetMenuItemState(#Menu, #LoadOem, 0)
Else
SetMenuItemState(#Menu, #LoadOem, 1)
EndIf
Case #SaveOem :
If GetMenuItemState(#Menu, #SaveOem)
SetMenuItemState(#Menu, #SaveOem, 0)
Else
SetMenuItemState(#Menu, #SaveOem, 1)
EndIf
EndSelect
EndIf
If Event = #PB_Event_Gadget
Select(GadgetID)
Case #Image_9:
Debug "Border Left"
AddBorder("º")
Case #Image_10:
Debug "Border Top"
AddBorder("Í")
Case #Image_11:
Debug "Border TopLeft"
AddBorder("É")
Case #Image_12:
Debug "Border BottomLeft"
AddBorder("È")
Case #Image_13:
Debug "Border Bottom"
AddBorder("Í")
Case #Image_14:
Debug "Border BottomRight"
AddBorder("¼")
Case #Image_15:
Debug "Border Right"
AddBorder("º")
Case #Image_16:
Debug "Border Top Right"
AddBorder("»")
Case #Editor_0:
AddEcho()
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow And WindowID = #Window_0; End of the event loop
End |
Partager