Download the latest editor source from CVS

Developed or developing a new product in PureBasic? Tell the world about it.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Kale.

I was a little bored tonight so i quickly coded this. It downloads the latest (i hope!) source of the PB IDE ready for compilation. Could this be done better? feel free to throw suggestions at me. :)

Code: Select all

;===========================================================================
; CONSTANTS
;===========================================================================

#ROOT_WINDOW = 0
#MenuBar_0 = 0
#MENU_UPDATE = 1
#MENU_QUIT = 2
#MENU_ABOUT = 3
#Gadget_1 = 0
#PROGRESS_BAR = 1
#BUTTON_UPDATE = 2
#Gadget_6 = 3
#PROGRESS_LIST = 4

;===========================================================================
; GLOBAL FLAGS / VARIABLES / STRUCTURES / ARRAYS
;===========================================================================

menuQuit.b
threadID.l
Global toggle.b

Global URL.s
URL = "[url]http://purebasic-cvs.dyndns.org/index.cgi/~checkout~/Sources/Editor/[/url]"
Dim files.s(24)
files(0) = "AboutWindow.pb"
files(1) = "AddTools.pb"
files(2) = "AsciiTable.pb"
files(3) = "CheckPureBasicKeyWords.pb"
files(4) = "Common.pb"
files(5) = "FindWindow.pb"
files(6) = "GotoWindow.pb"
files(7) = "Menu_AddHelpFiles.pb"
files(8) = "Misc.pb"
files(9) = "OptionWindow.pb"
files(10) = "PickColor.pb"
files(11) = "PreferenceWindow.pb"
files(12) = "ProcedureBrowser.pb"
files(13) = "ProcedureParser.pb"
files(14) = "Purebasic Ide.pb"
files(15) = "RecentFiles.pb"
files(16) = "RichEdit_OpenIncludeFile.pb"
files(17) = "RunOnce.pb"
files(18) = "SelectionComments.pb"
files(19) = "StructureViewer.pb"
files(20) = "Syntax Highlighting.pb"
files(21) = "Data/PureBasic IDE.ico"
files(22) = "Data/PureBasicLogo.bmp"
files(23) = "Data/Visual Designer.ico"

;===========================================================================
; PROCEDURES
;===========================================================================

Procedure updateSources(Value)
    If toggle = 0
        toggle = 1
        If DeleteDirectory("New Editor Source", "*.*", #PB_FileSystem_Force)
            CreateDirectory("New Editor Source")
            CreateDirectory("New Editor Source\Data")
        EndIf
        ClearGadgetItemList(#PROGRESS_LIST)
        SetGadgetItemText(#PROGRESS_LIST, -1, "Contacting Purebasic CVS...", 0)
        For x = 0 To 23
            DeleteUrlCacheEntry_(URL+files(x))
            If URLDownloadToFile_(0, URL+files(x), "New Editor Source\"+files(x), 0, 0) = 0
                SetGadgetItemText(#PROGRESS_LIST, -1, "Downloaded: "+files(x), 0)
            Else
                SetGadgetItemText(#PROGRESS_LIST, -1, "ERROR Downloading: "+files(x), 0)
            EndIf
            SetGadgetState(#PROGRESS_LIST, CountGadgetItems(#PROGRESS_LIST)-1)
            SetGadgetState(#PROGRESS_BAR, x+1)
        Next x
        SetGadgetState(#PROGRESS_BAR, 0)
        SetGadgetItemText(#PROGRESS_LIST, -1, "Finished!", 0)
        SetGadgetState(#PROGRESS_LIST, CountGadgetItems(#PROGRESS_LIST)-1)
        toggle = 0
    EndIf
EndProcedure

;===========================================================================
; GEOMETRY
;===========================================================================

If OpenWindow(#ROOT_WINDOW, 327, 148, 400, 200,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "Editor CVS Updater v1.0")
    If CreateMenu(#MenuBar_0, WindowID())
        MenuTitle("File")
        MenuItem(#MENU_UPDATE, "Update"+Chr(9)+"Ctrl+U")
        MenuBar()
        MenuItem(#MENU_QUIT, "Quit"+Chr(9)+"Ctrl+Q")
        MenuTitle("Help")
        MenuItem(#MENU_ABOUT, "About")
    EndIf
    If CreateGadgetList(WindowID())
        Frame3DGadget(#Gadget_1, 10, 3, 380, 112, "Editor Update Progress")
        ProgressBarGadget(#PROGRESS_BAR, 10, 125, 380, 10, 0, 24)
        ButtonGadget(#BUTTON_UPDATE, 300, 145, 90, 25, "Update")
        TextGadget(#Gadget_6, 10, 150, 285, 21, "Click here to begin downloading from CVS >>>", #PB_Text_Right)
        ListViewGadget(#PROGRESS_LIST, 20, 21, 360, 84)
    EndIf
EndIf

AddKeyboardShortcut(#ROOT_WINDOW, #PB_Shortcut_Control | #PB_Shortcut_U, #MENU_UPDATE)
AddKeyboardShortcut(#ROOT_WINDOW, #PB_Shortcut_Control | #PB_Shortcut_Q, #MENU_QUIT)

;===========================================================================
; MAIN LOOP
;===========================================================================

Repeat
    EventID.l = WaitWindowEvent()
    Select EventID
        Case #PB_EventMenu
            Select EventMenuID()
                Case #MENU_UPDATE
                    threadID = CreateThread(@updateSources(), 0)
                Case #MENU_QUIT
                    menuQuit = 1
                Case #MENU_ABOUT
                    MessageRequester("About", "A small utility to update the Purebasic Editor from CVS", Flags)
            EndSelect
        Case #PB_EventGadget
            Select EventGadgetID()
                Case #BUTTON_UPDATE
                    threadID = CreateThread(@updateSources(), 0)
            EndSelect
    EndSelect
Until EventID = #PB_EventCloseWindow Or menuQuit = 1
End
--Kale

In love with PureBasic! :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Jose.

Kale, I'm glad you got bored...
That's really cool.
Thanks
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Originally posted by Kale

Could this be done better?
Make it use CVS to download the source. I think you would only need to download the patches to apply to your existing file (instead of downloading the whole thing, but I can't remember if CVS transmission works like that or whether it is just the storage on the server) and it would automatically pick up any new sources that were added to the editor (for example, your program has no way of knowing that a new file is added to the editor sources until the user tries to compile it and finds they do not have new_xinclude_file_xyz.pb).

Or just use a CVS client and do it manually ;p


--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.51, Ed3.53)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Yes, using a CVS client like said in cvs.purebasic.com/Help/Help.txt seems the easier/better way...

Fred - AlphaSND
Post Reply