IDE - Insert path or path/file into code

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

IDE - Insert path or path/file into code

Post by USCode »

Occasionally I find the need to insert a path or a file path into code.

It might be a useful new feature for the IDE to be able to look up a path/file using the Path or Open File requesters which would then insert that path/file into code at the current cursor position.

E.g.
If OpenFile(0, "")
...
After entering in the above code you would put the cursor in between the quotes, then select the new IDE 'Insert Path...' or 'Insert File Path...' option & do the path/file lookup to be inserted into the code.

If OpenFile(0, "c:\myprog\data\test.dat") ;Inserted full file path
...

myfile.s = "test.dat"
If OpenFile(0, "c:\myprog\data\" + myfile) ;Inserted just path
...
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: IDE - Insert path or path/file into code

Post by PB »

LOL, this was first requested six years ago. :)

http://www.purebasic.fr/english/viewtopic.php?t=2435
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Things like this could be easily added as an external tool...
No need to wait for a builtin solution
quidquid Latine dictum sit altum videtur
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Post by USCode »

An external tool can insert text directly into the IDE editor?
(Not paste from clipboard but insert directly into the text after selecting the path/file)
inc.
Enthusiast
Enthusiast
Posts: 406
Joined: Thu May 06, 2004 4:28 pm
Location: Cologne/GER

Post by inc. »

USCode wrote:An external tool can insert text directly into the IDE editor?
(Not paste from clipboard but insert directly into the text after selecting the path/file)
Get the Scintilla handle provided by the IDE via arguments or envVariable and just start taking control of the IDEs Scintilla gadget ;-)
Check out OOP support for PB here!
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> An external tool can insert text directly into the IDE editor?

Sure. Here's my example. Make it an exe, then add it to the Tools menu.
Just set the "Commandline", "Name" and "Event to trigger" fields for it.

> Not paste from clipboard but insert directly into the text after selecting
> the path/file

Mine uses the clipboard but doesn't lose the existing contents, if that's
what you're worried about?

Code: Select all

p$=PathRequester("Select path to paste into the IDE:","")
If p$
  c$=GetClipboardText()
  SetClipboardText(Chr(34)+p$+Chr(34))
  keybd_event_(#VK_CONTROL,0,0,0)
  keybd_event_(#VK_V,0,0,0)
  keybd_event_(#VK_V,0,#KEYEVENTF_KEYUP,0)
  keybd_event_(#VK_CONTROL,0,#KEYEVENTF_KEYUP,0)
  SetClipboardText(c$)
EndIf
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

PB wrote:Mine uses the clipboard but doesn't lose the existing contents, if that's what you're worried about?
That's in fact exactly what it does if the clipboard contains a picture, sound, rich text, filenames or custom data.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Okay, I meant any plain text in the clipboard. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

cross-platform ?

Post by USCode »

Can this be done in a cross-platform manner, with pure PB or does it require platform-specific API calls?
Post Reply