Code : Tout sélectionner
Procedure KillProcessPureBasic()
If OpenLibrary (#PROCESS32LIB, "kernel32.dll")
snap = CallFunction (#PROCESS32LIB, "CreateToolhelp32Snapshot", #TH32CS_SNAPPROCESS, 0)
If snap
DefType.PROCESSENTRY32 Proc32
Proc32\dwSize = SizeOf (PROCESSENTRY32)
If CallFunction (#PROCESS32LIB, "Process32First", snap, @Proc32)
AddElement (Process32 ())
CopyMemory(@Proc32, @Process32 (), SizeOf (PROCESSENTRY32))
While CallFunction (#PROCESS32LIB, "Process32Next", snap, @Proc32)
AddElement (Process32 ())
CopyMemory(@Proc32, @Process32 (), SizeOf (PROCESSENTRY32))
Wend
EndIf
CloseHandle_ (snap)
EndIf
CloseLibrary (#PROCESS32LIB)
EndIf
ResetList(Process32 ())
processID.l = 0
While NextElement (Process32())
NomProcess$ = PeekS (@Process32 ()\szExeFile)
If Mid(NomProcess$,1,9) = "PureBasic"
processID = Process32 ()\th32ProcessID
EndIf
Wend
If processID
ph.l = OpenProcess_(1,#False,processID)
TerminateProcess_(ph,0)
CloseHandle_(ph)
EndIf
EndProcedure
Procedure ChargeSLV(IndexPanel)
ClearList(ListeS())
ForEach ListeSLV()
If ListeSLV()\Index = IndexPanel And ListeSLV()\type = 1 : AddElement(ListeS())
ListeS()\Texte = ListeSLV()\Texte
ListeS()\Ligne = ListeSLV()\Ligne
EndIf
Next
ClearGadgetItemList(ListeSignetID)
ForEach ListeS() : AddGadgetItem(ListeSignetID,-1,ListeS()\Texte) : Next
SendMessage_(GadgetID(ListeSignetID),#LVM_SETCOLUMNWIDTH,0,#LVSCW_AUTOSIZE)
ClearList(ListeL())
ForEach ListeSLV()
If ListeSLV()\Index = IndexPanel And ListeSLV()\type = 2 : AddElement(ListeL())
ListeL()\Texte = ListeSLV()\Texte
ListeL()\Ligne = ListeSLV()\Ligne
EndIf
Next
ClearGadgetItemList(ListeLabelID)
ForEach ListeL() : AddGadgetItem(ListeLabelID,-1,ListeL()\Texte) : Next
SendMessage_(GadgetID(ListeLabelID),#LVM_SETCOLUMNWIDTH,0,#LVSCW_AUTOSIZE)
ClearList(ListeV())
ForEach ListeSLV()
If ListeSLV()\Index = IndexPanel And ListeSLV()\type = 3 : AddElement(ListeV())
ListeV()\Texte = ListeSLV()\Texte
EndIf
Next
ClearGadgetItemList(ListeVariableID)
ForEach ListeV() : AddGadgetItem(ListeVariableID,-1,ListeV()\Texte) : Next
SendMessage_(GadgetID(ListeVariableID),#LVM_SETCOLUMNWIDTH,0,#LVSCW_AUTOSIZE)
EndProcedure
Procedure OuvrirFichier(Parametre$)
If Parametre$ = ""
file.s = OpenFileRequester("Ouvrir un fichier PureBasic", "", "Fichiers PureBasic|*.pb", 0)
Else : file = Parametre$ : Parametre$ = ""
EndIf
If file<>""
processID.l = RunProgram(PureBasicRepertoire+"PBCompiler.exe",Chr(34)+file+Chr(34)+" /COMMENTED","",1|2)
If processID = 0
MessageRequester("Erreur", "Le fichier PB n'a pu être compilé", #MB_ICONERROR)
Else : KillProcessPureBasic()
EndIf
fileASM.s = PureBasicRepertoire+"PureBasic.asm"
iFile = ReadFile(#PB_Any, fileASM)
If iFile
FileLength = Lof()
*TextBuffer = LocalAlloc_(#LMEM_ZEROINIT, FileLength+10)
ReadData(*TextBuffer, FileLength)
CloseFile(iFile)
*MemPtr = AllocateMemory(FileLength*3)
*RTF = *MemPtr
*Texte = *TextBuffer
ColoriserTexte()
FileName$ = GetFilePart(file)
CreerEditeurCode(FileName$)
SendMessage_(hEditeur()\Handle,#EM_REPLACESEL,0,*MemPtr)
MoveWindow_(hEditeur()\Handle,1,1,GetInnerSizeWidth(PanelCode)-2,GetInnersizeHeight(PanelCode)-2,#False)
SetGadgetState(PanelCode,CountGadgetItems(PanelCode)-1)
LocalFree_(*TextBuffer)
FreeMemory(*MemPtr)
ChargeSLV(IndexRTF-1)
EndIf
EndIf
EndProcedure
Procedure RunOnce(Name.s)
Editor_RunOnceMessage = RegisterWindowMessage_("ASM_Editor_RunOnce")
Editor_RunOnceMutex = CreateMutex_(0,0,"ASM_Editor")
If GetLastError_() = #ERROR_ALREADY_EXISTS
If GetVersion_() & $FF0000 ; Windows NT/XP
X = RegCreateKeyEx_(#HKEY_CLASSES_ROOT, "Applications\PureASM.exe\", 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, 0, @NewKey, @KeyInfo)
Else ; La même chose pour Win9x
X = RegCreateKeyEx_(#HKEY_LOCAL_MACHINE, "Software\Classes\PureASM.exe\", 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, 0, @NewKey, @KeyInfo)
EndIf
If X = #ERROR_SUCCESS
RegSetValueEx_(NewKey, "RunOnce_FileName", 0, #reg_sz, Name, Len(Name)+1)
RegCloseKey_(NewKey)
SendMessage_(#HWND_BROADCAST, Editor_RunOnceMessage, "OPENFILE", 0)
End
EndIf
EndIf
EndProcedure
Procedure RunOnce_Message()
If GetVersion_() & $FF0000 ; Windows NT/XP
X = RegOpenKeyEx_(#HKEY_CLASSES_ROOT, "Applications\PureASM.exe\",0,#KEY_ALL_ACCESS, @NewKey)
Else ; La même chose pour Win9x
X = RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, "Software\Classes\PureASM.exe\", 0, #KEY_ALL_ACCESS, @NewKey)
EndIf
If X = #ERROR_SUCCESS
a$ = Space(2000) : ASize = 2000
RegQueryValueEx_(NewKey, "RunOnce_FileName", 0, 0, @a$, @ASize)
RegSetValueEx_(NewKey, "RunOnce_FileName", 0, #reg_sz, "", 1)
RegCloseKey_(NewKey)
If a$ <> ""
OuvrirFichier(a$)
SendMessage_(hEditeur()\Handle, #EM_SETSEL, 0, 0)
EndIf
EndIf
EndProcedure
Procedure PanelCallback(WindowId, message, wParam, lParam)
Select message
Case #WM_PAINT
If NoPaintPanel : ProcedureReturn 0 :EndIf
If SplitterAction
GetWindowRect_(GadgetID(PanelCode),wPanelRect.RECT)
GetWindowRect_(hEditeur()\Handle,wListeRect.RECT)
hPanel = wListeRect\top-wPanelRect\top
GetClientRect_(GadgetID(PanelCode),PanelRect.RECT)
PanelRect\top = hPanel
ValidateRect_(GadgetID(PanelCode),@PanelRect)
EndIf
ProcedureReturn CallWindowProc_(OldPanelCallBack, WindowId,message, wParam, lParam)
Case #WM_LBUTTONDOWN
NoPaintPanel = #True
CallWindowProc_(OldPanelCallBack, WindowId,message, wParam, lParam)
SendMessage_(GadgetID(PanelCode),#WM_LBUTTONUP,0,0)
ProcedureReturn 0
Case #WM_LBUTTONUP
If NoPaintPanel
NoPaintPanel = #False
ProcedureReturn CallWindowProc_(OldPanelCallBack,WindowId,message,wParam,lParam)
Else : ProcedureReturn 0
EndIf
Default
ProcedureReturn CallWindowProc_(OldPanelCallBack,WindowId,message,wParam,lParam)
EndSelect
EndProcedure
Procedure SLVCallback(WindowId, message, wParam, lParam)
Select message
Case #WM_PAINT
If NoPaintSignet : ProcedureReturn 0 :EndIf
If SplitterAction
GetWindowRect_(GadgetID(PanelSignet),wPanelRect.RECT)
GetWindowRect_(GadgetID(ListeSignetID),wListeRect.RECT)
hPanel = wListeRect\top-wPanelRect\top
GetClientRect_(GadgetID(PanelSignet),PanelRect.RECT)
PanelRect\top = hPanel
ValidateRect_(GadgetID(PanelSignet),@PanelRect)
EndIf
ProcedureReturn CallWindowProc_(OldSLVCallBack, WindowId,message, wParam, lParam)
Case #WM_LBUTTONDOWN
NoPaintSignet = #True
CallWindowProc_(OldSLVCallBack, WindowId,message, wParam, lParam)
SendMessage_(GadgetID(PanelSignet),#WM_LBUTTONUP,0,0)
ProcedureReturn 0
Case #WM_LBUTTONUP
If NoPaintSignet
NoPaintSignet = #False
ProcedureReturn CallWindowProc_(OldSLVCallBack,WindowId,message,wParam,lParam)
Else : ProcedureReturn 0
EndIf
Default
ProcedureReturn CallWindowProc_(OldSLVCallBack,WindowId,message,wParam,lParam)
EndSelect
EndProcedure
Procedure SplitterCallback(WindowId, message, wParam, lParam)
Select message
Case #WM_LBUTTONDOWN
SplitterAction = #True
ProcedureReturn CallWindowProc_(OldSplitterCallBack, WindowId,message, wParam, lParam)
Case #WM_LBUTTONUP
SplitterAction = #False
InvalidateRect_(GadgetID(PanelCode),0,1)
ProcedureReturn CallWindowProc_(OldSplitterCallBack, WindowId,message, wParam, lParam)
Case #WM_MOUSEMOVE
If SplitterMove<>GetGadgetState(Splitter) And SplitterAction
InvalidateRect_(GadgetID(PanelSignet), 0, 1)
SendMessage_(GadgetID(PanelSignet),#WM_PAINT,0,0)
InvalidateRect_(GadgetID(PanelCode), 0, 1)
SendMessage_(GadgetID(PanelCode),#WM_PAINT,0,0)
InvalidateRect_(hEditeur()\Handle,0,1)
SendMessage_(hEditeur()\Handle,#WM_PAINT,0,0)
NumPanel = GetGadgetState(PanelSignet)
If NumPanel = 0
InvalidateRect_(GadgetID(ListeSignetID),0,1)
SendMessage_(GadgetID(ListeSignetID),#WM_PAINT,0,0)
ElseIf NumPanel = 1
InvalidateRect_(GadgetID(ListeLabelID),0,1)
SendMessage_(GadgetID(ListeLabelID),#WM_PAINT,0,0)
ElseIf NumPanel = 2
InvalidateRect_(GadgetID(ListeVariableID),0,1)
SendMessage_(GadgetID(ListeVariableID),#WM_PAINT,0,0)
EndIf
SplitterMove = GetGadgetState(Splitter)
EndIf
ProcedureReturn CallWindowProc_(OldSplitterCallBack, WindowId,message, wParam, lParam)
Default
ProcedureReturn CallWindowProc_(OldSplitterCallBack,WindowId,message,wParam,lParam)
EndSelect
EndProcedure
Procedure.l myWindowCallback(WindowId, message, wParam, lParam)
Select message
Case #WM_NOTIFY
*LVCDHeader.NMLVCUSTOMDRAW = lParam
Select *LVCDHeader\nmcd\hdr\hwndFrom
Case GadgetID(ListeSignetID)
Select *LVCDHeader\nmcd\hdr\Code
Case #NM_CUSTOMDRAW
Select *LVCDHeader\nmcd\dwDrawStage
Case #CDDS_PREPAINT
ProcedureReturn #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
Lig.l = *LVCDHeader\nmcd\dwItemSpec
If Mid(GetGadgetItemText(ListeSignetID,Lig,0),1,1) = ">"
*LVCDHeader\clrTextBk = RGB(100,100,150)
Else : *LVCDHeader\clrTextBk = RGB(100,150,100)
EndIf
*LVCDHeader\clrText = RGB(250,250,250)
SelectObject_(*LVCDHeader\nmcd\hDC,hFont)
ProcedureReturn #CDRF_NEWFONT
EndSelect
Case #LVN_ITEMCHANGED
*nmLV.NM_LISTVIEW = lParam
If *nmLV\unewstate & #LVIS_SELECTED
SelectElement(ListeS(),*nmLV\iItem)
PremiereLigneVisible = SendMessage_(hEditeur()\Handle,#EM_GETFIRSTVISIBLELINE,0,0)
Difference = ListeS()\Ligne - PremiereLigneVisible
NombreDeLignes = SendMessage_(hEditeur()\Handle,#EM_GETLINECOUNT,0,0)
While (PremiereLigneVisible+TotalLignesVisible+Difference) > NombreDeLignes : Difference - 1 : Wend
SendMessage_(hEditeur()\Handle, #EM_LINESCROLL, 0,Difference)
AncienDebutLigne = SendMessage_(hEditeur()\Handle,#EM_GETFIRSTVISIBLELINE,0,0)
lvi.LV_ITEM
lvi\Mask=#LVIF_STATE
lvi\iItem=*nmLV\iItem
lvi\state=0
lvi\stateMask=#LVIS_SELECTED
SendMessage_(GadgetID(ListeSignetID),#LVM_SETITEMSTATE,*nmLV\iItem,lvi)
ProcedureReturn 0
EndIf
EndSelect
SetFocus_(hEditeur()\Handle)
Case GadgetID(ListeLabelID)
Select *LVCDHeader\nmcd\hdr\Code
Case #NM_CUSTOMDRAW
Select *LVCDHeader\nmcd\dwDrawStage
Case #CDDS_PREPAINT
ProcedureReturn #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
*LVCDHeader\clrTextBk = RGB(100,150,100)
*LVCDHeader\clrText = RGB(250,250,250)
SelectObject_(*LVCDHeader\nmcd\hDC,hFont)
ProcedureReturn #CDRF_NEWFONT
EndSelect
Case #LVN_ITEMCHANGED
*nmLV.NM_LISTVIEW = lParam
If *nmLV\unewstate & #LVIS_SELECTED
SelectElement(ListeL(),*nmLV\iItem)
PremiereLigneVisible = SendMessage_(hEditeur()\Handle,#EM_GETFIRSTVISIBLELINE,0,0)
Difference = ListeL()\Ligne - PremiereLigneVisible
NombreDeLignes = SendMessage_(hEditeur()\Handle,#EM_GETLINECOUNT,0,0)
While (PremiereLigneVisible+TotalLignesVisible+Difference) > NombreDeLignes : Difference - 1 : Wend
SendMessage_(hEditeur()\Handle, #EM_LINESCROLL, 0,Difference)
AncienDebutLigne = SendMessage_(hEditeur()\Handle,#EM_GETFIRSTVISIBLELINE,0,0)
lvi.LV_ITEM
lvi\Mask=#LVIF_STATE
lvi\iItem=*nmLV\iItem
lvi\state=0
lvi\stateMask=#LVIS_SELECTED
SendMessage_(GadgetID(ListeLabelID),#LVM_SETITEMSTATE,*nmLV\iItem,lvi)
ProcedureReturn 0
EndIf
EndSelect
SetFocus_(hEditeur()\Handle)
Case GadgetID(ListeVariableID)
Select *LVCDHeader\nmcd\hdr\Code
Case #NM_CUSTOMDRAW
Select *LVCDHeader\nmcd\dwDrawStage
Case #CDDS_PREPAINT
ProcedureReturn #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
*LVCDHeader\clrTextBk = RGB(100,150,100)
*LVCDHeader\clrText = RGB(250,250,250)
SelectObject_(*LVCDHeader\nmcd\hDC,hFont)
ProcedureReturn #CDRF_NEWFONT
EndSelect
Case #LVN_ITEMCHANGED
*nmLV.NM_LISTVIEW = lParam
If *nmLV\unewstate & #LVIS_SELECTED
lvi.LV_ITEM
lvi\Mask=#LVIF_STATE
lvi\iItem=*nmLV\iItem
lvi\state=0
lvi\stateMask=#LVIS_SELECTED
SendMessage_(GadgetID(ListeVariableID),#LVM_SETITEMSTATE,*nmLV\iItem,lvi)
ProcedureReturn 0
EndIf
EndSelect
SetFocus_(hEditeur()\Handle)
EndSelect
Case #WM_SIZE
ResizeEditeurCode()
ProcedureReturn 0
Case #WM_ACTIVATE
If wParam & $FFFF <> #WA_INACTIVE
SetFocus_(hEditeur()\Handle)
EndIf
ProcedureReturn 0
Case Editor_RunOnceMessage
If PeekS(wParam,9) = "OPENFILE"
RunOnce_Message()
SetForegroundWindow_(hwnd)
EnableWindow_(hwnd,#True)
If IsZoomed_(hwnd)
ShowWindow_(hwnd, #SW_MAXIMIZE)
Else : ShowWindow_(hwnd, #SW_RESTORE)
EndIf
ProcedureReturn 0
EndIf
Default
ProcedureReturn #PB_ProcessPureBasicEvents
EndSelect
EndProcedure
;- Boucle Principale
Parametre$ = ""
Repeat
p$ = ProgramParameter()
Parametre$ + p$ + " "
Until p$ = ""
Parametre$ = Trim(Parametre$)
RunOnce(Parametre$)
SystemPath.s=Space(255)
GetSystemDirectory_(SystemPath,255)
hwnd = OpenWindow( 0, 0, 0, #Longueur, #Largeur, #PB_Window_Invisible | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "PureASM 1.0")
SendMessage_(hwnd,#wm_seticon,#False,ExtractIcon_(0,SystemPath+"\shell32.dll",130))
ToolBar = CreateToolBar( 0, hwnd)
If ToolBar
ToolBarStandardButton(#IDM_FILE_NEW, #PB_ToolBarIcon_New)
ToolBarStandardButton(#IDM_FILE_OPEN, #PB_ToolBarIcon_Open)
ToolBarStandardButton(#IDM_FILE_SAVE, #PB_ToolBarIcon_Save)
ToolBarSeparator()
ToolBarStandardButton(#IDM_EDIT_CUT, #PB_ToolBarIcon_Cut)
ToolBarStandardButton(#IDM_EDIT_COPY, #PB_ToolBarIcon_Copy)
ToolBarStandardButton(#IDM_EDIT_PASTE, #PB_ToolBarIcon_Paste)
ToolBarSeparator()
ToolBarImageButton(#IDM_EDIT_DELETE, #PB_ToolBarIcon_Delete)
ToolBarSeparator()
ToolBarStandardButton(#IDM_EDIT_UNDO, #PB_ToolBarIcon_Undo)
ToolBarStandardButton(#IDM_EDIT_REDO, #PB_ToolBarIcon_Redo)
;ToolBarSeparator()
;ToolBarImageButton(#IDM_EDIT_COMPIL, ExtractIcon_(0,SystemPath+"\shell32.dll",165))
EndIf
Tab.s = Chr(9)
hMenu = CreateMenu( 0, hwnd)
If hMenu
MenuTitle("Fichier")
MenuItem(#IDM_FILE_NEW, "Nouveau")
MenuItem(#IDM_FILE_OPEN, "Ouvrir")
MenuItem(#IDM_FILE_SAVE, "Enregistrer")
MenuBar()
MenuItem(#MENU_QUITTER, "Quitter")
MenuTitle("Edition")
MenuItem(#IDM_EDIT_CUT, "Couper"+Tab+"Ctl+X")
MenuItem(#IDM_EDIT_COPY, "Copier"+Tab+"Ctl+C")
MenuItem(#IDM_EDIT_PASTE, "Coller"+Tab+"Ctl+V")
MenuItem(#IDM_EDIT_DELETE, "Suprimer")
MenuBar()
MenuItem(#IDM_EDIT_SELECTALL, "Sélectionner tout")
MenuTitle("Projet")
MenuItem(#OPTIONS, "Options du projet")
EnableMenuItem_(hMenu, #OPTIONS,#True)
MenuBar()
MenuItem(#COMPILER, "Compiler")
EnableMenuItem_(hMenu, #COMPILER,#True)
MenuTitle("Aide")
MenuItem(#IDM_HELP_ABOUT, "A propos de PureASM...")
EndIf
If CreatePopupMenu(1)
MenuItem(#IDM_EDIT_CUT, "Couper"+Tab+"Ctl+X")
MenuItem(#IDM_EDIT_COPY, "Copier"+Tab+"Ctl+C")
MenuItem(#IDM_EDIT_PASTE, "Coller"+Tab+"Ctl+V")
MenuItem(#IDM_EDIT_DELETE, "Suprimer")
MenuBar()
MenuItem(#IDM_EDIT_SELECTALL, "Sélectionner tout")
EndIf
StatusBar = CreateStatusBar( 0, hwnd)
If StatusBar
BarT = WindowWidth() - 120
If BarT < 0 : BarT = 0 : EndIf
AddStatusBarField( 100)
AddStatusBarField( BarT)
StatusBarText(0, 1, " Programme Eric Ducoulombier (Erix14)", #PB_StatusBar_BorderLess)
EndIf
;/
hDC = StartDrawing(WindowOutput())
DrawingFont(LoadFont(0,"Verdana",10))
TexteHeight = GetTextHeight(hDC)
StopDrawing()
hFont = CreateFont_(TexteHeight,0,0,0,0,0,0,0,0,0,0,0,0,"Verdana")
PureBasicRepertoire = CheminPureBasic()
CreateGadgetList(hwnd)
PanelCode = PanelGadget(#PB_Any,0,0,0,0) : EnleveTabulation(GadgetID(PanelCode))
OldPanelCallBack = SetWindowLong_(GadgetID(PanelCode),#GWL_WNDPROC,@PanelCallback())
PanelSignet = PanelGadget(#PB_Any,0,0,0,0) : EnleveTabulation(GadgetID(PanelSignet))
OldSLVCallBack = SetWindowLong_(GadgetID(PanelSignet),#GWL_WNDPROC,@SLVCallback())
Splitter = SplitterGadget(#PB_Any,0,0,0,0,PanelCode,PanelSignet,#PB_Splitter_Vertical) : EnleveTabulation(GadgetID(Splitter))
OldSplitterCallBack = SetWindowLong_(GadgetID(Splitter),#GWL_WNDPROC,@SplitterCallback())
AddGadgetItem(PanelSignet, 0, "Signet")
ListeSignetID = ListIconGadget(#PB_Any,0,0,0,0,"Non trié",0,#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_FullRowSelect)
SendMessage_(GadgetID(ListeSignetID),#lvm_setbkcolor,0,RGB(100,150,100))
SendMessage_(GadgetID(ListeSignetID),#lvm_settextcolor,0,RGB(250,250,250))
SetGadgetFont(ListeSignetID,hFont)
AddGadgetItem(PanelSignet, 1, "Label")
ListeLabelID = ListIconGadget(#PB_Any,0,0,0,0,"Non trié",0,#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_FullRowSelect)
SendMessage_(GadgetID(ListeLabelID),#lvm_setbkcolor,0,RGB(100,150,100))
SendMessage_(GadgetID(ListeLabelID),#lvm_settextcolor,0,RGB(250,250,250))
SetGadgetFont(ListeLabelID,hFont)
AddGadgetItem(PanelSignet, 2, "Variable")
ListeVariableID = ListIconGadget(#PB_Any,0,0,0,0,"Non trié",0,#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_FullRowSelect)
SendMessage_(GadgetID(ListeVariableID),#lvm_setbkcolor,0,RGB(100,150,100))
SendMessage_(GadgetID(ListeVariableID),#lvm_settextcolor,0,RGB(250,250,250))
SetGadgetFont(ListeVariableID,hFont)
CloseGadgetList()
;/
Restore CodeASM
For t=1 To 294 : AddElement(Code()) : Read Code() : Next
For t=1 To 40 : AddElement(Registre()) : Read Registre() : Next
If Parametre$ <> "" : OuvrirFichier(Parametre$)
Else : CreerEditeurCode("Nouveau")
EndIf
ResizeEditeurCode() : SetGadgetState(Splitter,SplitterPos)
SetGadgetState(PanelCode,CountGadgetItems(PanelCode)-1)
SendMessage_(hEditeur()\Handle, #EM_SETSEL, 0, 0)
SetFocus_(hEditeur()\Handle)
SetWindowCallback(@myWindowCallback())
ShowWindow_(hwnd,#SW_MAXIMIZE)
Repeat
Select WaitWindowEvent()
Case #PB_EventMenu
Select EventMenuID()
Case #IDM_FILE_NEW
CreerEditeurCode("Nouveau")
SetGadgetState(PanelCode,CountGadgetItems(PanelCode)-1)
MoveWindow_(hEditeur()\Handle,1,1,GetInnerSizeWidth(PanelCode)-2,GetInnersizeHeight(PanelCode)-2,#False)
SetFocus_(hEditeur()\Handle)
Case #IDM_FILE_OPEN
OuvrirFichier("")
SendMessage_(hEditeur()\Handle, #EM_SETSEL,0,0)
SetFocus_(hEditeur()\Handle)
Case #IDM_FILE_SAVE
FileName$ = SaveFileRequester("Enregistrer le fichier ASM", "", "Fichier ASM (*.asm)|*.asm", 1)
If FileName$
If UCase(Right(FileName$,3)) <> ".ASM"
FileName$+".asm"
EndIf
iFile = CreateFile(#PB_Any,FileName$)
If iFile
FileLength = SendMessage_(hEditeur()\Handle, #WM_GETTEXTLENGTH, 0, 0)
*TextBuffer = LocalAlloc_(#LMEM_ZEROINIT, FileLength+1)
SendMessage_(hEditeur()\Handle, #WM_GETTEXT, FileLength+1,*TextBuffer)
WriteData(*TextBuffer, FileLength)
LocalFree_(*TextBuffer)
CloseFile(iFile)
EndIf
EndIf
Case #MENU_QUITTER
End
Case #IDM_EDIT_CUT
SendMessage_(hEditeur()\Handle, #WM_CUT, 0, 0)
Case #IDM_EDIT_COPY
SendMessage_(hEditeur()\Handle, #WM_COPY, 0, 0)
Case #IDM_EDIT_PASTE
SendMessage_(hEditeur()\Handle, #WM_PASTE, 0, 0)
Case #IDM_EDIT_DELETE
SendMessage_(hEditeur()\Handle, #EM_REPLACESEL, #True, 0)
Case #IDM_EDIT_SELECTALL
Editor_Select(hEditeur()\Handle,1,-1,-1,-1)
Case #IDM_EDIT_UNDO
SendMessage_(hEditeur()\Handle, #EM_UNDO, 0, 0)
Case #IDM_EDIT_REDO
SendMessage_(hEditeur()\Handle, #EM_REDO, 0, 0)
Case #IDM_HELP_ABOUT
AboutMessage.s = "Novembre 2004"+Chr(10)+"Programme Eric Ducoulombier (Erix14)"
ShellAbout_(hwnd, @"PureASM 1.0", @AboutMessage, LoadIcon_(#Null, #IDI_APPLICATION))
SetFocus_(hEditeur()\Handle)
EndSelect
Case #PB_EventGadget
Select EventGadgetID()
Case PanelCode
NumPanel = GetGadgetState(PanelCode)
SelectElement(hEditeur(),NumPanel)
ChargeSLV(NumPanel)
GetWindowRect_(GadgetID(PanelCode),wPanelRect.RECT)
GetWindowRect_(hEditeur()\Handle,wEditeurRect.RECT)
hPanel = wEditeurRect\top-wPanelRect\top
GetClientRect_(GadgetID(PanelCode),PanelRect.RECT)
PanelRect\top = hPanel
ValidateRect_(GadgetID(PanelCode),@PanelRect)
MoveWindow_(hEditeur()\Handle,1,1,GetInnerSizeWidth(PanelCode)-2,GetInnersizeHeight(PanelCode)-2,#False)
SetFocus_(hEditeur()\Handle)
AncienDebutLigne = SendMessage_(hEditeur()\Handle,#EM_GETFIRSTVISIBLELINE,0,0)
Case PanelSignet
GetWindowRect_(GadgetID(PanelSignet),wPanelRect.RECT)
GetWindowRect_(GadgetID(ListeSignetID),wListeRect.RECT)
hPanel = wListeRect\top-wPanelRect\top
GetClientRect_(GadgetID(PanelSignet),PanelRect.RECT)
PanelRect\top = hPanel
ValidateRect_(GadgetID(PanelSignet),@PanelRect)
NumPanel = GetGadgetState(PanelSignet)
If NumPanel = 0
InvalidateRect_(GadgetID(ListeSignetID),0,1)
SendMessage_(GadgetID(ListeSignetID),#WM_PAINT,0,0)
ElseIf NumPanel = 1
InvalidateRect_(GadgetID(ListeLabelID),0,1)
SendMessage_(GadgetID(ListeLabelID),#WM_PAINT,0,0)
ElseIf NumPanel = 2
InvalidateRect_(GadgetID(ListeVariableID),0,1)
SendMessage_(GadgetID(ListeVariableID),#WM_PAINT,0,0)
EndIf
SetFocus_(hEditeur()\Handle)
EndSelect
Case #PB_Event_CloseWindow: End
EndSelect
ForEver
DataSection
CodeASM:
;- Instructions des 8086/8088
Data.s "MOV","AAA","AAD","AAM","AAS","ADC","ADD","AND","CALL","CBW","CLC","CLD","CLI","CMC","CMP","CMPSB","CMPSB","CMPSW","CWD"
Data.s "MOVSW","MUL","NEG","NOP","NOT","OR","OUT","POP","POPF","PUSH","PUSHF","RCL","RCR","REP","REPE","REPNE","REPNZ","XOR"
Data.s "DAS","DEC","DIV","ESC","HLT","IDIV","IMUL","IN","INC","INT","INTO","IRET","JA","JAE","JB","JBE","JC","JCXZ","JE","JG","JGE","JL"
Data.s "JLE","JMP","JNA","JNAE","JNB","JNBE","JNC","JNE","JNG","JNL","JNLE","JNO","JNP","JNS","JNZ","JO","JP","JPE","JPO","JS","JZ"
Data.s "LAHF","LDS","LEA","LES","LOCK","LODSB","LODSW","LOOP","LOOPE","LOOPNE","LOOPNZ","LOOPZ","MOVSB","DAA"
Data.s "REPZ","RET","ROL","ROR","SAHF","SAL","SAR","SBB","SCASB","SCASW","SHL","SHR","STC","STD","STI","STOSB","STOSW"
Data.s "SUB","TEST","WAIT","XCHG","XLAT"
;- Coprocesseur numérique 8087
Data.s "F2XM1","FABS","FADD","FADDP","FBLD","FBSTP","FCHS","FCLEX","FCOM","FCOMP","FCOMPP","FDECSTP","FDISI"
Data.s "FDIV","FDIVP","FDIVR","FDIVRP","FENI","FFREE","FIADD","FICOM","FICOMP","FIDIV","FIDIVR","FILD","FIMUL","FINCSTP"
Data.s "FINIT","FIST","FISTP","FISUB","FISUBR","FLD","FLD1","FLDCW","FLDENV","FLD2E","FLDL2T","FLDLG2","FLDLN2","FLDPI"
Data.s "FLDZ","FMUL","FMULP","FNCLEX","FNDISI","FNENI","FNINIT","FNOP","FNSAVE","FNSTCW","FNSTENV","FNSTSW"
Data.s "FPATAN","FPREM","FPTAN","FRNDINT","FRSTOR","FSAVE","FSCALE","FSQRT","FST","FSTCW","FSTENV","FSTP","FSTSW"
Data.s "FSUB","FSUBP","FSUBR","FSUBRP","FTST","FWAIT","FXAM","FXCH","FXTRACT","FYL2X","FYL2XP1"
;- Instructions du 80286
Data.s "ARPL","BOUND","CLTS","ENTER","INS","INSB","INSW","LAR","LEAVE","LGDT","LIDT","LLDT","LMSW","LSL","LTR","OUTS"
Data.s "OUTSB","OUTSW","POPA","PUSHA","SGDT","SIDT","SLDT","SMSW","STR","VERR","VERW"
;- Coprocesseur numérique 80287
Data.s "FSETPM"
;- Instructions du 80386
Data.s "BSF","BSR","BT","BTC","BTR","BTS","CDQ","CMPSD","CWDE","INSD","JECXZ","LFS","LGS","LODSD","LSS","MOVSD","MOVSX"
Data.s "MOVZX","OUTSD","POPAD","POPFD","PUSHAD","PUSHFD","SCASD","SETA","SETAE","SETB","SETBE","SETC","SETE","SETG"
Data.s "SETGE","SETL","SETLE","SETNA","SETNAE","SETNB","SETNBE","SETNC","SETNE","SETNG","SETNGE","SETNL"
Data.s "SETNLE","SETNO","SETNP","SETNS","SETNZ","SETO","SETP","SETPE","SETPO","SETS","SETZ","SHLD","SHRD","STOSD"
;- Coprocesseur numérique 80387
Data.s "FCOS","FNSTSW","FPREM1","FSIN","FSINCOS","FSTSW","FUCOM","FUCOMP","FUCOMPP"
;- Instructions du 80486
Data.s "BSWAP","CMPXCHG","INVD","INVD","INVLPG","WBINVD","XADD"
;- Les registres
Data.s "EAX","EBX","ECX","EDX","ESP","EBP","EDI","ESI"
Data.s "AX","BX","CX","DX","SP","BP","DI","SI"
Data.s "AH","AL","BH","BL","CH","CL","DH","DL"
Data.s "ST0","ST1","ST2","ST3","ST4","ST5","ST6","ST7"
;-
Data.s "PUBLIC","EXTRN","MACRO","FORMAT","SECTION","RD","DB","DATA"
EndDataSection