in your source code at the current cursor location :
Code: Select all
; 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)
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...