; German forum: http://www.purebasic.fr/german/viewtopic.php?t=2086&start=10 ; Author: DarkDragon (updated for PB 4.00 by Andre) ; Date: 16. February 2005 ; OS: Windows ; Demo: No ; Editor code for editing PHP code with SyntaxHighlighting (using the relating userlib) ; and Online help pressing F1 on a command name ; (Note: code is incomplete, menu functions are missing) OnErrorGoto(?ERROR) Enumeration #FILE_NEW #FILE_OPEN #FILE_SAVEAS #FILE_SAVE #FILE_PREF #FILE_QUIT #EDIT_COPY #EDIT_PASTE #EDIT_CUT #EDIT_FIND #EDIT_FINDNEXT #EDIT_REPLACE EndEnumeration Enumeration #EDIT #FUNC #HELPFUNC EndEnumeration Global NewList Func.s() Procedure SortFunctions() n = 0 ResetList(Func()) While NextElement(Func()) v = Len(Func()) e = ListIndex(Func()) k.s = Func() m = 0 While NextElement(Func()) If Len(Func()) > v u.s = Func() Func() = k SelectElement(Func(), e) Func() = u m = 1 n = 1 Break EndIf Wend If m = 0 SelectElement(Func(), e) Else SelectElement(Func(), e-1) EndIf Wend ProcedureReturn n EndProcedure Procedure.l GetFieldIndex(String.s, Position, Separator.s) m = 1 For x=1 To Position If Mid(String, x, Len(Separator)) = Separator m + 1 EndIf Next ProcedureReturn m EndProcedure ; Procedure.s GetPHPVariables(Text.s, Separator.s) ; Shared Result.s ; Start = FindString(Text, "$", 1) ; While Start <> 0 ; c.s = "" ; For k=Start+1 To Len(Text)-1 ; b = PeekB(@Text+k-1) ; If (b > 'a' And b < 'z') Or (b > 'A' And b < 'Z') ; c + Chr(b) ; Else ; Break ; EndIf ; Next ; Result.s + c.s + Separator ; Start = FindString(Text, "$", Start+1) ; Wend ; ProcedureReturn Result ; EndProcedure If ReadFile(0, "Functions.txt") While Eof(0) = 0 Line.s = ReadString(0) If Trim(Line) <> "" AddElement(Func()) Func() = Line EndIf Wend CloseFile(0) EndIf If SortFunctions() = 1 If CreateFile(0, "Functions.txt") ForEach Func() WriteStringN(0, Func()) Next CloseFile(0) EndIf EndIf #WindowWidth = 640 #WindowHeight = 480 #WindowFlags = #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_SystemMenu hWnd = OpenWindow(0, 0, 0, #WindowWidth, #WindowHeight, "PHP-Editor", #WindowFlags) CreateMenu(0, hWnd) MenuTitle("File") MenuItem(#FILE_NEW , "New") MenuItem(#FILE_OPEN , "Open...") MenuItem(#FILE_SAVEAS , "Save as...") MenuItem(#FILE_SAVE , "Save") MenuBar() MenuItem(#FILE_PREF , "Preferences") MenuBar() MenuItem(#FILE_QUIT , "Quit") MenuTitle("Edit") MenuItem(#EDIT_COPY , "Copy") MenuItem(#EDIT_PASTE , "Paste") MenuItem(#EDIT_CUT , "Cut") MenuBar() MenuItem(#EDIT_FIND , "Find") MenuItem(#EDIT_FINDNEXT , "Find next") MenuItem(#EDIT_REPLACE , "Replace") CreateGadgetList(WindowID(0)) EditorGadget(#EDIT, 0, 20, WindowWidth(0), WindowHeight(0)-20) StringGadget(#FUNC, 0, 0, WindowWidth(0)-20, 20, "", #PB_String_ReadOnly) ButtonGadget(#HELPFUNC, WindowWidth(0)-20, 0, 20, 20, "?") ClearHighlightingAll(#EDIT, RGB(0, 0, 0), 10, "Arial", 0) Repeat Event = WindowEvent() Select Event Case #PB_Event_Gadget If EventGadget() = #HELPFUNC RunProgram("http://de3.php.net/manual/en/function."+GetGadgetText(#FUNC)+".php") EndIf Case #WM_KEYUP wParam = EventwParam() CPos.CHARRANGE LineNr = SendMessage_(GadgetID(#EDIT), #EM_EXLINEFROMCHAR, 0, CPos\cpMin) SendMessage_(GadgetID(#EDIT), #EM_EXGETSEL, 0, CPos) Word.s = StringField(GetGadgetText(#EDIT), GetFieldIndex(GetGadgetText(#EDIT), CPos\cpMin, " "), " ") ForEach Func() If Left(UCase(Func()), Len(Word)) = UCase(Word) SetGadgetText(#FUNC, Func()) EndIf Next Line.s = GetGadgetItemText(#EDIT, LineNr, 0) ClearHighlightingLine(#EDIT, RGB(0, 0, 0), 10, "Arial", 0) SyntaxHighlightingLine(#EDIT, "", "|", RGB(0, 0, 0), RGB(255, 255, 0), 10, "Arial", #CFM_BOLD) SyntaxHighlightingLine(#EDIT, "$|and|or|if|else|while|wend|swich|case|Break", "|", RGB(0, 0, 0), RGB(255, 255, 255), 10, "Arial", #CFM_BOLD) SyntaxHighlightingLine(#EDIT, Chr(34)+"_+_-_*_/_{_}_%_&_|_(_)_!_=_1_2_3_4_5_6_7_8_9_0", "_", RGB(0, 0, 255), RGB(255, 255, 255), 10, "Arial", 0) ForEach Func() If FindString(Line, Func(), 1) SyntaxHighlightingLine(#EDIT, Func(), "", RGB(255, 0, 0), RGB(255, 255, 255), 11, "Arial", #CFM_BOLD) EndIf Next Case #PB_Event_SizeWindow ResizeGadget(#EDIT, 0, 20, WindowWidth(0), WindowHeight(0)-20) ResizeGadget(#FUNC, 0, 0, WindowWidth(0)-20, 20) ResizeGadget(#HELPFUNC, WindowWidth(0)-20, 0, 20, 20) EndSelect Delay(10) Until Event = #PB_Event_CloseWindow End ERROR: MessageRequester("", Str(GetErrorLineNR())) ; IDE Options = PureBasic v4.02 (Windows - x86) ; Folding = - ; DisableDebugger