You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2013/10/30 14:43:29 UTC
[35/52] [partial] Remove unneeded ace files and codemirror
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/keyboard/keybinding_test.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/keyboard/keybinding_test.js b/src/fauxton/assets/js/libs/ace/keyboard/keybinding_test.js
deleted file mode 100644
index 617d99c..0000000
--- a/src/fauxton/assets/js/libs/ace/keyboard/keybinding_test.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-if (typeof process !== "undefined") {
- require("amd-loader");
-}
-
-define(function(require, exports, module) {
-"use strict";
-
-var EditSession = require("./../edit_session").EditSession,
- Editor = require("./../editor").Editor,
- MockRenderer = require("./../test/mockrenderer").MockRenderer,
- assert = require("./../test/assertions"),
- HashHandler = require('./hash_handler').HashHandler,
- keys = require('../lib/keys'),
- editor;
-
-function initEditor(docString) {
- var doc = new EditSession(docString.split("\n"));
- editor = new Editor(new MockRenderer(), doc);
-}
-
-module.exports = {
-
- "test: adding a new keyboard handler does not remove the default handler": function() {
- initEditor('abc');
- var handler = new HashHandler({'del': 'f1'});
- editor.keyBinding.setKeyboardHandler(handler);
- editor.onCommandKey({}, 0, keys['f1']);
- assert.equal('bc', editor.getValue(), "binding of new handler");
- editor.onCommandKey({}, 0, keys['delete']);
- assert.equal('c', editor.getValue(), "bindings of the old handler should still work");
- }
-
-};
-
-});
-
-if (typeof module !== "undefined" && module === require.main) {
- require("asyncjs").test.testcase(module.exports).exec()
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/keyboard/state_handler.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/keyboard/state_handler.js b/src/fauxton/assets/js/libs/ace/keyboard/state_handler.js
deleted file mode 100644
index 8265bbe..0000000
--- a/src/fauxton/assets/js/libs/ace/keyboard/state_handler.js
+++ /dev/null
@@ -1,249 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define(function(require, exports, module) {
-"use strict";
-
-// If you're developing a new keymapping and want to get an idea what's going
-// on, then enable debugging.
-var DEBUG = false;
-
-function StateHandler(keymapping) {
- this.keymapping = this.$buildKeymappingRegex(keymapping);
-}
-
-StateHandler.prototype = {
- /*
- * Build the RegExp from the keymapping as RegExp can't stored directly
- * in the metadata JSON and as the RegExp used to match the keys/buffer
- * need to be adapted.
- */
- $buildKeymappingRegex: function(keymapping) {
- for (var state in keymapping) {
- this.$buildBindingsRegex(keymapping[state]);
- }
- return keymapping;
- },
-
- $buildBindingsRegex: function(bindings) {
- // Escape a given Regex string.
- bindings.forEach(function(binding) {
- if (binding.key) {
- binding.key = new RegExp('^' + binding.key + '$');
- } else if (Array.isArray(binding.regex)) {
- if (!('key' in binding))
- binding.key = new RegExp('^' + binding.regex[1] + '$');
- binding.regex = new RegExp(binding.regex.join('') + '$');
- } else if (binding.regex) {
- binding.regex = new RegExp(binding.regex + '$');
- }
- });
- },
-
- $composeBuffer: function(data, hashId, key, e) {
- // Initialize the data object.
- if (data.state == null || data.buffer == null) {
- data.state = "start";
- data.buffer = "";
- }
-
- var keyArray = [];
- if (hashId & 1) keyArray.push("ctrl");
- if (hashId & 8) keyArray.push("command");
- if (hashId & 2) keyArray.push("option");
- if (hashId & 4) keyArray.push("shift");
- if (key) keyArray.push(key);
-
- var symbolicName = keyArray.join("-");
- var bufferToUse = data.buffer + symbolicName;
-
- // Don't add the symbolic name to the key buffer if the alt_ key is
- // part of the symbolic name. If it starts with alt_, this means
- // that the user hit an alt keycombo and there will be a single,
- // new character detected after this event, which then will be
- // added to the buffer (e.g. alt_j will result in ∆).
- //
- // We test for 2 and not for & 2 as we only want to exclude the case where
- // the option key is pressed alone.
- if (hashId != 2) {
- data.buffer = bufferToUse;
- }
-
- var bufferObj = {
- bufferToUse: bufferToUse,
- symbolicName: symbolicName
- };
-
- if (e) {
- bufferObj.keyIdentifier = e.keyIdentifier;
- }
-
- return bufferObj;
- },
-
- $find: function(data, buffer, symbolicName, hashId, key, keyIdentifier) {
- // Holds the command to execute and the args if a command matched.
- var result = {};
-
- // Loop over all the bindings of the keymap until a match is found.
- this.keymapping[data.state].some(function(binding) {
- var match;
-
- // Check if the key matches.
- if (binding.key && !binding.key.test(symbolicName)) {
- return false;
- }
-
- // Check if the regex matches.
- if (binding.regex && !(match = binding.regex.exec(buffer))) {
- return false;
- }
-
- // Check if the match function matches.
- if (binding.match && !binding.match(buffer, hashId, key, symbolicName, keyIdentifier)) {
- return false;
- }
-
- // Check for disallowed matches.
- if (binding.disallowMatches) {
- for (var i = 0; i < binding.disallowMatches.length; i++) {
- if (!!match[binding.disallowMatches[i]]) {
- return false;
- }
- }
- }
-
- // If there is a command to execute, then figure out the
- // command and the arguments.
- if (binding.exec) {
- result.command = binding.exec;
-
- // Build the arguments.
- if (binding.params) {
- var value;
- result.args = {};
- binding.params.forEach(function(param) {
- if (param.match != null && match != null) {
- value = match[param.match] || param.defaultValue;
- } else {
- value = param.defaultValue;
- }
-
- if (param.type === 'number') {
- value = parseInt(value);
- }
-
- result.args[param.name] = value;
- });
- }
- data.buffer = "";
- }
-
- // Handle the 'then' property.
- if (binding.then) {
- data.state = binding.then;
- data.buffer = "";
- }
-
- // If no command is set, then execute the "null" fake command.
- if (result.command == null) {
- result.command = "null";
- }
-
- if (DEBUG) {
- console.log("KeyboardStateMapper#find", binding);
- }
- return true;
- });
-
- if (result.command) {
- return result;
- } else {
- data.buffer = "";
- return false;
- }
- },
-
- /*
- * This function is called by keyBinding.
- */
- handleKeyboard: function(data, hashId, key, keyCode, e) {
- if (hashId == -1)
- hashId = 0
- // If we pressed any command key but no other key, then ignore the input.
- // Otherwise "shift-" is added to the buffer, and later on "shift-g"
- // which results in "shift-shift-g" which doesn't make sense.
- if (hashId != 0 && (key == "" || key == String.fromCharCode(0))) {
- return null;
- }
-
- // Compute the current value of the keyboard input buffer.
- var r = this.$composeBuffer(data, hashId, key, e);
- var buffer = r.bufferToUse;
- var symbolicName = r.symbolicName;
- var keyId = r.keyIdentifier;
-
- r = this.$find(data, buffer, symbolicName, hashId, key, keyId);
- if (DEBUG) {
- console.log("KeyboardStateMapper#match", buffer, symbolicName, r);
- }
-
- return r;
- }
-}
-
-/*
- * This is a useful matching function and therefore is defined here so that
- * users of KeyboardStateMapper can use it.
- *
- * @return {Boolean} If no command key (Command|Option|Shift|Ctrl) is pressed, it
- * returns true. If the only the Shift key is pressed + a character
- * true is returned as well. Otherwise, false is returned.
- * Summing up, the function returns true whenever the user typed
- * a normal character on the keyboard and no shortcut.
- */
-exports.matchCharacterOnly = function(buffer, hashId, key, symbolicName) {
- // If no command keys are pressed, then catch the input.
- if (hashId == 0) {
- return true;
- }
- // If only the shift key is pressed and a character key, then
- // catch that input as well.
- else if ((hashId == 4) && key.length == 1) {
- return true;
- }
- // Otherwise, we let the input got through.
- else {
- return false;
- }
-};
-
-exports.StateHandler = StateHandler;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/keyboard/textinput.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/keyboard/textinput.js b/src/fauxton/assets/js/libs/ace/keyboard/textinput.js
deleted file mode 100644
index ee09b20..0000000
--- a/src/fauxton/assets/js/libs/ace/keyboard/textinput.js
+++ /dev/null
@@ -1,503 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define(function(require, exports, module) {
-"use strict";
-
-var event = require("../lib/event");
-var useragent = require("../lib/useragent");
-var dom = require("../lib/dom");
-var lang = require("../lib/lang");
-var BROKEN_SETDATA = useragent.isChrome < 18;
-
-var TextInput = function(parentNode, host) {
- var text = dom.createElement("textarea");
- text.className = "ace_text-input";
-
- if (useragent.isTouchPad)
- text.setAttribute("x-palm-disable-auto-cap", true);
-
- text.wrap = "off";
- text.autocorrect = "off";
- text.autocapitalize = "off";
- text.spellcheck = false;
-
- text.style.opacity = "0";
- parentNode.insertBefore(text, parentNode.firstChild);
-
- var PLACEHOLDER = "\x01\x01";
-
- var cut = false;
- var copied = false;
- var pasted = false;
- var inComposition = false;
- var tempStyle = '';
- var isSelectionEmpty = true;
-
- // FOCUS
- // ie9 throws error if document.activeElement is accessed too soon
- try { var isFocused = document.activeElement === text; } catch(e) {}
-
- event.addListener(text, "blur", function() {
- host.onBlur();
- isFocused = false;
- });
- event.addListener(text, "focus", function() {
- isFocused = true;
- host.onFocus();
- resetSelection();
- });
- this.focus = function() { text.focus(); };
- this.blur = function() { text.blur(); };
- this.isFocused = function() {
- return isFocused;
- };
-
- // modifying selection of blured textarea can focus it (chrome mac/linux)
- var syncSelection = lang.delayedCall(function() {
- isFocused && resetSelection(isSelectionEmpty);
- });
- var syncValue = lang.delayedCall(function() {
- if (!inComposition) {
- text.value = PLACEHOLDER;
- isFocused && resetSelection();
- }
- });
-
- function resetSelection(isEmpty) {
- if (inComposition)
- return;
- if (inputHandler) {
- selectionStart = 0;
- selectionEnd = isEmpty ? 0 : text.value.length - 1;
- } else {
- var selectionStart = isEmpty ? 2 : 1;
- var selectionEnd = 2;
- }
- // on firefox this throws if textarea is hidden
- try {
- text.setSelectionRange(selectionStart, selectionEnd);
- } catch(e){}
- }
-
- function resetValue() {
- if (inComposition)
- return;
- text.value = PLACEHOLDER;
- //http://code.google.com/p/chromium/issues/detail?id=76516
- if (useragent.isWebKit)
- syncValue.schedule();
- }
-
- useragent.isWebKit || host.addEventListener('changeSelection', function() {
- if (host.selection.isEmpty() != isSelectionEmpty) {
- isSelectionEmpty = !isSelectionEmpty;
- syncSelection.schedule();
- }
- });
-
- resetValue();
- if (isFocused)
- host.onFocus();
-
-
- var isAllSelected = function(text) {
- return text.selectionStart === 0 && text.selectionEnd === text.value.length;
- };
- // IE8 does not support setSelectionRange
- if (!text.setSelectionRange && text.createTextRange) {
- text.setSelectionRange = function(selectionStart, selectionEnd) {
- var range = this.createTextRange();
- range.collapse(true);
- range.moveStart('character', selectionStart);
- range.moveEnd('character', selectionEnd);
- range.select();
- };
- isAllSelected = function(text) {
- try {
- var range = text.ownerDocument.selection.createRange();
- }catch(e) {}
- if (!range || range.parentElement() != text) return false;
- return range.text == text.value;
- }
- }
- if (useragent.isOldIE) {
- var inPropertyChange = false;
- var onPropertyChange = function(e){
- if (inPropertyChange)
- return;
- var data = text.value;
- if (inComposition || !data || data == PLACEHOLDER)
- return;
- // can happen either after delete or during insert operation
- if (e && data == PLACEHOLDER[0])
- return syncProperty.schedule();
-
- sendText(data);
- // ie8 calls propertychange handlers synchronously!
- inPropertyChange = true;
- resetValue();
- inPropertyChange = false;
- };
- var syncProperty = lang.delayedCall(onPropertyChange);
- event.addListener(text, "propertychange", onPropertyChange);
-
- var keytable = { 13:1, 27:1 };
- event.addListener(text, "keyup", function (e) {
- if (inComposition && (!text.value || keytable[e.keyCode]))
- setTimeout(onCompositionEnd, 0);
- if ((text.value.charCodeAt(0)||0) < 129) {
- return syncProperty.call();
- }
- inComposition ? onCompositionUpdate() : onCompositionStart();
- });
- // when user presses backspace after focusing the editor
- // propertychange isn't called for the next character
- event.addListener(text, "keydown", function (e) {
- syncProperty.schedule(50);
- });
- }
-
- var onSelect = function(e) {
- if (cut) {
- cut = false;
- } else if (copied) {
- copied = false;
- } else if (isAllSelected(text)) {
- host.selectAll();
- resetSelection();
- } else if (inputHandler) {
- resetSelection(host.selection.isEmpty());
- }
- };
-
- var inputHandler = null;
- this.setInputHandler = function(cb) {inputHandler = cb};
- this.getInputHandler = function() {return inputHandler};
- var afterContextMenu = false;
-
- var sendText = function(data) {
- if (inputHandler) {
- data = inputHandler(data);
- inputHandler = null;
- }
- if (pasted) {
- resetSelection();
- if (data)
- host.onPaste(data);
- pasted = false;
- } else if (data == PLACEHOLDER.charAt(0)) {
- if (afterContextMenu)
- host.execCommand("del", {source: "ace"});
- } else {
- if (data.substring(0, 2) == PLACEHOLDER)
- data = data.substr(2);
- else if (data.charAt(0) == PLACEHOLDER.charAt(0))
- data = data.substr(1);
- else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
- data = data.slice(0, -1);
- // can happen if undo in textarea isn't stopped
- if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
- data = data.slice(0, -1);
-
- if (data)
- host.onTextInput(data);
- }
- if (afterContextMenu)
- afterContextMenu = false;
- };
- var onInput = function(e) {
- // console.log("onInput", inComposition)
- if (inComposition)
- return;
- var data = text.value;
- sendText(data);
- resetValue();
- };
-
- var onCut = function(e) {
- var data = host.getCopyText();
- if (!data) {
- event.preventDefault(e);
- return;
- }
-
- var clipboardData = e.clipboardData || window.clipboardData;
-
- if (clipboardData && !BROKEN_SETDATA) {
- // Safari 5 has clipboardData object, but does not handle setData()
- var supported = clipboardData.setData("Text", data);
- if (supported) {
- host.onCut();
- event.preventDefault(e);
- }
- }
-
- if (!supported) {
- cut = true;
- text.value = data;
- text.select();
- setTimeout(function(){
- cut = false;
- resetValue();
- resetSelection();
- host.onCut();
- });
- }
- };
-
- var onCopy = function(e) {
- var data = host.getCopyText();
- if (!data) {
- event.preventDefault(e);
- return;
- }
-
- var clipboardData = e.clipboardData || window.clipboardData;
- if (clipboardData && !BROKEN_SETDATA) {
- // Safari 5 has clipboardData object, but does not handle setData()
- var supported = clipboardData.setData("Text", data);
- if (supported) {
- host.onCopy();
- event.preventDefault(e);
- }
- }
- if (!supported) {
- copied = true;
- text.value = data;
- text.select();
- setTimeout(function(){
- copied = false;
- resetValue();
- resetSelection();
- host.onCopy();
- });
- }
- };
-
- var onPaste = function(e) {
- var clipboardData = e.clipboardData || window.clipboardData;
-
- if (clipboardData) {
- var data = clipboardData.getData("Text");
- if (data)
- host.onPaste(data);
- if (useragent.isIE)
- setTimeout(resetSelection);
- event.preventDefault(e);
- }
- else {
- text.value = "";
- pasted = true;
- }
- };
-
- event.addCommandKeyListener(text, host.onCommandKey.bind(host));
-
- event.addListener(text, "select", onSelect);
-
- event.addListener(text, "input", onInput);
-
- event.addListener(text, "cut", onCut);
- event.addListener(text, "copy", onCopy);
- event.addListener(text, "paste", onPaste);
-
-
- // Opera has no clipboard events
- if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)){
- event.addListener(parentNode, "keydown", function(e) {
- if ((useragent.isMac && !e.metaKey) || !e.ctrlKey)
- return;
-
- switch (e.keyCode) {
- case 67:
- onCopy(e);
- break;
- case 86:
- onPaste(e);
- break;
- case 88:
- onCut(e);
- break;
- }
- });
- }
-
-
- // COMPOSITION
- var onCompositionStart = function(e) {
- if (inComposition) return;
- // console.log("onCompositionStart", inComposition)
- inComposition = {};
- host.onCompositionStart();
- setTimeout(onCompositionUpdate, 0);
- host.on("mousedown", onCompositionEnd);
- if (!host.selection.isEmpty()) {
- host.insert("");
- host.session.markUndoGroup();
- host.selection.clearSelection();
- }
- host.session.markUndoGroup();
- };
-
- var onCompositionUpdate = function() {
- // console.log("onCompositionUpdate", inComposition && JSON.stringify(text.value))
- if (!inComposition) return;
- var val = text.value.replace(/\x01/g, "");
- if (inComposition.lastValue === val) return;
-
- host.onCompositionUpdate(val);
- if (inComposition.lastValue)
- host.undo();
- inComposition.lastValue = val;
- if (inComposition.lastValue) {
- var r = host.selection.getRange();
- host.insert(inComposition.lastValue);
- host.session.markUndoGroup();
- inComposition.range = host.selection.getRange();
- host.selection.setRange(r);
- host.selection.clearSelection();
- }
- };
-
- var onCompositionEnd = function(e) {
- // console.log("onCompositionEnd", inComposition &&inComposition.lastValue)
- var c = inComposition;
- inComposition = false;
- var timer = setTimeout(function() {
- timer = null;
- var str = text.value.replace(/\x01/g, "");
- // console.log(str, c.lastValue)
- if (inComposition)
- return
- else if (str == c.lastValue)
- resetValue();
- else if (!c.lastValue && str) {
- resetValue();
- sendText(str);
- }
- });
- inputHandler = function compositionInputHandler(str) {
- // console.log("onCompositionEnd", str, c.lastValue)
- if (timer)
- clearTimeout(timer);
- str = str.replace(/\x01/g, "");
- if (str == c.lastValue)
- return "";
- if (c.lastValue && timer)
- host.undo();
- return str;
- };
- host.onCompositionEnd();
- host.removeListener("mousedown", onCompositionEnd);
- if (e.type == "compositionend" && c.range) {
- host.selection.setRange(c.range);
- }
- };
-
-
-
- var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
-
- event.addListener(text, "compositionstart", onCompositionStart);
- if (useragent.isGecko) {
- event.addListener(text, "text", function(){syncComposition.schedule()});
- } else {
- event.addListener(text, "keyup", function(){syncComposition.schedule()});
- event.addListener(text, "keydown", function(){syncComposition.schedule()});
- }
- event.addListener(text, "compositionend", onCompositionEnd);
-
- this.getElement = function() {
- return text;
- };
-
- this.setReadOnly = function(readOnly) {
- text.readOnly = readOnly;
- };
-
- this.onContextMenu = function(e) {
- afterContextMenu = true;
- if (!tempStyle)
- tempStyle = text.style.cssText;
-
- text.style.cssText = "z-index:100000;" + (useragent.isIE ? "opacity:0.1;" : "");
-
- resetSelection(host.selection.isEmpty());
- host._emit("nativecontextmenu", {target: host, domEvent: e});
- var rect = host.container.getBoundingClientRect();
- var style = dom.computedStyle(host.container);
- var top = rect.top + (parseInt(style.borderTopWidth) || 0);
- var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
- var maxTop = rect.bottom - top - text.clientHeight;
- var move = function(e) {
- text.style.left = e.clientX - left - 2 + "px";
- text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
- };
- move(e);
-
- if (e.type != "mousedown")
- return;
-
- if (host.renderer.$keepTextAreaAtCursor)
- host.renderer.$keepTextAreaAtCursor = null;
-
- // on windows context menu is opened after mouseup
- if (useragent.isWin)
- event.capture(host.container, move, onContextMenuClose);
- };
-
- this.onContextMenuClose = onContextMenuClose;
- function onContextMenuClose() {
- setTimeout(function () {
- if (tempStyle) {
- text.style.cssText = tempStyle;
- tempStyle = '';
- }
- if (host.renderer.$keepTextAreaAtCursor == null) {
- host.renderer.$keepTextAreaAtCursor = true;
- host.renderer.$moveTextAreaToCursor();
- }
- }, 0);
- }
-
- // firefox fires contextmenu event after opening it
- if (!useragent.isGecko || useragent.isMac) {
- var onContextMenu = function(e) {
- host.textInput.onContextMenu(e);
- onContextMenuClose();
- };
- event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
- event.addListener(text, "contextmenu", onContextMenu);
- }
-};
-
-exports.TextInput = TextInput;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/keyboard/vim.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/keyboard/vim.js b/src/fauxton/assets/js/libs/ace/keyboard/vim.js
deleted file mode 100644
index 7af83b0..0000000
--- a/src/fauxton/assets/js/libs/ace/keyboard/vim.js
+++ /dev/null
@@ -1,195 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define(function(require, exports, module) {
-"use strict";
-
-var cmds = require("./vim/commands");
-var coreCommands = cmds.coreCommands;
-var util = require("./vim/maps/util");
-var useragent = require("../lib/useragent");
-
-var startCommands = {
- "i": {
- command: coreCommands.start
- },
- "I": {
- command: coreCommands.startBeginning
- },
- "a": {
- command: coreCommands.append
- },
- "A": {
- command: coreCommands.appendEnd
- },
- "ctrl-f": {
- command: "gotopagedown"
- },
- "ctrl-b": {
- command: "gotopageup"
- }
-};
-
-exports.handler = {
- $id: "ace/keyboard/vim",
- // workaround for j not repeating with `defaults write -g ApplePressAndHoldEnabled -bool true`
- handleMacRepeat: function(data, hashId, key) {
- if (hashId == -1) {
- // record key
- data.inputChar = key;
- data.lastEvent = "input";
- } else if (data.inputChar && data.$lastHash == hashId && data.$lastKey == key) {
- // check for repeated keypress
- if (data.lastEvent == "input") {
- data.lastEvent = "input1";
- } else if (data.lastEvent == "input1") {
- // simulate textinput
- return true;
- }
- } else {
- // reset
- data.$lastHash = hashId;
- data.$lastKey = key;
- data.lastEvent = "keypress";
- }
- },
- // on mac, with some keyboard layouts (e.g swedish) ^ starts composition, we don't need it in normal mode
- updateMacCompositionHandlers: function(editor, enable) {
- var onCompositionUpdateOverride = function(text) {
- if (util.currentMode !== "insert") {
- var el = this.textInput.getElement();
- el.blur();
- el.focus();
- el.value = text;
- } else {
- this.onCompositionUpdateOrig(text);
- }
- };
- var onCompositionStartOverride = function(text) {
- if (util.currentMode === "insert") {
- this.onCompositionStartOrig(text);
- }
- }
- if (enable) {
- if (!editor.onCompositionUpdateOrig) {
- editor.onCompositionUpdateOrig = editor.onCompositionUpdate;
- editor.onCompositionUpdate = onCompositionUpdateOverride;
- editor.onCompositionStartOrig = editor.onCompositionStart;
- editor.onCompositionStart = onCompositionStartOverride;
- }
- } else {
- if (editor.onCompositionUpdateOrig) {
- editor.onCompositionUpdate = editor.onCompositionUpdateOrig;
- editor.onCompositionUpdateOrig = null;
- editor.onCompositionStart = editor.onCompositionStartOrig;
- editor.onCompositionStartOrig = null;
- }
- }
- },
-
- handleKeyboard: function(data, hashId, key, keyCode, e) {
- // ignore command keys (shift, ctrl etc.)
- if (hashId != 0 && (key == "" || key == "\x00"))
- return null;
-
- var editor = data.editor;
-
- if (hashId == 1)
- key = "ctrl-" + key;
- if (key == "ctrl-c") {
- if (!useragent.isMac && editor.getCopyText()) {
- editor.once("copy", function() {
- if (data.state == "start")
- coreCommands.stop.exec(editor);
- else
- editor.selection.clearSelection();
- });
- return {command: "null", passEvent: true};
- }
- return {command: coreCommands.stop};
- } else if ((key == "esc" && hashId == 0) || key == "ctrl-[") {
- return {command: coreCommands.stop};
- } else if (data.state == "start") {
- if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) {
- hashId = -1;
- key = data.inputChar;
- }
-
- if (hashId == -1 || hashId == 1 || hashId == 0 && key.length > 1) {
- if (cmds.inputBuffer.idle && startCommands[key])
- return startCommands[key];
- cmds.inputBuffer.push(editor, key);
- return {command: "null", passEvent: false};
- } // if no modifier || shift: wait for input.
- else if (key.length == 1 && (hashId == 0 || hashId == 4)) {
- return {command: "null", passEvent: true};
- } else if (key == "esc" && hashId == 0) {
- return {command: coreCommands.stop};
- }
- } else {
- if (key == "ctrl-w") {
- return {command: "removewordleft"};
- }
- }
- },
-
- attach: function(editor) {
- editor.on("click", exports.onCursorMove);
- if (util.currentMode !== "insert")
- cmds.coreCommands.stop.exec(editor);
- editor.$vimModeHandler = this;
-
- this.updateMacCompositionHandlers(editor, true);
- },
-
- detach: function(editor) {
- editor.removeListener("click", exports.onCursorMove);
- util.noMode(editor);
- util.currentMode = "normal";
- this.updateMacCompositionHandlers(editor, false);
- },
-
- actions: cmds.actions,
- getStatusText: function() {
- if (util.currentMode == "insert")
- return "INSERT";
- if (util.onVisualMode)
- return (util.onVisualLineMode ? "VISUAL LINE " : "VISUAL ") + cmds.inputBuffer.status;
- return cmds.inputBuffer.status;
- }
-};
-
-
-exports.onCursorMove = function(e) {
- cmds.onCursorMove(e.editor, e);
- exports.onCursorMove.scheduled = false;
-};
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/keyboard/vim/commands.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/keyboard/vim/commands.js b/src/fauxton/assets/js/libs/ace/keyboard/vim/commands.js
deleted file mode 100644
index dd3357d..0000000
--- a/src/fauxton/assets/js/libs/ace/keyboard/vim/commands.js
+++ /dev/null
@@ -1,613 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define(function(require, exports, module) {
-
-"never use strict";
-
-var lang = require("../../lib/lang");
-var util = require("./maps/util");
-var motions = require("./maps/motions");
-var operators = require("./maps/operators");
-var alias = require("./maps/aliases");
-var registers = require("./registers");
-
-var NUMBER = 1;
-var OPERATOR = 2;
-var MOTION = 3;
-var ACTION = 4;
-var HMARGIN = 8; // Minimum amount of line separation between margins;
-
-var repeat = function repeat(fn, count, args) {
- while (0 < count--)
- fn.apply(this, args);
-};
-
-var ensureScrollMargin = function(editor) {
- var renderer = editor.renderer;
- var pos = renderer.$cursorLayer.getPixelPosition();
-
- var top = pos.top;
-
- var margin = HMARGIN * renderer.layerConfig.lineHeight;
- if (2 * margin > renderer.$size.scrollerHeight)
- margin = renderer.$size.scrollerHeight / 2;
-
- if (renderer.scrollTop > top - margin) {
- renderer.session.setScrollTop(top - margin);
- }
-
- if (renderer.scrollTop + renderer.$size.scrollerHeight < top + margin + renderer.lineHeight) {
- renderer.session.setScrollTop(top + margin + renderer.lineHeight - renderer.$size.scrollerHeight);
- }
-};
-
-var actions = exports.actions = {
- "z": {
- param: true,
- fn: function(editor, range, count, param) {
- switch (param) {
- case "z":
- editor.renderer.alignCursor(null, 0.5);
- break;
- case "t":
- editor.renderer.alignCursor(null, 0);
- break;
- case "b":
- editor.renderer.alignCursor(null, 1);
- break;
- case "c":
- editor.session.onFoldWidgetClick(range.start.row, {domEvent:{target :{}}});
- break;
- case "o":
- editor.session.onFoldWidgetClick(range.start.row, {domEvent:{target :{}}});
- break;
- case "C":
- editor.session.foldAll();
- break;
- case "O":
- editor.session.unfold();
- break;
- }
- }
- },
- "r": {
- param: true,
- fn: function(editor, range, count, param) {
- if (param && param.length) {
- if (param.length > 1)
- param = param == "return" ? "\n" : param == "tab" ? "\t" : param;
- repeat(function() { editor.insert(param); }, count || 1);
- editor.navigateLeft();
- }
- }
- },
- "R": {
- fn: function(editor, range, count, param) {
- util.insertMode(editor);
- editor.setOverwrite(true);
- }
- },
- "~": {
- fn: function(editor, range, count) {
- repeat(function() {
- var range = editor.selection.getRange();
- if (range.isEmpty())
- range.end.column++;
- var text = editor.session.getTextRange(range);
- var toggled = text.toUpperCase();
- if (toggled == text)
- editor.navigateRight();
- else
- editor.session.replace(range, toggled);
- }, count || 1);
- }
- },
- "*": {
- fn: function(editor, range, count, param) {
- editor.selection.selectWord();
- editor.findNext();
- ensureScrollMargin(editor);
- var r = editor.selection.getRange();
- editor.selection.setSelectionRange(r, true);
- }
- },
- "#": {
- fn: function(editor, range, count, param) {
- editor.selection.selectWord();
- editor.findPrevious();
- ensureScrollMargin(editor);
- var r = editor.selection.getRange();
- editor.selection.setSelectionRange(r, true);
- }
- },
- "m": {
- param: true,
- fn: function(editor, range, count, param) {
- var s = editor.session;
- var markers = s.vimMarkers || (s.vimMarkers = {});
- var c = editor.getCursorPosition();
- if (!markers[param]) {
- markers[param] = editor.session.doc.createAnchor(c);
- }
- markers[param].setPosition(c.row, c.column, true);
- }
- },
- "n": {
- fn: function(editor, range, count, param) {
- var options = editor.getLastSearchOptions();
- options.backwards = false;
-
- editor.selection.moveCursorRight();
- editor.selection.clearSelection();
- editor.findNext(options);
-
- ensureScrollMargin(editor);
- var r = editor.selection.getRange();
- r.end.row = r.start.row;
- r.end.column = r.start.column;
- editor.selection.setSelectionRange(r, true);
- }
- },
- "N": {
- fn: function(editor, range, count, param) {
- var options = editor.getLastSearchOptions();
- options.backwards = true;
-
- editor.findPrevious(options);
- ensureScrollMargin(editor);
- var r = editor.selection.getRange();
- r.end.row = r.start.row;
- r.end.column = r.start.column;
- editor.selection.setSelectionRange(r, true);
- }
- },
- "v": {
- fn: function(editor, range, count, param) {
- editor.selection.selectRight();
- util.visualMode(editor, false);
- },
- acceptsMotion: true
- },
- "V": {
- fn: function(editor, range, count, param) {
- //editor.selection.selectLine();
- //editor.selection.selectLeft();
- var row = editor.getCursorPosition().row;
- editor.selection.clearSelection();
- editor.selection.moveCursorTo(row, 0);
- editor.selection.selectLineEnd();
- editor.selection.visualLineStart = row;
-
- util.visualMode(editor, true);
- },
- acceptsMotion: true
- },
- "Y": {
- fn: function(editor, range, count, param) {
- util.copyLine(editor);
- }
- },
- "p": {
- fn: function(editor, range, count, param) {
- var defaultReg = registers._default;
-
- editor.setOverwrite(false);
- if (defaultReg.isLine) {
- var pos = editor.getCursorPosition();
- pos.column = editor.session.getLine(pos.row).length;
- var text = lang.stringRepeat("\n" + defaultReg.text, count || 1);
- editor.session.insert(pos, text);
- editor.moveCursorTo(pos.row + 1, 0);
- }
- else {
- editor.navigateRight();
- editor.insert(lang.stringRepeat(defaultReg.text, count || 1));
- editor.navigateLeft();
- }
- editor.setOverwrite(true);
- editor.selection.clearSelection();
- }
- },
- "P": {
- fn: function(editor, range, count, param) {
- var defaultReg = registers._default;
- editor.setOverwrite(false);
-
- if (defaultReg.isLine) {
- var pos = editor.getCursorPosition();
- pos.column = 0;
- var text = lang.stringRepeat(defaultReg.text + "\n", count || 1);
- editor.session.insert(pos, text);
- editor.moveCursorToPosition(pos);
- }
- else {
- editor.insert(lang.stringRepeat(defaultReg.text, count || 1));
- }
- editor.setOverwrite(true);
- editor.selection.clearSelection();
- }
- },
- "J": {
- fn: function(editor, range, count, param) {
- var session = editor.session;
- range = editor.getSelectionRange();
- var pos = {row: range.start.row, column: range.start.column};
- count = count || range.end.row - range.start.row;
- var maxRow = Math.min(pos.row + (count || 1), session.getLength() - 1);
-
- range.start.column = session.getLine(pos.row).length;
- range.end.column = session.getLine(maxRow).length;
- range.end.row = maxRow;
-
- var text = "";
- for (var i = pos.row; i < maxRow; i++) {
- var nextLine = session.getLine(i + 1);
- text += " " + /^\s*(.*)$/.exec(nextLine)[1] || "";
- }
-
- session.replace(range, text);
- editor.moveCursorTo(pos.row, pos.column);
- }
- },
- "u": {
- fn: function(editor, range, count, param) {
- count = parseInt(count || 1, 10);
- for (var i = 0; i < count; i++) {
- editor.undo();
- }
- editor.selection.clearSelection();
- }
- },
- "ctrl-r": {
- fn: function(editor, range, count, param) {
- count = parseInt(count || 1, 10);
- for (var i = 0; i < count; i++) {
- editor.redo();
- }
- editor.selection.clearSelection();
- }
- },
- ":": {
- fn: function(editor, range, count, param) {
- var val = ":";
- if (count > 1)
- val = ".,.+" + count + val;
- if (editor.showCommandLine)
- editor.showCommandLine(val);
- }
- },
- "/": {
- fn: function(editor, range, count, param) {
- if (editor.showCommandLine)
- editor.showCommandLine("/");
- }
- },
- "?": {
- fn: function(editor, range, count, param) {
- if (editor.showCommandLine)
- editor.showCommandLine("?");
- }
- },
- ".": {
- fn: function(editor, range, count, param) {
- util.onInsertReplaySequence = inputBuffer.lastInsertCommands;
- var previous = inputBuffer.previous;
- if (previous) // If there is a previous action
- inputBuffer.exec(editor, previous.action, previous.param);
- }
- },
- "ctrl-x": {
- fn: function(editor, range, count, param) {
- editor.modifyNumber(-(count || 1));
- }
- },
- "ctrl-a": {
- fn: function(editor, range, count, param) {
- editor.modifyNumber(count || 1);
- }
- }
-};
-
-var inputBuffer = exports.inputBuffer = {
- accepting: [NUMBER, OPERATOR, MOTION, ACTION],
- currentCmd: null,
- //currentMode: 0,
- currentCount: "",
- status: "",
-
- // Types
- operator: null,
- motion: null,
-
- lastInsertCommands: [],
-
- push: function(editor, ch, keyId) {
- var status = this.status;
- var isKeyHandled = true;
- this.idle = false;
- var wObj = this.waitingForParam;
- if (/^numpad\d+$/i.test(ch))
- ch = ch.substr(6);
-
- if (wObj) {
- this.exec(editor, wObj, ch);
- }
- // If input is a number (that doesn't start with 0)
- else if (!(ch === "0" && !this.currentCount.length) &&
- (/^\d+$/.test(ch) && this.isAccepting(NUMBER))) {
- // Assuming that ch is always of type String, and not Number
- this.currentCount += ch;
- this.currentCmd = NUMBER;
- this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
- }
- else if (!this.operator && this.isAccepting(OPERATOR) && operators[ch]) {
- this.operator = {
- ch: ch,
- count: this.getCount()
- };
- this.currentCmd = OPERATOR;
- this.accepting = [NUMBER, MOTION, ACTION];
- this.exec(editor, { operator: this.operator });
- }
- else if (motions[ch] && this.isAccepting(MOTION)) {
- this.currentCmd = MOTION;
-
- var ctx = {
- operator: this.operator,
- motion: {
- ch: ch,
- count: this.getCount()
- }
- };
-
- if (motions[ch].param)
- this.waitForParam(ctx);
- else
- this.exec(editor, ctx);
- }
- else if (alias[ch] && this.isAccepting(MOTION)) {
- alias[ch].operator.count = this.getCount();
- this.exec(editor, alias[ch]);
- }
- else if (actions[ch] && this.isAccepting(ACTION)) {
- var actionObj = {
- action: {
- fn: actions[ch].fn,
- count: this.getCount()
- }
- };
-
- if (actions[ch].param) {
- this.waitForParam(actionObj);
- }
- else {
- this.exec(editor, actionObj);
- }
-
- if (actions[ch].acceptsMotion)
- this.idle = false;
- }
- else if (this.operator) {
- this.operator.count = this.getCount();
- this.exec(editor, { operator: this.operator }, ch);
- }
- else {
- isKeyHandled = ch.length == 1;
- this.reset();
- }
-
- if (this.waitingForParam || this.motion || this.operator) {
- this.status += ch;
- } else if (this.currentCount) {
- this.status = this.currentCount;
- } else if (this.status) {
- this.status = "";
- }
- if (this.status != status)
- editor._emit("changeStatus");
- return isKeyHandled;
- },
-
- waitForParam: function(cmd) {
- this.waitingForParam = cmd;
- },
-
- getCount: function() {
- var count = this.currentCount;
- this.currentCount = "";
- return count && parseInt(count, 10);
- },
-
- exec: function(editor, action, param) {
- var m = action.motion;
- var o = action.operator;
- var a = action.action;
-
- if (!param)
- param = action.param;
-
- if (o) {
- this.previous = {
- action: action,
- param: param
- };
- }
-
- if (o && !editor.selection.isEmpty()) {
- if (operators[o.ch].selFn) {
- operators[o.ch].selFn(editor, editor.getSelectionRange(), o.count, param);
- this.reset();
- }
- return;
- }
-
- // There is an operator, but no motion or action. We try to pass the
- // current ch to the operator to see if it responds to it (an example
- // of this is the 'dd' operator).
- else if (!m && !a && o && param) {
- operators[o.ch].fn(editor, null, o.count, param);
- this.reset();
- }
- else if (m) {
- var run = function(fn) {
- if (fn && typeof fn === "function") { // There should always be a motion
- if (m.count && !motionObj.handlesCount)
- repeat(fn, m.count, [editor, null, m.count, param]);
- else
- fn(editor, null, m.count, param);
- }
- };
-
- var motionObj = motions[m.ch];
- var selectable = motionObj.sel;
-
- if (!o) {
- if ((util.onVisualMode || util.onVisualLineMode) && selectable)
- run(motionObj.sel);
- else
- run(motionObj.nav);
- }
- else if (selectable) {
- repeat(function() {
- run(motionObj.sel);
- operators[o.ch].fn(editor, editor.getSelectionRange(), o.count, param);
- }, o.count || 1);
- }
- this.reset();
- }
- else if (a) {
- a.fn(editor, editor.getSelectionRange(), a.count, param);
- this.reset();
- }
- handleCursorMove(editor);
- },
-
- isAccepting: function(type) {
- return this.accepting.indexOf(type) !== -1;
- },
-
- reset: function() {
- this.operator = null;
- this.motion = null;
- this.currentCount = "";
- this.status = "";
- this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
- this.idle = true;
- this.waitingForParam = null;
- }
-};
-
-function setPreviousCommand(fn) {
- inputBuffer.previous = { action: { action: { fn: fn } } };
-}
-
-exports.coreCommands = {
- start: {
- exec: function start(editor) {
- util.insertMode(editor);
- setPreviousCommand(start);
- }
- },
- startBeginning: {
- exec: function startBeginning(editor) {
- editor.navigateLineStart();
- util.insertMode(editor);
- setPreviousCommand(startBeginning);
- }
- },
- // Stop Insert mode as soon as possible. Works like typing <Esc> in
- // insert mode.
- stop: {
- exec: function stop(editor) {
- inputBuffer.reset();
- util.onVisualMode = false;
- util.onVisualLineMode = false;
- inputBuffer.lastInsertCommands = util.normalMode(editor);
- }
- },
- append: {
- exec: function append(editor) {
- var pos = editor.getCursorPosition();
- var lineLen = editor.session.getLine(pos.row).length;
- if (lineLen)
- editor.navigateRight();
- util.insertMode(editor);
- setPreviousCommand(append);
- }
- },
- appendEnd: {
- exec: function appendEnd(editor) {
- editor.navigateLineEnd();
- util.insertMode(editor);
- setPreviousCommand(appendEnd);
- }
- }
-};
-
-var handleCursorMove = exports.onCursorMove = function(editor, e) {
- if (util.currentMode === 'insert' || handleCursorMove.running)
- return;
- else if(!editor.selection.isEmpty()) {
- handleCursorMove.running = true;
- if (util.onVisualLineMode) {
- var originRow = editor.selection.visualLineStart;
- var cursorRow = editor.getCursorPosition().row;
- if(originRow <= cursorRow) {
- var endLine = editor.session.getLine(cursorRow);
- editor.selection.clearSelection();
- editor.selection.moveCursorTo(originRow, 0);
- editor.selection.selectTo(cursorRow, endLine.length);
- } else {
- var endLine = editor.session.getLine(originRow);
- editor.selection.clearSelection();
- editor.selection.moveCursorTo(originRow, endLine.length);
- editor.selection.selectTo(cursorRow, 0);
- }
- }
- handleCursorMove.running = false;
- return;
- }
- else {
- if (e && (util.onVisualLineMode || util.onVisualMode)) {
- editor.selection.clearSelection();
- util.normalMode(editor);
- }
-
- handleCursorMove.running = true;
- var pos = editor.getCursorPosition();
- var lineLen = editor.session.getLine(pos.row).length;
-
- if (lineLen && pos.column === lineLen)
- editor.navigateLeft();
- handleCursorMove.running = false;
- }
-};
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/aliases.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/aliases.js b/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/aliases.js
deleted file mode 100644
index 1a5f32f..0000000
--- a/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/aliases.js
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-"use strict"
-
-define(function(require, exports, module) {
-module.exports = {
- "x": {
- operator: {
- ch: "d",
- count: 1
- },
- motion: {
- ch: "l",
- count: 1
- }
- },
- "X": {
- operator: {
- ch: "d",
- count: 1
- },
- motion: {
- ch: "h",
- count: 1
- }
- },
- "D": {
- operator: {
- ch: "d",
- count: 1
- },
- motion: {
- ch: "$",
- count: 1
- }
- },
- "C": {
- operator: {
- ch: "c",
- count: 1
- },
- motion: {
- ch: "$",
- count: 1
- }
- },
- "s": {
- operator: {
- ch: "c",
- count: 1
- },
- motion: {
- ch: "l",
- count: 1
- }
- },
- "S": {
- operator: {
- ch: "c",
- count: 1
- },
- param: "c"
- }
-};
-});
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/motions.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/motions.js b/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/motions.js
deleted file mode 100644
index 91c8b8a..0000000
--- a/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/motions.js
+++ /dev/null
@@ -1,664 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-define(function(require, exports, module) {
-"use strict";
-
-var util = require("./util");
-
-var keepScrollPosition = function(editor, fn) {
- var scrollTopRow = editor.renderer.getScrollTopRow();
- var initialRow = editor.getCursorPosition().row;
- var diff = initialRow - scrollTopRow;
- fn && fn.call(editor);
- editor.renderer.scrollToRow(editor.getCursorPosition().row - diff);
-};
-
-function Motion(m) {
- if (typeof m == "function") {
- var getPos = m;
- m = this;
- } else {
- var getPos = m.getPos;
- }
- m.nav = function(editor, range, count, param) {
- var a = getPos(editor, range, count, param, false);
- if (!a)
- return;
- editor.clearSelection();
- editor.moveCursorTo(a.row, a.column);
- };
- m.sel = function(editor, range, count, param) {
- var a = getPos(editor, range, count, param, true);
- if (!a)
- return;
- editor.selection.selectTo(a.row, a.column);
- };
- return m;
-}
-
-var nonWordRe = /[\s.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
-var wordSeparatorRe = /[.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
-var whiteRe = /\s/;
-var StringStream = function(editor, cursor) {
- var sel = editor.selection;
- this.range = sel.getRange();
- cursor = cursor || sel.selectionLead;
- this.row = cursor.row;
- this.col = cursor.column;
- var line = editor.session.getLine(this.row);
- var maxRow = editor.session.getLength();
- this.ch = line[this.col] || '\n';
- this.skippedLines = 0;
-
- this.next = function() {
- this.ch = line[++this.col] || this.handleNewLine(1);
- //this.debug()
- return this.ch;
- };
- this.prev = function() {
- this.ch = line[--this.col] || this.handleNewLine(-1);
- //this.debug()
- return this.ch;
- };
- this.peek = function(dir) {
- var ch = line[this.col + dir];
- if (ch)
- return ch;
- if (dir == -1)
- return '\n';
- if (this.col == line.length - 1)
- return '\n';
- return editor.session.getLine(this.row + 1)[0] || '\n';
- };
-
- this.handleNewLine = function(dir) {
- if (dir == 1){
- if (this.col == line.length)
- return '\n';
- if (this.row == maxRow - 1)
- return '';
- this.col = 0;
- this.row ++;
- line = editor.session.getLine(this.row);
- this.skippedLines++;
- return line[0] || '\n';
- }
- if (dir == -1) {
- if (this.row === 0)
- return '';
- this.row --;
- line = editor.session.getLine(this.row);
- this.col = line.length;
- this.skippedLines--;
- return '\n';
- }
- };
- this.debug = function() {
- console.log(line.substring(0, this.col)+'|'+this.ch+'\''+this.col+'\''+line.substr(this.col+1));
- };
-};
-
-var Search = require("../../../search").Search;
-var search = new Search();
-
-function find(editor, needle, dir) {
- search.$options.needle = needle;
- search.$options.backwards = dir == -1;
- return search.find(editor.session);
-}
-
-var Range = require("../../../range").Range;
-
-var LAST_SEARCH_MOTION = {};
-
-module.exports = {
- "w": new Motion(function(editor) {
- var str = new StringStream(editor);
-
- if (str.ch && wordSeparatorRe.test(str.ch)) {
- while (str.ch && wordSeparatorRe.test(str.ch))
- str.next();
- } else {
- while (str.ch && !nonWordRe.test(str.ch))
- str.next();
- }
- while (str.ch && whiteRe.test(str.ch) && str.skippedLines < 2)
- str.next();
-
- str.skippedLines == 2 && str.prev();
- return {column: str.col, row: str.row};
- }),
- "W": new Motion(function(editor) {
- var str = new StringStream(editor);
- while(str.ch && !(whiteRe.test(str.ch) && !whiteRe.test(str.peek(1))) && str.skippedLines < 2)
- str.next();
- if (str.skippedLines == 2)
- str.prev();
- else
- str.next();
-
- return {column: str.col, row: str.row};
- }),
- "b": new Motion(function(editor) {
- var str = new StringStream(editor);
-
- str.prev();
- while (str.ch && whiteRe.test(str.ch) && str.skippedLines > -2)
- str.prev();
-
- if (str.ch && wordSeparatorRe.test(str.ch)) {
- while (str.ch && wordSeparatorRe.test(str.ch))
- str.prev();
- } else {
- while (str.ch && !nonWordRe.test(str.ch))
- str.prev();
- }
- str.ch && str.next();
- return {column: str.col, row: str.row};
- }),
- "B": new Motion(function(editor) {
- var str = new StringStream(editor);
- str.prev();
- while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(-1))) && str.skippedLines > -2)
- str.prev();
-
- if (str.skippedLines == -2)
- str.next();
-
- return {column: str.col, row: str.row};
- }),
- "e": new Motion(function(editor) {
- var str = new StringStream(editor);
-
- str.next();
- while (str.ch && whiteRe.test(str.ch))
- str.next();
-
- if (str.ch && wordSeparatorRe.test(str.ch)) {
- while (str.ch && wordSeparatorRe.test(str.ch))
- str.next();
- } else {
- while (str.ch && !nonWordRe.test(str.ch))
- str.next();
- }
- str.ch && str.prev();
- return {column: str.col, row: str.row};
- }),
- "E": new Motion(function(editor) {
- var str = new StringStream(editor);
- str.next();
- while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(1))))
- str.next();
-
- return {column: str.col, row: str.row};
- }),
-
- "l": {
- nav: function(editor) {
- var pos = editor.getCursorPosition();
- var col = pos.column;
- var lineLen = editor.session.getLine(pos.row).length;
- if (lineLen && col !== lineLen)
- editor.navigateRight();
- },
- sel: function(editor) {
- var pos = editor.getCursorPosition();
- var col = pos.column;
- var lineLen = editor.session.getLine(pos.row).length;
-
- // Solving the behavior at the end of the line due to the
- // different 0 index-based colum positions in ACE.
- if (lineLen && col !== lineLen) //In selection mode you can select the newline
- editor.selection.selectRight();
- }
- },
- "h": {
- nav: function(editor) {
- var pos = editor.getCursorPosition();
- if (pos.column > 0)
- editor.navigateLeft();
- },
- sel: function(editor) {
- var pos = editor.getCursorPosition();
- if (pos.column > 0)
- editor.selection.selectLeft();
- }
- },
- "H": {
- nav: function(editor) {
- var row = editor.renderer.getScrollTopRow();
- editor.moveCursorTo(row);
- },
- sel: function(editor) {
- var row = editor.renderer.getScrollTopRow();
- editor.selection.selectTo(row);
- }
- },
- "M": {
- nav: function(editor) {
- var topRow = editor.renderer.getScrollTopRow();
- var bottomRow = editor.renderer.getScrollBottomRow();
- var row = topRow + ((bottomRow - topRow) / 2);
- editor.moveCursorTo(row);
- },
- sel: function(editor) {
- var topRow = editor.renderer.getScrollTopRow();
- var bottomRow = editor.renderer.getScrollBottomRow();
- var row = topRow + ((bottomRow - topRow) / 2);
- editor.selection.selectTo(row);
- }
- },
- "L": {
- nav: function(editor) {
- var row = editor.renderer.getScrollBottomRow();
- editor.moveCursorTo(row);
- },
- sel: function(editor) {
- var row = editor.renderer.getScrollBottomRow();
- editor.selection.selectTo(row);
- }
- },
- "k": {
- nav: function(editor) {
- editor.navigateUp();
- },
- sel: function(editor) {
- editor.selection.selectUp();
- }
- },
- "j": {
- nav: function(editor) {
- editor.navigateDown();
- },
- sel: function(editor) {
- editor.selection.selectDown();
- }
- },
-
- "i": {
- param: true,
- sel: function(editor, range, count, param) {
- switch (param) {
- case "w":
- editor.selection.selectWord();
- break;
- case "W":
- editor.selection.selectAWord();
- break;
- case "(":
- case "{":
- case "[":
- var cursor = editor.getCursorPosition();
- var end = editor.session.$findClosingBracket(param, cursor, /paren/);
- if (!end)
- return;
- var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/);
- if (!start)
- return;
- start.column ++;
- editor.selection.setSelectionRange(Range.fromPoints(start, end));
- break;
- case "'":
- case '"':
- case "/":
- var end = find(editor, param, 1);
- if (!end)
- return;
- var start = find(editor, param, -1);
- if (!start)
- return;
- editor.selection.setSelectionRange(Range.fromPoints(start.end, end.start));
- break;
- }
- }
- },
- "a": {
- param: true,
- sel: function(editor, range, count, param) {
- switch (param) {
- case "w":
- editor.selection.selectAWord();
- break;
- case "W":
- editor.selection.selectAWord();
- break;
- case "(":
- case "{":
- case "[":
- var cursor = editor.getCursorPosition();
- var end = editor.session.$findClosingBracket(param, cursor, /paren/);
- if (!end)
- return;
- var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/);
- if (!start)
- return;
- end.column ++;
- editor.selection.setSelectionRange(Range.fromPoints(start, end));
- break;
- case "'":
- case "\"":
- case "/":
- var end = find(editor, param, 1);
- if (!end)
- return;
- var start = find(editor, param, -1);
- if (!start)
- return;
- end.column ++;
- editor.selection.setSelectionRange(Range.fromPoints(start.start, end.end));
- break;
- }
- }
- },
-
- "f": new Motion({
- param: true,
- handlesCount: true,
- getPos: function(editor, range, count, param, isSel, isRepeat) {
- if (!isRepeat)
- LAST_SEARCH_MOTION = {ch: "f", param: param};
- var cursor = editor.getCursorPosition();
- var column = util.getRightNthChar(editor, cursor, param, count || 1);
-
- if (typeof column === "number") {
- cursor.column += column + (isSel ? 2 : 1);
- return cursor;
- }
- }
- }),
- "F": new Motion({
- param: true,
- handlesCount: true,
- getPos: function(editor, range, count, param, isSel, isRepeat) {
- if (!isRepeat)
- LAST_SEARCH_MOTION = {ch: "F", param: param};
- var cursor = editor.getCursorPosition();
- var column = util.getLeftNthChar(editor, cursor, param, count || 1);
-
- if (typeof column === "number") {
- cursor.column -= column + 1;
- return cursor;
- }
- }
- }),
- "t": new Motion({
- param: true,
- handlesCount: true,
- getPos: function(editor, range, count, param, isSel, isRepeat) {
- if (!isRepeat)
- LAST_SEARCH_MOTION = {ch: "t", param: param};
- var cursor = editor.getCursorPosition();
- var column = util.getRightNthChar(editor, cursor, param, count || 1);
-
- if (isRepeat && column == 0 && !(count > 1))
- var column = util.getRightNthChar(editor, cursor, param, 2);
-
- if (typeof column === "number") {
- cursor.column += column + (isSel ? 1 : 0);
- return cursor;
- }
- }
- }),
- "T": new Motion({
- param: true,
- handlesCount: true,
- getPos: function(editor, range, count, param, isSel, isRepeat) {
- if (!isRepeat)
- LAST_SEARCH_MOTION = {ch: "T", param: param};
- var cursor = editor.getCursorPosition();
- var column = util.getLeftNthChar(editor, cursor, param, count || 1);
-
- if (isRepeat && column == 0 && !(count > 1))
- var column = util.getLeftNthChar(editor, cursor, param, 2);
-
- if (typeof column === "number") {
- cursor.column -= column;
- return cursor;
- }
- }
- }),
- ";": new Motion({
- handlesCount: true,
- getPos: function(editor, range, count, param, isSel) {
- var ch = LAST_SEARCH_MOTION.ch;
- if (!ch)
- return;
- return module.exports[ch].getPos(
- editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
- );
- }
- }),
- ",": new Motion({
- handlesCount: true,
- getPos: function(editor, range, count, param, isSel) {
- var ch = LAST_SEARCH_MOTION.ch;
- if (!ch)
- return;
- var up = ch.toUpperCase();
- ch = ch === up ? ch.toLowerCase() : up;
-
- return module.exports[ch].getPos(
- editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
- );
- }
- }),
-
- "^": {
- nav: function(editor) {
- editor.navigateLineStart();
- },
- sel: function(editor) {
- editor.selection.selectLineStart();
- }
- },
- "$": {
- nav: function(editor) {
- editor.navigateLineEnd();
- },
- sel: function(editor) {
- editor.selection.selectLineEnd();
- }
- },
- "0": new Motion(function(ed) {
- return {row: ed.selection.lead.row, column: 0};
- }),
- "G": {
- nav: function(editor, range, count, param) {
- if (!count && count !== 0) { // Stupid JS
- count = editor.session.getLength();
- }
- editor.gotoLine(count);
- },
- sel: function(editor, range, count, param) {
- if (!count && count !== 0) { // Stupid JS
- count = editor.session.getLength();
- }
- editor.selection.selectTo(count, 0);
- }
- },
- "g": {
- param: true,
- nav: function(editor, range, count, param) {
- switch(param) {
- case "m":
- console.log("Middle line");
- break;
- case "e":
- console.log("End of prev word");
- break;
- case "g":
- editor.gotoLine(count || 0);
- case "u":
- editor.gotoLine(count || 0);
- case "U":
- editor.gotoLine(count || 0);
- }
- },
- sel: function(editor, range, count, param) {
- switch(param) {
- case "m":
- console.log("Middle line");
- break;
- case "e":
- console.log("End of prev word");
- break;
- case "g":
- editor.selection.selectTo(count || 0, 0);
- }
- }
- },
- "o": {
- nav: function(editor, range, count, param) {
- count = count || 1;
- var content = "";
- while (0 < count--)
- content += "\n";
-
- if (content.length) {
- editor.navigateLineEnd()
- editor.insert(content);
- util.insertMode(editor);
- }
- }
- },
- "O": {
- nav: function(editor, range, count, param) {
- var row = editor.getCursorPosition().row;
- count = count || 1;
- var content = "";
- while (0 < count--)
- content += "\n";
-
- if (content.length) {
- if(row > 0) {
- editor.navigateUp();
- editor.navigateLineEnd()
- editor.insert(content);
- } else {
- editor.session.insert({row: 0, column: 0}, content);
- editor.navigateUp();
- }
- util.insertMode(editor);
- }
- }
- },
- "%": new Motion(function(editor){
- var brRe = /[\[\]{}()]/g;
- var cursor = editor.getCursorPosition();
- var ch = editor.session.getLine(cursor.row)[cursor.column];
- if (!brRe.test(ch)) {
- var range = find(editor, brRe);
- if (!range)
- return;
- cursor = range.start;
- }
- var match = editor.session.findMatchingBracket({
- row: cursor.row,
- column: cursor.column + 1
- });
-
- return match;
- }),
- "{": new Motion(function(ed) {
- var session = ed.session;
- var row = session.selection.lead.row;
- while(row > 0 && !/\S/.test(session.getLine(row)))
- row--;
- while(/\S/.test(session.getLine(row)))
- row--;
- return {column: 0, row: row};
- }),
- "}": new Motion(function(ed) {
- var session = ed.session;
- var l = session.getLength();
- var row = session.selection.lead.row;
- while(row < l && !/\S/.test(session.getLine(row)))
- row++;
- while(/\S/.test(session.getLine(row)))
- row++;
- return {column: 0, row: row};
- }),
- "ctrl-d": {
- nav: function(editor, range, count, param) {
- editor.selection.clearSelection();
- keepScrollPosition(editor, editor.gotoPageDown);
- },
- sel: function(editor, range, count, param) {
- keepScrollPosition(editor, editor.selectPageDown);
- }
- },
- "ctrl-u": {
- nav: function(editor, range, count, param) {
- editor.selection.clearSelection();
- keepScrollPosition(editor, editor.gotoPageUp);
- },
- sel: function(editor, range, count, param) {
- keepScrollPosition(editor, editor.selectPageUp);
- }
- },
- "`": new Motion({
- param: true,
- handlesCount: true,
- getPos: function(editor, range, count, param, isSel) {
- var s = editor.session;
- var marker = s.vimMarkers && s.vimMarkers[param];
- if (marker) {
- return marker.getPosition();
- }
- }
- }),
- "'": new Motion({
- param: true,
- handlesCount: true,
- getPos: function(editor, range, count, param, isSel) {
- var s = editor.session;
- var marker = s.vimMarkers && s.vimMarkers[param];
- if (marker) {
- var pos = marker.getPosition();
- var line = editor.session.getLine(pos.row);
- pos.column = line.search(/\S/);
- if (pos.column == -1)
- pos.column = line.length;
- return pos;
- }
- }
- })
-};
-
-module.exports.backspace = module.exports.left = module.exports.h;
-module.exports.space = module.exports['return'] = module.exports.right = module.exports.l;
-module.exports.up = module.exports.k;
-module.exports.down = module.exports.j;
-module.exports.pagedown = module.exports["ctrl-d"];
-module.exports.pageup = module.exports["ctrl-u"];
-
-});