FileExplorer:Tabs & Drag'n'Drop

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
A.D.
User
User
Posts: 98
Joined: Tue Oct 06, 2009 9:11 pm

FileExplorer:Tabs & Drag'n'Drop

Post by A.D. »

Hi there !

I would like to have Tabs for the FileExplorer which is on right side of the IDE so that you can easily copy files with drag'n'drop from other places into the source folder.
Drag'n'Drop from the FileExplorer to the Projekt-Tab would be nice too...

Greets

A.D:
Repeat
PureBasic
ForEver
User avatar
A.D.
User
User
Posts: 98
Joined: Tue Oct 06, 2009 9:11 pm

Re: FileExplorer:Tabs & Drag'n'Drop

Post by A.D. »

Thanks for adding the Favorites to the IDE.
Could you make it possible to copy and replace files from the explorer tool into the favorite directories by drag'n'drop please, too !?!

There's another thing i would like to have, dear fred :

Code: Select all

LoadImage(1,"test.png")
It would be nice if we could drag'n'drop files from the explorer tool
onto the codeline to replace the filename automatically.

A.D.
Repeat
PureBasic
ForEver
User avatar
Bisonte
Addict
Addict
Posts: 1306
Joined: Tue Oct 09, 2007 2:15 am

Re: FileExplorer:Tabs & Drag'n'Drop

Post by Bisonte »

This can be done with an external IDE tool...

There triggers about that handling.... Replace FileViewer - Special File
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
A.D.
User
User
Posts: 98
Joined: Tue Oct 06, 2009 9:11 pm

Re: FileExplorer:Tabs & Drag'n'Drop

Post by A.D. »

I think you can't do it with an external tool because there isn't a way to retrieve the dragged file string. And how do you replace
the string in the source code ?
Repeat
PureBasic
ForEver
User avatar
Bisonte
Addict
Addict
Posts: 1306
Joined: Tue Oct 09, 2007 2:15 am

Re: FileExplorer:Tabs & Drag'n'Drop

Post by Bisonte »

Basecode from StarGate: http://purebasic.fr/german/viewtopic.ph ... 45#p294445

Code: Select all

