(cm, vim)
| 14251 | vim.fakeCursor = cm.markText(from, to, {className: 'cm-animate-fat-cursor'}); |
| 14252 | } |
| 14253 | function handleExternalSelection(cm, vim) { |
| 14254 | var anchor = cm.getCursor('anchor'); |
| 14255 | var head = cm.getCursor('head'); |
| 14256 | // Enter or exit visual mode to match mouse selection. |
| 14257 | if (vim.visualMode && !cm.somethingSelected()) { |
| 14258 | exitVisualMode(cm, false); |
| 14259 | } else if (!vim.visualMode && !vim.insertMode && cm.somethingSelected()) { |
| 14260 | vim.visualMode = true; |
| 14261 | vim.visualLine = false; |
| 14262 | CodeMirror.signal(cm, "vim-mode-change", {mode: "visual"}); |
| 14263 | } |
| 14264 | if (vim.visualMode) { |
| 14265 | // Bind CodeMirror selection model to vim selection model. |
| 14266 | // Mouse selections are considered visual characterwise. |
| 14267 | var headOffset = !cursorIsBefore(head, anchor) ? -1 : 0; |
| 14268 | var anchorOffset = cursorIsBefore(head, anchor) ? -1 : 0; |
| 14269 | head = offsetCursor(head, 0, headOffset); |
| 14270 | anchor = offsetCursor(anchor, 0, anchorOffset); |
| 14271 | vim.sel = { |
| 14272 | anchor: anchor, |
| 14273 | head: head |
| 14274 | }; |
| 14275 | updateMark(cm, vim, '<', cursorMin(head, anchor)); |
| 14276 | updateMark(cm, vim, '>', cursorMax(head, anchor)); |
| 14277 | } else if (!vim.insertMode) { |
| 14278 | // Reset lastHPos if selection was modified by something outside of vim mode e.g. by mouse. |
| 14279 | vim.lastHPos = cm.getCursor().ch; |
| 14280 | } |
| 14281 | } |
| 14282 | |
| 14283 | /** Wrapper for special keys pressed in insert mode */ |
| 14284 | function InsertModeKey(keyName) { |
no test coverage detected