[Vimperator] patch for 'shift-insert' -> paste from clipboard
calmar
mac at calmar.ws
Sat Jul 7 12:59:52 PDT 2007
Hi,
I added a patch for allowing shift-insert-pasting.
Maybe it's necesssary to make it more flexible instad of
hard-coding that keybinding.
too much for me actually, but probably I could learn about it when
someone would do that additionally.
cheers
marco
--
(o_ It rocks: LINUX + Command-Line-Interface
//\
V_/_ http://www.calmar.ws
-------------- next part --------------
? chrome/vimperator.jar
? chrome/content/vimperator/.vimperator.js.swp
? chrome/content/vimperator/shift-insert.patch
Index: chrome/content/vimperator/vimperator.js
===================================================================
RCS file: /cvs/vimperator/src/chrome/content/vimperator/vimperator.js,v
retrieving revision 1.90
diff -u -r1.90 vimperator.js
--- chrome/content/vimperator/vimperator.js 5 Jul 2007 06:48:15 -0000 1.90
+++ chrome/content/vimperator/vimperator.js 7 Jul 2007 19:57:12 -0000
@@ -483,7 +483,27 @@
// XXX: for now only, later: input mappings if form element focused
if (isFormElemFocused())
+ {
+ if (key == "<S-Insert>")
+ {
+ var elt = window.document.commandDispatcher.focusedElement;
+
+ if(elt.setSelectionRange) // to check if it's a selection?
+ {
+ var rangeStart = elt.selectionStart; // caret position
+ var rangeEnd = elt.selectionEnd;
+ var tempStr1 = elt.value.substring(0,rangeStart);
+ var tempStr2 = readFromClipboard();
+ var tempStr3 = elt.value.substring(rangeEnd);
+ elt.value = tempStr1 + tempStr2 + tempStr3;
+ elt.selectionStart = rangeStart + tempStr2.length;
+ elt.selectionEnd = elt.selectionStart;
+ }
+ }
+
return false;
+ }
+
// handle Escape-one-key mode (Ctrl-v)
if (vimperator.hasMode(vimperator.modes.ESCAPE_ONE_KEY) && !vimperator.hasMode(vimperator.modes.ESCAPE_ALL_KEYS))
@@ -813,6 +833,8 @@
key = "PageUp";
else if (this.keyCode == KeyEvent.DOM_VK_PAGE_DOWN)
key = "PageDown";
+ else if (this.keyCode == KeyEvent.DOM_VK_INSERT)
+ key = "Insert";
else if (this.keyCode == KeyEvent.DOM_VK_F1)
key = "F1";
else if (this.keyCode == KeyEvent.DOM_VK_F2)
More information about the Vimperator
mailing list