MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / Vim

Function Vim

lib/web/CodeMirror/keymap/vim.js:252–5712  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

250 var Pos = CodeMirror.Pos;
251
252 var Vim = function() {
253 function enterVimMode(cm) {
254 cm.setOption('disableInput', true);
255 cm.setOption('showCursorWhenSelecting', false);
256 CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"});
257 cm.on('cursorActivity', onCursorActivity);
258 maybeInitVimState(cm);
259 CodeMirror.on(cm.getInputField(), 'paste', getOnPasteFn(cm));
260 }
261
262 function leaveVimMode(cm) {
263 cm.setOption('disableInput', false);
264 cm.off('cursorActivity', onCursorActivity);
265 CodeMirror.off(cm.getInputField(), 'paste', getOnPasteFn(cm));
266 cm.state.vim = null;
267 }
268
269 function detachVimMap(cm, next) {
270 if (this == CodeMirror.keyMap.vim) {
271 CodeMirror.rmClass(cm.getWrapperElement(), "cm-fat-cursor");
272 if (cm.getOption("inputStyle") == "contenteditable" && document.body.style.caretColor != null) {
273 disableFatCursorMark(cm);
274 cm.getInputField().style.caretColor = "";
275 }
276 }
277
278 if (!next || next.attach != attachVimMap)
279 leaveVimMode(cm);
280 }
281 function attachVimMap(cm, prev) {
282 if (this == CodeMirror.keyMap.vim) {
283 CodeMirror.addClass(cm.getWrapperElement(), "cm-fat-cursor");
284 if (cm.getOption("inputStyle") == "contenteditable" && document.body.style.caretColor != null) {
285 enableFatCursorMark(cm);
286 cm.getInputField().style.caretColor = "transparent";
287 }
288 }
289
290 if (!prev || prev.attach != attachVimMap)
291 enterVimMode(cm);
292 }
293
294 function updateFatCursorMark(cm) {
295 if (!cm.state.fatCursorMarks) return;
296 clearFatCursorMark(cm);
297 var ranges = cm.listSelections(), result = []
298 for (var i = 0; i < ranges.length; i++) {
299 var range = ranges[i];
300 if (range.empty()) {
301 var lineLength = cm.getLine(range.anchor.line).length;
302 if (range.anchor.ch < lineLength) {
303 result.push(cm.markText(range.anchor, Pos(range.anchor.line, range.anchor.ch + 1),
304 {className: "cm-fat-cursor-mark"}));
305 } else {
306 result.push(cm.markText(Pos(range.anchor.line, lineLength - 1),
307 Pos(range.anchor.line, lineLength),
308 {className: "cm-fat-cursor-mark"}));
309 }

Callers 1

vim.jsFile · 0.85

Calls 15

matchMethod · 0.95
eatWhileMethod · 0.95
eatMethod · 0.95
nextMethod · 0.95
backUpMethod · 0.95
eolMethod · 0.95
eatSpaceMethod · 0.95
makeKeyRangeFunction · 0.85
defineOptionFunction · 0.85
toCtxArrayFunction · 0.85
maybeInitVimStateFunction · 0.85
handleKeyInsertModeFunction · 0.85

Tested by

no test coverage detected