Code Explorer [jaPBe plugin]

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Code Explorer [jaPBe plugin]

Post by gnozal »

Code Explorer (jaPBe standalone plugin) Last update : SEPT 10th 2008

Description :
Code Explorer is an enhanced version of the PBI's Code Templates plugin for jaPBe.
I use it to view / find code templates in my purebasic code archives (some are
zipped).

Major changes (new features) :

Code: Select all

- ZIP archive support in file explorer panel.
- new search panel to find text in files (ZIP archive supported) with favorite
  directories and search history support.
- syntax highlighting (not so fast that I hoped, so it can be disabled).
- find text function.
- added compile/run (jaPBe plugin).
- added Win32 help in viewer context-menu (search for selected text)
  (the file win32.hlp must be located in %PUREBASIC%\HELP).
Minor changes :
- it can be used as a jaPBe plugin (Options\'Register jaPBe Plugin' button)
  or not : just run CodeExplorer.exe from any directory. You will have all
  the features minus the jaPBe copy/insert functions.
- files list is now sorted.
- right-click context menu in viewer (if used as a jaPBe plugin).
- the jaPBe functions now work with >64 text (using pointers and not strings).
- code loading through RichEdit stream callback (faster).
Download :
http://gnozal.ucoz.com/CodeExplorer.zip
Last edited by gnozal on Wed Sep 10, 2008 12:55 pm, edited 7 times in total.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update
Fixed some installation problems
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update
Fixed CopyToJaPBe function

This message was lost during the forum crash
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Jan2004
Enthusiast
Enthusiast
Posts: 154
Joined: Fri Jan 07, 2005 7:17 pm

Post by Jan2004 »

Could you explain 2 options in Options tab:
"Load keywords from PureBasic.exe"
"Start PBCompiler if necessary"

Thanks in advance:
Jan2004
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Jan2004 wrote:Could you explain 2 options in Options tab:
"Load keywords from PureBasic.exe"
"Start PBCompiler if necessary"
"Load keywords from PureBasic.exe"
Search for purebasic keywords in the Purebasic.exe (editor) for the syntax highlighting.
"Start PBCompiler if necessary"
The functions names (for the syntax highlighting) are loaded from file PBFunctionListing.txt created by the compiler. If this file does not exist and the option is checked, CoodeExplorer will launch the compiler to create the file.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Jan2004
Enthusiast
Enthusiast
Posts: 154
Joined: Fri Jan 07, 2005 7:17 pm

Post by Jan2004 »

All clear.
Thanks again.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update

Changes
- Updated keywords extraction code (compatible with the new editor)
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

gnozal, i would like to know how you did the update keywords thingy exactly, would you be willing to share the info / code?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

blueznl wrote:gnozal, i would like to know how you did the update keywords thingy exactly, would you be willing to share the info / code?
I don't have the CodeExplorer code at hand right now, but here is the code from PureSynPlus viewtopic.php?t=14343 wich should be the same (old code, not very clean, it has been updated many times to match with every new PB Editor version, but seems to work).

Code: Select all

