It is currently Sat Jan 23, 2021 8:47 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: IDE Tool to insert text into your source code
PostPosted: Fri Mar 06, 2015 12:38 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 725
Location: Canada
The following piece of code makes it possible to insert some fixed expression
in your source code at the current cursor location :

Code:
; Compile the following bit of code as Unicode
; and add the resulting exe to your IDE Tools by
; (1) providing the path to your exe
; (2) giving your tool a descriptive name
; (3) assigning it a KBD shortcut (for added convenience)

Procedure MakeScintillaText(text.s)
  Static sciText.s
  CompilerIf #PB_Compiler_Unicode
    sciText = Space(StringByteLength(text, #PB_UTF8))
    PokeS(@sciText, text, -1, #PB_UTF8)
  CompilerElse
    sciText = text
  CompilerEndIf
  ProcedureReturn @sciText
EndProcedure

textBuffer = MakeScintillaText("Let's try this...")
scintilla = Val(GetEnvironmentVariable("PB_Tool_Scintilla"))
SendMessage_(scintilla, #EM_REPLACESEL, 0, textBuffer)


Remember to replace the demo text with your own !

I use it with <Control>+i, for instance, to quickly insert the forever recurring "#PB_" constant identifier,
and to insert standardized identifier lines at the beginning of my source code files.

It does save a lot of finger work.

The Procedure itself comes straight from the Help File (topic : ScintillaGadget()),
while the rest is from a piece of code offered by Netmaestro (Look here).

Using the code Netmaestro provided, i could only insert the first character of any text.
So, to insert a 5 characters word, SendMessage_() had to be called 5 times with 5 different characters...
Using the above, everything gets insrted in one shot.

At this writing, this code works nicely in PB 5.31 (x86) on a Windows 8.1 x64 system.
I haven't tried it on other configurations.

If you come up with interesting improvements/modifications, please share.
In particular, it would be great if one of the propeller heads around here
helped provide a scrolling list for selecting among a choice of
expressions, à la PureBasic IDE's auto-complete feature.

Enjoy.

BTW: (off topic, but...) if anyone knows how to get the URL to a specific message in a topic page, i'd really appreciate being told how to do it...

_________________
"That's not a bug..." said the programmer. "...It's a feature! "
"Oh! I see..." replied the blind man.


Last edited by Blue on Sun Mar 15, 2015 5:30 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Inserting text in your source code
PostPosted: Fri Mar 06, 2015 4:12 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Aug 11, 2009 1:56 pm
Posts: 858
Location: Essen (Germany)
Blue wrote:
BTW: (off topic, but...) if anyone knows how to get the URL to a specific message in a topic page, i'd really appreciate being told how to do it...

The page-icon in a posting-title contains its specific posting-address :arrow: Image Posted: 06.03.15 12h38

happy sharing :-)

_________________
Two growing code-collections: WinApi-Lib by RSBasic ~ LinuxAPI-Lib by Omi

Missing a download-file on the forums? ~ check out this backup page.


Top
 Profile  
Reply with quote  
 Post subject: Re: Inserting text in your source code
PostPosted: Sat Mar 07, 2015 2:36 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 725
Location: Canada
Vera wrote:
[...] The page-icon in a posting-title contains its specific posting-address
Ummm... Thank you for the tip, Vera... but what is the page-icon ??? :oops:
I've dragged my mouse all over the current page, but i never saw the specific post number appear anywhere.
Maybe i just need stronger glasses... :(

OK. Never mind. I think i finally got it. :P
You were referring to the tiny icon at the extreme right of the message header, just before the 'Posted' date, correct ? :shock:

_________________
"That's not a bug..." said the programmer. "...It's a feature! "
"Oh! I see..." replied the blind man.


Top
 Profile  
Reply with quote  
 Post subject: Re: Inserting text in your source code
PostPosted: Sat Mar 07, 2015 9:41 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Aug 11, 2009 1:56 pm
Posts: 858
Location: Essen (Germany)
Blue wrote:
I think i finally got it. :P
You were referring to the tiny icon at the extreme right of the message header, just before the 'Posted' date, correct ? :shock:

I'm glad you did :D
and yes. I'd thought that my 'reconstruction' would have already been selfexplaning enough, but I can comprehend that this single word 'page' must have been missleading to focus on the full thread-page, instead on that increadibly tiny icImagen.

_________________
Two growing code-collections: WinApi-Lib by RSBasic ~ LinuxAPI-Lib by Omi

Missing a download-file on the forums? ~ check out this backup page.


Top
 Profile  
Reply with quote  
 Post subject: Re: Inserting text in your source code
PostPosted: Sat Mar 07, 2015 11:13 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 725
Location: Canada
Vera wrote:
[...]I'd thought that my 'reconstruction' would have already been selfexplaning enough
Oh, Vera, you manifestly don't know who you're dealing with here ... :mrgreen:
But since i've got it all figured out now, i can see how brilliant and self-explanatory your artful reconstruction was. :!: :!: :!:
I really don't know how i could have missed it the first time around. I guess it was just too clever.

That tells you a lot about the perils of human communication.

Thanks a lot for your illustrated contribution.

_________________
"That's not a bug..." said the programmer. "...It's a feature! "
"Oh! I see..." replied the blind man.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye