aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorStephen Blott2015-01-28 14:00:38 +0000
committerStephen Blott2015-01-28 17:30:08 +0000
commitd6450ed2122c3bf539c9ea837d4423a69f043a68 (patch)
tree3961ea0a1302347b9fbab8ed399e668a2e87f74f /lib
parent786b8ba0854b71e7bee00248b3ee29da357ba8d0 (diff)
downloadvimium-d6450ed2122c3bf539c9ea837d4423a69f043a68.tar.bz2
Visual/edit modes: fix some movements...
Also, change how vim's "w" is implemented. Also some code-review/cleanup. Better dd and yy for gmail.
Diffstat (limited to 'lib')
-rw-r--r--lib/dom_utils.coffee14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index c1ce051f..9360bb95 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -236,6 +236,20 @@ DomUtils =
event.initTextEvent "textInput", true, true, null, text
element.dispatchEvent event
+ # Adapted from: http://roysharon.com/blog/37.
+ # This finds the element containing the selection focus.
+ getElementWithFocus: (selection, backwards) ->
+ r = t = selection.getRangeAt 0
+ if selection.type == "Range"
+ r = t.cloneRange()
+ r.collapse backwards
+ t = r.startContainer
+ t = t.childNodes[r.startOffset] if t.nodeType == 1
+ o = t
+ o = o.previousSibling while o and o.nodeType != 1
+ t = o || t?.parentNode
+ t
+
extend DomUtils,
# From: https://github.com/component/textarea-caret-position/blob/master/index.js
getCaretCoordinates: do ->