Procedure.l ExtractPBFunctions()
  Protected FunctionsFile.s, Stream.l
  FunctionsFile =  GetPBFolder() + "Compilers\PBFunctionListing.txt"
  If FileSize(FunctionsFile) < 1
    ; Call PBCompiler to create the file
    #PB_MSG_Compiler_Ready = 10157
    PB_MSG_ID = RegisterWindowMessage_("PB_MSG_ID")
    PBCompiler.s = GetPBFolder() + "Compilers\PBCompiler.exe"
    Parameters.s = Str(GetCurrentThreadId_()) + " /STANDBY"
    CompilerProcessID = RunProgram(PBCompiler, Parameters, "", 2)
    If CompilerProcessID
      Repeat 
        Event = WindowEvent()
        If Event = PB_MSG_ID
          If EventwParam() = #PB_MSG_Compiler_Ready
            CompilerThreadID = EventlParam()
            TerminateProcess_(CompilerProcessID,0)
            Break
          EndIf
        EndIf
      ForEver
    EndIf
  EndIf
  Stream = ReadFile(#PB_Any, FunctionsFile)
  If Stream
    ; Load functions
    NbBasicFunctions = Val(ReadString())
    If NbBasicFunctions < 60000 And NbBasicFunctions > 0
      ClearList(PurebasicFunctions())
      ; Charger fonctions
      CurrentFunction = 1
      *MotsClefs_Fonctions_AllocMem = GlobalAlloc_(#GMEM_FIXED | #GMEM_ZEROINIT, Lof() + 2)
      *ProgressionMem.BYTE = *MotsClefs_Fonctions_AllocMem
      If *ProgressionMem
        ReadData(*ProgressionMem, Lof())
        Repeat
          OldProgressionMem = *ProgressionMem
          Repeat
            *ProgressionMem = *ProgressionMem + 1
          Until *ProgressionMem\b = 32 Or *ProgressionMem\b = 10 Or *ProgressionMem\b = 0
          If *ProgressionMem\b = 32
            *ProgressionMem\b = 0
            AddElement(PurebasicFunctions())
            PurebasicFunctions()= PeekS(OldProgressionMem)
            Repeat
              *ProgressionMem = *ProgressionMem + 1
            Until *ProgressionMem\b = 10 Or *ProgressionMem\b = 0
          ElseIf *ProgressionMem\b = 10
            *ProgressionMem\b = 0
            AddElement(PurebasicFunctions())
            PurebasicFunctions()= PeekS(OldProgressionMem)
          Else
            Break
          EndIf
          *ProgressionMem = *ProgressionMem + 1
        Until CurrentFunction > NbBasicFunctions Or *ProgressionMem\b = 0
        GlobalFree_(*MotsClefs_Fonctions_AllocMem)
      EndIf
    EndIf
    CloseFile(Stream)
  EndIf
  ProcedureReturn CountList(PurebasicFunctions())
EndProcedure
;
Procedure.l ExtractPBKeywords()
  Protected PurebasicEXEFile.s, Stream.l
  PurebasicEXEFile = GetPBFolder() + "purebasic.exe"
  TailleFichier.l = FileSize(PurebasicEXEFile)
  If TailleFichier > 4
    Stream = ReadFile(#PB_Any, PurebasicEXEFile)
    If Stream
      ClearList(PurebasicKeywords())
      *MotsClefs_Fonctions_AllocMem = GlobalAlloc_(#GMEM_FIXED | #GMEM_ZEROINIT, Lof() + 2)
      *ProgressionMem1.LONG = *MotsClefs_Fonctions_AllocMem
      FinProgressionMem = *ProgressionMem1 + Lof()
      If *ProgressionMem1
        ReadData(*ProgressionMem1, Lof())
        ; Recherche début
        Repeat
          If *ProgressionMem1\l = $00646E41 ; '<Nul>dnA'
            *ProgressionMem1 = *ProgressionMem1 + 4
            If *ProgressionMem1\l = $00646E61 ; '<Nul>dna'
              *ProgressionMem2.BYTE = *ProgressionMem1 - 5
              Debug "found : " + Str(*ProgressionMem1 - 4 - *MotsClefs_Fonctions_AllocMem)
              Break
            EndIf
          EndIf
          *ProgressionMem1 = *ProgressionMem1 + 1
        Until *ProgressionMem1 = FinProgressionMem
        ; Extraction des mots clés
        If *ProgressionMem2
          MotClef.s = ""
          MotClefToggle.l = 1
          LastMotClef.l = -1
          Repeat
            *ProgressionMem2 = *ProgressionMem2 + 1
            If *ProgressionMem2\b = 0 And LastMotClef <> 0
              MotClef = Trim(MotClef)
              If UCase(MotClef) =  "AAA"
                ; on s'arrête aux mot clés ASM [en majuscules]
                Break
              EndIf
              If MotClef
                If CountList(PurebasicKeywords())
                  ExisteDeja = #FALSE
                  ForEach PurebasicKeywords()
                    If UCase(PurebasicKeywords()) = UCase(MotClef)
                      ExisteDeja = #TRUE
                      Break
                    EndIf
                  Next
                  If ExisteDeja = #FALSE
                    AddElement(PurebasicKeywords())
                    PurebasicKeywords()= MotClef 
                    Debug MotClef
                  EndIf
                Else
                  AddElement(PurebasicKeywords())
                  PurebasicKeywords()= MotClef 
                  Debug MotClef
                EndIf
                MotClef = ""
              EndIf
            ElseIf (*ProgressionMem2\b > 96 And *ProgressionMem2\b < 123) Or (*ProgressionMem2\b > 64 And *ProgressionMem2\b < 91)
              MotClef = MotClef + Chr(*ProgressionMem2\b)
            EndIf
            LastMotClef = *ProgressionMem2\b
          Until *ProgressionMem2 = FinProgressionMem
        EndIf
        GlobalFree_(*MotsClefs_Fonctions_AllocMem)
      EndIf
      CloseFile(Stream)
    EndIf
  EndIf
  ProcedureReturn CountList(PurebasicKeywords())
EndProcedure
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
oryaaaaa
Enthusiast
Enthusiast
Posts: 791
Joined: Mon Jan 12, 2004 11:40 pm
Location: Okazaki, JAPAN

Post by oryaaaaa »

Launch Error
No drive E: !

My Drive Setting
A: Floppy
C: & D: SD&CF Memory slot
E: DVD-RW
F: Windows
G: External HDD

<ADD&Solved)
Special Directry Remove Example
Restart
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update

- added PB4.1x support

I mostly use PureTemplate now : http://www.purebasic.fr/english/viewtopic.php?t=28477
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update (build 12)

Changes :
- updated PB folder detection for PB4.10 beta 4
- fixed crash with Vista
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update

Changes :
- update for PB4.20 beta
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
mjwiech
New User
New User
Posts: 4
Joined: Wed Oct 31, 2007 10:59 am
Location: Sweden

Problems with CodeExplorer

Post by mjwiech »

Running CodeExplorer from any directory (even from within the IDE) gives error message: "Purebasic not found".

Regards
mjw
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

CodeExplorer uses this code to get the PB directory :

Code: Select all

Procedure.s GetPBFolder() ; Retrieves Purebasic folder [empty string if not installed]
  Protected hKey1.l, Type.l, Res.l, Folder$, lpbData.l, cbData.l, WindowsVersion.l
  cbData = (#MAX_PATH * 2) + 2
  lpbData = AllocateMemory(cbData)
  Folder$=""
  hKey1=0
  Type=0
  Res=-1
  WindowsVersion = OSVersion()
  If WindowsVersion = #PB_OS_Windows_95 Or WindowsVersion = #PB_OS_Windows_98 Or WindowsVersion = #PB_OS_Windows_ME
    Debug "Detected OS : Windows 95/98/ME"
    Res=RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, "Software\Classes\PureBasic.exe\shell\open\command", 0, #KEY_ALL_ACCESS, @hKey1)
  ElseIf WindowsVersion = #PB_OS_Windows_NT3_51 Or WindowsVersion = #PB_OS_Windows_NT_4 Or WindowsVersion = #PB_OS_Windows_2000 Or WindowsVersion = #PB_OS_Windows_XP Or WindowsVersion = #PB_OS_Windows_Server_2003
    Debug "Detected OS : Windows NT/2000/XP"
    Res=RegOpenKeyEx_(#HKEY_CLASSES_ROOT, "Applications\PureBasic.exe\shell\open\command", 0, #KEY_ALL_ACCESS, @hKey1)
  Else
    Debug "Detected OS : Windows Vista/Server 2008"
    Res=RegOpenKeyEx_(#HKEY_CURRENT_USER, "Software\Classes\PureBasic.exe\shell\open\command", 0, #KEY_ALL_ACCESS , @hKey1)
  EndIf
  If Res = #ERROR_SUCCESS And hKey1
    If RegQueryValueEx_(hKey1, "", 0, @Type, lpbData, @cbData)=#ERROR_SUCCESS
      Folder$ = PeekS(lpbData)
      Folder$ = GetPathPart(StringField(Folder$,2,Chr(34)))
    EndIf
    RegCloseKey_(hKey1)
  EndIf
  If lpbData
    FreeMemory(lpbData)
    lpbData=0
  EndIf
  ProcedureReturn Folder$
EndProcedure
Does it work for you ?
The PB registry keys are changing with every version lately ...

<EDIT>
Update : updated PB folder detection code
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply