You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2015/03/03 11:00:11 UTC
[43/52] [abbrv] [partial] incubator-kylin git commit: update
ace-builds to new version
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/99a418c0/webapp/app/components/ace-builds/kitchen-sink/demo.js
----------------------------------------------------------------------
diff --git a/webapp/app/components/ace-builds/kitchen-sink/demo.js b/webapp/app/components/ace-builds/kitchen-sink/demo.js
deleted file mode 100644
index 8115102..0000000
--- a/webapp/app/components/ace-builds/kitchen-sink/demo.js
+++ /dev/null
@@ -1,6643 +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('kitchen-sink/demo', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/multi_select', 'ace/ext/spellcheck', 'kitchen-sink/inline_editor', 'kitchen-sink/dev_util', 'kitchen-sink/file_drop', 'ace/config', 'ace/lib/dom', 'ace/lib/net', 'ace/lib/lang', 'ace/lib/useragent', 'ace/lib/event', 'ace/theme/textmate', 'ace/edit_session', 'ace/undomanager', 'ace/keyboard/hash_handler', 'ace/virtual_renderer', 'ace/editor', 'ace/ext/whitespace', 'kitchen-sink/doclist', 'ace/ext/modelist', 'ace/ext/themelist', 'kitchen-sink/layout', 'kitchen-sink/token_tooltip', 'kitchen-sink/util', 'ace/ext/elastic_tabstops_lite', 'ace/incremental_search', 'ace/worker/worker_client', 'ace/split', 'ace/keyboard/vim', 'ace/ext/statusbar', 'ace/ext/emmet', 'ace/snippets', 'ace/ext/language_tools'], function(require, exports, module) {
-
-
-require("ace/lib/fixoldbrowsers");
-
-require("ace/multi_select");
-require("ace/ext/spellcheck");
-require("./inline_editor");
-require("./dev_util");
-require("./file_drop");
-
-var config = require("ace/config");
-config.init();
-var env = {};
-
-var dom = require("ace/lib/dom");
-var net = require("ace/lib/net");
-var lang = require("ace/lib/lang");
-var useragent = require("ace/lib/useragent");
-
-var event = require("ace/lib/event");
-var theme = require("ace/theme/textmate");
-var EditSession = require("ace/edit_session").EditSession;
-var UndoManager = require("ace/undomanager").UndoManager;
-
-var HashHandler = require("ace/keyboard/hash_handler").HashHandler;
-
-var Renderer = require("ace/virtual_renderer").VirtualRenderer;
-var Editor = require("ace/editor").Editor;
-
-var whitespace = require("ace/ext/whitespace");
-
-
-
-var doclist = require("./doclist");
-var modelist = require("ace/ext/modelist");
-var themelist = require("ace/ext/themelist");
-var layout = require("./layout");
-var TokenTooltip = require("./token_tooltip").TokenTooltip;
-var util = require("./util");
-var saveOption = util.saveOption;
-var fillDropdown = util.fillDropdown;
-var bindCheckbox = util.bindCheckbox;
-var bindDropdown = util.bindDropdown;
-
-var ElasticTabstopsLite = require("ace/ext/elastic_tabstops_lite").ElasticTabstopsLite;
-
-var IncrementalSearch = require("ace/incremental_search").IncrementalSearch;
-
-
-var workerModule = require("ace/worker/worker_client");
-if (location.href.indexOf("noworker") !== -1) {
- workerModule.WorkerClient = workerModule.UIWorkerClient;
-}
-var container = document.getElementById("editor-container");
-var Split = require("ace/split").Split;
-var split = new Split(container, theme, 1);
-env.editor = split.getEditor(0);
-split.on("focus", function(editor) {
- env.editor = editor;
- updateUIEditorOptions();
-});
-env.split = split;
-window.env = env;
-
-
-var consoleEl = dom.createElement("div");
-container.parentNode.appendChild(consoleEl);
-consoleEl.style.cssText = "position:fixed; bottom:1px; right:0;\
-border:1px solid #baf; z-index:100";
-
-var cmdLine = new layout.singleLineEditor(consoleEl);
-cmdLine.editor = env.editor;
-env.editor.cmdLine = cmdLine;
-
-env.editor.showCommandLine = function(val) {
- this.cmdLine.focus();
- if (typeof val == "string")
- this.cmdLine.setValue(val, 1);
-};
-env.editor.commands.addCommands([{
- name: "gotoline",
- bindKey: {win: "Ctrl-L", mac: "Command-L"},
- exec: function(editor, line) {
- if (typeof line == "object") {
- var arg = this.name + " " + editor.getCursorPosition().row;
- editor.cmdLine.setValue(arg, 1);
- editor.cmdLine.focus();
- return;
- }
- line = parseInt(line, 10);
- if (!isNaN(line))
- editor.gotoLine(line);
- },
- readOnly: true
-}, {
- name: "snippet",
- bindKey: {win: "Alt-C", mac: "Command-Alt-C"},
- exec: function(editor, needle) {
- if (typeof needle == "object") {
- editor.cmdLine.setValue("snippet ", 1);
- editor.cmdLine.focus();
- return;
- }
- var s = snippetManager.getSnippetByName(needle, editor);
- if (s)
- snippetManager.insertSnippet(editor, s.content);
- },
- readOnly: true
-}, {
- name: "focusCommandLine",
- bindKey: "shift-esc|ctrl-`",
- exec: function(editor, needle) { editor.cmdLine.focus(); },
- readOnly: true
-}, {
- name: "nextFile",
- bindKey: "Ctrl-tab",
- exec: function(editor) { doclist.cycleOpen(editor, 1); },
- readOnly: true
-}, {
- name: "previousFile",
- bindKey: "Ctrl-shift-tab",
- exec: function(editor) { doclist.cycleOpen(editor, -1); },
- readOnly: true
-}, {
- name: "execute",
- bindKey: "ctrl+enter",
- exec: function(editor) {
- try {
- var r = window.eval(editor.getCopyText() || editor.getValue());
- } catch(e) {
- r = e;
- }
- editor.cmdLine.setValue(r + "");
- },
- readOnly: true
-}, {
- name: "showKeyboardShortcuts",
- bindKey: {win: "Ctrl-Alt-h", mac: "Command-Alt-h"},
- exec: function(editor) {
- config.loadModule("ace/ext/keybinding_menu", function(module) {
- module.init(editor);
- editor.showKeyboardShortcuts();
- });
- }
-}, {
- name: "increaseFontSize",
- bindKey: "Ctrl-+",
- exec: function(editor) {
- var size = parseInt(editor.getFontSize(), 10) || 12;
- editor.setFontSize(size + 1);
- }
-}, {
- name: "decreaseFontSize",
- bindKey: "Ctrl+-",
- exec: function(editor) {
- var size = parseInt(editor.getFontSize(), 10) || 12;
- editor.setFontSize(Math.max(size - 1 || 1));
- }
-}, {
- name: "resetFontSize",
- bindKey: "Ctrl+0",
- exec: function(editor) {
- editor.setFontSize(12);
- }
-}]);
-
-
-env.editor.commands.addCommands(whitespace.commands);
-
-cmdLine.commands.bindKeys({
- "Shift-Return|Ctrl-Return|Alt-Return": function(cmdLine) { cmdLine.insert("\n"); },
- "Esc|Shift-Esc": function(cmdLine){ cmdLine.editor.focus(); },
- "Return": function(cmdLine){
- var command = cmdLine.getValue().split(/\s+/);
- var editor = cmdLine.editor;
- editor.commands.exec(command[0], editor, command[1]);
- editor.focus();
- }
-});
-
-cmdLine.commands.removeCommands(["find", "gotoline", "findall", "replace", "replaceall"]);
-
-var commands = env.editor.commands;
-commands.addCommand({
- name: "save",
- bindKey: {win: "Ctrl-S", mac: "Command-S"},
- exec: function(arg) {
- var session = env.editor.session;
- var name = session.name.match(/[^\/]+$/);
- localStorage.setItem(
- "saved_file:" + name,
- session.getValue()
- );
- env.editor.cmdLine.setValue("saved "+ name);
- }
-});
-
-commands.addCommand({
- name: "load",
- bindKey: {win: "Ctrl-O", mac: "Command-O"},
- exec: function(arg) {
- var session = env.editor.session;
- var name = session.name.match(/[^\/]+$/);
- var value = localStorage.getItem("saved_file:" + name);
- if (typeof value == "string") {
- session.setValue(value);
- env.editor.cmdLine.setValue("loaded "+ name);
- } else {
- env.editor.cmdLine.setValue("no previuos value saved for "+ name);
- }
- }
-});
-
-var keybindings = {
- ace: null, // Null = use "default" keymapping
- vim: require("ace/keyboard/vim").handler,
- emacs: "ace/keyboard/emacs",
- custom: new HashHandler({
- "gotoright": "Tab",
- "indent": "]",
- "outdent": "[",
- "gotolinestart": "^",
- "gotolineend": "$"
- })
-};
-var consoleHeight = 20;
-function onResize() {
- var left = env.split.$container.offsetLeft;
- var width = document.documentElement.clientWidth - left;
- container.style.width = width + "px";
- container.style.height = document.documentElement.clientHeight - consoleHeight + "px";
- env.split.resize();
-
- consoleEl.style.width = width + "px";
- cmdLine.resize();
-}
-
-window.onresize = onResize;
-onResize();
-var docEl = document.getElementById("doc");
-var modeEl = document.getElementById("mode");
-var wrapModeEl = document.getElementById("soft_wrap");
-var themeEl = document.getElementById("theme");
-var foldingEl = document.getElementById("folding");
-var selectStyleEl = document.getElementById("select_style");
-var highlightActiveEl = document.getElementById("highlight_active");
-var showHiddenEl = document.getElementById("show_hidden");
-var showGutterEl = document.getElementById("show_gutter");
-var showPrintMarginEl = document.getElementById("show_print_margin");
-var highlightSelectedWordE = document.getElementById("highlight_selected_word");
-var showHScrollEl = document.getElementById("show_hscroll");
-var showVScrollEl = document.getElementById("show_vscroll");
-var animateScrollEl = document.getElementById("animate_scroll");
-var softTabEl = document.getElementById("soft_tab");
-var behavioursEl = document.getElementById("enable_behaviours");
-
-fillDropdown(docEl, doclist.all);
-
-fillDropdown(modeEl, modelist.modes);
-var modesByName = modelist.modesByName;
-bindDropdown("mode", function(value) {
- env.editor.session.setMode(modesByName[value].mode || modesByName.text.mode);
- env.editor.session.modeName = value;
-});
-
-doclist.history = doclist.docs.map(function(doc) {
- return doc.name;
-});
-doclist.history.index = 0;
-doclist.cycleOpen = function(editor, dir) {
- var h = this.history;
- h.index += dir;
- if (h.index >= h.length)
- h.index = 0;
- else if (h.index <= 0)
- h.index = h.length - 1;
- var s = h[h.index];
- docEl.value = s;
- docEl.onchange();
-};
-doclist.addToHistory = function(name) {
- var h = this.history;
- var i = h.indexOf(name);
- if (i != h.index) {
- if (i != -1)
- h.splice(i, 1);
- h.index = h.push(name);
- }
-};
-
-bindDropdown("doc", function(name) {
- doclist.loadDoc(name, function(session) {
- if (!session)
- return;
- doclist.addToHistory(session.name);
- session = env.split.setSession(session);
- whitespace.detectIndentation(session);
- updateUIEditorOptions();
- env.editor.focus();
- });
-});
-
-
-function updateUIEditorOptions() {
- var editor = env.editor;
- var session = editor.session;
-
- session.setFoldStyle(foldingEl.value);
-
- saveOption(docEl, session.name);
- saveOption(modeEl, session.modeName || "text");
- saveOption(wrapModeEl, session.getUseWrapMode() ? session.getWrapLimitRange().min || "free" : "off");
-
- saveOption(selectStyleEl, editor.getSelectionStyle() == "line");
- saveOption(themeEl, editor.getTheme());
- saveOption(highlightActiveEl, editor.getHighlightActiveLine());
- saveOption(showHiddenEl, editor.getShowInvisibles());
- saveOption(showGutterEl, editor.renderer.getShowGutter());
- saveOption(showPrintMarginEl, editor.renderer.getShowPrintMargin());
- saveOption(highlightSelectedWordE, editor.getHighlightSelectedWord());
- saveOption(showHScrollEl, editor.renderer.getHScrollBarAlwaysVisible());
- saveOption(animateScrollEl, editor.getAnimatedScroll());
- saveOption(softTabEl, session.getUseSoftTabs());
- saveOption(behavioursEl, editor.getBehavioursEnabled());
-}
-
-themelist.themes.forEach(function(x){ x.value = x.theme });
-fillDropdown(themeEl, {
- Bright: themelist.themes.filter(function(x){return !x.isDark}),
- Dark: themelist.themes.filter(function(x){return x.isDark}),
-});
-
-event.addListener(themeEl, "mouseover", function(e){
- themeEl.desiredValue = e.target.value;
- if (!themeEl.$timer)
- themeEl.$timer = setTimeout(themeEl.updateTheme);
-});
-
-event.addListener(themeEl, "mouseout", function(e){
- themeEl.desiredValue = null;
- if (!themeEl.$timer)
- themeEl.$timer = setTimeout(themeEl.updateTheme, 20);
-});
-
-themeEl.updateTheme = function(){
- env.split.setTheme((themeEl.desiredValue || themeEl.selectedValue));
- themeEl.$timer = null;
-};
-
-bindDropdown("theme", function(value) {
- if (!value)
- return;
- env.editor.setTheme(value);
- themeEl.selectedValue = value;
-});
-
-bindDropdown("keybinding", function(value) {
- env.editor.setKeyboardHandler(keybindings[value]);
-});
-
-bindDropdown("fontsize", function(value) {
- env.split.setFontSize(value);
-});
-
-bindDropdown("folding", function(value) {
- env.editor.session.setFoldStyle(value);
- env.editor.setShowFoldWidgets(value !== "manual");
-});
-
-bindDropdown("soft_wrap", function(value) {
- var session = env.editor.session;
- var renderer = env.editor.renderer;
- switch (value) {
- case "off":
- session.setUseWrapMode(false);
- renderer.setPrintMarginColumn(80);
- break;
- case "free":
- session.setUseWrapMode(true);
- session.setWrapLimitRange(null, null);
- renderer.setPrintMarginColumn(80);
- break;
- default:
- session.setUseWrapMode(true);
- var col = parseInt(value, 10);
- session.setWrapLimitRange(col, col);
- renderer.setPrintMarginColumn(col);
- }
-});
-
-bindCheckbox("select_style", function(checked) {
- env.editor.setSelectionStyle(checked ? "line" : "text");
-});
-
-bindCheckbox("highlight_active", function(checked) {
- env.editor.setHighlightActiveLine(checked);
-});
-
-bindCheckbox("show_hidden", function(checked) {
- env.editor.setShowInvisibles(checked);
-});
-
-bindCheckbox("display_indent_guides", function(checked) {
- env.editor.setDisplayIndentGuides(checked);
-});
-
-bindCheckbox("show_gutter", function(checked) {
- env.editor.renderer.setShowGutter(checked);
-});
-
-bindCheckbox("show_print_margin", function(checked) {
- env.editor.renderer.setShowPrintMargin(checked);
-});
-
-bindCheckbox("highlight_selected_word", function(checked) {
- env.editor.setHighlightSelectedWord(checked);
-});
-
-bindCheckbox("show_hscroll", function(checked) {
- env.editor.setOption("hScrollBarAlwaysVisible", checked);
-});
-
-bindCheckbox("show_vscroll", function(checked) {
- env.editor.setOption("vScrollBarAlwaysVisible", checked);
-});
-
-bindCheckbox("animate_scroll", function(checked) {
- env.editor.setAnimatedScroll(checked);
-});
-
-bindCheckbox("soft_tab", function(checked) {
- env.editor.session.setUseSoftTabs(checked);
-});
-
-bindCheckbox("enable_behaviours", function(checked) {
- env.editor.setBehavioursEnabled(checked);
-});
-
-bindCheckbox("fade_fold_widgets", function(checked) {
- env.editor.setFadeFoldWidgets(checked);
-});
-bindCheckbox("read_only", function(checked) {
- env.editor.setReadOnly(checked);
-});
-bindCheckbox("scrollPastEnd", function(checked) {
- env.editor.setOption("scrollPastEnd", checked);
-});
-
-bindDropdown("split", function(value) {
- var sp = env.split;
- if (value == "none") {
- sp.setSplits(1);
- } else {
- var newEditor = (sp.getSplits() == 1);
- sp.setOrientation(value == "below" ? sp.BELOW : sp.BESIDE);
- sp.setSplits(2);
-
- if (newEditor) {
- var session = sp.getEditor(0).session;
- var newSession = sp.setSession(session, 1);
- newSession.name = session.name;
- }
- }
-});
-
-
-bindCheckbox("elastic_tabstops", function(checked) {
- env.editor.setOption("useElasticTabstops", checked);
-});
-
-var iSearchCheckbox = bindCheckbox("isearch", function(checked) {
- env.editor.setOption("useIncrementalSearch", checked);
-});
-
-env.editor.addEventListener('incrementalSearchSettingChanged', function(event) {
- iSearchCheckbox.checked = event.isEnabled;
-});
-
-
-function synchroniseScrolling() {
- var s1 = env.split.$editors[0].session;
- var s2 = env.split.$editors[1].session;
- s1.on('changeScrollTop', function(pos) {s2.setScrollTop(pos)});
- s2.on('changeScrollTop', function(pos) {s1.setScrollTop(pos)});
- s1.on('changeScrollLeft', function(pos) {s2.setScrollLeft(pos)});
- s2.on('changeScrollLeft', function(pos) {s1.setScrollLeft(pos)});
-}
-
-bindCheckbox("highlight_token", function(checked) {
- var editor = env.editor;
- if (editor.tokenTooltip && !checked) {
- editor.tokenTooltip.destroy();
- delete editor.tokenTooltip;
- } else if (checked) {
- editor.tokenTooltip = new TokenTooltip(editor);
- }
-});
-
-var StatusBar = require("ace/ext/statusbar").StatusBar;
-new StatusBar(env.editor, cmdLine.container);
-
-
-var Emmet = require("ace/ext/emmet");
-net.loadScript("http://nightwing.github.io/emmet-core/emmet.js", function() {
- Emmet.setCore(window.emmet);
- env.editor.setOption("enableEmmet", true);
-});
-
-var snippetManager = require("ace/snippets").snippetManager;
-
-env.editSnippets = function() {
- var sp = env.split;
- if (sp.getSplits() == 2) {
- sp.setSplits(1);
- return;
- }
- sp.setSplits(1);
- sp.setSplits(2);
- sp.setOrientation(sp.BESIDE);
- var editor = sp.$editors[1];
- var id = sp.$editors[0].session.$mode.$id || "";
- var m = snippetManager.files[id];
- if (!doclist["snippets/" + id]) {
- var text = m.snippetText;
- var s = doclist.initDoc(text, "", {});
- s.setMode("ace/mode/snippets");
- doclist["snippets/" + id] = s;
- }
- editor.on("blur", function() {
- m.snippetText = editor.getValue();
- snippetManager.unregister(m.snippets);
- m.snippets = snippetManager.parseSnippetFile(m.snippetText, m.scope);
- snippetManager.register(m.snippets);
- });
- sp.$editors[0].once("changeMode", function() {
- sp.setSplits(1);
- });
- editor.setSession(doclist["snippets/" + id], 1);
- editor.focus();
-};
-
-require("ace/ext/language_tools");
-env.editor.setOptions({
- enableBasicAutocompletion: true,
- enableSnippets: true
-});
-
-});
-
-define('ace/ext/elastic_tabstops_lite', ['require', 'exports', 'module' , 'ace/editor', 'ace/config'], function(require, exports, module) {
-
-
-var ElasticTabstopsLite = function(editor) {
- this.$editor = editor;
- var self = this;
- var changedRows = [];
- var recordChanges = false;
- this.onAfterExec = function() {
- recordChanges = false;
- self.processRows(changedRows);
- changedRows = [];
- };
- this.onExec = function() {
- recordChanges = true;
- };
- this.onChange = function(e) {
- var range = e.data.range
- if (recordChanges) {
- if (changedRows.indexOf(range.start.row) == -1)
- changedRows.push(range.start.row);
- if (range.end.row != range.start.row)
- changedRows.push(range.end.row);
- }
- };
-};
-
-(function() {
- this.processRows = function(rows) {
- this.$inChange = true;
- var checkedRows = [];
-
- for (var r = 0, rowCount = rows.length; r < rowCount; r++) {
- var row = rows[r];
-
- if (checkedRows.indexOf(row) > -1)
- continue;
-
- var cellWidthObj = this.$findCellWidthsForBlock(row);
- var cellWidths = this.$setBlockCellWidthsToMax(cellWidthObj.cellWidths);
- var rowIndex = cellWidthObj.firstRow;
-
- for (var w = 0, l = cellWidths.length; w < l; w++) {
- var widths = cellWidths[w];
- checkedRows.push(rowIndex);
- this.$adjustRow(rowIndex, widths);
- rowIndex++;
- }
- }
- this.$inChange = false;
- };
-
- this.$findCellWidthsForBlock = function(row) {
- var cellWidths = [], widths;
- var rowIter = row;
- while (rowIter >= 0) {
- widths = this.$cellWidthsForRow(rowIter);
- if (widths.length == 0)
- break;
-
- cellWidths.unshift(widths);
- rowIter--;
- }
- var firstRow = rowIter + 1;
- rowIter = row;
- var numRows = this.$editor.session.getLength();
-
- while (rowIter < numRows - 1) {
- rowIter++;
-
- widths = this.$cellWidthsForRow(rowIter);
- if (widths.length == 0)
- break;
-
- cellWidths.push(widths);
- }
-
- return { cellWidths: cellWidths, firstRow: firstRow };
- };
-
- this.$cellWidthsForRow = function(row) {
- var selectionColumns = this.$selectionColumnsForRow(row);
-
- var tabs = [-1].concat(this.$tabsForRow(row));
- var widths = tabs.map(function(el) { return 0; } ).slice(1);
- var line = this.$editor.session.getLine(row);
-
- for (var i = 0, len = tabs.length - 1; i < len; i++) {
- var leftEdge = tabs[i]+1;
- var rightEdge = tabs[i+1];
-
- var rightmostSelection = this.$rightmostSelectionInCell(selectionColumns, rightEdge);
- var cell = line.substring(leftEdge, rightEdge);
- widths[i] = Math.max(cell.replace(/\s+$/g,'').length, rightmostSelection - leftEdge);
- }
-
- return widths;
- };
-
- this.$selectionColumnsForRow = function(row) {
- var selections = [], cursor = this.$editor.getCursorPosition();
- if (this.$editor.session.getSelection().isEmpty()) {
- if (row == cursor.row)
- selections.push(cursor.column);
- }
-
- return selections;
- };
-
- this.$setBlockCellWidthsToMax = function(cellWidths) {
- var startingNewBlock = true, blockStartRow, blockEndRow, maxWidth;
- var columnInfo = this.$izip_longest(cellWidths);
-
- for (var c = 0, l = columnInfo.length; c < l; c++) {
- var column = columnInfo[c];
- if (!column.push) {
- console.error(column);
- continue;
- }
- column.push(NaN);
-
- for (var r = 0, s = column.length; r < s; r++) {
- var width = column[r];
- if (startingNewBlock) {
- blockStartRow = r;
- maxWidth = 0;
- startingNewBlock = false;
- }
- if (isNaN(width)) {
- blockEndRow = r;
-
- for (var j = blockStartRow; j < blockEndRow; j++) {
- cellWidths[j][c] = maxWidth;
- }
- startingNewBlock = true;
- }
-
- maxWidth = Math.max(maxWidth, width);
- }
- }
-
- return cellWidths;
- };
-
- this.$rightmostSelectionInCell = function(selectionColumns, cellRightEdge) {
- var rightmost = 0;
-
- if (selectionColumns.length) {
- var lengths = [];
- for (var s = 0, length = selectionColumns.length; s < length; s++) {
- if (selectionColumns[s] <= cellRightEdge)
- lengths.push(s);
- else
- lengths.push(0);
- }
- rightmost = Math.max.apply(Math, lengths);
- }
-
- return rightmost;
- };
-
- this.$tabsForRow = function(row) {
- var rowTabs = [], line = this.$editor.session.getLine(row),
- re = /\t/g, match;
-
- while ((match = re.exec(line)) != null) {
- rowTabs.push(match.index);
- }
-
- return rowTabs;
- };
-
- this.$adjustRow = function(row, widths) {
- var rowTabs = this.$tabsForRow(row);
-
- if (rowTabs.length == 0)
- return;
-
- var bias = 0, location = -1;
- var expandedSet = this.$izip(widths, rowTabs);
-
- for (var i = 0, l = expandedSet.length; i < l; i++) {
- var w = expandedSet[i][0], it = expandedSet[i][1];
- location += 1 + w;
- it += bias;
- var difference = location - it;
-
- if (difference == 0)
- continue;
-
- var partialLine = this.$editor.session.getLine(row).substr(0, it );
- var strippedPartialLine = partialLine.replace(/\s*$/g, "");
- var ispaces = partialLine.length - strippedPartialLine.length;
-
- if (difference > 0) {
- this.$editor.session.getDocument().insertInLine({row: row, column: it + 1}, Array(difference + 1).join(" ") + "\t");
- this.$editor.session.getDocument().removeInLine(row, it, it + 1);
-
- bias += difference;
- }
-
- if (difference < 0 && ispaces >= -difference) {
- this.$editor.session.getDocument().removeInLine(row, it + difference, it);
- bias += difference;
- }
- }
- };
- this.$izip_longest = function(iterables) {
- if (!iterables[0])
- return [];
- var longest = iterables[0].length;
- var iterablesLength = iterables.length;
-
- for (var i = 1; i < iterablesLength; i++) {
- var iLength = iterables[i].length;
- if (iLength > longest)
- longest = iLength;
- }
-
- var expandedSet = [];
-
- for (var l = 0; l < longest; l++) {
- var set = [];
- for (var i = 0; i < iterablesLength; i++) {
- if (iterables[i][l] === "")
- set.push(NaN);
- else
- set.push(iterables[i][l]);
- }
-
- expandedSet.push(set);
- }
-
-
- return expandedSet;
- };
- this.$izip = function(widths, tabs) {
- var size = widths.length >= tabs.length ? tabs.length : widths.length;
-
- var expandedSet = [];
- for (var i = 0; i < size; i++) {
- var set = [ widths[i], tabs[i] ];
- expandedSet.push(set);
- }
- return expandedSet;
- };
-
-}).call(ElasticTabstopsLite.prototype);
-
-exports.ElasticTabstopsLite = ElasticTabstopsLite;
-
-var Editor = require("../editor").Editor;
-require("../config").defineOptions(Editor.prototype, "editor", {
- useElasticTabstops: {
- set: function(val) {
- if (val) {
- if (!this.elasticTabstops)
- this.elasticTabstops = new ElasticTabstopsLite(this);
- this.commands.on("afterExec", this.elasticTabstops.onAfterExec);
- this.commands.on("exec", this.elasticTabstops.onExec);
- this.on("change", this.elasticTabstops.onChange);
- } else if (this.elasticTabstops) {
- this.commands.removeListener("afterExec", this.elasticTabstops.onAfterExec);
- this.commands.removeListener("exec", this.elasticTabstops.onExec);
- this.removeListener("change", this.elasticTabstops.onChange);
- }
- }
- }
-});
-
-});
-
-define('ace/incremental_search', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/search', 'ace/search_highlight', 'ace/commands/incremental_search_commands', 'ace/lib/dom', 'ace/commands/command_manager', 'ace/editor', 'ace/config'], function(require, exports, module) {
-
-
-var oop = require("./lib/oop");
-var Range = require("./range").Range;
-var Search = require("./search").Search;
-var SearchHighlight = require("./search_highlight").SearchHighlight;
-var iSearchCommandModule = require("./commands/incremental_search_commands");
-var ISearchKbd = iSearchCommandModule.IncrementalSearchKeyboardHandler;
-function IncrementalSearch() {
- this.$options = {wrap: false, skipCurrent: false};
- this.$keyboardHandler = new ISearchKbd(this);
-}
-
-oop.inherits(IncrementalSearch, Search);
-
-;(function() {
-
- this.activate = function(ed, backwards) {
- this.$editor = ed;
- this.$startPos = this.$currentPos = ed.getCursorPosition();
- this.$options.needle = '';
- this.$options.backwards = backwards;
- ed.keyBinding.addKeyboardHandler(this.$keyboardHandler);
- this.$mousedownHandler = ed.addEventListener('mousedown', this.onMouseDown.bind(this));
- this.selectionFix(ed);
- this.statusMessage(true);
- }
-
- this.deactivate = function(reset) {
- this.cancelSearch(reset);
- this.$editor.keyBinding.removeKeyboardHandler(this.$keyboardHandler);
- if (this.$mousedownHandler) {
- this.$editor.removeEventListener('mousedown', this.$mousedownHandler);
- delete this.$mousedownHandler;
- }
- this.message('');
- }
-
- this.selectionFix = function(editor) {
- if (editor.selection.isEmpty() && !editor.session.$emacsMark) {
- editor.clearSelection();
- }
- }
-
- this.highlight = function(regexp) {
- var sess = this.$editor.session,
- hl = sess.$isearchHighlight = sess.$isearchHighlight || sess.addDynamicMarker(
- new SearchHighlight(null, "ace_isearch-result", "text"));
- hl.setRegexp(regexp);
- sess._emit("changeBackMarker"); // force highlight layer redraw
- }
-
- this.cancelSearch = function(reset) {
- var e = this.$editor;
- this.$prevNeedle = this.$options.needle;
- this.$options.needle = '';
- if (reset) {
- e.moveCursorToPosition(this.$startPos);
- this.$currentPos = this.$startPos;
- } else {
- e.pushEmacsMark && e.pushEmacsMark(this.$startPos, false);
- }
- this.highlight(null);
- return Range.fromPoints(this.$currentPos, this.$currentPos);
- }
-
- this.highlightAndFindWithNeedle = function(moveToNext, needleUpdateFunc) {
- if (!this.$editor) return null;
- var options = this.$options;
- if (needleUpdateFunc) {
- options.needle = needleUpdateFunc.call(this, options.needle || '') || '';
- }
- if (options.needle.length === 0) {
- this.statusMessage(true);
- return this.cancelSearch(true);
- };
- options.start = this.$currentPos;
- var session = this.$editor.session,
- found = this.find(session);
- if (found) {
- if (options.backwards) found = Range.fromPoints(found.end, found.start);
- this.$editor.moveCursorToPosition(found.end);
- if (moveToNext) this.$currentPos = found.end;
- this.highlight(options.re)
- }
-
- this.statusMessage(found);
-
- return found;
- }
-
- this.addChar = function(c) {
- return this.highlightAndFindWithNeedle(false, function(needle) {
- return needle + c;
- });
- }
-
- this.removeChar = function(c) {
- return this.highlightAndFindWithNeedle(false, function(needle) {
- return needle.length > 0 ? needle.substring(0, needle.length-1) : needle;
- });
- }
-
- this.next = function(options) {
- options = options || {};
- this.$options.backwards = !!options.backwards;
- this.$currentPos = this.$editor.getCursorPosition();
- return this.highlightAndFindWithNeedle(true, function(needle) {
- return options.useCurrentOrPrevSearch && needle.length === 0 ?
- this.$prevNeedle || '' : needle;
- });
- }
-
- this.onMouseDown = function(evt) {
- this.deactivate();
- return true;
- }
-
- this.statusMessage = function(found) {
- var options = this.$options, msg = '';
- msg += options.backwards ? 'reverse-' : '';
- msg += 'isearch: ' + options.needle;
- msg += found ? '' : ' (not found)';
- this.message(msg);
- }
-
- this.message = function(msg) {
- if (this.$editor.showCommandLine) {
- this.$editor.showCommandLine(msg);
- this.$editor.focus();
- } else {
- console.log(msg);
- }
- }
-
-}).call(IncrementalSearch.prototype);
-
-
-exports.IncrementalSearch = IncrementalSearch;
-
-var dom = require('./lib/dom');
-dom.importCssString && dom.importCssString("\
-.ace_marker-layer .ace_isearch-result {\
- position: absolute;\
- z-index: 6;\
- -moz-box-sizing: border-box;\
- -webkit-box-sizing: border-box;\
- box-sizing: border-box;\
-}\
-div.ace_isearch-result {\
- border-radius: 4px;\
- background-color: rgba(255, 200, 0, 0.5);\
- box-shadow: 0 0 4px rgb(255, 200, 0);\
-}\
-.ace_dark div.ace_isearch-result {\
- background-color: rgb(100, 110, 160);\
- box-shadow: 0 0 4px rgb(80, 90, 140);\
-}", "incremental-search-highlighting");
-var commands = require("./commands/command_manager");
-(function() {
- this.setupIncrementalSearch = function(editor, val) {
- if (this.usesIncrementalSearch == val) return;
- this.usesIncrementalSearch = val;
- var iSearchCommands = iSearchCommandModule.iSearchStartCommands;
- var method = val ? 'addCommands' : 'removeCommands';
- this[method](iSearchCommands);
- };
-}).call(commands.CommandManager.prototype);
-var Editor = require("./editor").Editor;
-require("./config").defineOptions(Editor.prototype, "editor", {
- useIncrementalSearch: {
- set: function(val) {
- this.keyBinding.$handlers.forEach(function(handler) {
- if (handler.setupIncrementalSearch) {
- handler.setupIncrementalSearch(this, val);
- }
- });
- this._emit('incrementalSearchSettingChanged', {isEnabled: val});
- }
- }
-});
-
-});
-
-define('ace/commands/incremental_search_commands', ['require', 'exports', 'module' , 'ace/config', 'ace/lib/oop', 'ace/keyboard/hash_handler', 'ace/commands/occur_commands'], function(require, exports, module) {
-
-var config = require("../config");
-var oop = require("../lib/oop");
-var HashHandler = require("../keyboard/hash_handler").HashHandler;
-var occurStartCommand = require("./occur_commands").occurStartCommand;
-exports.iSearchStartCommands = [{
- name: "iSearch",
- bindKey: {win: "Ctrl-F", mac: "Command-F"},
- exec: function(editor, options) {
- config.loadModule(["core", "ace/incremental_search"], function(e) {
- var iSearch = e.iSearch = e.iSearch || new e.IncrementalSearch();
- iSearch.activate(editor, options.backwards);
- if (options.jumpToFirstMatch) iSearch.next(options);
- });
- },
- readOnly: true
-}, {
- name: "iSearchBackwards",
- exec: function(editor, jumpToNext) { editor.execCommand('iSearch', {backwards: true}); },
- readOnly: true
-}, {
- name: "iSearchAndGo",
- bindKey: {win: "Ctrl-K", mac: "Command-G"},
- exec: function(editor, jumpToNext) { editor.execCommand('iSearch', {jumpToFirstMatch: true, useCurrentOrPrevSearch: true}); },
- readOnly: true
-}, {
- name: "iSearchBackwardsAndGo",
- bindKey: {win: "Ctrl-Shift-K", mac: "Command-Shift-G"},
- exec: function(editor) { editor.execCommand('iSearch', {jumpToFirstMatch: true, backwards: true, useCurrentOrPrevSearch: true}); },
- readOnly: true
-}];
-exports.iSearchCommands = [{
- name: "restartSearch",
- bindKey: {win: "Ctrl-F", mac: "Command-F"},
- exec: function(iSearch) {
- iSearch.cancelSearch(true);
- },
- readOnly: true,
- isIncrementalSearchCommand: true
-}, {
- name: "searchForward",
- bindKey: {win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G"},
- exec: function(iSearch, options) {
- options.useCurrentOrPrevSearch = true;
- iSearch.next(options);
- },
- readOnly: true,
- isIncrementalSearchCommand: true
-}, {
- name: "searchBackward",
- bindKey: {win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G"},
- exec: function(iSearch, options) {
- options.useCurrentOrPrevSearch = true;
- options.backwards = true;
- iSearch.next(options);
- },
- readOnly: true,
- isIncrementalSearchCommand: true
-}, {
- name: "extendSearchTerm",
- exec: function(iSearch, string) {
- iSearch.addChar(string);
- },
- readOnly: true,
- isIncrementalSearchCommand: true
-}, {
- name: "extendSearchTermSpace",
- bindKey: "space",
- exec: function(iSearch) { iSearch.addChar(' '); },
- readOnly: true,
- isIncrementalSearchCommand: true
-}, {
- name: "shrinkSearchTerm",
- bindKey: "backspace",
- exec: function(iSearch) {
- iSearch.removeChar();
- },
- readOnly: true,
- isIncrementalSearchCommand: true
-}, {
- name: 'confirmSearch',
- bindKey: 'return',
- exec: function(iSearch) { iSearch.deactivate(); },
- readOnly: true,
- isIncrementalSearchCommand: true
-}, {
- name: 'cancelSearch',
- bindKey: 'esc|Ctrl-G',
- exec: function(iSearch) { iSearch.deactivate(true); },
- readOnly: true,
- isIncrementalSearchCommand: true
-}, {
- name: 'occurisearch',
- bindKey: 'Ctrl-O',
- exec: function(iSearch) {
- var options = oop.mixin({}, iSearch.$options);
- iSearch.deactivate();
- occurStartCommand.exec(iSearch.$editor, options);
- },
- readOnly: true,
- isIncrementalSearchCommand: true
-}];
-
-function IncrementalSearchKeyboardHandler(iSearch) {
- this.$iSearch = iSearch;
-}
-
-oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
-
-;(function() {
-
- this.attach = function(editor) {
- var iSearch = this.$iSearch;
- HashHandler.call(this, exports.iSearchCommands, editor.commands.platform);
- this.$commandExecHandler = editor.commands.addEventListener('exec', function(e) {
- if (!e.command.isIncrementalSearchCommand) return undefined;
- e.stopPropagation();
- e.preventDefault();
- return e.command.exec(iSearch, e.args || {});
- });
- }
-
- this.detach = function(editor) {
- if (!this.$commandExecHandler) return;
- editor.commands.removeEventListener('exec', this.$commandExecHandler);
- delete this.$commandExecHandler;
- }
-
- var handleKeyboard$super = this.handleKeyboard;
- this.handleKeyboard = function(data, hashId, key, keyCode) {
- var cmd = handleKeyboard$super.call(this, data, hashId, key, keyCode);
- if (cmd.command) { return cmd; }
- if (hashId == -1) {
- var extendCmd = this.commands.extendSearchTerm;
- if (extendCmd) { return {command: extendCmd, args: key}; }
- }
- return {command: "null", passEvent: hashId == 0 || hashId == 4};
- }
-
-}).call(IncrementalSearchKeyboardHandler.prototype);
-
-
-exports.IncrementalSearchKeyboardHandler = IncrementalSearchKeyboardHandler;
-
-});
-
-define('kitchen-sink/util', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/lib/event', 'ace/edit_session', 'ace/undomanager', 'ace/virtual_renderer', 'ace/editor', 'ace/multi_select'], function(require, exports, module) {
-
-
-var dom = require("ace/lib/dom");
-var event = require("ace/lib/event");
-
-var EditSession = require("ace/edit_session").EditSession;
-var UndoManager = require("ace/undomanager").UndoManager;
-var Renderer = require("ace/virtual_renderer").VirtualRenderer;
-var Editor = require("ace/editor").Editor;
-var MultiSelect = require("ace/multi_select").MultiSelect;
-
-exports.createEditor = function(el) {
- return new Editor(new Renderer(el));
-};
-
-exports.createSplitEditor = function(el) {
- if (typeof(el) == "string")
- el = document.getElementById(el);
-
- var e0 = document.createElement("div");
- var s = document.createElement("splitter");
- var e1 = document.createElement("div");
- el.appendChild(e0);
- el.appendChild(e1);
- el.appendChild(s);
- e0.style.position = e1.style.position = s.style.position = "absolute";
- el.style.position = "relative";
- var split = {$container: el};
-
- split.editor0 = split[0] = new Editor(new Renderer(e0));
- split.editor1 = split[1] = new Editor(new Renderer(e1));
- split.splitter = s;
-
- s.ratio = 0.5;
-
- split.resize = function resize(){
- var height = el.parentNode.clientHeight - el.offsetTop;
- var total = el.clientWidth;
- var w1 = total * s.ratio;
- var w2 = total * (1- s.ratio);
- s.style.left = w1 - 1 + "px";
- s.style.height = el.style.height = height + "px";
-
- var st0 = split[0].container.style;
- var st1 = split[1].container.style;
- st0.width = w1 + "px";
- st1.width = w2 + "px";
- st0.left = 0 + "px";
- st1.left = w1 + "px";
-
- st0.top = st1.top = "0px";
- st0.height = st1.height = height + "px";
-
- split[0].resize();
- split[1].resize();
- };
-
- split.onMouseDown = function(e) {
- var rect = el.getBoundingClientRect();
- var x = e.clientX;
- var y = e.clientY;
-
- var button = e.button;
- if (button !== 0) {
- return;
- }
-
- var onMouseMove = function(e) {
- x = e.clientX;
- y = e.clientY;
- };
- var onResizeEnd = function(e) {
- clearInterval(timerId);
- };
-
- var onResizeInterval = function() {
- s.ratio = (x - rect.left) / rect.width;
- split.resize();
- };
-
- event.capture(s, onMouseMove, onResizeEnd);
- var timerId = setInterval(onResizeInterval, 40);
-
- return e.preventDefault();
- };
-
-
-
- event.addListener(s, "mousedown", split.onMouseDown);
- event.addListener(window, "resize", split.resize);
- split.resize();
- return split;
-};
-exports.stripLeadingComments = function(str) {
- if(str.slice(0,2)=='/*') {
- var j = str.indexOf('*/')+2;
- str = str.substr(j);
- }
- return str.trim() + "\n";
-};
-exports.saveOption = function(el, val) {
- if (!el.onchange && !el.onclick)
- return;
-
- if ("checked" in el) {
- if (val !== undefined)
- el.checked = val;
-
- localStorage && localStorage.setItem(el.id, el.checked ? 1 : 0);
- }
- else {
- if (val !== undefined)
- el.value = val;
-
- localStorage && localStorage.setItem(el.id, el.value);
- }
-};
-
-exports.bindCheckbox = function(id, callback, noInit) {
- if (typeof id == "string")
- var el = document.getElementById(id);
- else {
- var el = id;
- id = el.id;
- }
- var el = document.getElementById(id);
- if (localStorage && localStorage.getItem(id))
- el.checked = localStorage.getItem(id) == "1";
-
- var onCheck = function() {
- callback(!!el.checked);
- exports.saveOption(el);
- };
- el.onclick = onCheck;
- noInit || onCheck();
- return el;
-};
-
-exports.bindDropdown = function(id, callback, noInit) {
- if (typeof id == "string")
- var el = document.getElementById(id);
- else {
- var el = id;
- id = el.id;
- }
- if (localStorage && localStorage.getItem(id))
- el.value = localStorage.getItem(id);
-
- var onChange = function() {
- callback(el.value);
- exports.saveOption(el);
- };
-
- el.onchange = onChange;
- noInit || onChange();
-};
-
-exports.fillDropdown = function(el, values) {
- if (typeof el == "string")
- el = document.getElementById(el);
-
- dropdown(values).forEach(function(e) {
- el.appendChild(e);
- });
-};
-
-function elt(tag, attributes, content) {
- var el = dom.createElement(tag);
- if (typeof content == "string") {
- el.appendChild(document.createTextNode(content));
- } else if (content) {
- content.forEach(function(ch) {
- el.appendChild(ch);
- });
- }
-
- for (var i in attributes)
- el.setAttribute(i, attributes[i]);
- return el;
-}
-
-function optgroup(values) {
- return values.map(function(item) {
- if (typeof item == "string")
- item = {name: item, caption: item};
- return elt("option", {value: item.value || item.name}, item.caption || item.desc);
- });
-}
-
-function dropdown(values) {
- if (Array.isArray(values))
- return optgroup(values);
-
- return Object.keys(values).map(function(i) {
- return elt("optgroup", {"label": i}, optgroup(values[i]));
- });
-}
-
-
-});
-
-define('ace/occur', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/search', 'ace/edit_session', 'ace/search_highlight', 'ace/lib/dom'], function(require, exports, module) {
-
-
-var oop = require("./lib/oop");
-var Range = require("./range").Range;
-var Search = require("./search").Search;
-var EditSession = require("./edit_session").EditSession;
-var SearchHighlight = require("./search_highlight").SearchHighlight;
-function Occur() {}
-
-oop.inherits(Occur, Search);
-
-(function() {
- this.enter = function(editor, options) {
- if (!options.needle) return false;
- var pos = editor.getCursorPosition();
- this.displayOccurContent(editor, options);
- var translatedPos = this.originalToOccurPosition(editor.session, pos);
- editor.moveCursorToPosition(translatedPos);
- return true;
- }
- this.exit = function(editor, options) {
- var pos = options.translatePosition && editor.getCursorPosition();
- var translatedPos = pos && this.occurToOriginalPosition(editor.session, pos);
- this.displayOriginalContent(editor);
- if (translatedPos)
- editor.moveCursorToPosition(translatedPos);
- return true;
- }
-
- this.highlight = function(sess, regexp) {
- var hl = sess.$occurHighlight = sess.$occurHighlight || sess.addDynamicMarker(
- new SearchHighlight(null, "ace_occur-highlight", "text"));
- hl.setRegexp(regexp);
- sess._emit("changeBackMarker"); // force highlight layer redraw
- }
-
- this.displayOccurContent = function(editor, options) {
- this.$originalSession = editor.session;
- var found = this.matchingLines(editor.session, options);
- var lines = found.map(function(foundLine) { return foundLine.content; });
- var occurSession = new EditSession(lines.join('\n'));
- occurSession.$occur = this;
- occurSession.$occurMatchingLines = found;
- editor.setSession(occurSession);
- this.highlight(occurSession, options.re);
- occurSession._emit('changeBackMarker');
- }
-
- this.displayOriginalContent = function(editor) {
- editor.setSession(this.$originalSession);
- }
- this.originalToOccurPosition = function(session, pos) {
- var lines = session.$occurMatchingLines;
- var nullPos = {row: 0, column: 0};
- if (!lines) return nullPos;
- for (var i = 0; i < lines.length; i++) {
- if (lines[i].row === pos.row)
- return {row: i, column: pos.column};
- }
- return nullPos;
- }
- this.occurToOriginalPosition = function(session, pos) {
- var lines = session.$occurMatchingLines;
- if (!lines || !lines[pos.row])
- return pos;
- return {row: lines[pos.row].row, column: pos.column};
- }
-
- this.matchingLines = function(session, options) {
- options = oop.mixin({}, options);
- if (!session || !options.needle) return [];
- var search = new Search();
- search.set(options);
- return search.findAll(session).reduce(function(lines, range) {
- var row = range.start.row;
- var last = lines[lines.length-1];
- return last && last.row === row ?
- lines :
- lines.concat({row: row, content: session.getLine(row)});
- }, []);
- }
-
-}).call(Occur.prototype);
-
-var dom = require('./lib/dom');
-dom.importCssString(".ace_occur-highlight {\n\
- border-radius: 4px;\n\
- background-color: rgba(87, 255, 8, 0.25);\n\
- position: absolute;\n\
- z-index: 4;\n\
- -moz-box-sizing: border-box;\n\
- -webkit-box-sizing: border-box;\n\
- box-sizing: border-box;\n\
- box-shadow: 0 0 4px rgb(91, 255, 50);\n\
-}\n\
-.ace_dark .ace_occur-highlight {\n\
- background-color: rgb(80, 140, 85);\n\
- box-shadow: 0 0 4px rgb(60, 120, 70);\n\
-}\n", "incremental-occur-highlighting");
-
-exports.Occur = Occur;
-
-});
-
-define('ace/split', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/lib/event_emitter', 'ace/editor', 'ace/virtual_renderer', 'ace/edit_session'], function(require, exports, module) {
-
-
-var oop = require("./lib/oop");
-var lang = require("./lib/lang");
-var EventEmitter = require("./lib/event_emitter").EventEmitter;
-
-var Editor = require("./editor").Editor;
-var Renderer = require("./virtual_renderer").VirtualRenderer;
-var EditSession = require("./edit_session").EditSession;
-
-
-var Split = function(container, theme, splits) {
- this.BELOW = 1;
- this.BESIDE = 0;
-
- this.$container = container;
- this.$theme = theme;
- this.$splits = 0;
- this.$editorCSS = "";
- this.$editors = [];
- this.$orientation = this.BESIDE;
-
- this.setSplits(splits || 1);
- this.$cEditor = this.$editors[0];
-
-
- this.on("focus", function(editor) {
- this.$cEditor = editor;
- }.bind(this));
-};
-
-(function(){
-
- oop.implement(this, EventEmitter);
-
- this.$createEditor = function() {
- var el = document.createElement("div");
- el.className = this.$editorCSS;
- el.style.cssText = "position: absolute; top:0px; bottom:0px";
- this.$container.appendChild(el);
- var editor = new Editor(new Renderer(el, this.$theme));
-
- editor.on("focus", function() {
- this._emit("focus", editor);
- }.bind(this));
-
- this.$editors.push(editor);
- editor.setFontSize(this.$fontSize);
- return editor;
- };
-
- this.setSplits = function(splits) {
- var editor;
- if (splits < 1) {
- throw "The number of splits have to be > 0!";
- }
-
- if (splits == this.$splits) {
- return;
- } else if (splits > this.$splits) {
- while (this.$splits < this.$editors.length && this.$splits < splits) {
- editor = this.$editors[this.$splits];
- this.$container.appendChild(editor.container);
- editor.setFontSize(this.$fontSize);
- this.$splits ++;
- }
- while (this.$splits < splits) {
- this.$createEditor();
- this.$splits ++;
- }
- } else {
- while (this.$splits > splits) {
- editor = this.$editors[this.$splits - 1];
- this.$container.removeChild(editor.container);
- this.$splits --;
- }
- }
- this.resize();
- };
- this.getSplits = function() {
- return this.$splits;
- };
- this.getEditor = function(idx) {
- return this.$editors[idx];
- };
- this.getCurrentEditor = function() {
- return this.$cEditor;
- };
- this.focus = function() {
- this.$cEditor.focus();
- };
- this.blur = function() {
- this.$cEditor.blur();
- };
- this.setTheme = function(theme) {
- this.$editors.forEach(function(editor) {
- editor.setTheme(theme);
- });
- };
- this.setKeyboardHandler = function(keybinding) {
- this.$editors.forEach(function(editor) {
- editor.setKeyboardHandler(keybinding);
- });
- };
- this.forEach = function(callback, scope) {
- this.$editors.forEach(callback, scope);
- };
-
-
- this.$fontSize = "";
- this.setFontSize = function(size) {
- this.$fontSize = size;
- this.forEach(function(editor) {
- editor.setFontSize(size);
- });
- };
-
- this.$cloneSession = function(session) {
- var s = new EditSession(session.getDocument(), session.getMode());
-
- var undoManager = session.getUndoManager();
- if (undoManager) {
- var undoManagerProxy = new UndoManagerProxy(undoManager, s);
- s.setUndoManager(undoManagerProxy);
- }
- s.$informUndoManager = lang.delayedCall(function() { s.$deltas = []; });
- s.setTabSize(session.getTabSize());
- s.setUseSoftTabs(session.getUseSoftTabs());
- s.setOverwrite(session.getOverwrite());
- s.setBreakpoints(session.getBreakpoints());
- s.setUseWrapMode(session.getUseWrapMode());
- s.setUseWorker(session.getUseWorker());
- s.setWrapLimitRange(session.$wrapLimitRange.min,
- session.$wrapLimitRange.max);
- s.$foldData = session.$cloneFoldData();
-
- return s;
- };
- this.setSession = function(session, idx) {
- var editor;
- if (idx == null) {
- editor = this.$cEditor;
- } else {
- editor = this.$editors[idx];
- }
- var isUsed = this.$editors.some(function(editor) {
- return editor.session === session;
- });
-
- if (isUsed) {
- session = this.$cloneSession(session);
- }
- editor.setSession(session);
- return session;
- };
- this.getOrientation = function() {
- return this.$orientation;
- };
- this.setOrientation = function(orientation) {
- if (this.$orientation == orientation) {
- return;
- }
- this.$orientation = orientation;
- this.resize();
- };
- this.resize = function() {
- var width = this.$container.clientWidth;
- var height = this.$container.clientHeight;
- var editor;
-
- if (this.$orientation == this.BESIDE) {
- var editorWidth = width / this.$splits;
- for (var i = 0; i < this.$splits; i++) {
- editor = this.$editors[i];
- editor.container.style.width = editorWidth + "px";
- editor.container.style.top = "0px";
- editor.container.style.left = i * editorWidth + "px";
- editor.container.style.height = height + "px";
- editor.resize();
- }
- } else {
- var editorHeight = height / this.$splits;
- for (var i = 0; i < this.$splits; i++) {
- editor = this.$editors[i];
- editor.container.style.width = width + "px";
- editor.container.style.top = i * editorHeight + "px";
- editor.container.style.left = "0px";
- editor.container.style.height = editorHeight + "px";
- editor.resize();
- }
- }
- };
-
-}).call(Split.prototype);
-
-
-function UndoManagerProxy(undoManager, session) {
- this.$u = undoManager;
- this.$doc = session;
-}
-
-(function() {
- this.execute = function(options) {
- this.$u.execute(options);
- };
-
- this.undo = function() {
- var selectionRange = this.$u.undo(true);
- if (selectionRange) {
- this.$doc.selection.setSelectionRange(selectionRange);
- }
- };
-
- this.redo = function() {
- var selectionRange = this.$u.redo(true);
- if (selectionRange) {
- this.$doc.selection.setSelectionRange(selectionRange);
- }
- };
-
- this.reset = function() {
- this.$u.reset();
- };
-
- this.hasUndo = function() {
- return this.$u.hasUndo();
- };
-
- this.hasRedo = function() {
- return this.$u.hasRedo();
- };
-}).call(UndoManagerProxy.prototype);
-
-exports.Split = Split;
-});
-
-define('ace/keyboard/vim', ['require', 'exports', 'module' , 'ace/keyboard/vim/commands', 'ace/keyboard/vim/maps/util', 'ace/lib/useragent'], function(require, exports, module) {
-
-
-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",
- handleMacRepeat: function(data, hashId, key) {
- if (hashId == -1) {
- data.inputChar = key;
- data.lastEvent = "input";
- } else if (data.inputChar && data.$lastHash == hashId && data.$lastKey == key) {
- if (data.lastEvent == "input") {
- data.lastEvent = "input1";
- } else if (data.lastEvent == "input1") {
- return true;
- }
- } else {
- data.$lastHash = hashId;
- data.$lastKey = key;
- data.lastEvent = "keypress";
- }
- },
- 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) {
- if (hashId !== 0 && (!key || keyCode == -1))
- 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];
- var isHandled = cmds.inputBuffer.push(editor, key);
- return {command: "null", passEvent: !isHandled};
- } // 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;
-};
-
-});
-
-define('ace/keyboard/vim/commands', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/keyboard/vim/maps/util', 'ace/keyboard/vim/maps/motions', 'ace/keyboard/vim/maps/operators', 'ace/keyboard/vim/maps/aliases', 'ace/keyboard/vim/registers'], 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) {
- var row = editor.getCursorPosition().row;
- editor.selection.moveTo(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,
- currentCount: "",
- status: "",
- 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);
- }
- else if (!(ch === "0" && !this.currentCount.length) &&
- (/^\d+$/.test(ch) && this.isAccepting(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;
- }
- 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: {
- 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.moveTo(originRow, 0);
- editor.selection.selectTo(cursorRow, endLine.length);
- } else {
- var endLine = editor.session.getLine(originRow);
- editor.selection.moveTo(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;
- }
-};
-});
-define('ace/keyboard/vim/maps/util', ['require', 'exports', 'module' , 'ace/keyboard/vim/registers', 'ace/lib/dom'], function(require, exports, module) {
-var registers = require("../registers");
-
-var dom = require("../../../lib/dom");
-dom.importCssString('.insert-mode .ace_cursor{\
- border-left: 2px solid #333333;\
-}\
-.ace_dark.insert-mode .ace_cursor{\
- border-left: 2px solid #eeeeee;\
-}\
-.normal-mode .ace_cursor{\
- border: 0!important;\
- background-color: red;\
- opacity: 0.5;\
-}', 'vimMode');
-
-module.exports = {
- onVisualMode: false,
- onVisualLineMode: false,
- currentMode: 'normal',
- noMode: function(editor) {
- editor.unsetStyle('insert-mode');
- editor.unsetStyle('normal-mode');
- if (editor.commands.recording)
- editor.commands.toggleRecording(editor);
- editor.setOverwrite(false);
- },
- insertMode: function(editor) {
- this.currentMode = 'insert';
- editor.setStyle('insert-mode');
- editor.unsetStyle('normal-mode');
-
- editor.setOverwrite(false);
- editor.keyBinding.$data.buffer = "";
- editor.keyBinding.$data.state = "insertMode";
- this.onVisualMode = false;
- this.onVisualLineMode = false;
- if(this.onInsertReplaySequence) {
- editor.commands.macro = this.onInsertReplaySequence;
- editor.commands.replay(editor);
- this.onInsertReplaySequence = null;
- this.normalMode(editor);
- } else {
- editor._emit("changeStatus");
- if(!editor.commands.recording)
- editor.commands.toggleRecording(editor);
- }
- },
- normalMode: function(editor) {
- this.currentMode = 'normal';
-
- editor.unsetStyle('insert-mode');
- editor.setStyle('normal-mode');
- editor.clearSelection();
-
- var pos;
- if (!editor.getOverwrite()) {
- pos = editor.getCursorPosition();
- if (pos.column > 0)
- editor.navigateLeft();
- }
-
- editor.setOverwrite(true);
- editor.keyBinding.$data.buffer = "";
- editor.keyBinding.$data.state = "start";
- this.onVisualMode = false;
- this.onVisualLineMode = false;
- editor._emit("changeStatus");
- if (editor.commands.recording) {
- editor.commands.toggleRecording(editor);
- return editor.commands.macro;
- }
- else {
- return [];
- }
- },
- visualMode: function(editor, lineMode) {
- if (
- (this.onVisualLineMode && lineMode)
- || (this.onVisualMode && !lineMode)
- ) {
- this.normalMode(editor);
- return;
- }
-
- editor.setStyle('insert-mode');
- editor.unsetStyle('normal-mode');
-
- editor._emit("changeStatus");
- if (lineMode) {
- this.onVisualLineMode = true;
- } else {
- this.onVisualMode = true;
- this.onVisualLineMode = false;
- }
- },
- getRightNthChar: function(editor, cursor, ch, n) {
- var line = editor.getSession().getLine(cursor.row);
- var matches = line.substr(cursor.column + 1).split(ch);
-
- return n < matches.length ? matches.slice(0, n).join(ch).length : null;
- },
- getLeftNthChar: function(editor, cursor, ch, n) {
- var line = editor.getSession().getLine(cursor.row);
- var matches = line.substr(0, cursor.column).split(ch);
-
- return n < matches.length ? matches.slice(-1 * n).join(ch).length : null;
- },
- toRealChar: function(ch) {
- if (ch.length === 1)
- return ch;
-
- if (/^shift-./.test(ch))
- return ch[ch.length - 1].toUpperCase();
- else
- return "";
- },
- copyLine: function(editor) {
- var pos = editor.getCursorPosition();
- editor.selection.moveTo(pos.row, pos.column);
- editor.selection.selectLine();
- registers._default.isLine = true;
- registers._default.text = editor.getCopyText().replace(/\n$/, "");
- editor.selection.moveTo(pos.row, pos.column);
- }
-};
-});
-
-define('kitchen-sink/token_tooltip', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/lib/oop', 'ace/lib/event', 'ace/range', 'ace/tooltip'], function(require, exports, module) {
-
-
-var dom = require("ace/lib/dom");
-var oop = require("ace/lib/oop");
-var event = require("ace/lib/event");
-var Range = require("ace/range").Range;
-var Tooltip = require("ace/tooltip").Tooltip;
-
-function TokenTooltip (editor) {
- if (editor.tokenTooltip)
- return;
- Tooltip.call(this, editor.container);
- editor.tokenTooltip = this;
- this.editor = editor;
-
- this.update = this.update.bind(this);
- this.onMouseMove = this.onMouseMove.bind(this);
- this.onMouseOut = this.onMouseOut.bind(this);
- event.addListener(editor.renderer.scroller, "mousemove", this.onMouseMove);
- event.addListener(editor.renderer.content, "mouseout", this.onMouseOut);
-}
-
-oop.inherits(TokenTooltip, Tooltip);
-
-(function(){
- this.token = {};
- this.range = new Range();
-
- this.update = function() {
- this.$timer = null;
-
- var r = this.editor.renderer;
- if (this.lastT - (r.timeStamp || 0) > 1000) {
- r.rect = null;
- r.timeStamp = this.lastT;
- this.maxHeight = window.innerHeight;
- this.maxWidth = window.innerWidth;
- }
-
- var canvasPos = r.rect || (r.rect = r.scroller.getBoundingClientRect());
- var offset = (this.x + r.scrollLeft - canvasPos.left - r.$padding) / r.characterWidth;
- var row = Math.floor((this.y + r.scrollTop - canvasPos.top) / r.lineHeight);
- var col = Math.round(offset);
-
- var screenPos = {row: row, column: col, side: offset - col > 0 ? 1 : -1};
- var session = this.editor.session;
- var docPos = session.screenToDocumentPosition(screenPos.row, screenPos.column);
- var token = session.getTokenAt(docPos.row, docPos.column);
-
- if (!token && !session.getLine(docPos.row)) {
- token = {
- type: "",
- value: "",
- state: session.bgTokenizer.getState(0)
- };
- }
- if (!token) {
- session.removeMarker(this.marker);
- this.hide();
- return;
- }
-
- var tokenText = token.type;
- if (token.state)
- tokenText += "|" + token.state;
- if (token.merge)
- tokenText += "\n merge";
- if (token.stateTransitions)
- tokenText += "\n " + token.stateTransitions.join("\n ");
-
- if (this.tokenText != tokenText) {
- this.setText(tokenText);
- this.width = this.getWidth();
- this.height = this.getHeight();
- this.tokenText = tokenText;
- }
-
- this.show(null, this.x, this.y);
-
- this.token = token;
- session.removeM
<TRUNCATED>