Automatically put text into clipboard when yanking
Review Request #109512 - Created March 15, 2013 and submitted
This patch adds yanked text to the clipboard when no specific register was specified. Unfortunately, it can't be used for the deletion commnands. Support for them could be easily added in KateViModeBase::deleteRange (the yankToClipBoard function would then moved there).However that would require including the needed header in KateViModeBase. As I'm not sure if this is a good idea, and would like to hear your opinion on this. I'd also like to hear if you have a better idea where this could be implemented. Last but not least, there aren't unit tests for my code at the moment. I'd like to write some, but I couldn't find documentation about them so far.
compiled and run; worked as intended
|If you make this: QApplication::clipboard()->setText(text); you do not need the member variable m_clipboard at all. Or do I miss something?||Dominik Haumann|
|make it #include "kateglobal.h" if you use KateGlobal::copyToClipboard().||Dominik Haumann|
|I just stumbled over void KateGlobal::copyToClipboard (const QString &text) which provides a clipboard history. I suggest to use this instead ...||Dominik Haumann|
I think this *is* a good idea. If we put deletions in the clipboard too, it will mean that every little “x” or “d” command, no matter how small will end up in the clipboard, these will often be useless. Not sure if this really is a problem, though.
Review request changed
Moved yankToClipBoard function to katevimodebase to additionally support deletion options. Added a length > 1 check (because I assume that if you only yank/delete one character, you'd normally type it again rather than pasting it if you want to have it at another place).
Revision 3 (+23 -5)
make it #include "kateglobal.h" if you use KateGlobal::copyToClipboard().
I just stumbled over void KateGlobal::copyToClipboard (const QString &text) which provides a clipboard history. I suggest to use this instead of QApplication::clipboard(). The clipboard history is also accessible through the context menu in text views.