Page 1 of 2
Paste as comment
Posted: Sat Mar 05, 2016 11:52 pm
by sys64802
Beyond Edit->Paste would be nice to have Edit->Paste as comment
Often I need to paste code from other languages, or text I want add as a comment and I have to use a temporary external editor to paste, add ";", and then copy+paste in the IDE.
Else case correction wrecks havoc (as can be seen in most codes here in the forum, where innocent English words are capitalized).
I know I could implement it by myself by writing a IDE tool, but the code to do it it's practically already there in the PB IDE.
Thanks.
Re: Paste as comment
Posted: Sat Mar 05, 2016 11:54 pm
by Andre
+1
Re: Paste as comment
Posted: Sun Mar 06, 2016 1:10 am
by IdeasVacuum
+1 would be good
Re: Paste as comment
Posted: Sun Mar 06, 2016 5:19 am
by Tenaja
Although I am also +1 on this, I usually use the comment creator plugin someone contributed. While not as instant, it gives the opportunity to reformat without styling added.
Re: Paste as comment
Posted: Sun Mar 06, 2016 10:32 am
by davido
+1
Re: Paste as comment
Posted: Sun Mar 06, 2016 11:48 am
by Little John
That would be helpful.
+1
Re: Paste as comment
Posted: Mon Mar 07, 2016 10:06 am
by Kukulkan
+1
That would be helpful, indeed.
Re: Paste as comment
Posted: Mon Mar 07, 2016 10:53 am
by Michael Vogel
As you mentioned, it shouldn't be a great deal to create an IDE tool, just send a ctrl+v event after changing the clipboard
as you like it - which gives you total flexibility.
Code: Select all
; Tool "ClipInsert" Written by Michael Vogel
; Command Line: %COMPILEFILE\..\Catalogs\Tool ClipComment.exe
; Working Directory: %COMPILEFILE\..
; Name: Insert Clipboard as Comment...
; Run Hidden
#Header=";"+#TAB$
SetClipboardText(#Header+ReplaceString(GetClipboardText(),#CRLF$,#CRLF$+#Header))
keybd_event_(#VK_CONTROL,1,0,0)
keybd_event_(#VK_V,1,0,0)
keybd_event_(#VK_V,1,2,0)
keybd_event_(#VK_CONTROL,1,2,0)
Re: Paste as comment
Posted: Tue Mar 08, 2016 1:27 pm
by IdeasVacuum
..... Very nice Michael.

Re: Paste as comment
Posted: Tue Mar 08, 2016 5:56 pm
by kenmo
+1
I like this idea! I think I will add it to my own IDE tool and link it to Ctrl-Shift-V.
Michael already posted a working snippet, here is a slightly different one (it uses #SCI_PASTE directly to the Scintilla gadget instead of virtual keypresses, and it restores the original clipboard)
Code: Select all
Prefix.s = "; "
SCID = Val(GetEnvironmentVariable("PB_TOOL_Scintilla"))
Orig.s = GetClipboardText()
If (SCID And Orig)
Mod.s = ReplaceString(Orig, #CRLF$, #LF$)
Mod = Prefix + ReplaceString(Mod, #LF$, #LF$ + Prefix) + #LF$
SetClipboardText(Mod)
SendMessage_(SCID, #SCI_PASTE, 0, 0)
SetClipboardText(Orig)
EndIf
Re: Paste as comment
Posted: Wed Mar 09, 2016 9:58 am
by Michael Vogel
Okay, one more iteration (hold 'ctrl' to change behaviour)...
Code: Select all
; Tool "ClipInsert" Written by Michael Vogel and Kenmo
; Command Line: %COMPILEFILE\..\Catalogs\Tool ClipComment.exe
; Working Directory: %COMPILEFILE\..
; Name: Insert Clipboard as Comment...
; Run Hidden
Define.s in,out
#Scintilla= 1
#Prefix= ";"+#TAB$
CompilerIf #Scintilla
Ok=Val(GetEnvironmentVariable("PB_TOOL_Scintilla"))
CompilerElse
Ok=#True
CompilerEndIf
in=GetClipboardText()
If in And Ok
out=ReplaceString(in,#CRLF$,#CR$)
out=#Prefix + ReplaceString(out,#CR$,#CR$ + #Prefix)
If Right(out,1)<>#CR$
out+#CR$
EndIf
If GetKeyState_(#VK_CONTROL)&128
out=ReplaceString(out,#CR$+#Prefix+#CR$,#CR$+#CR$)
EndIf
SetClipboardText(out)
CompilerIf #Scintilla
SendMessage_(Ok,#SCI_PASTE,0,0)
CompilerElse
keybd_event_(#VK_CONTROL,1,0,0)
keybd_event_(#VK_V,1,0,0)
keybd_event_(#VK_V,1,2,0)
keybd_event_(#VK_CONTROL,1,2,0)
CompilerEndIf
SetClipboardText(in)
EndIf
Re: Paste as comment
Posted: Sun Nov 26, 2017 9:53 pm
by Lunasole
Nice.
I've used Kenmo variant (additionally added #LFCR$ to replace), other works fine too
Re: Paste as comment
Posted: Tue Jul 07, 2020 4:40 pm
by kenmo
Implemented in PB 5.72 IDE, so we don't need tools which disrupt the clipboard anymore

Re: Paste as comment
Posted: Tue Jul 07, 2020 9:50 pm
by Demivec
kenmo wrote:Implemented in PB 5.72 IDE, so we don't need tools which disrupt the clipboard anymore

This was already implemented
as a right- click option in the IDE previous to it going open source.
Re: Paste as comment
Posted: Wed Jul 08, 2020 3:55 am
by leonhardt
select all,Ctlr+B . doesn't work?