; Arguments : "%FILE"
; Trigger : Replace FileViewer Special File
; Wait till tool ends
; supported extension : png,bmp,jpg 
EnableExplicit
Procedure GetProcessFromWindow(WindowID.i)
   Protected ProcessID.i
   If GetWindowThreadProcessId_(WindowID, @ProcessID)
      ProcedureReturn OpenProcess_(#PROCESS_ALL_ACCESS, #False, ProcessID)
   EndIf
EndProcedure
Procedure SendText(ScintillaID.i, Text.s)
   Protected ProcessID.i = GetProcessFromWindow(ScintillaID)
   Protected Length.i
   Protected *MemoryID, *Buffer, Format.i
   If ProcessID
      Select SendMessage_(ScintillaID, #SCI_GETCODEPAGE, #Null, #Null)
         Case 0     : Format = #PB_Ascii
         Case 65001 : Format = #PB_UTF8
      EndSelect
      Length.i = StringByteLength(Text, Format)
      *Buffer = AllocateMemory(Length+SizeOf(Character))
      If *Buffer
         PokeS(*Buffer, Text, #PB_Default, Format)
         *MemoryID = VirtualAllocEx_(ProcessID, #Null, Length, #MEM_RESERVE|#MEM_COMMIT, #PAGE_EXECUTE_READWRITE)
         If *MemoryID
            WriteProcessMemory_(ProcessID, *MemoryID, *Buffer, Length, #Null)
            SendMessage_(ScintillaID, #SCI_ADDTEXT, Length, *MemoryID)
            VirtualFreeEx_(ProcessID, *MemoryID, Length, #MEM_RELEASE)
         EndIf
         FreeMemory(*Buffer)
      EndIf
      CloseHandle_(ProcessID)
   EndIf
EndProcedure

Define FileName.s = ProgramParameter(0)
Define Output.s
Define WindowID.i = Val(GetEnvironmentVariable("PB_TOOL_MAINWINDOW"))

If Not WindowID
   MessageRequester("FileNameToEditor.Tool", "Fehler: Das Programm kann nicht außerhalb von PureBasic gestartet werden!")
   End
EndIf

If Not FileName
   MessageRequester("FileNameToEditor.Tool", "Fehler: Es wurde keine Datei übergeben!")
   End
EndIf

Output = Chr(34) + FileName + Chr(34)
SendText(FindWindowEx_(WindowID,0,"Scintilla",0), Output)
Only a little example what can be made ;)
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
A.D.
User
User
Posts: 98
Joined: Tue Oct 06, 2009 9:11 pm

Re: FileExplorer:Tabs & Drag'n'Drop

Post by A.D. »

Wow, okay, it's such a looong way to become a code guru :)
It would be perfect if the old filename would be replaced by the new one, i don't know at the moment how
to add that but i will try to.

Greets
A.D.

P.S.: Can you show me how to read text / complete line from a scintilla gadget? I guess this code won't work : :|

Code: Select all

Procedure GetProcessFromWindow(WindowID.i)
   Protected ProcessID.i
   If GetWindowThreadProcessId_(WindowID, @ProcessID)
      ProcedureReturn OpenProcess_(#PROCESS_ALL_ACCESS, #False, ProcessID)
   EndIf
EndProcedure

Procedure GetText(ScintillaID.i)

Protected ProcessID.i = GetProcessFromWindow(ScintillaID)
   Protected Length.i
   Protected *MemoryID, *Buffer, Format.i
   If ProcessID
      Select SendMessage_(ScintillaID, #SCI_GETCODEPAGE, #Null, #Null)
         Case 0     : Format = #PB_Ascii
         Case 65001 : Format = #PB_UTF8
      EndSelect
   
      Length.i = StringByteLength(String.s{20}, Format)
      *Buffer = AllocateMemory(Length+SizeOf(Character))
       
       *MemoryID = VirtualAllocEx_(ProcessID, #Null, Length, #MEM_RESERVE|#MEM_COMMIT, #PAGE_EXECUTE_READWRITE)
        If *MemoryID
         WriteProcessMemory_(ProcessID, *MemoryID, *Buffer, Length, #Null)
         SendMessage_(ScintillaID, #SCI_GETTEXT,20, *Buffer)
         VirtualFreeEx_(ProcessID, *MemoryID, Length, #MEM_RELEASE)
        EndIf
      
      Debug PeekS(*Buffer)   
      CloseHandle_(ProcessID)
      FreeMemory(*Buffer)
      
   EndIf
   
EndProcedure


Define WindowID.i = Val(GetEnvironmentVariable("PB_TOOL_MAINWINDOW"))
GetText(FindWindowEx_(WindowID,0,"Scintilla",0))

Repeat
PureBasic
ForEver
User avatar
Bisonte
Addict
Addict
Posts: 1306
Joined: Tue Oct 09, 2007 2:15 am

Re: FileExplorer:Tabs & Drag'n'Drop

Post by Bisonte »

A.D. wrote:Wow, okay, it's such a looong way to become a code guru :)
It would be perfect if the old filename would be replaced by the new one, i don't know at the moment how
to add that but i will try to.

Greets
A.D.

P.S.: Can you show me how to read text / complete line from a scintilla gadget? I guess this code won't work : :|
I don't know what you want exactly .... but you have on this example only mark up the filename and then drop a file on
the IDE window... Readtext is not necessary.

But if you add "%TEMPFILE" to the arguments and "%CURSOR" you have the exact position and the filename of the sourcecode
and you have to parse it by yourself ... or only the "%WORD" under the cursor... (and don't forget to mark "Reload Source after....")
But if your source is very huge...

Its all explained at the help file of pb (F1) - IDE External Tools
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
A.D.
User
User
Posts: 98
Joined: Tue Oct 06, 2009 9:11 pm

Re: FileExplorer:Tabs & Drag'n'Drop

Post by A.D. »

I want that you can replace the file without having a current selection or the cursor in the right place, just the drag'n'drop . So I need to read the whole line, replace the filename and then write
the modified line back to scintilla. There is a command for reading text from scintilla (#SCI_GETTEXT,#SCI_GETLINE) but i don't understand how to get readaccess to the scintilla process:

Code: Select all

*MemoryID = VirtualAllocEx_(ProcessID, #Null, Length, #MEM_RESERVE|#MEM_COMMIT, #PAGE_EXECUTE_READWRITE)
        If *MemoryID
         WriteProcessMemory_(ProcessID, *MemoryID, *Buffer, Length, #Null)
         SendMessage_(ScintillaID, #SCI_GETTEXT,20, *Buffer)
         VirtualFreeEx_(ProcessID, *MemoryID, Length, #MEM_RELEASE)
        EndIf
I replaced the SendMessage Command, but theres nothing in the buffer. What are VirtualAllocEx_ , WriteProcessMemory_ for ?

Greets
A.D.
Repeat
PureBasic
ForEver
Post Reply