Paste as comment
Paste as comment
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.
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.
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Paste as comment
+1 would be good
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Paste as comment
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.
-
- Addict
- Posts: 4519
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Paste as comment
+1
That would be helpful, indeed.
That would be helpful, indeed.
- Michael Vogel
- Addict
- Posts: 2666
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Paste as comment
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)
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Paste as comment
..... Very nice Michael.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Paste as comment
+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)
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
- Michael Vogel
- Addict
- Posts: 2666
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Paste as comment
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
Nice.
I've used Kenmo variant (additionally added #LFCR$ to replace), other works fine too
I've used Kenmo variant (additionally added #LFCR$ to replace), other works fine too
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Re: Paste as comment
Implemented in PB 5.72 IDE, so we don't need tools which disrupt the clipboard anymore
Re: Paste as comment
This was already implemented as a right- click option in the IDE previous to it going open source.kenmo wrote:Implemented in PB 5.72 IDE, so we don't need tools which disrupt the clipboard anymore