Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » override copy action of editorpart (CopyCurrentLine)
override copy action of editorpart (CopyCurrentLine) [message #54363] Fri, 10 April 2009 12:44 Go to next message
lembas  is currently offline lembas Friend
Messages: 13
Registered: July 2009
Junior Member
Hi,

I want to write a small plugin for eclipse. It is name is CopyCurrentLine.

As the name implies, When I press ctrl-c or call the copy action via context
menu, I want to copy the current line when nothing is selected by the user.
(like in visual studio)

How can I catch the copy action of an editorpart?

Thanks
Ken
Re: override copy action of editorpart (CopyCurrentLine) [message #54391 is a reply to message #54363] Fri, 10 April 2009 13:04 Go to previous messageGo to next message
Ankur Sharma is currently offline Ankur SharmaFriend
Messages: 84
Registered: July 2009
Member
Kerem wrote:
> Hi,
>
> I want to write a small plugin for eclipse. It is name is CopyCurrentLine.
>
> As the name implies, When I press ctrl-c or call the copy action via context
> menu, I want to copy the current line when nothing is selected by the user.
> (like in visual studio)
>
> How can I catch the copy action of an editorpart?
>
> Thanks
> Ken
>
>


You've got 2 options

1. Go to Window -> Preferences -> General -> Keys
Scroll down to find "Copy all from left to right".
This, by default, has no key binding. Add one of your liking.
Use it with Home (takes cursor to start of line).
Save yourself from writing a plug-in.

2. If you want a shorted Key binding, you will have to write a plugin
Need not catch the copy action. Just contribute to the extension "org.eclipse.ui.bindings"
And have a key binding of you liking.

--
hth,
Ankur..
Re: override copy action of editorpart (CopyCurrentLine) [message #54417 is a reply to message #54391] Fri, 10 April 2009 13:32 Go to previous messageGo to next message
lembas  is currently offline lembas Friend
Messages: 13
Registered: July 2009
Junior Member
Ankur thank you for your answer.
But in either case I cannot bind ctrl-c to that command. I have to bind
another key.
Isn't there a way to catch copy action?
Or can I change the handler of the copy command "org.eclipse.ui.edit.copy"?

"Ankur Sharma" <sharma.ankur@gmail.com> wrote in message
news:grng43$iph$1@build.eclipse.org...
> Kerem wrote:
>> Hi,
>>
>> I want to write a small plugin for eclipse. It is name is
>> CopyCurrentLine.
>>
>> As the name implies, When I press ctrl-c or call the copy action via
>> context menu, I want to copy the current line when nothing is selected by
>> the user. (like in visual studio)
>>
>> How can I catch the copy action of an editorpart?
>>
>> Thanks
>> Ken
>
>
> You've got 2 options
>
> 1. Go to Window -> Preferences -> General -> Keys
> Scroll down to find "Copy all from left to right".
> This, by default, has no key binding. Add one of your liking.
> Use it with Home (takes cursor to start of line).
> Save yourself from writing a plug-in.
>
> 2. If you want a shorted Key binding, you will have to write a plugin
> Need not catch the copy action. Just contribute to the extension
> "org.eclipse.ui.bindings"
> And have a key binding of you liking.
>
> --
> hth,
> Ankur..
Re: override copy action of editorpart (CopyCurrentLine) [message #54445 is a reply to message #54417] Fri, 10 April 2009 17:07 Go to previous messageGo to next message
Ankur Sharma is currently offline Ankur SharmaFriend
Messages: 84
Registered: July 2009
Member
Kerem wrote:
> Ankur thank you for your answer.
> But in either case I cannot bind ctrl-c to that command. I have to bind
> another key.
> Isn't there a way to catch copy action?
> Or can I change the handler of the copy command "org.eclipse.ui.edit.copy"?
>

I am new to commands and really don't know how to hook or override and existing handler. Perhaps some SWT gurus at eclipse.platform.swt newsgroup can help you better than I can.

Sidenote: Why after Ctrl+C ? A similar one wont do? like Alt + C or Ctrl + Alt + C
--
hth,
Ankur..
Re: override copy action of editorpart (CopyCurrentLine) [message #60115 is a reply to message #54391] Thu, 07 May 2009 12:09 Go to previous message
lembas  is currently offline lembas Friend
Messages: 13
Registered: July 2009
Junior Member
Thanks for your help.
I have implemented it on http://copycutcurrentline.googlecode.com/

Copy/Cut current line in Eclipse as in .NET

What is it?
Press Ctrl-C to copy the whole line in an editor when you select nothing.
It works as usual when you select something. And paste anywhere with Ctrl-V.
Works on Linux. Should work on Mac but not tested.

Download
- Eclipse Update Site
If you are already familiar with installing Eclipse plugins, you can just
use the update site URL below.
http://copycutcurrentline.googlecode.com/svn/trunk/
Tested for Java 6 and above. Tested for Eclipse 3.4 and above.

- Manual Download
Copy
http://copycutcurrentline.googlecode.com/svn/trunk/plugins/c om.lembas.CopyCutCurrentLine_1.0.0.jar
into your dropins folder and restart Eclipse.

"Ankur Sharma" <sharma.ankur@gmail.com> wrote in message
news:grng43$iph$1@build.eclipse.org...
> Kerem wrote:
>> Hi,
>>
>> I want to write a small plugin for eclipse. It is name is
>> CopyCurrentLine.
>>
>> As the name implies, When I press ctrl-c or call the copy action via
>> context menu, I want to copy the current line when nothing is selected by
>> the user. (like in visual studio)
>>
>> How can I catch the copy action of an editorpart?
>>
>> Thanks
>> Ken
>
>
> You've got 2 options
>
> 1. Go to Window -> Preferences -> General -> Keys
> Scroll down to find "Copy all from left to right".
> This, by default, has no key binding. Add one of your liking.
> Use it with Home (takes cursor to start of line).
> Save yourself from writing a plug-in.
>
> 2. If you want a shorted Key binding, you will have to write a plugin
> Need not catch the copy action. Just contribute to the extension
> "org.eclipse.ui.bindings"
> And have a key binding of you liking.
>
> --
> hth,
> Ankur..
Re: override copy action of editorpart (CopyCurrentLine) [message #594892 is a reply to message #54363] Fri, 10 April 2009 13:04 Go to previous message
Ankur Sharma is currently offline Ankur SharmaFriend
Messages: 84
Registered: July 2009
Member
Kerem wrote:
> Hi,
>
> I want to write a small plugin for eclipse. It is name is CopyCurrentLine.
>
> As the name implies, When I press ctrl-c or call the copy action via context
> menu, I want to copy the current line when nothing is selected by the user.
> (like in visual studio)
>
> How can I catch the copy action of an editorpart?
>
> Thanks
> Ken
>
>


You've got 2 options

1. Go to Window -> Preferences -> General -> Keys
Scroll down to find "Copy all from left to right".
This, by default, has no key binding. Add one of your liking.
Use it with Home (takes cursor to start of line).
Save yourself from writing a plug-in.

2. If you want a shorted Key binding, you will have to write a plugin
Need not catch the copy action. Just contribute to the extension "org.eclipse.ui.bindings"
And have a key binding of you liking.

--
hth,
Ankur..
Re: override copy action of editorpart (CopyCurrentLine) [message #594900 is a reply to message #54391] Fri, 10 April 2009 13:32 Go to previous message
lembas  is currently offline lembas Friend
Messages: 13
Registered: July 2009
Junior Member
Ankur thank you for your answer.
But in either case I cannot bind ctrl-c to that command. I have to bind
another key.
Isn't there a way to catch copy action?
Or can I change the handler of the copy command "org.eclipse.ui.edit.copy"?

"Ankur Sharma" <sharma.ankur@gmail.com> wrote in message
news:grng43$iph$1@build.eclipse.org...
> Kerem wrote:
>> Hi,
>>
>> I want to write a small plugin for eclipse. It is name is
>> CopyCurrentLine.
>>
>> As the name implies, When I press ctrl-c or call the copy action via
>> context menu, I want to copy the current line when nothing is selected by
>> the user. (like in visual studio)
>>
>> How can I catch the copy action of an editorpart?
>>
>> Thanks
>> Ken
>
>
> You've got 2 options
>
> 1. Go to Window -> Preferences -> General -> Keys
> Scroll down to find "Copy all from left to right".
> This, by default, has no key binding. Add one of your liking.
> Use it with Home (takes cursor to start of line).
> Save yourself from writing a plug-in.
>
> 2. If you want a shorted Key binding, you will have to write a plugin
> Need not catch the copy action. Just contribute to the extension
> "org.eclipse.ui.bindings"
> And have a key binding of you liking.
>
> --
> hth,
> Ankur..
Re: override copy action of editorpart (CopyCurrentLine) [message #594911 is a reply to message #54417] Fri, 10 April 2009 17:07 Go to previous message
Ankur Sharma is currently offline Ankur SharmaFriend
Messages: 84
Registered: July 2009
Member
Kerem wrote:
> Ankur thank you for your answer.
> But in either case I cannot bind ctrl-c to that command. I have to bind
> another key.
> Isn't there a way to catch copy action?
> Or can I change the handler of the copy command "org.eclipse.ui.edit.copy"?
>

I am new to commands and really don't know how to hook or override and existing handler. Perhaps some SWT gurus at eclipse.platform.swt newsgroup can help you better than I can.

Sidenote: Why after Ctrl+C ? A similar one wont do? like Alt + C or Ctrl + Alt + C
--
hth,
Ankur..
Re: override copy action of editorpart (CopyCurrentLine) [message #596996 is a reply to message #54391] Thu, 07 May 2009 12:09 Go to previous message
lembas  is currently offline lembas Friend
Messages: 13
Registered: July 2009
Junior Member
Thanks for your help.
I have implemented it on http://copycutcurrentline.googlecode.com/

Copy/Cut current line in Eclipse as in .NET

What is it?
Press Ctrl-C to copy the whole line in an editor when you select nothing.
It works as usual when you select something. And paste anywhere with Ctrl-V.
Works on Linux. Should work on Mac but not tested.

Download
- Eclipse Update Site
If you are already familiar with installing Eclipse plugins, you can just
use the update site URL below.
http://copycutcurrentline.googlecode.com/svn/trunk/
Tested for Java 6 and above. Tested for Eclipse 3.4 and above.

- Manual Download
Copy
http://copycutcurrentline.googlecode.com/svn/trunk/plugins/c om.lembas.CopyCutCurrentLine_1.0.0.jar
into your dropins folder and restart Eclipse.

"Ankur Sharma" <sharma.ankur@gmail.com> wrote in message
news:grng43$iph$1@build.eclipse.org...
> Kerem wrote:
>> Hi,
>>
>> I want to write a small plugin for eclipse. It is name is
>> CopyCurrentLine.
>>
>> As the name implies, When I press ctrl-c or call the copy action via
>> context menu, I want to copy the current line when nothing is selected by
>> the user. (like in visual studio)
>>
>> How can I catch the copy action of an editorpart?
>>
>> Thanks
>> Ken
>
>
> You've got 2 options
>
> 1. Go to Window -> Preferences -> General -> Keys
> Scroll down to find "Copy all from left to right".
> This, by default, has no key binding. Add one of your liking.
> Use it with Home (takes cursor to start of line).
> Save yourself from writing a plug-in.
>
> 2. If you want a shorted Key binding, you will have to write a plugin
> Need not catch the copy action. Just contribute to the extension
> "org.eclipse.ui.bindings"
> And have a key binding of you liking.
>
> --
> hth,
> Ankur..
Previous Topic:Issue in building feature by fetching it from repository
Next Topic:3.5M7 - Problem setting transform start levels
Goto Forum:
  


Current Time: Mon Jun 14 16:09:03 GMT 2021

Powered by FUDForum. Page generated in 0.01783 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top