[IDE Tool] Show Includes

Working on new editor enhancements?
dige
Addict
Addict
Posts: 1405
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

[IDE Tool] Show Includes

Post by dige »

Code: Select all

; by dige 01/2024
EnableExplicit

Structure _FILE
  file.s
  path.s
EndStructure


Define file.s, FileID, FF, txt.s, i, Path.s, Event
Define NewMap files.s(), NewList SortedList._FILE()


file.s = ProgramParameter(0)
; Path = "C:\Temp\"

If file = ""
  file = OpenFileRequester( "Source Code wählen", "", "Text (*.txt;*.bat)|*.txt;*.bat|PureBasic (*.pb)|*.pb|Alle Dateien (*.*)|*.*", 1)
EndIf

If FileSize(file) <= 0
  MessageRequester("IDE Tool Show All Includes", ~"Argument \"%FILE\"")
  End
EndIf

FileID = ReadFile(#PB_Any, file, #PB_File_SharedRead)
If FileID
  FF = ReadStringFormat(FileID)
  
	While Eof(FileID) = 0
	  txt = Trim(ReadString(FileID, FF))
	  
	  If Mid(txt, 1, 1) = ";"
	    Continue
	  EndIf
	  
	  i = FindString(txt, "IncludePath", 0, #PB_String_NoCase)
	  If i
	    Path = Mid(txt, 11)
   	  Path = StringField(Path, 2, Chr(34))
	    Path = StringField(Path, 1, Chr(34))
	  EndIf
	  
	  If FindString(txt, "includefile", 0, #PB_String_NoCase)
	    If Path <> ""
	      i = FindString(txt, Chr(34))
	      txt = Mid(txt, 1, i) + Path + Mid(txt, i + 1)
	    EndIf
	    
	    txt = StringField(txt, 2, Chr(34))
	    
	    If GetPathPart(txt) = ""
	      txt = GetPathPart(file) + txt
	    EndIf
	    
	    AddMapElement(files(), LCase(txt))
	    files() = txt
	    
	  EndIf
	Wend
  
  CloseFile(FileID)
EndIf

Procedure SizeWindow()
  Protected w, h
  
  w = WindowWidth(0)
  h = WindowHeight(0)
  
  ResizeGadget(0, 0, 0, w, h)
  
EndProcedure

OpenWindow(0, 50, 50, 600, 400, file, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget)
ListIconGadget(0, 0, 0, 600, 400, "File", 300, #PB_ListIcon_FullRowSelect | #PB_ListIcon_GridLines)
AddGadgetColumn(0, 1, "Path", 200)
AddGadgetColumn(0, 2, "Date", 60)
AddGadgetColumn(0, 3, "Size", 40)
SetGadgetColor(0, #PB_Gadget_BackColor, #Black)
SetGadgetColor(0, #PB_Gadget_FrontColor, #Green)
SetGadgetColor(0, #PB_Gadget_LineColor , $222222)

BindEvent(#PB_Event_SizeWindow, @SizeWindow())

ForEach files()
  AddElement(SortedList())
  SortedList()\file = GetFilePart(files())
  SortedList()\path = GetPathPart(files())
Next

SortStructuredList(SortedList(), #PB_Sort_Ascending | #PB_Sort_NoCase, OffsetOf(_FILE\file), TypeOf(_FILE\file))

ForEach SortedList()
  
  file = SortedList()\path + SortedList()\file
  
  AddGadgetItem(0, -1, SortedList()\file + #LF$ + 
                       SortedList()\path + #LF$ + 
                       FormatDate("%dd.%mm.%yyyy %hh:%ii", GetFileDate(file, #PB_Date_Modified)) + #LF$ +
                       Str(FileSize(file)/1024) + "KB" )
Next

Repeat
  Event = WaitWindowEvent()
  If Event = #PB_Event_Gadget And EventGadget() = 0 And EventType() = #PB_EventType_LeftDoubleClick
    i = GetGadgetState(0)
    file = GetGadgetItemText(0, i, 1) + GetGadgetItemText(0, i, 0)
    RunProgram(file)
    
  EndIf
  
Until Event = #PB_Event_CloseWindow
"Daddy, I'll run faster, then it is not so far..."
Sergey
User
User
Posts: 57
Joined: Wed Jan 12, 2022 2:41 pm

Re: [IDE Tool] Show Includes

Post by Sergey »

Nice tool, but IncludePath #constant aren't supported (ignored)
Post Reply